Skip to content

Commit dce5339

Browse files
committed
Fix e2e release and websocket readiness tests
1 parent ca45b18 commit dce5339

2 files changed

Lines changed: 32 additions & 15 deletions

File tree

tests/e2e/e2e.spec.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ const TAB_STABILITY_DIRS = [
1616
path.join(HOME_DIR, 'coder-studio-e2e-tab-b'),
1717
];
1818
const TAB_STABILITY_LABELS = TAB_STABILITY_DIRS.map((dir) => path.basename(dir));
19+
const COMPLETION_AUDIO_EVENT_PATTERN = /play:.*task-complete(?:-[A-Za-z0-9_-]+)?\.(wav|mp3|ogg)/;
20+
const REMOTE_HTTP_HOST = 'remote.example.test';
21+
const REMOTE_HTTP_PASSWORD = 'coder-studio-remote-e2e';
1922

2023
type RuntimeCommandMockState = {
2124
claude: boolean;
@@ -616,7 +619,7 @@ test('background turn_completed sends a completion reminder notification', async
616619
page,
617620
`notify:${backgroundSession!.title}:${pair.background.workspace.title} · Task complete`,
618621
);
619-
await waitForAudioEvent(page, /play:.*task-complete\.(wav|mp3|ogg)/);
622+
await waitForAudioEvent(page, COMPLETION_AUDIO_EVENT_PATTERN);
620623
} finally {
621624
await cleanup();
622625
}
@@ -663,7 +666,7 @@ test('background turn_completed still sends a reminder while viewing settings',
663666
page,
664667
`notify:${backgroundSession!.title}:${pair.background.workspace.title} · Task complete`,
665668
);
666-
await waitForAudioEvent(page, /play:.*task-complete\.(wav|mp3|ogg)/);
669+
await waitForAudioEvent(page, COMPLETION_AUDIO_EVENT_PATTERN);
667670
} finally {
668671
await cleanup();
669672
}

tests/e2e/transport.spec.ts

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ type WorkspaceControllerLeaseSnapshot = {
8080
type TransportTrackerSnapshot = {
8181
urls: string[];
8282
connectTimes: number[];
83+
openTimes: number[];
8384
closeTimes: number[];
8485
scheduledTimeouts: number[];
8586
frames: string[];
@@ -704,18 +705,6 @@ test.describe('workspace transport baseline', () => {
704705
mode: 'branch',
705706
});
706707

707-
await invokeRpc(page, 'workspace_view_update', {
708-
...controller,
709-
patch: {
710-
active_session_id: String(session.id),
711-
active_pane_id: `pane-${session.id}`,
712-
pane_layout: {
713-
type: 'leaf',
714-
id: `pane-${session.id}`,
715-
sessionId: String(session.id),
716-
},
717-
},
718-
});
719708
await invokeRpc(page, 'session_update', {
720709
...controller,
721710
sessionId: session.id,
@@ -724,6 +713,23 @@ test.describe('workspace transport baseline', () => {
724713
claude_session_id: resumeClaudeSessionId,
725714
},
726715
});
716+
const interruptedSessionCard = page.locator(`.agent-pane-card[data-session-id="${session.id}"]`).first();
717+
await expect(interruptedSessionCard).toBeVisible();
718+
await interruptedSessionCard.click();
719+
await expect.poll(async () => {
720+
const runtime = await invokeRpc<{
721+
snapshot: {
722+
view_state: {
723+
active_session_id: string;
724+
};
725+
};
726+
}>(page, 'workspace_runtime_attach', {
727+
workspaceId: workspace.workspaceId,
728+
deviceId: ids.deviceId,
729+
clientId: ids.clientId,
730+
});
731+
return runtime.snapshot.view_state.active_session_id;
732+
}).toBe(String(session.id));
727733

728734
await page.reload();
729735
await expect(page.getByTestId('workspace-topbar')).toBeVisible();
@@ -1048,6 +1054,7 @@ async function installTransportProbe(
10481054
const store = {
10491055
urls: [] as string[],
10501056
connectTimes: [] as number[],
1057+
openTimes: [] as number[],
10511058
closeTimes: [] as number[],
10521059
scheduledTimeouts: [] as number[],
10531060
frames: [] as string[],
@@ -1066,6 +1073,9 @@ async function installTransportProbe(
10661073
store.urls.push(String(url));
10671074
store.connectTimes.push(Date.now());
10681075
store.sockets.push(socket);
1076+
socket.addEventListener('open', () => {
1077+
store.openTimes.push(Date.now());
1078+
});
10691079
socket.addEventListener('message', (event) => {
10701080
store.frames.push(String(event.data));
10711081
});
@@ -1088,6 +1098,7 @@ async function installTransportProbe(
10881098
return {
10891099
urls: [...store.urls],
10901100
connectTimes: [...store.connectTimes],
1101+
openTimes: [...store.openTimes],
10911102
closeTimes: [...store.closeTimes],
10921103
scheduledTimeouts: [...store.scheduledTimeouts],
10931104
frames: [...store.frames],
@@ -1375,7 +1386,10 @@ function countTrackedSockets(tracker: TransportTrackerSnapshot, fragment: string
13751386

13761387
async function waitForBackendSocket(page: Page) {
13771388
await expect
1378-
.poll(async () => countTrackedSockets(await readTransportTracker(page), BACKEND_WS_PATH), {
1389+
.poll(async () => {
1390+
const tracker = await readTransportTracker(page);
1391+
return tracker.openTimes.length - tracker.closeTimes.length;
1392+
}, {
13791393
timeout: 10000,
13801394
})
13811395
.toBeGreaterThan(0);

0 commit comments

Comments
 (0)