// Verifies real Bootstrap resources across repeated live Development workspace replacement. const {chromium}=require('playwright'),assert=require('node:assert/strict'),fs=require('node:fs'); const [identityPath,fixturePath]=process.argv.slice(2); if(![identityPath,fixturePath].every(p=>p?.startsWith('/tmp/pd-dev-browser-')))throw Error('Dedicated Development identity and fixture required.'); const identity=JSON.parse(fs.readFileSync(identityPath)),fixture=JSON.parse(fs.readFileSync(fixturePath)),base='https://dev.plotdirector.com'; if(identity.Database!=='PlotDirector_Development'||!identity.Email.startsWith('pwa-browser-'))throw Error('Development identity required.'); (async()=>{const browser=await chromium.launch();try{ const login=await browser.newContext(),page=await login.newPage();await page.goto(base+'/Account/Login');await page.locator('#Email').fill(identity.Email);await page.locator('#Password').fill(identity.Password);await Promise.all([page.waitForURL('**/Projects'),page.locator('form[action="/Account/Login"] button[type=submit]').click()]); for(const pwa of [false,true]){ const context=await browser.newContext({storageState:await login.storageState(),viewport:{width:1600,height:1000}});if(pwa)await context.addInitScript(()=>Object.defineProperty(navigator,'standalone',{value:true})); const p=await context.newPage(),errors=[];p.on('pageerror',e=>errors.push(e.message));await p.goto(`${base}/FloorPlans/Edit/${fixture.FloorPlanID}`); for(let i=0;i<3;i++){ await p.locator('[data-toolbox-tab=floors]').click(); const old=await p.locator('[data-floor-plan-workspace]').elementHandle(),oldHelp=await p.locator('[data-floor-plan-workspace] [data-help-icon]').first().elementHandle(); await p.locator('[name=Name][form=floor-plan-add-floor-form]').fill(`Help lifecycle ${pwa?'PWA':'web'} ${i}`); await p.locator('[form=floor-plan-add-floor-form][type=submit]').click();await p.waitForFunction(n=>!n.isConnected,old); await p.waitForFunction(()=>document.querySelector('[data-floor-plan-editor]')?.dataset.floorPlanInitialized==='true'); assert(await oldHelp.evaluate(n=>!bootstrap.Popover.getInstance(n)&&!bootstrap.Tooltip.getInstance(n.querySelector('[data-help-tooltip]'))),'removed controls release Bootstrap instances'); assert(await p.locator('[data-floor-plan-workspace] [data-help-icon]').evaluateAll(ns=>ns.every(n=>!!bootstrap.Popover.getInstance(n)))); await p.locator('[data-toolbox-tab=add]').click();await p.locator('[data-toolbox-panel=add] [data-help-icon] button').first().click();await p.locator('.popover.show').waitFor();await p.locator('.popover.show .plotline-help-more').click();await p.locator('[data-help-content] .help-drawer-article').waitFor();await p.locator('[data-help-close]').click(); } assert.deepEqual(errors,[]);console.log(`PASS Development Help lifecycle ${pwa?'PWA':'web'}: three replacements release old Bootstrap instances; new Help and More/drawer work without refresh.`);await context.close(); } await login.close(); }finally{await browser.close();}})().catch(e=>{console.error(e);process.exitCode=1;});