From 80c615daeef145d65b44341b1f69e4fbf40cdc46 Mon Sep 17 00:00:00 2001 From: Shakker Date: Tue, 12 May 2026 16:45:37 +0100 Subject: [PATCH] test: bind pairing hint commands --- ui/src/ui/views/overview.render.test.ts | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/ui/src/ui/views/overview.render.test.ts b/ui/src/ui/views/overview.render.test.ts index 0676c917638..17596a08133 100644 --- a/ui/src/ui/views/overview.render.test.ts +++ b/ui/src/ui/views/overview.render.test.ts @@ -60,6 +60,10 @@ function createOverviewProps(overrides: Partial = {}): OverviewPr }; } +function compactText(node: Element | null): string | undefined { + return node?.textContent?.trim().replace(/\s+/g, " "); +} + describe("overview view rendering", () => { it("keeps the persisted overview locale selected before i18n hydration finishes", async () => { const container = document.createElement("div"); @@ -102,11 +106,14 @@ describe("overview view rendering", () => { render(renderOverview(props), container); await Promise.resolve(); - expect(container.textContent).toContain("Scope upgrade pending approval."); - expect(container.textContent).toContain( - "This device is already paired, but the requested wider scope is waiting for approval.", + const hint = container.querySelector(".mono")?.closest(".muted") ?? null; + expect(compactText(hint)).toBe( + "Scope upgrade pending approval. This device is already paired, but the requested wider scope is waiting for approval. openclaw devices approve req-123 openclaw devices list On mobile? Copy the full URL (including #token=...) from openclaw dashboard --no-open on your desktop. Docs: Device pairing", ); - expect(container.textContent).toContain("openclaw devices approve req-123"); + expect([...container.querySelectorAll(".mono")].map((node) => node.textContent)).toEqual([ + "openclaw devices approve req-123", + "openclaw devices list", + ]); }); it("does not suggest preview-only latest approval when the request id is absent", async () => { @@ -119,8 +126,12 @@ describe("overview view rendering", () => { render(renderOverview(props), container); await Promise.resolve(); - expect(container.textContent).toContain("Scope upgrade pending approval."); - expect(container.textContent).toContain("openclaw devices list"); - expect(container.textContent).not.toContain("openclaw devices approve --latest"); + const hint = container.querySelector(".mono")?.closest(".muted") ?? null; + expect(compactText(hint)).toBe( + "Scope upgrade pending approval. This device is already paired, but the requested wider scope is waiting for approval. openclaw devices list On mobile? Copy the full URL (including #token=...) from openclaw dashboard --no-open on your desktop. Docs: Device pairing", + ); + expect([...container.querySelectorAll(".mono")].map((node) => node.textContent)).toEqual([ + "openclaw devices list", + ]); }); });