Skip to content

test(show): pin the timestamp expectation to en-US/UTC like the formatter - #169

Merged
obra merged 1 commit into
obra:mainfrom
vicnaum:fix/show-test-utc
Sep 10, 2026
Merged

obra merged 1 commit into
obra:mainfrom
vicnaum:fix/show-test-utc

Conversation

@vicnaum

@vicnaum vicnaum commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Problem

formatConversationAsMarkdown renders timestamps with toLocaleString('en-US', { timeZone: 'UTC' }) (#120, #130), but the test in test/show.test.ts still builds its expectation with a bare toLocaleString(), i.e. the host's locale and timezone. The two only agree on en-US / UTC hosts, so the suite passes on CI and fails for anyone running it locally elsewhere:

Europe/Warsaw:  expected "9/19/2025, 7:34:29 PM", formatter produced "9/19/2025, 5:34:29 PM"
de_DE on UTC:   fails on the locale format

Fix

Format the expectation the same way the code does. One-line test change, no runtime change.

Verified passing under TZ=Europe/Warsaw, TZ=America/New_York and TZ=UTC, including LC_ALL=de_DE.UTF-8.

🤖 Generated with Claude Code

https://claude.ai/code/session_01L7qt58cTm5rFNfV38EQfEN

…tter

formatConversationAsMarkdown renders timestamps with
toLocaleString('en-US', { timeZone: 'UTC' }) (obra#120, obra#130), but the test still
built its expectation with a bare toLocaleString(), so the expectation depends
on the host locale and timezone while the formatter's output does not. The
suite passes on en-US/UTC CI runners and fails for anyone running it locally
outside that setup (Europe/Warsaw: expected "9/19/2025, 7:34:29 PM", got
"9/19/2025, 5:34:29 PM"; de-DE on UTC also fails).

Format the expectation the same way the code does. Verified passing under
Europe/Warsaw, America/New_York and UTC, including LC_ALL=de_DE.UTF-8.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L7qt58cTm5rFNfV38EQfEN

@obra obra left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified and landing. Thank you — this is a real portability bug and the diagnosis is exactly right.

formatConversationAsMarkdown pins timestamps at src/show.ts:97:

const timestamp = new Date(msg.timestamp).toLocaleString('en-US', { timeZone: 'UTC' });

and the expectation used a bare toLocaleString(). Those agree only on an en-US/UTC host, which is what CI happens to be — so the suite was green for everyone who could run it and red for everyone who couldn't.

Confirmed with a negative control, because a test change that passes everywhere proves nothing on its own:

base 28f0933a, TZ=Europe/Warsaw  ->  1 failed | 21 passed
PR   6854e8d5, TZ=Europe/Warsaw  ->  22 passed

Then across the environments the fix targets — TZ=UTC, TZ=America/New_York, and TZ=UTC LC_ALL=de_DE.UTF-8 — all 22 pass. No CI ran on the fork branch, so that local matrix is standing in for it.

One note, not a change request. The expectation now mirrors the implementation's exact call, so if someone changes the formatter's locale the test follows silently rather than failing. The alternative — asserting the literal "9/19/2025, 5:34:29 PM" — would catch that, at the cost of breaking whenever Node's ICU data shifts its formatting. For a timestamp render I think you've picked the right side of that trade; I'm flagging it only so the next person knows it was a choice.

@obra
obra merged commit 7e06519 into obra:main Sep 10, 2026
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.

2 participants