mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:00:42 +00:00
test: move query token checks to settings unit
This commit is contained in:
@@ -299,7 +299,7 @@ describe("applySettingsFromUrl", () => {
|
||||
});
|
||||
|
||||
it("hydrates query token params and strips them from the URL", () => {
|
||||
setTestWindowUrl("https://control.example/ui/overview?token=abc123");
|
||||
setTestWindowUrl("https://control.example/ui/overview?token=abc123&password=sekret");
|
||||
const host = createHost("overview");
|
||||
host.settings.gatewayUrl = "wss://control.example/openclaw";
|
||||
|
||||
@@ -307,6 +307,9 @@ describe("applySettingsFromUrl", () => {
|
||||
|
||||
expect(host.settings.token).toBe("abc123");
|
||||
expect(window.location.search).toBe("");
|
||||
expect(JSON.parse(localStorage.getItem("openclaw.control.settings.v1") ?? "{}").token).toBe(
|
||||
undefined,
|
||||
);
|
||||
});
|
||||
|
||||
it("prefers fragment tokens over legacy query tokens when both are present", () => {
|
||||
|
||||
@@ -39,22 +39,6 @@ function expectConfirmedGatewayChange(app: ReturnType<typeof mountApp>) {
|
||||
}
|
||||
|
||||
describe("control UI routing", () => {
|
||||
it("keeps chat navigation links visible and updates the URL when clicked", async () => {
|
||||
const app = mountApp("/chat");
|
||||
await app.updateComplete;
|
||||
|
||||
const dreamsLink = app.querySelector<HTMLAnchorElement>('a.nav-item[href="/dreaming"]');
|
||||
expect(dreamsLink).not.toBeNull();
|
||||
|
||||
const link = app.querySelector<HTMLAnchorElement>('a.nav-item[href="/channels"]');
|
||||
expect(link).not.toBeNull();
|
||||
link?.dispatchEvent(new MouseEvent("click", { bubbles: true, cancelable: true, button: 0 }));
|
||||
|
||||
await app.updateComplete;
|
||||
expect(app.tab).toBe("channels");
|
||||
expect(window.location.pathname).toBe("/channels");
|
||||
});
|
||||
|
||||
it("renders the dreaming view on the /dreaming route", async () => {
|
||||
const app = mountApp("/dreaming");
|
||||
app.dreamingStatus = {
|
||||
@@ -127,6 +111,9 @@ describe("control UI routing", () => {
|
||||
|
||||
expect(window.matchMedia("(max-width: 768px)").matches).toBe(true);
|
||||
|
||||
const dreamsLink = app.querySelector<HTMLAnchorElement>('a.nav-item[href="/dreaming"]');
|
||||
expect(dreamsLink).not.toBeNull();
|
||||
|
||||
expect(app.querySelector(".topnav-shell")).not.toBeNull();
|
||||
expect(app.querySelector(".topnav-shell__content")).not.toBeNull();
|
||||
expect(app.querySelector(".topnav-shell__actions")).not.toBeNull();
|
||||
@@ -400,19 +387,6 @@ describe("control UI routing", () => {
|
||||
expect(container.scrollTop).toBe(targetScrollTop);
|
||||
});
|
||||
|
||||
it("hydrates safe query params and strips unsafe credentials from the URL", async () => {
|
||||
const app = mountApp("/ui/overview?token=abc123&password=sekret");
|
||||
await app.updateComplete;
|
||||
|
||||
expect(app.settings.token).toBe("abc123");
|
||||
expect(app.password).toBe("");
|
||||
expect(JSON.parse(localStorage.getItem("openclaw.control.settings.v1") ?? "{}").token).toBe(
|
||||
undefined,
|
||||
);
|
||||
expect(window.location.pathname).toBe("/ui/overview");
|
||||
expect(window.location.search).toBe("");
|
||||
});
|
||||
|
||||
it("hydrates token from URL hash, strips it, and clears it after gateway changes", async () => {
|
||||
const app = mountApp("/ui/overview#token=abc123");
|
||||
await app.updateComplete;
|
||||
|
||||
Reference in New Issue
Block a user