Skip to content

Commit 0d4933d

Browse files
committed
test(e2e): fix flaky model switchto test race condition
The test previously expected `after.modelId` to equal `before.modelId` after successfully switching to `gpt-4.1`. This only passed due to a race condition where the `session.model_change` event hadn't yet propagated to the client before `getCurrent()` was called. On some environments (like Windows CI), the event arrived faster, causing the model to correctly update to `gpt-4.1`, which then failed the logically incorrect assertion. This commit properly awaits the `session.model_change` event and asserts that the model successfully changed to `gpt-4.1`.
1 parent 867e78c commit 0d4933d

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

nodejs/test/e2e/rpc_session_state.e2e.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,11 @@ describe("Session-scoped RPC", async () => {
6262
modelId: "gpt-4.1",
6363
reasoningEffort: "high",
6464
});
65+
await waitForEvent(session, (event) => event.type === "session.model_change" && event.data.newModel === "gpt-4.1", "session.model_change event after switchTo");
6566
const after = await session.rpc.model.getCurrent();
6667

6768
expect(result.modelId).toBe("gpt-4.1");
68-
expect(after.modelId).toBe(before.modelId);
69+
expect(after.modelId).toBe("gpt-4.1");
6970

7071
await session.disconnect();
7172
});

0 commit comments

Comments
 (0)