test(harness): make formatClockTime tests locale independent - #657
Open
memosr wants to merge 1 commit into
Open
Conversation
The date assertions matched the English month abbreviation, so the suite failed on any machine whose system locale is not English (for example tr-TR renders Jul as Tem). formatClockTime deliberately formats in the user's locale, so the source is correct and the test was over-specified. Assert the shape instead: the dated form is the same-day form with a date and a comma prepended. Verified across de-DE, ja-JP, tr-TR and en-GB in three timezones.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Primary change type
Problem and motivation
pnpm testfails on any machine whose system locale is not English:CI runs in an English locale, so this is green upstream and red for contributors elsewhere. I hit it on a fresh clone of
main, before changing anything, on macOS with atr-TRsystem locale.formatClockTimecallstoLocaleDateString([], ...)deliberately, so a timestamp reads in the user's own locale. That is correct for a user-facing string. The test was the over-specified side: matching/Jul/pins an English month abbreviation, while the behavior it means to assert is "a date is added when the turn is from another day".Summary and scope
Assert the shape instead of the wording. The same instant is formatted twice, once with
nowat that instant and once three days later, and the dated form is asserted to be the same-day form with a date and", "in front.Out of scope: no source file is touched, and no other locale-dependent assertion elsewhere in the repo is changed.
Related work
Related issue or discussion: N/A — direct PR, focused test fix under the direct-PR policy.
Validation
The two tests were additionally run under de-DE, ja-JP, tr-TR and en-GB, each in Asia/Tokyo, America/Los_Angeles and UTC.
Tests and documentation
Tests: the two
formatClockTimeassertions are rewritten. Documentation: N/A, no user-facing behavior changed.Compatibility and release impact
Security
AI assistance
I used Claude (Claude Code and the Claude app). The failure was found by running
pnpm teston a clean clone. I decided that the test rather than the source was wrong, and directed the change to assert the same-day/other-day relationship rather than an English month name. Claude wrote the two rewritten assertions and ran them across the locale and timezone matrix listed above. I reviewed the diff line by line and re-ran the full package suite myself.Checklist
CONTRIBUTING.md, and this contribution follows the direct-PR or issue-first policy.