fix(web): stop doubling the dot modifier on the status page head

`serverDotClass()` already returns the full `dot--<status>` class, but the head
fed it to a `DotStatus` prop that prepends `dot--` again, so the dot never
matched a status color. Strip the prefix and assert the concrete class
(`dot--attention` / `dot--ok`) in the page tests instead of just the size.
This commit is contained in:
yuez committed 2026-10-27 18:07:11 +08:00
1 parent f549045ed2
commit ec80ee4bab
2 files changed
+31 -2

No files matched your search

+1 -1
View File
@@ -157,7 +157,7 @@ export function StatusPage() {
}
const statusLabel = t(`state.${server.status}`, { defaultValue: server.status });
const headDot = serverDotClass(server.status) as DotStatus;
const headDot = serverDotClass(server.status).replace("dot--", "") as DotStatus;
// "updated <relative>" — the prototype's quiet freshness hint in the head.
const updatedAt = info.dataUpdatedAt || null;
const updatedLabel = t("status.updated", {
+30 -1
View File
@@ -284,7 +284,10 @@ describe("StatusPage", () => {
const head = document.querySelector(".page-head.status-head");
expect(head).not.toBeNull();
expect(head?.querySelector(".dot--lg")).not.toBeNull();
await waitFor(() => {
const dot = head?.querySelector(".dot--lg");
expect(dot).toHaveClass("dot--attention");
});
await waitFor(() =>
expect(within(head as HTMLElement).getByText(/pi2-box · pi2-box ·/)).toBeInTheDocument(),
);
@@ -305,6 +308,32 @@ describe("StatusPage", () => {
expect(within(info).queryByText("—")).not.toBeInTheDocument();
});
it("renders the page header dot with dot--ok for a healthy daemon", async () => {
mockApi(
apiRoutes([
{
path: "/api/v1/health",
handler: () => ({
body: {
ok: true,
checkedAt: Date.now(),
items: [{ name: "plugin", ok: true, detail: "connected" }],
},
}),
},
]),
);
await renderPage(routes(), "/status", { paired: true });
await screen.findByText("Server info");
const head = document.querySelector(".page-head.status-head");
expect(head).not.toBeNull();
await waitFor(() => {
const dot = head?.querySelector(".dot--lg");
expect(dot).toHaveClass("dot--ok");
});
});
it("counts failed health checks and keeps the per-check list", async () => {
mockApi(apiRoutes());
await renderPage(routes(), "/status", { paired: true });