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.
This commit is contained in:
David Brailovsky 2026-11-05 09:45:13 +01:00
parent c5d98a78ed
commit 8eddfe82ff

View file

@ -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]);