Skip to content

Fully autonomous AI Agents system capable of performing complex penetration testing tasks

test(e2e): tighten the graphql-ws mock's id reuse, completion test and comment

Sergey Kozyrenko5803d5adc6a4
diff --git a/frontend/e2e/mocks/ws-graphql.ts b/frontend/e2e/mocks/ws-graphql.ts
index 679f32fc..8273b42e 100644
--- a/frontend/e2e/mocks/ws-graphql.ts
+++ b/frontend/e2e/mocks/ws-graphql.ts
@@ -53,9 +53,8 @@ export const handleWsConnection = (
}
case 'connection_init': {
- // Ack immediately and never send any frame before it: a pre-ack frame
- // throws inside graphql-ws, and this app's shouldRetry:()=>true turns
- // that into an infinite reconnect storm.
+ // Ack immediately; a frame sent before the ack is a graphql-ws protocol
+ // violation that closes the socket. Ack-first ordering is pinned by the unit test.
send({ type: 'connection_ack' });
break;
}
@@ -78,6 +77,9 @@ export const handleWsConnection = (
break;
}
+ // Reusing a live id is a protocol violation (4409); at minimum release the
+ // prior subscription so it can't leak both subscribers onto one id.
+ unsubscribes.get(id)?.();
unsubscribes.set(
id,
world.subscribeStream(match.streamKey, match.entry, {
diff --git a/frontend/e2e/mocks/ws-graphql.unit.test.ts b/frontend/e2e/mocks/ws-graphql.unit.test.ts
index 0d845cbb..e622b7f2 100644
--- a/frontend/e2e/mocks/ws-graphql.unit.test.ts
+++ b/frontend/e2e/mocks/ws-graphql.unit.test.ts
@@ -113,12 +113,22 @@ describe('graphql-ws mock protocol contract', () => {
it('completes the sink only for streams that opt into complete', async () => {
const { client } = await start({
- subscriptions: { finite: [{ complete: true, frames: [{ payload: { data: { finite: 1 } } }] }] },
+ subscriptions: {
+ finite: [{ complete: true, frames: [{ payload: { data: { finite: 1 } } }] }],
+ open: [{ frames: [{ payload: { data: { open: 1 } } }] }],
+ },
});
- const sink = collect(client, 'finite');
+ const finite = collect(client, 'finite');
+ const open = collect(client, 'open');
+
+ await vi.waitFor(() => expect(finite.isComplete()).toBe(true));
+ expect(finite.received).toEqual([{ data: { finite: 1 } }]);
- await vi.waitFor(() => expect(sink.isComplete()).toBe(true));
- expect(sink.received).toEqual([{ data: { finite: 1 } }]);
+ // A stream without `complete` delivers its frames but must stay open — the real server
+ // never completes live subscriptions, so flipping the default to complete would fail here.
+ await vi.waitFor(() => expect(open.received).toEqual([{ data: { open: 1 } }]));
+ await new Promise((resolve) => setTimeout(resolve, 50));
+ expect(open.isComplete()).toBe(false);
});
it('recovers from a 1001 drop and never replays already-delivered frames', async () => {