feat(report): add annotated wrinkle views and restore capture countdown

This commit is contained in:
xsl
2026-10-15 19:45:21 +08:00
parent 2d80f6dfd0
commit 757b96dfad
23 changed files with 396 additions and 75 deletions
+17 -4
View File
@@ -17,15 +17,16 @@ try {
captureFromVideo=function(){window.__shots.push(step);return 'fixture';};
checkStill=function(){return Promise.resolve(null);};
onPhotoCaptured=function(){window.__completed.push(step);}; doCapture(); },
again:doCapture, cancel:function(){camSeq++; voice.stop(true);},
again:doCapture, cancel:leaveCamera,
busy:function(){return shutterLock;}
};
})();`)}));
await page.addInitScript(()=>{
window.__audio=[];window.__shots=[];window.__completed=[];
window.AudioContext=class {
constructor(){this.state='running';this.destination={};}
decodeAudioData(ab,resolve){const b={id:new TextDecoder().decode(ab),duration:3};resolve(b);return Promise.resolve(b);}
constructor(){this.destination={};}
get state(){return window.__mute?'suspended':'running';}
decodeAudioData(ab,resolve){const b={id:new TextDecoder().decode(ab),duration:.9};resolve(b);return Promise.resolve(b);}
createBufferSource(){return {connect(){},stop(){},start(){window.__audio.push(this);}};}
};
});
@@ -36,18 +37,30 @@ try {
await page.evaluate(n=>window.__countdown.start(n),step);
await page.waitForFunction(n=>window.__audio.length===n,step+1);
assert.equal(await page.evaluate(()=>window.__audio.at(-1).buffer.id),'countdown-321.mp3');
assert.equal(await page.locator('#cam-countdown').textContent(),'3');
assert.equal(await page.locator('#cam-countdown').evaluate(e=>e.hidden),false);
await page.evaluate(()=>window.__countdown.again());
await page.waitForTimeout(350);
assert.equal(await page.evaluate(()=>window.__shots.length),step,'no capture before audio ended');
assert(await page.evaluate(()=>window.__countdown.busy()));
assert.equal(await page.locator('#cam-countdown').textContent(),'2');
await page.waitForFunction(()=>document.querySelector('#cam-countdown').textContent==='1');
await page.evaluate(()=>window.__audio.at(-1).onended());
await page.waitForFunction(n=>window.__completed.length===n,step+1);
assert.equal(await page.locator('#cam-countdown').evaluate(e=>e.hidden),true);
}
await page.evaluate(()=>window.__countdown.start(0));
await page.waitForFunction(()=>window.__audio.length===4);
await page.evaluate(()=>window.__countdown.cancel());
assert.equal(await page.locator('#cam-countdown').evaluate(e=>e.hidden),true,'cancel immediately clears countdown');
await page.waitForTimeout(700);
assert.equal(await page.evaluate(()=>window.__shots.length),3,'cancelled countdown never captures');
await page.evaluate(()=>{window.__mute=true;window.__countdown.start(0);});
assert.equal(await page.locator('#cam-countdown').textContent(),'3');
await page.waitForTimeout(350);
assert.equal(await page.evaluate(()=>window.__shots.length),3,'silent devices still wait for visual countdown');
await page.waitForFunction(()=>window.__completed.length===4);
assert.equal(await page.locator('#cam-countdown').evaluate(e=>e.hidden),true);
assert.deepEqual(errors,[]);
console.log('PASS: each of 3 shots waits for countdown ended; duplicate shutter ignored; cancellation safe');
console.log('PASS: all 3 shots show animated 3/2/1, wait for voice and visual completion; duplicate shutter ignored; cancellation clears digits; silent-device countdown');
}finally{await browser.close();}