Skip to content

test(harness): make formatClockTime tests locale independent - #657

Open
memosr wants to merge 1 commit into
sapiom:mainfrom
memosr:fix/harness-locale-dependent-clock-test
Open

test(harness): make formatClockTime tests locale independent#657
memosr wants to merge 1 commit into
sapiom:mainfrom
memosr:fix/harness-locale-dependent-clock-test

Conversation

@memosr

@memosr memosr commented Aug 17, 2026

Copy link
Copy Markdown

Primary change type

  • Tests

Problem and motivation

pnpm test fails on any machine whose system locale is not English:

FAIL  web/src/lib/session-record-view.test.ts > formatClockTime > adds the date for a turn from another day
AssertionError: expected '1 Tem, 13:00' to match /Jul/

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 a tr-TR system locale.

formatClockTime calls toLocaleDateString([], ...) 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 now at 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

pnpm --filter @sapiom/harness test        — pass (2095/2095)
pnpm build                                — pass
pnpm typecheck                            — pass
pnpm lint                                 — pass (0 errors)

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 formatClockTime assertions are rewritten. Documentation: N/A, no user-facing behavior changed.

Compatibility and release impact

  • Breaking or externally visible changes: None. Test-only.
  • Changeset: An empty changeset is included, since no published behavior changes.

Security

  • I have not included secrets, credentials, private data, or unsanitized logs.
  • This pull request does not publicly disclose a suspected vulnerability.

AI assistance

  • I used AI assistance and have described it below.

I used Claude (Claude Code and the Claude app). The failure was found by running pnpm test on 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

  • I read CONTRIBUTING.md, and this contribution follows the direct-PR or issue-first policy.
  • This pull request addresses one focused problem and contains no unrelated cleanup.
  • I added or updated tests, or explained above why tests are not applicable.
  • I ran the relevant build, typecheck, lint, and test commands, or explained any N/A checks above.
  • I updated documentation for user-facing changes, or marked it N/A above.
  • I added a Changeset for a published-package change, or explained why it is not applicable.
  • I can explain and maintain every submitted change, including any AI-assisted work.

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.
@github-actions github-actions Bot added contribution: incomplete Required pull request information is incomplete or ambiguous contributor: external Pull request author does not have write, maintain, or admin access to sapiom-js needs-triage Awaiting maintainer review and classification review: manual External pull request requires maintainer review before automation size: small Review size is at most 100 changed lines area: studio Changes to Agent Studio or harness applications labels Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: studio Changes to Agent Studio or harness applications contribution: incomplete Required pull request information is incomplete or ambiguous contributor: external Pull request author does not have write, maintain, or admin access to sapiom-js needs-triage Awaiting maintainer review and classification review: manual External pull request requires maintainer review before automation size: small Review size is at most 100 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant