const {chromium}=require('playwright'),path=require('path'),assert=require('node:assert/strict');
(async()=>{const browser=await chromium.launch();try{const page=await browser.newPage();const markup=id=>`
Saved objective evidence
'}));await page.waitForSelector('text=Saved objective evidence');await page.click('[data-intent-analyse]');await page.evaluate(html=>document.body.innerHTML=html,markup(23));await page.evaluate(()=>requests[2].resolve({ok:true,text:async()=>'STALE SCENE RESULT
'}));await page.waitForTimeout(50);assert.equal(await page.locator('text=STALE SCENE RESULT').count(),0,'scene switch refuses stale response');await page.click('[data-intent-load]');await page.evaluate(()=>requests[3].resolve({ok:false,status:403}));await page.waitForFunction(()=>document.querySelector('[data-intent-assessment-status]').textContent.includes('Sign in'));console.log('PASS explicit Intent assessment, persisted-result load, cancellation, scene isolation and permission feedback');}finally{await browser.close();}})().catch(e=>{console.error(e);process.exit(1);});