-
Notifications
You must be signed in to change notification settings - Fork 26
Description
Describe the bug
Description
The test suite in SagaDiagram.spec.ts
compares rendered date-time strings against hard-coded values (e.g., "3/28/2025 3:04:05 AM"
), assuming a US locale (en-US
). However, when running the tests on systems with different locale settings such as en-AU
, the default string formatting of Date.toLocaleString()
results in different formats (e.g., "28/03/2025 3:04:05 am"
), causing assertions to fail.
Expected behavior
Tests should pass consistently across all environments, regardless of the system or runtime locale. Date formatting in tests should either:
- Be explicitly formatted in a locale-agnostic way (e.g., using
toISOString())
, or - Use a fixed locale explicitly in the component or test code (e.g.,
toLocaleString("en-US", options))
.
Actual behavior
Tests fail in environments with non-US locales due to mismatched date formats in rendered output vs. expected values.
Steps to reproduce
- Set your system or Node.js locale to
en-AU
- Run the test suite (
SagaDiagram.spec.ts
). - Observe test failures due to mismatched date formats.
Relevant log output
Example failures:
FAIL src/components/messages/SagaDiagram.spec.ts > Feature: 3 Visual Representation of Saga Timeline > Rule: 3.3 Display a chronological timeline of saga events in PST. > EXAMPLE: Rendering a Saga with 4 changes
AssertionError: expected [ '27/03/2025 8:04:05 pm', …(3) ] to deeply equal [ '3/27/2025 8:04:05 PM', …(3) ]
- Expected
+ Received
[
- "3/27/2025 8:04:05 PM",
- "3/27/2025 8:04:06 PM",
- "3/27/2025 8:04:07 PM",
- "3/27/2025 8:04:08 PM",
+ "27/03/2025 8:04:05 pm",
+ "27/03/2025 8:04:06 pm",
+ "27/03/2025 8:04:07 pm",
+ "27/03/2025 8:04:08 pm",
]
FAIL src/components/messages/SagaDiagram.spec.ts > Feature: 3 Visual Representation of Saga Timeline > Rule: 3.2 Display a chronological timeline of saga events in UTC. > EXAMPLE: Rendering a Saga with 4 changes
AssertionError: expected [ '28/03/2025 3:04:05 am', …(3) ] to deeply equal [ '3/28/2025 3:04:05 AM', …(3) ]
- Expected
+ Received
[
- "3/28/2025 3:04:05 AM",
- "3/28/2025 3:04:06 AM",
- "3/28/2025 3:04:07 AM",
- "3/28/2025 3:04:08 AM",
+ "28/03/2025 3:04:05 am",
+ "28/03/2025 3:04:06 am",
+ "28/03/2025 3:04:07 am",
+ "28/03/2025 3:04:08 am",
]
Additional Information
Workarounds
N/A
Possible solutions
Update the toLocalDateTimeString function in formatUtils.ts to accept an optional locale parameter. This allows tests to explicitly specify a locale (e.g. "en-US") to ensure consistent output across environments.
Additional information
- The issue is environment-specific and may only surface when running tests locally on machines with non-
en-US
locales, such asen-AU
,en-GB
, or other regional settings. - The test environment (e.g., GitHub Actions) likely defaults to
en-US
, which is why this bug may go unnoticed in CI pipelines. - Relying on
Date.toLocaleString()
without specifying a locale introduces flakiness in both tests and UI consistency across different user systems.