Files
HealthLog/src/lib/onboarding/__tests__/disclaimer.test.ts
T
Marc-André Bombeck 542ca91be5 Finish the wiring polish: verbosity gate, upload flash, /about links, dead settings slugs
- The Coach verbosity picker is disabled while the concise tone forces
  brief, with a hint saying so, instead of a live control that silently
  does nothing.
- A fresh document upload flashes its new row like the duplicate path
  always did; the settle decision is a pure exported helper with a test.
- /about gains its two inbound links: the /privacy footer and a
  Settings→About credits row (the GeoLite2 EULA wants the attribution
  reachable from the running app).
- The eight settings slugs shadowed by permanent redirects (the seven
  layout children + sharing) leave the slug registry: no more
  prerendering unreachable pages, no dead component wirings, and the
  SectionPlaceholder fallback that could never render is gone. The
  redirects, section components, and layout-hub subpages are unchanged.
2026-08-14 05:31:33 +02:00

48 lines
1.4 KiB
TypeScript

/**
* The disclaimer-version gate (welcome step 0).
*
* Watched red: with `isDisclaimerAcknowledgmentCurrent` reduced to the
* pre-fix timestamp-only check (`acknowledgedAt != null`) the stale-version
* case below fails — the version column was written on acknowledgment but
* never compared, so bumping `DISCLAIMER_VERSION` could not re-prompt.
*/
import { describe, expect, it } from "vitest";
import {
DISCLAIMER_VERSION,
isDisclaimerAcknowledgmentCurrent,
} from "../disclaimer";
describe("isDisclaimerAcknowledgmentCurrent", () => {
it("holds for an acknowledgment of the current version", () => {
expect(
isDisclaimerAcknowledgmentCurrent(
"2026-06-20T08:00:00.000Z",
DISCLAIMER_VERSION,
),
).toBe(true);
});
it("re-prompts when the stored acknowledgment is for an older version", () => {
expect(
isDisclaimerAcknowledgmentCurrent(
"2026-06-20T08:00:00.000Z",
"2025-01-01",
),
).toBe(false);
});
it("re-prompts when the version was never recorded", () => {
expect(
isDisclaimerAcknowledgmentCurrent("2026-06-20T08:00:00.000Z", null),
).toBe(false);
});
it("requires an acknowledgment timestamp at all", () => {
expect(isDisclaimerAcknowledgmentCurrent(null, DISCLAIMER_VERSION)).toBe(
false,
);
expect(isDisclaimerAcknowledgmentCurrent(undefined, undefined)).toBe(false);
});
});