import fs from 'node:fs'; import {test,expect} from '@playwright/test'; const runtime=fs.readFileSync('public/app-runtime.js','utf8'); function moduleSource(name){const start=runtime.indexOf(`/* ===== MODULE: ${name} ===== */`),end=runtime.indexOf('/* ===== MODULE:',start+1);return runtime.slice(start,end<0?undefined:end);} async function fixture(page,body){ await page.route('**/index.html',r=>r.fulfill({contentType:'text/html; charset=utf-8',body:`
${body}`})); await page.goto('/index.html'); await page.evaluate(()=>window.SunSafe={escapeHTML:v=>String(v??'').replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c])),insertBefore:(p,n,a)=>p.insertBefore(n,a)}); } test('modal stacking respects existing layers and closing never steals input focus',async({page})=>{ await fixture(page,'