Skip to content

Commit a3db1ea

Browse files
committed
test(ui): await catalog terminal restore completion
Wait for catalog RPC dispatch and pending-intent completion before asserting exactly one restored terminal. Reuse the request filter without weakening payload, activation, or cache checks.
1 parent 147621c commit a3db1ea

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

‎ui/src/e2e/service-worker-update.e2e.test.ts‎

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,13 @@ describe("Control UI service-worker production update E2E", () => {
305305
},
306306
terminalEnabled: true,
307307
});
308+
const getCatalogOpens = async () =>
309+
(await gateway.getRequests("terminal.open")).filter(
310+
(request) =>
311+
typeof request.params === "object" &&
312+
request.params !== null &&
313+
"catalog" in request.params,
314+
);
308315
let installGate: InstallGate | null = null;
309316

310317
try {
@@ -413,14 +420,7 @@ describe("Control UI service-worker production update E2E", () => {
413420
.poll(() => page.evaluate(() => sessionStorage.getItem("openclaw.terminal.actions.v1")))
414421
.toContain("thread-during-worker-refresh");
415422
await page.waitForTimeout(300);
416-
const catalogOpensBeforeWorkerActivation = (
417-
await gateway.getRequests("terminal.open")
418-
).filter(
419-
(request) =>
420-
typeof request.params === "object" &&
421-
request.params !== null &&
422-
"catalog" in request.params,
423-
);
423+
const catalogOpensBeforeWorkerActivation = await getCatalogOpens();
424424
expect(catalogOpensBeforeWorkerActivation.length).toBeLessThanOrEqual(1);
425425
if (catalogOpensBeforeWorkerActivation.length > 0) {
426426
const currentConnect = (await gateway.getRequests("connect")).at(-1);
@@ -451,12 +451,13 @@ describe("Control UI service-worker production update E2E", () => {
451451
}),
452452
)
453453
.toEqual({ agentId: "research", available: true, open: true });
454-
const catalogOpens = (await gateway.getRequests("terminal.open")).filter(
455-
(request) =>
456-
typeof request.params === "object" &&
457-
request.params !== null &&
458-
"catalog" in request.params,
459-
);
454+
// Panel visibility precedes asynchronous terminal boot and RPC dispatch.
455+
// Observe the request and finish its intent before counting exactly once.
456+
await expect.poll(getCatalogOpens).toHaveLength(1);
457+
await expect
458+
.poll(() => page.evaluate(() => sessionStorage.getItem("openclaw.terminal.actions.v1")))
459+
.toBeNull();
460+
const catalogOpens = await getCatalogOpens();
460461
expect(catalogOpens).toHaveLength(1);
461462
const [terminalOpen] = catalogOpens;
462463
expect(terminalOpen?.params).toMatchObject({

0 commit comments

Comments
 (0)