






















@@ -1,5 +1,4 @@
11import { afterEach, describe, expect, it, vi } from "vitest";
2-import "../test-helpers/load-styles.ts";
32import { mountApp as mountTestApp, registerAppMountHooks } from "./test-helpers/app-mount.ts";
4354registerAppMountHooks();
@@ -84,17 +83,13 @@ describe("control UI routing", () => {
8483const split = app.querySelector(".chat-split-container");
8584expect(split).not.toBeNull();
8685if (split) {
87-expect(getComputedStyle(split).position).not.toBe("fixed");
8886split.classList.add("chat-split-container--open");
8987await app.updateComplete;
9088expect(split.classList.contains("chat-split-container--open")).toBe(true);
9189}
92909391const chatMain = app.querySelector(".chat-main");
9492expect(chatMain).not.toBeNull();
95-if (chatMain) {
96-expect(getComputedStyle(chatMain).display).not.toBe("none");
97-}
98939994const topShell = app.querySelector<HTMLElement>(".topnav-shell");
10095const content = app.querySelector<HTMLElement>(".topnav-shell__content");
@@ -313,7 +308,7 @@ describe("control UI routing", () => {
313308expect(container.scrollTop).toBe(targetScrollTop);
314309});
315310316-it("hydrates token from URL hash, strips it, and clears it after gateway changes", async () => {
311+it("hydrates hash tokens, restores same-tab refreshes, and clears after gateway changes", async () => {
317312const app = mountApp("/ui/overview#token=abc123");
318313await app.updateComplete;
319314@@ -323,17 +318,26 @@ describe("control UI routing", () => {
323318);
324319expect(window.location.pathname).toBe("/ui/overview");
325320expect(window.location.hash).toBe("");
321+app.remove();
322+323+const refreshed = mountApp("/ui/overview");
324+await refreshed.updateComplete;
326325327-const gatewayUrlInput = app.querySelector<HTMLInputElement>(
326+expect(refreshed.settings.token).toBe("abc123");
327+expect(JSON.parse(localStorage.getItem("openclaw.control.settings.v1") ?? "{}").token).toBe(
328+undefined,
329+);
330+331+const gatewayUrlInput = refreshed.querySelector<HTMLInputElement>(
328332'input[placeholder="ws://100.x.y.z:18789"]',
329333);
330334expect(gatewayUrlInput).not.toBeNull();
331335gatewayUrlInput!.value = "wss://other-gateway.example/openclaw";
332336gatewayUrlInput!.dispatchEvent(new Event("input", { bubbles: true }));
333-await app.updateComplete;
337+await refreshed.updateComplete;
334338335-expect(app.settings.gatewayUrl).toBe("wss://other-gateway.example/openclaw");
336-expect(app.settings.token).toBe("");
339+expect(refreshed.settings.gatewayUrl).toBe("wss://other-gateway.example/openclaw");
340+expect(refreshed.settings.token).toBe("");
337341});
338342339343it("keeps a hash token pending until the gateway URL change is confirmed", async () => {
@@ -349,18 +353,4 @@ describe("control UI routing", () => {
349353350354expectConfirmedGatewayChange(app);
351355});
352-353-it("restores the token after a same-tab refresh", async () => {
354-const first = mountApp("/ui/overview#token=abc123");
355-await first.updateComplete;
356-first.remove();
357-358-const refreshed = mountApp("/ui/overview");
359-await refreshed.updateComplete;
360-361-expect(refreshed.settings.token).toBe("abc123");
362-expect(JSON.parse(localStorage.getItem("openclaw.control.settings.v1") ?? "{}").token).toBe(
363-undefined,
364-);
365-});
366356});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。