diff --git a/tools/e2e/68-composition.mjs b/tools/e2e/68-composition.mjs index a238441a..bbb9f7d3 100644 --- a/tools/e2e/68-composition.mjs +++ b/tools/e2e/68-composition.mjs @@ -185,23 +185,30 @@ export async function composition(t) { c.objects = [{ ...structuredClone(c.objects[0]), id: 'cp68-v', assetId: 'cp68-screen', name: 'Video 68', overrides: {} }]; c.items = [{ id: 'cp68-v', track: 'cp68-front', start: 0, length: 120, offset: 0 }]; c.clips = [];`); - await play(); // The video time the composition writes into its item every frame. const clock = `__gm.world()?.entities.find((e) => e.objectId === '${id('v')}')?.props.videoTime ?? null`; - const wait = JSON.parse( - await evaluate(`new Promise((done) => { - const loading = []; + // Sampled from before the click on Play: play() settles after the start, and a video that loads + // quickly is ready by then, with no wait left to see (CI task 669). + await evaluate(`{ + const loading = []; + const until = performance.now() + 20000; + window.cp68Wait = new Promise((done) => { const step = () => { - const time = ${clock}; - const player = __gm.gameVideo('${id('v')}'); + const playing = __gm.state.mode === 'play'; + const time = playing ? ${clock} : null; + const player = playing ? __gm.gameVideo('${id('v')}') : null; if (player?.ready) return done(JSON.stringify({ loading, ready: time })); if (player) loading.push(time); - if (!__gm.world() || loading.length > 300) return done(JSON.stringify({ loading, ready: null })); + if (performance.now() > until) return done(JSON.stringify({ loading, ready: null })); requestAnimationFrame(step); }; step(); - })`), - ); + }); + // Not the promise as the block's value: evaluate would wait for it, and Play would come too late. + null; + }`); + await play(); + const wait = JSON.parse(await evaluate('window.cp68Wait')); await sleep(500); const after = await json(clock); check(