Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
test(frontend): close the three gaps mutation testing found
zchpeterd5cdbec58528
diff --git a/frontend/src/hooks/useTimeReading.test.tsx b/frontend/src/hooks/useTimeReading.test.tsxindex cf45b1007d..b34c83178c 100644--- a/frontend/src/hooks/useTimeReading.test.tsx+++ b/frontend/src/hooks/useTimeReading.test.tsx@@ -9,7 +9,11 @@ import { useTimeReading } from "./useTimeReading";const DAY_MS = 86_400_000;-// A boundary that names one instant and never changes again.+// A boundary that names one instant and never changes again. Retiring to+// Infinity is the difference from a plain `() => deadlineMs`: it changes the+// effect's dependency, so the display drops its subscription and, if it was+// the last one, the clock disarms. Tests that need the clock quiet afterwards+// use this; tests that need a live subscription use the plain closure.const onceAt = (changesAtMs: number) => () =>Date.now() < changesAtMs ? changesAtMs : Number.POSITIVE_INFINITY;@@ -71,9 +75,10 @@ const mount = (probes: ProbeSpec[]) => {// The clock's state is the page's: it has no reset, so a test that rewound the// wall clock would hand the next one a clock stepped backward -- the very// condition the clock exists to detect, and it would detect it. Time only-// moves forward here, as it does on a page. Each test starts a day after the-// last one *ended*, since a test that waits out the timer ceiling ends weeks-// after it began.+// moves forward here, as it does on a page: every test starts later than any+// clock reading in every test before it. A test that waits out the timer+// ceiling ends weeks after it began, and one that steps the clock back ends+// before it began, so the next start is taken from the later of the two.let testStartMs = Date.UTC(2026, 2, 2, 12);describe("useTimeReading", () => {@@ -87,7 +92,7 @@ describe("useTimeReading", () => {act(() => root.unmount());}// Read while the fake clock still holds where this test reached.- testStartMs = Date.now() + 86_400_000;+ testStartMs = Math.max(testStartMs, Date.now()) + DAY_MS;vi.restoreAllMocks();vi.useRealTimers();});@@ -346,6 +351,26 @@ describe("useTimeReading", () => {expect(renders).toEqual([1, 2]);});+ test("handles one backward step once, not at every later check", () => {+ // The step lowers the mark it was detected against. Left standing, every+ // re-check until the clock climbs back reads as a fresh step, and an hour+ // of NTP correction becomes an hour of waking every display on the page.+ const deadlineMs = Date.now() + 5 * 60_000;+ const { renders } = mount([{ changesAtMs: () => deadlineMs }]);++ vi.setSystemTime(Date.now() - 10 * 60_000);+ act(() => {+ vi.advanceTimersByTime(60_000);+ });+ expect(renders).toEqual([2]);++ // A second re-check, still below the clock the step was taken from.+ act(() => {+ vi.advanceTimersByTime(60_000);+ });+ expect(renders).toEqual([2]);+ });+test("never stretches the wake gap past its bound after a clock step", () => {const firstMs = Date.now() + 1_000;mount([{ changesAtMs: onceAt(firstMs) }]);diff --git a/frontend/src/modules/sql-editor/components/AccessGrantItem.test.tsx b/frontend/src/modules/sql-editor/components/AccessGrantItem.test.tsxindex 55dde25d64..2cc9fc12a0 100644--- a/frontend/src/modules/sql-editor/components/AccessGrantItem.test.tsx+++ b/frontend/src/modules/sql-editor/components/AccessGrantItem.test.tsx@@ -64,8 +64,18 @@ vi.mock("@/components/ui/badge", () => ({}));vi.mock("@/components/ui/tooltip", () => ({- Tooltip: ({ children }: { children: React.ReactNode }) => (- <span data-testid="tooltip">{children}</span>+ // The real Tooltip renders nothing for an absent body, so the stub carries+ // the body it was given: a row that hides a reading has to offer it back.+ Tooltip: ({+ children,+ content,+ }: {+ children: React.ReactNode;+ content?: React.ReactNode;+ }) => (+ <span data-testid="tooltip" data-has-content={content !== undefined}>+ {children}+ </span>),}));@@ -366,6 +376,14 @@ describe("AccessGrantItem", () => {};expect(container.textContent).toContain("sql-editor.expire-in:3m");+ // A countdown is the one form that hides the deadline, so the row has to+ // offer it: a tooltip with nothing to say renders its children bare, and+ // the trigger it wraps them in is what says the offer is there.+ const countdownTooltip = Array.from(+ container.querySelectorAll("[data-testid=tooltip]")+ ).find((node) => node.textContent === "sql-editor.expire-in:3m");+ expect(countdownTooltip?.getAttribute("data-has-content")).toBe("true");+advanceSeconds(1);expect(container.textContent).toContain("sql-editor.expire-in:2m");advanceSeconds(60);diff --git a/frontend/src/utils/datetime.test.ts b/frontend/src/utils/datetime.test.tsindex 47f1100728..733e37a85f 100644--- a/frontend/src/utils/datetime.test.ts+++ b/frontend/src/utils/datetime.test.ts@@ -20,6 +20,7 @@ const withLocale = (language: string, run: () => void) => {};import {+ absoluteTimeReading,compactTimeReading,countdownReading,daysLeftReading,@@ -305,6 +306,11 @@ describe("reading boundaries", () => {describe.each([["work-queue", queueTimeReading],["relative", relativeTimeReading],+ // A constant rendering names no instant at all, which is what keeps every+ // absolute timestamp in every table off the shared clock.+ ["absolute", absoluteTimeReading],+ ["compact", compactTimeReading],+ ["operational", operationalTimeReading],])("%s", (_name, reading) => {test.each(boundaryCases(SAMPLED_AGES_MS))("names the instant the reading changes (age $offset ms from $start, +$fractionMs ms)",