mirror of
https://github.com/block/buzz.git
synced 2026-10-31 14:31:02 +00:00
fix(desktop): pin the transcript baseline fixture to UTC
The captured-markup fixture embeds formatted timestamps, because `formatTranscriptTimestampTitle` renders in the ambient zone. It was captured at UTC-7, so the byte-for-byte comparison failed in CI (UTC) for a reason that had nothing to do with markup: "at 12:00:01 PM" vs "at 7:00:01 PM". This is why Desktop Core failed on the previous two heads. Pin `process.env.TZ = "UTC"` before the transcript modules are imported — their `Intl.DateTimeFormat` instances are module-level constants that resolve the zone once at construction — and recapture the baseline from pre-change main under that zone. A guard assertion in the coverage test now fails with a specific message if the ambient zone is not UTC, rather than dumping a 12KB markup diff. Verified passing under TZ=UTC, TZ=America/New_York, and TZ=Asia/Tokyo. Signed-off-by: ss-dev-01 <11939edb7df583f855dbef923f2358f1184538f88ca452e19e7e35e42ad6d796@buzz.block.builderlab.xyz> Co-authored-by: Bradley Axen <baxen@squareup.com> Signed-off-by: Bradley Axen <baxen@squareup.com>
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -20,6 +20,15 @@ import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { after, afterEach, before, test } from "node:test";
|
||||
|
||||
// The captured markup embeds locally-formatted timestamps ("… at 7:00:01 PM"),
|
||||
// because `formatTranscriptTimestampTitle` formats in the ambient zone. Pin the
|
||||
// zone so the fixture is reproducible on any developer machine and in CI (which
|
||||
// runs UTC) — otherwise the byte-for-byte comparison fails purely on the
|
||||
// capturer's offset. Must be set before the transcript modules are imported:
|
||||
// their `Intl.DateTimeFormat` instances are module-level constants that resolve
|
||||
// the zone once, at construction.
|
||||
process.env.TZ = "UTC";
|
||||
|
||||
import { JSDOM } from "jsdom";
|
||||
|
||||
const BASELINE_MARKUP = JSON.parse(
|
||||
@@ -731,6 +740,14 @@ test("default and compactPreview markup is unchanged by the conversation variant
|
||||
});
|
||||
|
||||
test("the byte-for-byte baseline actually exercises every renderable item kind", async () => {
|
||||
// The fixture embeds formatted timestamps, so a zone other than the one it was
|
||||
// captured in fails the comparison above for a reason that has nothing to do
|
||||
// with markup. Fail loudly and specifically instead.
|
||||
assert.equal(
|
||||
new Intl.DateTimeFormat().resolvedOptions().timeZone,
|
||||
"UTC",
|
||||
"the baseline fixture is captured in UTC — see the TZ pin at the top of this file",
|
||||
);
|
||||
// Guards the fixture itself: a baseline that silently stopped covering a kind
|
||||
// would keep passing the comparison above while protecting nothing. Asserted
|
||||
// against `default`, which renders every kind.
|
||||
|
||||
Reference in New Issue
Block a user