10 lines
3.1 KiB
JavaScript
10 lines
3.1 KiB
JavaScript
// Actual installed Development PWA; reads only the dedicated fixture left by locations-workspace-dev.cjs.
|
|
const{chromium}=require('playwright'),assert=require('node:assert/strict'),fs=require('node:fs');
|
|
const base='https://dev.plotdirector.com',file=process.argv[2];if(!file?.startsWith('/tmp/pd-dev-browser-'))throw Error('Dedicated private identity required');const identity=JSON.parse(fs.readFileSync(file,'utf8'));assert.equal(identity.Database,'PlotDirector_Development');assert(identity.Email.startsWith('pwa-browser-'));assert(identity.ProjectID);
|
|
(async()=>{const profile=fs.mkdtempSync('/tmp/pd-locations-dev-pwa-'),context=await chromium.launchPersistentContext(profile,{headless:false,viewport:{width:1440,height:1000}}),cdp=await context.browser().newBrowserCDPSession(),manifestId=base+'/Projects';try{
|
|
const tab=context.pages()[0];await tab.goto(base+'/Account/Login');await tab.locator('[name=Email]').fill(identity.Email);await tab.locator('[name=Password]').fill(identity.Password);await tab.locator('form button[type=submit]').click();await tab.waitForURL(base+'/Projects');
|
|
await cdp.send('PWA.install',{manifestId,installUrlOrBundleUrl:base+'/Projects'});await cdp.send('PWA.changeAppUserSettings',{manifestId,displayMode:'standalone'});const opened=context.waitForEvent('page');await cdp.send('PWA.launch',{manifestId,url:base+`/Locations?projectId=${identity.ProjectID}`});const page=await opened;await page.waitForLoadState();assert(await page.evaluate(()=>matchMedia('(display-mode: standalone)').matches));await page.locator('[data-location-records][aria-busy=false]').waitFor();const row=page.locator('[data-location-id]').first();await row.locator('[data-location-name]').click();assert.equal(await page.locator('[data-details]').getByRole('combobox',{name:'Classification',exact:true}).inputValue(),'Fictional');await row.getByRole('button',{name:/Actions for/}).click();await page.getByRole('menu').first().waitFor();await page.screenshot({path:'/tmp/pd-locations-evidence/development-pwa-context.png'});await page.keyboard.press('Escape');
|
|
await page.getByRole('button',{name:'Cards',exact:true}).click();assert(await page.getByText('Author-controlled synthetic description.',{exact:true}).count());await page.screenshot({path:'/tmp/pd-locations-evidence/development-pwa-cards.png'});const pages=context.pages().length;await page.locator('[data-details]').getByRole('link',{name:'Full details',exact:true}).click();await page.waitForURL(/\/Locations\/Details\/\d+/);assert.equal(context.pages().length,pages,'same-window navigation');
|
|
fs.writeFileSync('/tmp/pd-locations-evidence/development-pwa-smoke.json',JSON.stringify({status:'passed',target:'Development',installed:true,checks:['real installed Chromium PWA','authenticated workspace directory','saved classification','shared context menu','card description','same-window Location Details navigation']},null,2));console.log('PASS actual authenticated installed Development PWA, saved state, context menu, cards and same-window details.');
|
|
}finally{await cdp.send('PWA.uninstall',{manifestId}).catch(()=>{});await context.close();fs.rmSync(profile,{recursive:true,force:true});}})().catch(e=>{console.error(e);process.exitCode=1;});
|