// Bring the wave-six snapshot in line with round 40's corrected background // check (a ten-second background window can legitimately cross a track // boundary, which is playback continuing, not playback stopping). const fs = require('fs'); const f = process.argv[process.argv.length - 1] + '/tests/mobile/smoke.mjs'; let s = fs.readFileSync(f, 'utf8'); const done = []; const a1 = ` const posBefore = (await cdp.evaluate(PLAYER))?.pos ?? 0; cdp.close();`; const b1 = ` const bgBefore = await cdp.evaluate(PLAYER); const posBefore = bgBefore?.pos ?? 0; cdp.close();`; if (s.includes(a1)) { s = s.replace(a1, () => b1); done.push('posBefore'); } const a2 = ` const posAfter = (await cdp.evaluate(PLAYER))?.pos ?? 0; const bgOk = stillPlaying && posAfter >= posBefore + 8; if (!bgOk) problems.push("EXPECT background " + JSON.stringify({ posBefore, posAfter, stillPlaying })); console.log((bgOk ? " ok " : " FAIL ") + "background".padEnd(16) + " " + JSON.stringify({ posBefore, posAfter, stillPlaying }));`; const b2 = ` const bgAfter = await cdp.evaluate(PLAYER); const posAfter = bgAfter?.pos ?? 0; const crossed = !!(bgBefore && bgAfter && bgBefore.title !== bgAfter.title); const bgOk = stillPlaying && (crossed || posAfter >= posBefore + 8); const bgSeen = { posBefore, posAfter, stillPlaying, crossed, from: bgBefore?.title ?? null, to: bgAfter?.title ?? null }; if (!bgOk) problems.push("EXPECT background " + JSON.stringify(bgSeen)); console.log((bgOk ? " ok " : " FAIL ") + "background".padEnd(16) + " " + JSON.stringify(bgSeen));`; if (s.includes(a2)) { s = s.replace(a2, () => b2); done.push('bgOk'); } fs.writeFileSync(f, s); console.log('realigned: ' + (done.join(', ') || 'nothing to do'));