admin: tables fit a phone, their first cell carrying the hidden columns, and no positioned label widens the page
This commit is contained in:
@@ -12,6 +12,7 @@ import { createAppRouter } from "@/routes";
|
||||
import { health } from "@/lib/healthFixture";
|
||||
import type { Client, Coverage, QueriesPage, QueryRow } from "@/lib/types";
|
||||
import { queryRow } from "@/features/provenance/provenanceFixture";
|
||||
import { activityCell } from "./activityCell";
|
||||
import { FakeEventSource } from "./fakeEventSource";
|
||||
|
||||
function client(id: number, ip: string, name: string, learnedName: string): Client {
|
||||
@@ -185,17 +186,16 @@ test("renders the first page with the seven columns filled in", async () => {
|
||||
"Route",
|
||||
"Duration",
|
||||
]);
|
||||
const first = screen.getByText("first.example").closest("tr")!;
|
||||
expect(within(first).getByText("HTTPS")).toBeTruthy();
|
||||
expect(within(first).getByText("NOERROR")).toBeTruthy();
|
||||
expect(within(first).getByText("Cache")).toBeTruthy();
|
||||
expect(within(first).getByText("1.2 ms")).toBeTruthy();
|
||||
expect(activityCell("first.example", "Type").textContent).toBe("HTTPS");
|
||||
expect(activityCell("first.example", "Result").textContent).toBe("NOERROR");
|
||||
expect(activityCell("first.example", "Route").textContent).toBe("Cache");
|
||||
expect(activityCell("first.example", "Duration").textContent).toBe("1.2 ms");
|
||||
|
||||
const blocked = screen.getByText("ads.example").closest("tr")!;
|
||||
// The Result cell says Blocked even though the client saw NOERROR, and the
|
||||
// Route cell says how: this is the pair the old Status column could not show.
|
||||
expect(within(blocked).getAllByText("Blocked")).toHaveLength(2);
|
||||
expect(within(blocked).getByText("—")).toBeTruthy();
|
||||
expect(activityCell("ads.example", "Result").textContent).toBe("Blocked");
|
||||
expect(activityCell("ads.example", "Route").textContent).toBe("Blocked");
|
||||
expect(activityCell("ads.example", "Duration").textContent).toBe("—");
|
||||
expect(countLine(/Showing 2 queries/)).toBeTruthy();
|
||||
});
|
||||
|
||||
@@ -216,9 +216,10 @@ test("resolves each row's client to its display name, reading the IP out with it
|
||||
});
|
||||
|
||||
renderPage();
|
||||
await screen.findAllByText("Kitchen Pi");
|
||||
|
||||
// A hand-typed name wins outright; the learned name never surfaces for it.
|
||||
const named = await screen.findByText("Kitchen Pi");
|
||||
const named = within(activityCell("named.example", "Client")).getByText("Kitchen Pi");
|
||||
// The address reads out with the name it replaced, rather than sitting in a
|
||||
// title only a mouse can reach.
|
||||
expect(named.textContent).toBe("Kitchen Pi (192.0.2.10)");
|
||||
@@ -227,14 +228,39 @@ test("resolves each row's client to its display name, reading the IP out with it
|
||||
|
||||
// A learned name reads muted and nothing more here: the "learned" tag would
|
||||
// repeat on every row of the table, so the Clients page carries it instead.
|
||||
const learned = screen.getByText("laptop.lan");
|
||||
const learned = within(activityCell("learned.example", "Client")).getByText("laptop.lan");
|
||||
expect(learned.textContent).toBe("laptop.lan (192.0.2.11)");
|
||||
expect(within(learned.closest("tr")!).queryByText("learned")).toBeNull();
|
||||
|
||||
// A known client with neither name, and a client the loaded list has never
|
||||
// seen, both fall back to the bare address with nothing standing in for it.
|
||||
expect(screen.getByText("192.0.2.12").textContent).toBe("192.0.2.12");
|
||||
expect(screen.getByText("192.0.2.99").textContent).toBe("192.0.2.99");
|
||||
expect(within(activityCell("nameless.example", "Client")).getByText("192.0.2.12").textContent).toBe("192.0.2.12");
|
||||
expect(within(activityCell("stranger.example", "Client")).getByText("192.0.2.99").textContent).toBe("192.0.2.99");
|
||||
});
|
||||
|
||||
test("the Domain cell carries the hidden columns' facts for a table too narrow for them", async () => {
|
||||
stubFetch((url) => {
|
||||
if (url === "/api/clients") return json({ clients: CLIENTS });
|
||||
if (url !== "/api/queries") return new Response(JSON.stringify({ error: "not stubbed" }), { status: 404 });
|
||||
return json({
|
||||
queries: [row(20, "named.example", { client_ip: "192.0.2.10" })],
|
||||
next_before: null,
|
||||
coverage: COMPLETE,
|
||||
} satisfies QueriesPage);
|
||||
});
|
||||
|
||||
renderPage();
|
||||
await screen.findAllByText("Kitchen Pi");
|
||||
|
||||
const domain = activityCell("named.example", "Domain");
|
||||
expect(within(domain).getByText("Kitchen Pi").textContent).toBe("Kitchen Pi (192.0.2.10)");
|
||||
const facts = [
|
||||
activityCell("named.example", "Time").textContent,
|
||||
`Type ${activityCell("named.example", "Type").textContent}`,
|
||||
activityCell("named.example", "Route").textContent,
|
||||
activityCell("named.example", "Duration").textContent,
|
||||
].join(" · ");
|
||||
expect(domain.textContent).toContain(facts);
|
||||
});
|
||||
|
||||
test("load more appends the next page and stops at the end of the log", async () => {
|
||||
|
||||
Reference in New Issue
Block a user