PlotDirector/PlotLine.Tests/Browser/writing-embedded-theme.cjs

4 lines
1.1 KiB
JavaScript

const {chromium}=require('playwright');
const path=require('path');
(async()=>{const browser=await chromium.launch({headless:true});try{const page=await browser.newPage();await page.setContent('<html data-app-theme="plum" data-bs-theme="dark"><iframe srcdoc="<!doctype html><html><body>Writing screen</body></html>"></iframe></html>');const frame=page.frames()[1];await frame.addScriptTag({path:path.resolve(__dirname,'../../PlotLine/wwwroot/js/writing-embedded-theme.js')});await frame.waitForFunction(()=>document.documentElement.getAttribute('data-app-theme')==='plum'&&document.documentElement.getAttribute('data-bs-theme')==='dark');await page.evaluate(()=>{document.documentElement.setAttribute('data-app-theme','sage');document.documentElement.removeAttribute('data-bs-theme');});await frame.waitForFunction(()=>document.documentElement.getAttribute('data-app-theme')==='sage'&&!document.documentElement.hasAttribute('data-bs-theme'));console.log('PASS embedded writing screens inherit and track existing PWA theme without separate persistence');}finally{await browser.close();}})().catch(e=>{console.error(e);process.exitCode=1;});