fix(camera): remove post-capture photo revalidation

This commit is contained in:
xsl
2026-10-16 16:01:25 +08:00
parent 6a628f837b
commit 5e07985b19
9 changed files with 54 additions and 67 deletions
+13 -3
View File
@@ -96,6 +96,14 @@ try {
assert.equal(await page.locator('#s-cam.cam-manual').count(), 0, 'real automatic pipeline, not manual bypass');
await page.evaluate(() => {
window.__holdSamples = []; window.__hints = []; window.__evaluations = [];
window.__stillDetections = 0;
const detectFaces = faceapi.detectAllFaces;
faceapi.detectAllFaces = function(input, options) {
// Fixture setup uses sample-file images to align the synthetic video;
// captured/uploaded JPEGs are data URLs and must never be detected again.
if (input instanceof HTMLImageElement && input.src.startsWith('data:')) { window.__stillDetections++; throw Error('post-capture detection must not run'); }
return detectFaces.call(this, input, options);
};
const evaluate = CaptureQuality.evaluate;
CaptureQuality.evaluate = function(d, options) {
const result = evaluate(d, options);
@@ -118,7 +126,7 @@ try {
assert.equal(await page.evaluate(() => window.__voice.some(row => /^hint-turn-|^step[23]-|^shot-done$/.test(row.id))), false, 'no turn/next-step/completion audio before a successful front photo');
await page.evaluate(() => { window.__cameraFixture.light(.6); return window.__cameraFixture.set('C3_180.jpg'); });
await page.waitForFunction(()=>document.querySelector('#cam-hint').textContent.includes('建议到光线明亮处拍摄'));
// Keep the dim sample through countdown AND final JPEG validation.
// Keep the dim sample through countdown and capture, without a JPEG recheck.
try { await page.waitForFunction(() => document.querySelector('#cam-step').textContent.includes('2/3')); }
catch (error) {
console.log(await page.evaluate(async () => {
@@ -151,14 +159,16 @@ try {
for (const key of ['front', 'left', 'right']) {
const row = body.capture_diagnostics.views[key];
assert.equal(row.mode, 'live'); assert.equal(row.direction_checked, true);
assert.equal(row.check_stage, 'preview');
assert(row.score >= (key==='front'?.25:.3));
if(key==='front') assert(row.luma < 110, 'dim JPEG still passes final validation');
if(key==='front') assert(row.luma < 110, 'dim preview still permits capture');
assert(Math.abs(row.roll) <= 22);
}
assert(Math.abs(body.capture_diagnostics.views.front.yaw) <= 18);
assert(body.capture_diagnostics.views.left.yaw <= -24 && body.capture_diagnostics.views.left.yaw >= -84);
assert(body.capture_diagnostics.views.right.yaw >= 24 && body.capture_diagnostics.views.right.yaw <= 84);
assert(await page.evaluate(() => document.querySelector('#cam-video').srcObject === null), 'camera released after success');
assert.equal(await page.evaluate(() => window.__stillDetections),0,'all three photos proceed without still-image detection');
assert.deepEqual(errors, []);
console.log('PASS: actual local models + automatic three-view capture + final JPEG revalidation; invalid front stays on step 1 with neutral audio, no early turn; actual decoded shot-done finishes before side guidance; wrong-direction frames blocked; approved samples/camera cleanup; no paid call/backend writes');
console.log('PASS: actual local models + automatic three-view capture without JPEG revalidation; invalid preview stays on its step, neutral audio; shot-done finishes before side guidance; camera cleanup; no paid call/backend writes');
} finally { await browser.close(); }