Skip to content

Commit ab77628

Browse files
committed
test(ui): stabilize history and reconnect e2e races
1 parent 08d2062 commit ab77628

2 files changed

Lines changed: 35 additions & 6 deletions

File tree

‎ui/src/e2e/claude-sessions.e2e.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,11 @@ suite.define(() => {
505505
await expect
506506
.poll(() => thread.evaluate((element) => element.scrollHeight > element.clientHeight + 100))
507507
.toBe(true);
508+
await thread.evaluate((element) => {
509+
element.scrollTop = element.scrollHeight;
510+
element.dispatchEvent(new Event("scroll"));
511+
});
512+
await expect.poll(() => thread.evaluate((element) => element.scrollTop)).toBeGreaterThan(0);
508513
const initialReadCount = (await gateway.getRequests("sessions.catalog.read")).length;
509514
await gateway.deferNext("sessions.catalog.read");
510515
await thread.evaluate((element) => {

‎ui/src/e2e/session-management.sidebar.e2e.test.ts‎

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import path from "node:path";
22
import { expect, it } from "vitest";
3+
import {
4+
waitForControlUiGatewayReady,
5+
waitForControlUiGatewayReconnecting,
6+
} from "../test-helpers/control-ui-e2e-readiness.ts";
37
import { expectRequestCountStable } from "./chat-flow.test-support.ts";
48
import {
59
actionOpacity,
@@ -434,12 +438,24 @@ suite.define(() => {
434438
await expect.poll(() => sidebarRows.count()).toBe(3);
435439
const initialListCount = (await gateway.getRequests("sessions.list")).length;
436440

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+
}
440451
await captureUiProof(page, "sidebar-sessions-during-reconnect.png");
441452

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);
443459
await expect
444460
.poll(async () => (await gateway.getRequests("sessions.list")).length, { timeout: 15_000 })
445461
.toBeGreaterThan(initialListCount);
@@ -501,10 +517,18 @@ suite.define(() => {
501517
const initialObserverCount = (await gateway.getRequests("sessions.subscribe")).length;
502518
const initialListCount = (await gateway.getRequests("sessions.list")).length;
503519

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);
504528
await gateway.deferNext("sessions.subscribe");
505529
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);
508532
await expect
509533
.poll(async () => (await gateway.getRequests("sessions.subscribe")).length, {
510534
timeout: 15_000,

0 commit comments

Comments
 (0)