From 83c14d3a8eb7282958468bad7acc637eb22f763b Mon Sep 17 00:00:00 2001 From: CRT Date: Wed, 14 Oct 2026 09:13:04 +0800 Subject: [PATCH] tests: console-fill idmsa frame test waits for the frame, its form and its click log instead of reading them right after the sign-in hint (race under load) --- tests/console-fill.test.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/console-fill.test.ts b/tests/console-fill.test.ts index 156f7d1..d98c490 100644 --- a/tests/console-fill.test.ts +++ b/tests/console-fill.test.ts @@ -557,7 +557,14 @@ describe.skipIf(!browser)('sign-in and watching (headless, modeled pages on the expect(said.some(m => m.includes('Keep me signed in'))).toBe(true); expect(new URL(b.page.url()).pathname).toBe('/login'); expect(await signInPage(b.page)).toBe(true); - const frame = b.page.frames().find((f: any) => f.url().startsWith('https://idmsa.apple.com/')); + // the hint can come before the idmsa frame has navigated and run _common.js: wait for the frame, its form and + // its click log instead of reading them right away (a race on a loaded machine) + const idmsa = (f: any) => f.url().startsWith('https://idmsa.apple.com/'); + await b.page.waitForFunction(() => document.querySelector('iframe') !== null, null, { timeout: scaled(10_000) }); + let frame: any; + for (const end = Date.now() + scaled(10_000); !(frame = b.page.frames().find(idmsa)) && Date.now() < end;) await new Promise(r => setTimeout(r, 50)); + expect(frame).toBeTruthy(); + await frame.waitForFunction(() => Array.isArray((window as any).__clicks) && !!document.querySelector('#acc'), null, { timeout: scaled(10_000) }); expect(await frame.evaluate(() => (window as any).__clicks)).toEqual([]); // nothing clicked on the sign-in form expect(await frame.locator('#acc').inputValue()).toBe(''); // nothing typed await b.page.evaluate(() => (window as any).__signIn()); // the owner signs in