Desktop boot check: accept the in-app dry-run preview before the native confirm

This commit is contained in:
CRTkafa 2026-10-23 10:25:26 +08:00
parent c7bae75ed0
commit 5b7b16ac08

View file

@ -230,6 +230,16 @@ function serve(dist: string, csp: string, breakBundle: boolean) {
interface CaseResult { name: string; ok: boolean; problems: string[]; visited: number; notes: string[] }
/** A page that accepts the in-app dry-run preview of a write (Continue) whenever it shows, like a person reading it and
* going on: the native confirm dialog after it is what each case checks. */
async function newPage(ctx: { newPage(): Promise<import('playwright').Page> }): Promise<import('playwright').Page> {
const page = await ctx.newPage();
await page.addLocatorHandler(page.locator('.ds-scrim:has(.dr-cmd)'), async () => {
await page.locator('.ds-scrim:has(.dr-cmd) .btn-primary').click();
});
return page;
}
async function state(page: Page) {
return page.evaluate(() => ({
booted: document.documentElement.dataset.booted === '1',
@ -272,7 +282,7 @@ async function runCase(browser: Browser, name: string, sidecar: Sidecar, o: { br
const freeze = conf.app.security.freezePrototype === true;
const server = serve(DIST, cspHeader(conf.app.security.csp), !!o.breakBundle);
const ctx = await browser.newContext({ viewport: { width: 1280, height: 800 }, reducedMotion: 'reduce' });
const page = await ctx.newPage();
const page = await newPage(ctx);
const problems: string[] = [];
const notes: string[] = [];
const unmocked = new Set<string>();
@ -397,7 +407,7 @@ async function runSubmitCase(browser: Browser, sidecar: Sidecar, base: 'd3-full'
const freeze = conf.app.security.freezePrototype === true;
const server = serve(DIST, cspHeader(conf.app.security.csp), false);
const ctx = await browser.newContext({ viewport: { width: 1360, height: 900 }, reducedMotion: 'reduce' });
const page = await ctx.newPage();
const page = await newPage(ctx);
const problems: string[] = [];
const notes: string[] = [];
const unmocked = new Set<string>();
@ -524,7 +534,7 @@ async function runReleaseStateCase(browser: Browser, sidecar: Sidecar, page404:
const freeze = conf.app.security.freezePrototype === true;
const server = serve(DIST, cspHeader(conf.app.security.csp), false);
const ctx = await browser.newContext({ viewport: { width: 1360, height: 900 }, reducedMotion: 'reduce' });
const page = await ctx.newPage();
const page = await newPage(ctx);
const problems: string[] = [];
const notes: string[] = [];
const unmocked = new Set<string>();
@ -615,7 +625,7 @@ async function runAutoReadCase(browser: Browser): Promise<CaseResult> {
const freeze = conf.app.security.freezePrototype === true;
const server = serve(DIST, cspHeader(conf.app.security.csp), false);
const ctx = await browser.newContext({ viewport: { width: 1360, height: 900 }, reducedMotion: 'reduce' });
const page = await ctx.newPage();
const page = await newPage(ctx);
const problems: string[] = [];
const notes: string[] = [];
const logged: string[] = [];
@ -740,7 +750,7 @@ async function runErrorCase(browser: Browser, sidecar: Sidecar, variant: 'api-di
const freeze = conf.app.security.freezePrototype === true;
const server = serve(DIST, cspHeader(conf.app.security.csp), false);
const ctx = await browser.newContext({ viewport: { width: 1360, height: 900 }, reducedMotion: 'reduce' });
const page = await ctx.newPage();
const page = await newPage(ctx);
const problems: string[] = [];
const notes: string[] = [];
const unmocked = new Set<string>();
@ -858,7 +868,7 @@ async function runEditorCase(browser: Browser, sidecar: Sidecar): Promise<CaseRe
const freeze = conf.app.security.freezePrototype === true;
const server = serve(DIST, cspHeader(conf.app.security.csp), false);
const ctx = await browser.newContext({ viewport: { width: 1360, height: 900 }, reducedMotion: 'reduce' });
const page = await ctx.newPage();
const page = await newPage(ctx);
const problems: string[] = [];
const notes: string[] = [];
const unmocked = new Set<string>();
@ -1013,7 +1023,7 @@ async function runLiveArtCase(browser: Browser, sidecar: Sidecar): Promise<CaseR
const freeze = conf.app.security.freezePrototype === true;
const server = serve(DIST, cspHeader(conf.app.security.csp), false);
const ctx = await browser.newContext({ viewport: { width: 1360, height: 900 }, reducedMotion: 'reduce' });
const page = await ctx.newPage();
const page = await newPage(ctx);
const problems: string[] = [];
const notes: string[] = [];
const unmocked = new Set<string>();