From ec80ee4bab0b5328c5849640da2918d1d9911a94 Mon Sep 17 00:00:00 2001 From: yuez Date: Tue, 27 Oct 2026 18:07:11 +0800 Subject: [PATCH] fix(web): stop doubling the dot modifier on the status page head `serverDotClass()` already returns the full `dot--` 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. --- web/src/pages/status.tsx | 2 +- web/tests/status-page.test.tsx | 31 ++++++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/web/src/pages/status.tsx b/web/src/pages/status.tsx index 1a16e72..f22504a 100644 --- a/web/src/pages/status.tsx +++ b/web/src/pages/status.tsx @@ -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 " — the prototype's quiet freshness hint in the head. const updatedAt = info.dataUpdatedAt || null; const updatedLabel = t("status.updated", { diff --git a/web/tests/status-page.test.tsx b/web/tests/status-page.test.tsx index 92c74cc..c90d64e 100644 --- a/web/tests/status-page.test.tsx +++ b/web/tests/status-page.test.tsx @@ -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 });