From 38fd018025f0998f02383f94003ff25327b4a73b Mon Sep 17 00:00:00 2001 From: David Ewing <143760935+david-firia@users.noreply.github.com> Date: Thu, 3 Dec 2026 10:27:08 -0600 Subject: [PATCH] Guided lesson tests: wait out the simulator's rebuild, not a fixed time learn-guided's "the ring is on the board again" and learn-journey's "changing the words meets it" failed now and then in CI and locally. Traced: when the simulator comes back, its 3D view is built again, and under the software renderer the tests run on (no GPU) that is one task holding the page's main thread for 8 to 15 seconds; the coach's 250 ms timer (and the goal watcher) run only after it. The lesson logic is right: the part is found and on screen within a second. The tests now wait for the ring (30 s) and for the met step (15 s) instead of 10 s and a fixed 900 ms. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01SS5gJ3k8r2g6DZMxocZDyP --- tests/learn-guided.mjs | 5 ++++- tests/learn-journey.mjs | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/learn-guided.mjs b/tests/learn-guided.mjs index a5a68f8..73537d3 100644 --- a/tests/learn-guided.mjs +++ b/tests/learn-guided.mjs @@ -162,7 +162,10 @@ for (const [name, width, height, touch] of SIZES) { await page.evaluate(() => window.openCodeBot.device.disconnect()) await page.waitForFunction(() => window.openCodeBot.device.simulating, null, { timeout: 20000 }).catch(() => {}) check((await state()).sim, 'the simulator closed during a mission comes back') - const ringBack = await page.waitForFunction(() => !document.querySelector('.journey-ring').hidden, null, { timeout: 10000 }).then(() => true, () => false) + // The simulator back, its 3D view is built again: under the software renderer the + // tests run on (no GPU), that holds the page's main thread for 8 to 15 seconds in + // one task, and the ring's timer runs only after it. Allow for it. + const ringBack = await page.waitForFunction(() => !document.querySelector('.journey-ring').hidden, null, { timeout: 30000 }).then(() => true, () => false) if (!ringBack) console.log(await page.evaluate(() => { const j = window.openCodeBot.learn.journey; return JSON.stringify({ i: j.index, point: j.steps[j.index]?.point, found: !!j._locate(j.steps[j.index]), view: !!window.openCodeBot.device.sim.view, good: j.coach?.good, folded: j.coach?.folded }) })) check(ringBack, 'and the ring is on the board again') diff --git a/tests/learn-journey.mjs b/tests/learn-journey.mjs index f651e75..0338fd2 100644 --- a/tests/learn-journey.mjs +++ b/tests/learn-journey.mjs @@ -198,8 +198,10 @@ for (const [name, width, height, touch, motion = 'no-preference'] of SIZES) { const app = window.openCodeBot app.workspace.replaceBlocks(app.blocksFromPython('from codex import *\n\ndisplay.show("Hi, I\'m Sam!")\n').state) }) - await page.waitForTimeout(900) - check(await bubble().evaluate((b) => b.classList.contains('good')), 'changing the words meets it') + // Met as soon as the goal watcher next looks; under the tests' software renderer the + // simulator can hold the main thread for seconds, so wait for it rather than a fixed time. + const met = await page.waitForFunction(() => document.querySelector('.journey-bubble')?.classList.contains('good'), null, { timeout: 15000 }).then(() => true, () => false) + check(met, 'changing the words meets it') // A reload in the middle comes back to the next step. await page.reload({ waitUntil: 'networkidle' })