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' })