Skip to content

test: keep the client suite independent of the host locale - #280

Open
miadisabelle wants to merge 1 commit into
johannesjo:mainfrom
miadisabelle:contrib/session-picker-locale-test
Open

miadisabelle wants to merge 1 commit into
johannesjo:mainfrom
miadisabelle:contrib/session-picker-locale-test

Conversation

@miadisabelle

Copy link
Copy Markdown
Contributor

Two client tests assert English output from code that formats in the host's default locale — correct for the app, but it fails the suite on a developer machine set to another language.

npm run test:client on a clean checkout of main:

LC_ALL before after
fr_FR.UTF-8 3 failed 0
de_DE.UTF-8 4 failed 0
empty (Intl resolves und) 2 failed 0
en_US.UTF-8 0 0

SessionPicker

relativeTime formats with Intl.RelativeTimeFormat(undefined, …) and its tests match /day/ and /second/. Two days ago is 'avant-hier' under fr_FR, 'vorgestern' under de_DE, and '-2 d' under und.

The function already takes now so its tests are deterministic. It now takes an optional locale for the same reason, and the tests pass 'en'. The call site passes nothing, so the app still formats in the user's locale.

AgentChatView

The context and token titles use toLocaleString(), and the tests expected '50,000 of 200,000' and '12,500 tokens''50.000' under de_DE, U+202F-grouped under fr_FR. The expected text is now built with toLocaleString(), as AnnotationMarker's test already does.

If you'd prefer one line instead, setting test.env.LC_ALL in vitest.client.config.ts also works, since the forks pool starts its workers with that environment — but it pins every client test to English and depends on the pool staying process-based, so I went with fixing the two tests.

npm run compile, typecheck, lint pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SK5d1Qh4JcJVF39HEkFBxX

Two client tests assert English output from code that formats in the host's
default locale, which is right for the app but fails the suite on a developer
machine set to another language. `npm run test:client` on a clean checkout:

  LC_ALL=fr_FR.UTF-8   3 failed
  LC_ALL=de_DE.UTF-8   4 failed
  LC_ALL= (empty)      2 failed   Intl resolves `und`
  LC_ALL=en_US.UTF-8   0 failed

- SessionPicker: `relativeTime` uses `Intl.RelativeTimeFormat(undefined, ...)`
  and its tests match /day/, /second/. Under fr_FR two days ago is
  'avant-hier', under de_DE 'vorgestern', under `und` '-2 d'. The function
  already takes `now` so its tests are deterministic; it now takes an optional
  `locale` for the same reason, and the tests pass 'en'. The app passes none.
- AgentChatView: the context and token titles use `toLocaleString()`, and the
  tests expected '50,000 of 200,000' and '12,500 tokens'. Under de_DE those are
  '50.000' and '12.500'; under fr_FR the groups are separated by U+202F. The
  expected text is now built with `toLocaleString()`, as AnnotationMarker's
  test already does.

With both, the client suite passes 803/803 under all four settings above.
@miadisabelle
miadisabelle force-pushed the contrib/session-picker-locale-test branch from f9b3651 to a7a14ea Compare September 19, 2026 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant