From 2bdb11eebaf64d170257612736e72583d4977d30 Mon Sep 17 00:00:00 2001 From: chengyongru Date: Tue, 18 Aug 2026 18:02:07 +0800 Subject: [PATCH] test(tui): simplify expired credential fixture --- tui/src/app.test.ts | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/tui/src/app.test.ts b/tui/src/app.test.ts index 2dd289b92..723e81842 100644 --- a/tui/src/app.test.ts +++ b/tui/src/app.test.ts @@ -552,7 +552,6 @@ describe("NanobotTui layout", () => { test("refreshes expired API credentials before opening sessions", async () => { setup = await createRenderer({ width: 80, height: 24, screenMode: "alternate-screen" }) const original = globalThis.fetch - let expired = false let bootstrapRequests = 0 const sessionAuthorizations: Array = [] globalThis.fetch = (async (input: string | URL | Request, init?: RequestInit) => { @@ -567,7 +566,7 @@ describe("NanobotTui layout", () => { })) } if (authorization === "Bearer expired-api-token") { - if (expired) return new Response("Unauthorized", { status: 401 }) + return new Response("Unauthorized", { status: 401 }) } if (url.endsWith("/api/sessions")) { sessionAuthorizations.push(authorization) @@ -575,21 +574,6 @@ describe("NanobotTui layout", () => { sessions: [{ key: "websocket:chat", title: "Current chat" }], })) } - if (url.endsWith("/api/commands")) { - return new Response(JSON.stringify({ commands: [] })) - } - if (url.endsWith("/api/settings")) { - return new Response(JSON.stringify({ model_presets: [] })) - } - if (url.endsWith("/api/workspaces")) { - return new Response(JSON.stringify({ controls: {} })) - } - if (url.includes("/api/settings/cli-apps")) { - return new Response(JSON.stringify({ apps: [] })) - } - if (url.endsWith("/api/settings/mcp-presets")) { - return new Response(JSON.stringify({ presets: [] })) - } return new Response("{}") }) as typeof fetch const app = NanobotTui.mount( @@ -614,11 +598,10 @@ describe("NanobotTui layout", () => { try { await waitUntil(() => ui.ready) - expired = true ui.composer.setText("/sessions") ui.composer.submit() - await waitUntil(() => bootstrapRequests === 1) + await waitUntil(() => bootstrapRequests >= 1) await waitUntil(() => ui.sessionMenu.visible) expect(bootstrapRequests).toBe(1) expect(sessionAuthorizations.at(-1)).toBe("Bearer fresh-api-token")