From 71565e93283dc1d7ee35ef4b7a97e1e1320314f5 Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Wed, 29 Jul 2026 11:47:42 +1200 Subject: [PATCH] test: restore TZ after pinning it in forward-as-attachment tests Setting process.env.TZ at module scope without restoring it could leak into other test files sharing the same Vitest worker. Match the beforeAll/afterAll restore pattern already used in lib/__tests__/calendar-utils.test.ts. --- lib/__tests__/forward-as-attachment.test.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/__tests__/forward-as-attachment.test.ts b/lib/__tests__/forward-as-attachment.test.ts index 9f98ca28..40d3d5d7 100644 --- a/lib/__tests__/forward-as-attachment.test.ts +++ b/lib/__tests__/forward-as-attachment.test.ts @@ -1,10 +1,18 @@ -// Pin TZ so the local-time date rendering in the filename test is deterministic. -process.env.TZ = 'UTC'; - -import { describe, it, expect } from 'vitest'; +import { describe, it, expect, beforeAll, afterAll } from 'vitest'; import { buildForwardAsAttachmentPayload } from '@/lib/forward-as-attachment'; import type { Email } from '@/lib/jmap/types'; +// Pin TZ so the local-time date rendering in the filename test is deterministic, +// restoring it after so this doesn't leak into other test files in the same worker. +let originalTZ: string | undefined; +beforeAll(() => { + originalTZ = process.env.TZ; + process.env.TZ = 'UTC'; +}); +afterAll(() => { + process.env.TZ = originalTZ; +}); + function makeEmail(overrides: Partial = {}): Email { return { id: 'e1',