Files
nxdns/admin/src/lib/CoverageNotice.test.tsx
T
mokhtar 0fd6bbd312
Gates / frontend (push) Successful in 1m36s
Gates / test (push) Successful in 1m56s
Gates / test-aarch64 (push) Successful in 7m37s
Gates / package (push) Successful in 9m12s
Gates / container (push) Successful in 13s
CI / gates (push) Successful in 19m4s
milestone 28: query provenance — every logged query is exactly explainable
query rows gain qclass, rcode, group, policy action and reason, the
matched rule or list entry with its source, cname and safe-search
targets, route kind, forward zone, and the resolver that actually
answered — the pool and local markers die. servfails are logged and
name the resolver that lost; post-parse protocol refusals become rows.
a detail page at /queries/:id renders the ordered explanation, and
coverage watermarks distinguish an empty history from a missing one.

the schema fingerprint changes: existing query history is recreated
with the old file kept aside and the reset filed as a resolved
diagnostic. fixes an oversized udp reply being rebuilt as noerror,
which handed clients a truncated nxdomain as success.
2026-08-22 09:16:40 +02:00

32 lines
1.3 KiB
TypeScript

import { render, screen } from "@testing-library/react";
import CoverageNotice from "./CoverageNotice";
import { formatTime } from "./format";
const WATERMARK = 1_700_000_000;
test("a window the log covers in full says nothing", () => {
const { container } = render(<CoverageNotice coverage={{ complete: true, available_since: WATERMARK }} />);
expect(container.textContent).toBe("");
});
test("a window reaching past the watermark names the instant history starts", () => {
render(<CoverageNotice coverage={{ complete: false, available_since: WATERMARK }} />);
const notice = screen.getByRole("status");
expect(notice.textContent).toContain("Query history is available from");
expect(notice.textContent).toContain(formatTime(WATERMARK));
});
/**
* The server judges completeness, not the page: an unbounded request is
* incomplete whatever the watermark reads, and the notice must follow that
* verdict rather than compare timestamps itself.
*/
test("the server's verdict decides, not the numbers beside it", () => {
const { rerender, container } = render(
<CoverageNotice coverage={{ complete: true, available_since: WATERMARK }} />,
);
expect(container.textContent).toBe("");
rerender(<CoverageNotice coverage={{ complete: false, available_since: 0 }} />);
expect(screen.getByRole("status").textContent).toContain(formatTime(0));
});