|
1 | 1 | import path from "node:path"; |
2 | 2 | import { expect, it } from "vitest"; |
| 3 | +import { |
| 4 | + waitForControlUiGatewayReady, |
| 5 | + waitForControlUiGatewayReconnecting, |
| 6 | +} from "../test-helpers/control-ui-e2e-readiness.ts"; |
3 | 7 | import { expectRequestCountStable } from "./chat-flow.test-support.ts"; |
4 | 8 | import { |
5 | 9 | actionOpacity, |
@@ -434,12 +438,24 @@ suite.define(() => { |
434 | 438 | await expect.poll(() => sidebarRows.count()).toBe(3); |
435 | 439 | const initialListCount = (await gateway.getRequests("sessions.list")).length; |
436 | 440 |
|
437 | | - await gateway.deferNext("sessions.list"); |
438 | | - await gateway.closeLatest(1006, "disconnect proof"); |
439 | | - await sidebarRow.waitFor({ state: "visible" }); |
| 441 | + const socketsBefore = await gateway.getSocketCount(); |
| 442 | + await gateway.setOnline(false); |
| 443 | + await waitForControlUiGatewayReconnecting(page); |
| 444 | + await expect.poll(() => sidebarRow.textContent()).toContain("Disconnect proof"); |
| 445 | + await expect.poll(() => sidebarRows.count()).toBe(3); |
| 446 | + for (const otherKey of otherSessionKeys) { |
| 447 | + await page |
| 448 | + .locator(`.sidebar-recent-session[data-session-key="${otherKey}"]`) |
| 449 | + .waitFor({ state: "visible" }); |
| 450 | + } |
440 | 451 | await captureUiProof(page, "sidebar-sessions-during-reconnect.png"); |
441 | 452 |
|
442 | | - await expect.poll(() => gateway.getSocketCount(), { timeout: 15_000 }).toBeGreaterThan(1); |
| 453 | + await expect |
| 454 | + .poll(() => gateway.getSocketCount(), { timeout: 15_000 }) |
| 455 | + .toBe(socketsBefore + 1); |
| 456 | + await gateway.deferNext("sessions.list"); |
| 457 | + await gateway.setOnline(true); |
| 458 | + await waitForControlUiGatewayReady(page); |
443 | 459 | await expect |
444 | 460 | .poll(async () => (await gateway.getRequests("sessions.list")).length, { timeout: 15_000 }) |
445 | 461 | .toBeGreaterThan(initialListCount); |
@@ -501,10 +517,18 @@ suite.define(() => { |
501 | 517 | const initialObserverCount = (await gateway.getRequests("sessions.subscribe")).length; |
502 | 518 | const initialListCount = (await gateway.getRequests("sessions.list")).length; |
503 | 519 |
|
| 520 | + const socketsBefore = await gateway.getSocketCount(); |
| 521 | + await gateway.setOnline(false); |
| 522 | + await waitForControlUiGatewayReconnecting(page); |
| 523 | + await expect.poll(() => selectedRow.getAttribute("class")).toContain("--active"); |
| 524 | + expect(new URL(page.url()).pathname).toBe(controlUiSessionPath(selectedKey)); |
| 525 | + await expect |
| 526 | + .poll(() => gateway.getSocketCount(), { timeout: 15_000 }) |
| 527 | + .toBe(socketsBefore + 1); |
504 | 528 | await gateway.deferNext("sessions.subscribe"); |
505 | 529 | await gateway.deferNext("sessions.list"); |
506 | | - await gateway.closeLatest(1006, "session route reconnect"); |
507 | | - await expect.poll(() => gateway.getSocketCount(), { timeout: 15_000 }).toBeGreaterThan(1); |
| 530 | + await gateway.setOnline(true); |
| 531 | + await waitForControlUiGatewayReady(page); |
508 | 532 | await expect |
509 | 533 | .poll(async () => (await gateway.getRequests("sessions.subscribe")).length, { |
510 | 534 | timeout: 15_000, |
|
0 commit comments