'use strict'; const assert=require('node:assert/strict'),fs=require('node:fs'),path=require('node:path'),vm=require('node:vm'); const source=fs.readFileSync(path.join(__dirname,'../js/app.js'),'utf8'); assert(!source.includes('checkStill'), 'no still-photo detection helper or call remains'); const fileFunction=source.slice(source.indexOf(' function readPhotoFile('),source.indexOf(' function showCamStatus(')); let read,load;const completed=[]; const ctx={camStep:0,camSeq:1,IS_MOCK:false,captureDiagnostics:[],Math, FileReader:class{readAsDataURL(){this.result='data:image/jpeg;base64,fixture';read=()=>this.onload();}}, Image:class{constructor(){this.width=640;this.height=640;load=()=>this.onload();}}, document:{createElement(){return {getContext(){return {drawImage(){}};},toDataURL(){return 'saved-jpeg';}};}}, onPhotoCaptured(url){completed.push(url);},toast(){throw Error('unexpected failure');}}; vm.createContext(ctx);vm.runInContext(fileFunction,ctx); for(let step=0;step<3;step++){ctx.camStep=step;ctx.readPhotoFile({});read();load();assert.equal(ctx.captureDiagnostics[step].check_stage,'none');assert.equal(completed.length,step+1);} ctx.readPhotoFile({});read();ctx.camSeq++;load();assert.equal(completed.length,3,'canceled file callback cannot advance'); const Diagnostics=require('../lib/capture-diagnostics'); const normalized=Diagnostics.normalize({version:'test',views:{front:{mode:'live',check_stage:'preview'},left:{mode:'file',check_stage:'none'},right:{check_stage:'invented'}}}); assert.equal(normalized.views.front.check_stage,'preview');assert.equal(normalized.views.left.check_stage,'none');assert.equal(normalized.views.right.check_stage,undefined); console.log('PASS: no saved-photo recheck, file captures advance directly, stale callbacks ignored, preview-only diagnostics explicit');