Skip to content

fix(test): make desktop ui tests locale-agnostic - #73123

Closed
ypQQ1984 wants to merge 1 commit into
NousResearch:mainfrom
ypQQ1984:fix/test-locale-agnostic
Closed

fix(test): make desktop ui tests locale-agnostic#73123
ypQQ1984 wants to merge 1 commit into
NousResearch:mainfrom
ypQQ1984:fix/test-locale-agnostic

Conversation

@ypQQ1984

Copy link
Copy Markdown
Contributor

Summary

Three desktop UI tests froze en-US-formatted strings while the implementation formatters deliberately use the runtime locale (new Intl.DateTimeFormat(undefined, ...) / new Intl.NumberFormat(undefined, ...)). Runtime-locale output is the intended behavior for a localized UI — but it means these tests fail on any non-en-US dev machine even though the code is correct:

# zh-CN host:
src/lib/time.test.ts
  → expected '三月' to be 'March'
src/app/settings/billing/index.test.tsx
  → Unable to find text 'Threshold: minimum is $10.'
    (zh-CN renders USD currency as 'US$10')
  → Unable to find text '$25 added. Balance is refreshing.'

Upstream CI is en-US, so this stays invisible there; it only bites contributors on non-English locales.

Fix

Assert the behavior contract instead of the frozen snapshot, per the repo's testing guidance ("behavior contracts over snapshots"):

  • time.test.ts: same-year month buckets render via fmtMonth, prior-year buckets via fmtMonthYear — assert sessionBucketLabel(bucket) equals the shared formatter's output for bucket.at, with bucket-kind narrowing.
  • billing/index.test.tsx: interpolate formatMoney(10) / formatMoney(25) into the expected strings.

No production code changes.

Test plan

  • zh-CN host: vitest run --project ui src/lib/time.test.ts src/app/settings/billing/index.test.tsx40/40 pass (was 37/40)
  • LANG=C.UTF-8 LC_ALL=C.UTF-8: 40/40 pass
  • tsc --noEmit clean, eslint clean

Three desktop UI tests froze en-US-formatted strings while the
implementation formatters deliberately use the runtime locale
(new Intl.DateTimeFormat(undefined, ...) / Intl.NumberFormat(undefined,
...)) — runtime-locale output is the intended behavior for a localized
UI. On any non-en-US dev machine the tests fail even though the code is
correct:

    # zh-CN host:
    time.test.ts -> expected '三月' to be 'March'
    billing      -> Unable to find text 'Threshold: minimum is $10.'
                    (zh-CN renders USD as 'US$10')
    billing      -> Unable to find text '$25 added. Balance is refreshing.'

Assert the behavior contract instead of the frozen snapshot, per the
repo's testing guidance (behavior contracts over snapshots):

- time.test.ts: same-year month buckets render via fmtMonth, prior-year
  via fmtMonthYear — assert sessionBucketLabel(bucket) equals the shared
  formatter's output for bucket.at, with bucket-kind narrowing.
- billing/index.test.tsx: interpolate formatMoney(10) / formatMoney(25)
  into the expected strings.

No production code changes.

Verified: zh-CN host 40/40, LANG=C.UTF-8 40/40, tsc clean, eslint clean.
@alt-glitch alt-glitch added type/test Test coverage or test infrastructure comp/desktop Electron desktop app (apps/desktop/*) P3 Low — cosmetic, nice to have labels Jul 28, 2026
@teknium1 teknium1 added sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users area/i18n Localization, locales, translations labels Jul 30, 2026
@teknium1

teknium1 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Merged in #81965 — clean cherry-pick with authorship; verified 40/40 vitest green. Fixes #71659. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/i18n Localization, locales, translations comp/desktop Electron desktop app (apps/desktop/*) P3 Low — cosmetic, nice to have sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users type/test Test coverage or test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants