mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
The suite was not timezone-pinned. CI runs UTC, so a whole class of day-bucketing defect was invisible to the gate while a contributor outside UTC saw a red suite on unmodified main. Verified: a UTC+14 host fails five tests on an otherwise green tree. Pin TZ=UTC in both vitest configs; tests that need a different HOST zone now set and restore it explicitly. The resting-pulse fixtures passed offset-less ISO literals, which parse as host-local, so they could not distinguish the Berlin day-key the implementation uses from a UTC one — swapping the day-key's zone left the file green. Build each instant explicitly in Berlin and add cases whose local day and UTC day genuinely differ; that swap now fails two of them. Delete the 'DST boundary (spring-forward)' compliance case. It passed no timezone, so the slot builder took the legacy UTC path where the date carries no transition, and it asserted totalExpected === 7 — which holds in every zone and therefore could never see the double-emit its own comment described. Threading a real zone does not rescue it: the assertion stays true in Berlin, UTC, UTC+14 and UTC-11 alike. The property it claimed is already pinned properly in the scheduling suite, which walks buildCadenceTimeline with an explicit zone across both the 23 h spring-forward and the 25 h fall-back day.
50 lines
2.2 KiB
TypeScript
50 lines
2.2 KiB
TypeScript
import { defineConfig } from "vitest/config";
|
||
import { dirname, resolve } from "node:path";
|
||
import { fileURLToPath } from "node:url";
|
||
|
||
const __filename = fileURLToPath(import.meta.url);
|
||
const __dirname = dirname(__filename);
|
||
|
||
// Integration suite — boots a real Postgres in a testcontainer and runs
|
||
// migrations against it. Slow (container boot ~5–15s on a cold pull),
|
||
// so excluded from the default `pnpm test` and triggered explicitly via
|
||
// `pnpm test:integration`.
|
||
export default defineConfig({
|
||
test: {
|
||
globals: true,
|
||
environment: "node",
|
||
// Same host-timezone pin as the unit config — CI runs UTC, so the
|
||
// integration contracts must be read against the same clock.
|
||
env: { TZ: "UTC" },
|
||
include: ["tests/integration/**/*.test.ts"],
|
||
// Container boot + migration apply is slow; give each test a generous
|
||
// budget and beforeAll/afterAll twice that.
|
||
testTimeout: 60_000,
|
||
hookTimeout: 120_000,
|
||
// Run sequentially in a single fork so files reuse one container and
|
||
// amortise the migration-apply cost. Vitest 4 moved these to the top
|
||
// level (the old `poolOptions.forks.singleFork` was removed).
|
||
pool: "forks",
|
||
fileParallelism: false,
|
||
// v1.4.37 W-CI — switched from `isolate: false` to `isolate: true`.
|
||
// The previous setting reused the module graph across files inside
|
||
// one fork; mock declarations (`vi.mock("@/lib/notifications/...")`,
|
||
// `vi.mock("@parse/node-apn")`) registered in `apns-dispatch.test.ts`
|
||
// and `integration-status.test.ts` lost to whichever earlier file
|
||
// had already pulled the real dispatcher / sender modules into the
|
||
// shared graph, so the in-suite run showed flaky 0-call mocks while
|
||
// each file passed in isolation. Re-isolating module state per file
|
||
// costs ~10 s of import-rebuild on a 56-file run; the Postgres
|
||
// testcontainer + migrations still live in `globalSetup` so the
|
||
// expensive boot cost is unaffected.
|
||
isolate: true,
|
||
// One container for the whole run; tests truncate between them.
|
||
globalSetup: ["./tests/integration/global-setup.ts"],
|
||
},
|
||
resolve: {
|
||
alias: {
|
||
"@": resolve(__dirname, "src"),
|
||
},
|
||
},
|
||
});
|