From 8eddfe82ffcd39e19bd7aa9f1080488a75358ad9 Mon Sep 17 00:00:00 2001 From: David Brailovsky Date: Thu, 5 Nov 2026 09:45:13 +0100 Subject: [PATCH] fix(ai): advance fake timers until Copilot login settles in OAuth test models.login loads the OAuth flow module through a URL import since 5c6ce2b32, which takes real I/O under vitest. A single 1000ms fake-timer advance ran before the device flow started, leaving the poll wait unadvanced and the test hanging. --- packages/ai/test/github-copilot-oauth.test.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/ai/test/github-copilot-oauth.test.ts b/packages/ai/test/github-copilot-oauth.test.ts index 468f021f6..0554409df 100644 --- a/packages/ai/test/github-copilot-oauth.test.ts +++ b/packages/ai/test/github-copilot-oauth.test.ts @@ -467,7 +467,14 @@ describe("GitHub Copilot OAuth device flow", () => { notify: () => {}, }); - await vi.advanceTimersByTimeAsync(1000); + // models.login loads the flow module with real I/O before the device flow starts, + // so keep moving the fake clock until login settles instead of advancing once. + let settled = false; + const markSettled = () => { + settled = true; + }; + loginPromise.then(markSettled, markSettled); + while (!settled) await vi.advanceTimersByTimeAsync(1000); const credential = await loginPromise; expect(credential).toMatchObject({ type: "oauth", access: testCopilotAccessToken }); expect(policyModelIds).toEqual([firstModelId]);