Files
vibemake/tests/cad/browser-e2e.mjs
T
2026-11-05 17:50:35 +08:00

356 lines
25 KiB
JavaScript

import assert from 'node:assert/strict';
import { mkdir, writeFile } from 'node:fs/promises';
import { resolve } from 'node:path';
import { chromium } from 'playwright';
import { runPlatformAgentBrowserChecks } from './platform-agent-browser.mjs';
const base = (process.env.VM_CAD_BASE_URL || 'http://localhost:8091').replace(/\/$/, '');
const artifactDir = process.env.VM_CAD_ARTIFACT_DIR ? resolve(process.env.VM_CAD_ARTIFACT_DIR) : null;
const browserOptions = { headless: true, args: ['--enable-unsafe-webgpu', '--use-angle=swiftshader', '--enable-webgl'] };
if (process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE) browserOptions.executablePath = process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE;
const browser = await chromium.launch(browserOptions), checks = [], errors = [];
const auth = { token: 'cad-browser-test-token', user: { userCode: 'cad-browser-test-user', nickname: 'CAD Browser Test', email: 'cad-test@example.test' } };
async function authenticatedContext(viewport = { width: 1440, height: 1000 }) {
const context = await browser.newContext({ viewport });
await context.addInitScript((value) => localStorage.setItem('vm.auth', JSON.stringify(value)), auth);
await context.route('https://cad-covers.example.test/**', async (route) => {
const response = await fetch(`${base}/api/cad/mock-cover-source/${new URL(route.request().url()).pathname.split('/').at(-1)}`);
await route.fulfill({ status: response.status, contentType: 'image/png', body: Buffer.from(await response.arrayBuffer()) });
});
return context;
}
async function ready(page) {
await page.waitForFunction(() => window.vibemakeCad && typeof window.solidcraft?.execute === 'function', null, { timeout: 180000 });
let stable = 0;
for (let i = 0; i < 900; i++) {
const state = await page.evaluate(() => window.vibemakeCad.getState());
const hostReady = await page.evaluate(() => document.querySelector('#cad-main')?.hidden && !document.querySelector('#cad-viewport')?.inert);
stable = state.binding && !state.locked && hostReady ? stable + 1 : 0;
if (stable >= 3) return;
await page.waitForTimeout(200);
}
throw new Error('CAD editor did not become interactive');
}
const execute = (page, command, params) => page.evaluate(([id, value]) => window.solidcraft.execute(id, value), [command, params]);
const apiHeaders = { Authorization: `Bearer ${auth.token}`, 'Content-Type': 'application/json' };
if (artifactDir) await mkdir(artifactDir, { recursive: true });
try {
const projectName = `CAD browser integration ${Date.now()}`;
const created = await (await fetch(`${base}/api/cad/workspace/projects`, { method: 'POST', headers: apiHeaders, body: JSON.stringify({ name: projectName, description: '' }) })).json();
assert.equal(created.code, 'OK');
const project = created.data, url = `${base}/cad/editor/?project=${project.cadProjectCode}`;
const firstContext = await authenticatedContext(), first = await firstContext.newPage();
first.on('pageerror', (error) => errors.push(String(error)));
first.on('dialog', (dialog) => dialog.accept());
await first.goto(`${base}/`);
const navLayout = (page) => page.locator('body > header.nav .nav-inner').evaluate((element) => {
const rect = (selector) => {
const node = element.querySelector(selector), box = node?.getBoundingClientRect();
if (!box) return null;
return { left: box.left, right: box.right, width: box.width, height: box.height, fontSize: getComputedStyle(node).fontSize };
};
const box = element.getBoundingClientRect();
return {
container: { left: box.left, right: box.right, width: box.width },
logo: rect('.nav-logo'), links: rect('.nav-links'), actions: rect('.nav-actions'),
search: rect('.nav-search'), account: rect('[data-auth]'),
};
});
const homeNav = await navLayout(first);
await first.goto(`${base}/cad/`);
assert.equal(await first.locator('body > header.nav').count(), 1);
assert.equal(await first.locator('body > header.nav .nav-links a.active').getAttribute('href'), '/cad/');
const listNav = await navLayout(first);
assert.deepEqual(listNav, homeNav); checks.push('project-list-navigation-matches-home-position');
await first.getByRole('heading', { name: '我的 CAD 项目' }).waitFor();
if (artifactDir) await first.screenshot({ path: resolve(artifactDir, 'project-list-zh.png') });
await first.getByRole('searchbox').fill(projectName);
const projectCard = first.locator('.cad-card').filter({ hasText: projectName });
await projectCard.waitFor();
await first.waitForFunction(() => document.querySelectorAll('.cad-card').length === 1);
assert.equal(await first.locator('.cad-card').count(), 1); checks.push('project-list-search-and-filter');
await projectCard.getByRole('link', { name: '打开' }).click();
await ready(first); checks.push('actual-wasm-and-font-ready');
assert.equal(await first.locator('body > header.nav').count(), 1);
assert.deepEqual(await first.locator('.cad-engine-menus button').evaluateAll((buttons) => buttons.map((button) => button.dataset.engineMenu)), ['file', 'assistant', 'preferences', 'help']);
const editorBar = await first.locator('body > header.nav').evaluate((header) => {
const logo = header.querySelector('.nav-logo').getBoundingClientRect();
const left = header.querySelector('.cad-appbar-left').getBoundingClientRect();
const actions = header.querySelector('.nav-actions').getBoundingClientRect();
const height = header.getBoundingClientRect().height;
return { height, logoLeft: logo.left, controlsLeft: left.left, actionsRight: actions.right, viewportWidth: innerWidth };
});
assert.equal(editorBar.height, 42);
assert.ok(editorBar.logoLeft < editorBar.controlsLeft);
assert.ok(editorBar.actionsRight >= editorBar.viewportWidth - 20);
assert.equal(await first.locator('body > header.nav a[href="/"]').count(), 0);
assert.equal((await first.locator('[data-save]').innerText()).trim(), '');
assert.equal(await first.locator('[data-save]').getAttribute('aria-label'), '保存');
assert.equal(await first.locator('[data-history="undo"]').isDisabled(), true);
assert.equal(await first.locator('[data-history="redo"]').isDisabled(), true);
assert.equal(await first.locator('.cad-language').count(), 0);
assert.equal(await first.getByText('VibeMake CAD', { exact: true }).count(), 0);
const listLogo = first.getByRole('link', { name: '返回项目列表' });
assert.equal(await listLogo.count(), 1);
assert.equal((await listLogo.innerText()).trim(), '');
assert.equal(await first.locator('header.nav select').count(), 0);
assert.equal(await first.locator('.nav-logo').getAttribute('href'), '/cad/');
checks.push('editor-uses-cad-app-bar-with-logo-and-hidden-locale-controls');
await execute(first, 'solid.box', { length: 20, width: 30, height: 8 });
await first.waitForFunction(async () => (await window.vibemakeCad.getState()).canUndo === true);
await first.locator('[data-history="undo"]').click();
await first.waitForFunction(async () => { const state = await window.vibemakeCad.getState(); return !state.canUndo && state.canRedo; });
assert.equal((await first.evaluate(() => window.solidcraft.inspect({}))).bodies.length, 0);
await first.locator('[data-history="redo"]').click();
await first.waitForFunction(async () => { const state = await window.vibemakeCad.getState(); return state.canUndo && !state.canRedo; });
assert.equal((await first.evaluate(() => window.solidcraft.inspect({}))).bodies.length, 1);
checks.push('editor-history-controls-follow-engine-state');
const atomic = await first.evaluate(async () => {
const before = await window.vibemakeCad.getState(); let code;
try { await window.vibemakeCad.openProject({ projectId: 'invalid', bytes: new Uint8Array([1, 2, 3]) }); } catch (error) { code = error.code; }
const after = await window.vibemakeCad.getState();
return { code, same: before.binding === after.binding && before.revision === after.revision };
});
assert.deepEqual(atomic, { code: 'BAD_DESIGN', same: true }); checks.push('corrupt-open-is-atomic');
await assert.rejects(execute(first, 'file.new', {}), /HOST_MANAGED_DOCUMENT/); checks.push('host-managed-commands-reject-rebinding');
const snapshotAck = await first.evaluate(async () => {
const bridge = window.vibemakeCad, snapshot = await bridge.createSnapshot();
await window.solidcraft.execute('solid.box', { length: 5, width: 5, height: 10, corner: [25, 0, 0] });
await bridge.acknowledgeSave({ binding: snapshot.binding, snapshotId: snapshot.snapshotId });
const dirty = (await bridge.getState()).dirty; await bridge.releaseSnapshot(snapshot.snapshotId); return dirty;
});
assert.equal(snapshotAck, true); checks.push('snapshot-ack-keeps-later-edits-dirty');
const coverCapture = await first.evaluate(async () => {
const bridge = window.vibemakeCad;
const capture = async () => {
const snapshot = await bridge.createSnapshot({ includeCover: true });
const result = { bytes: Array.from(snapshot.cover?.bytes || []), width: snapshot.cover?.width, height: snapshot.cover?.height, mimeType: snapshot.cover?.mimeType };
await bridge.releaseSnapshot(snapshot.snapshotId);
return result;
};
const original = await window.solidcraft.request('ui.inspect', {});
const first = await capture();
await window.solidcraft.request('ui.view', { view: 'back' });
const before = await window.solidcraft.request('ui.inspect', {});
const second = await capture();
const after = await window.solidcraft.request('ui.inspect', {});
return { first, second, cameraStable: JSON.stringify(before.camera) === JSON.stringify(after.camera), originalCamera: original.camera };
});
assert.equal(coverCapture.first.width, 640);
assert.equal(coverCapture.first.height, 400);
assert.equal(coverCapture.first.mimeType, 'image/png');
assert.ok(coverCapture.first.bytes.length > 1000);
assert.deepEqual(coverCapture.second.bytes, coverCapture.first.bytes);
assert.equal(coverCapture.cameraStable, true);
if (artifactDir) await writeFile(resolve(artifactDir, 'fixed-camera-cover.png'), Buffer.from(coverCapture.first.bytes));
checks.push('fixed-isometric-cover-ignores-live-camera-and-leaves-it-unchanged');
const saveRequests = [];
first.on('request', (request) => {
if (['POST', 'PUT'].includes(request.method()) && /\/api\/cad\/(workspace\/projects\/|mock-oss\/)/.test(request.url()) && !request.url().includes('/mock-oss/cover-')) {
saveRequests.push({ url: request.url(), body: request.url().includes('/mock-oss/') ? null : request.postDataJSON() });
}
});
await first.route('**/api/cad/mock-oss/*', async (route) => {
assert.equal(route.request().headers().authorization, undefined);
const response = await route.fetch();
assert.equal(response.status(), 200);
await route.abort('failed');
}, { times: 1 });
await first.locator('[data-save]').click();
await first.waitForFunction(() => document.querySelector('[data-state]')?.dataset.state === 'saved', null, { timeout: 90000 });
assert.equal((await first.evaluate(() => window.vibemakeCad.getState())).dirty, false); checks.push('manual-cloud-save-commits');
assert.equal(saveRequests.length, 3);
assert.ok(saveRequests[0].url.endsWith('/uploads/signature'));
assert.ok(saveRequests[1].url.includes('/mock-oss/'));
assert.ok(saveRequests[2].url.endsWith('/document'));
assert.equal(saveRequests[2].body.uploadCode, saveRequests[1].url.split('/').at(-1));
assert.equal(await first.locator('#cad-notice').isHidden(), true);
checks.push('lost-upload-response-confirms-original-batch-once');
const covered = (await (await fetch(`${base}/api/cad/workspace/projects/${project.cadProjectCode}`, { headers: apiHeaders })).json()).data;
assert.match(covered.coverUrl, /^https:\/\/cad-covers\.example\.test\//);
assert.equal(covered.version, 1);
const listPage = await firstContext.newPage(), listEngineRequests = [];
listPage.on('request', (request) => { if (request.url().includes('/cad/_assets/') || request.url().includes('/cad/engine.json')) listEngineRequests.push(request.url()); });
await listPage.goto(`${base}/cad/`);
await listPage.getByRole('searchbox').fill(projectName);
const coveredCard = listPage.locator('.cad-card').filter({ hasText: projectName });
const image = coveredCard.locator('.cad-card-art img');
await image.waitFor();
await image.evaluate((node) => node.decode());
assert.equal(await image.getAttribute('src'), covered.coverUrl);
assert.equal(await image.getAttribute('loading'), 'lazy');
assert.equal(await image.evaluate((node) => node.naturalWidth), 640);
assert.deepEqual(listEngineRequests, []);
if (artifactDir) await listPage.screenshot({ path: resolve(artifactDir, 'project-list-with-cover-zh.png') });
await listPage.route('https://cad-covers.example.test/**', (route) => route.fulfill({ status: 404, body: '' }));
await listPage.reload();
await listPage.getByRole('searchbox').fill(projectName);
await coveredCard.locator('.cad-card-art svg').waitFor();
assert.equal(await coveredCard.locator('.cad-card-art img').count(), 0);
await listPage.close();
checks.push('native-save-publishes-cover-list-displays-it-without-engine-and-broken-images-fall-back');
if (artifactDir) await first.screenshot({ path: resolve(artifactDir, 'editor-zh.png') });
const secondContext = await authenticatedContext(), second = await secondContext.newPage();
second.on('pageerror', (error) => errors.push(String(error)));
second.on('dialog', (dialog) => dialog.accept());
let documentReads = 0, sourceReads = 0, saveBase;
second.on('request', (request) => {
if (request.method() === 'GET' && request.url().endsWith('/document')) documentReads++;
if (request.url().includes('/mock-source/')) {
sourceReads++;
assert.equal(request.headers().authorization, undefined);
}
if (request.url().endsWith('/uploads/signature')) saveBase = request.postDataJSON().expectedVersion;
});
await second.route('**/api/cad/workspace/projects/' + project.cadProjectCode, async (route) => {
const response = await route.fetch(), json = await response.json();
json.data.version = 500; // Detail may be from a different snapshot than the document.
await route.fulfill({ response, json });
});
await second.route('**/api/cad/mock-source/*', (route) => route.fulfill({ status: 403 }));
await second.goto(url);
await second.locator('#cad-notice').filter({ hasText: 'OSS/CDN' }).waitFor();
assert.equal(documentReads, 1);
assert.equal(sourceReads, 1);
assert.equal((await second.evaluate(() => JSON.parse(localStorage.getItem('vm.auth')))).token, auth.token);
if (artifactDir) await second.screenshot({ path: resolve(artifactDir, 'public-file-forbidden-zh.png') });
checks.push('public-url-403-does-not-renew-or-sign-out');
await second.unroute('**/api/cad/mock-source/*');
await second.locator('#cad-main [data-action]').click();
await ready(second);
const document = (await (await fetch(`${base}/api/cad/workspace/projects/${project.cadProjectCode}/document`, { headers: apiHeaders })).json()).data;
assert.equal(document.expiresAt, null);
assert.equal(new URL(document.downloadUrl, base).search, '');
checks.push('native-design-reopens-from-public-url-with-null-expiry');
assert.equal((await second.evaluate(() => window.vibemakeCad.getState())).dirty, false);
assert.equal((await second.evaluate(() => window.solidcraft.inspect({}))).bodies.length, 2); checks.push('independent-context-reopens-native-design');
await execute(first, 'solid.box', { length: 4, width: 4, height: 4, corner: [40, 0, 0] });
await first.locator('[data-save]').click();
await first.waitForFunction(() => document.querySelector('[data-state]')?.dataset.state === 'saved', null, { timeout: 90000 });
await execute(second, 'solid.box', { length: 3, width: 3, height: 3, corner: [-10, 0, 0] });
await second.locator('[data-save]').click(); await second.getByRole('dialog').waitFor();
assert.match(await second.getByRole('dialog').innerText(), /冲突/);
await second.locator('[data-choice=stay]').click();
assert.equal(saveBase, document.version);
checks.push('save-base-comes-from-document-snapshot-not-project-detail');
assert.equal((await second.evaluate(() => window.vibemakeCad.getState())).dirty, true);
checks.push('concurrent-save-keeps-local-work-on-cas-conflict');
if (artifactDir) await second.screenshot({ path: resolve(artifactDir, 'conflict-zh.png') });
await first.setViewportSize({ width: 800, height: 800 }); await first.locator('#cad-blocker').waitFor({ state: 'visible' });
assert.equal(new URL(first.url()).pathname, '/cad/editor/');
await first.setViewportSize({ width: 1440, height: 1000 }); await ready(first); checks.push('narrow-window-locks-without-navigation');
await first.evaluate(() => window.vibemakeCad.setLocale('en'));
for (let i = 0; i < 100 && (await first.evaluate(() => window.vibemakeCad.getState())).locale !== 'en'; i++) await first.waitForTimeout(100);
assert.equal((await first.evaluate(() => window.vibemakeCad.getState())).locale, 'en'); checks.push('editor-locale-syncs-to-english');
assert.equal(await first.locator('[data-engine-menu=\"file\"]').textContent(), 'File');
if (artifactDir) await first.screenshot({ path: resolve(artifactDir, 'editor-en.png') });
await Promise.all([firstContext.close(), secondContext.close()]);
const draftProject = (await (await fetch(`${base}/api/cad/workspace/projects`, { method: 'POST', headers: apiHeaders, body: JSON.stringify({ name: 'IndexedDB draft recovery', description: '' }) })).json()).data;
const draftContext = await authenticatedContext(), draftPage = await draftContext.newPage();
draftPage.on('pageerror', (error) => errors.push(String(error)));
await draftPage.goto(`${base}/cad/editor/?project=${draftProject.cadProjectCode}`); await ready(draftPage);
await draftPage.locator('[data-save]').click();
await draftPage.waitForFunction(() => document.querySelector('[data-state]')?.dataset.state === 'coverUnavailable', null, { timeout: 90000 });
assert.equal((await draftPage.evaluate(() => window.vibemakeCad.getState())).dirty, false);
assert.match(await draftPage.locator('#cad-notice').innerText(), /工程已保存/);
checks.push('empty-design-saves-without-replacing-the-cover');
await execute(draftPage, 'solid.box', { length: 8, width: 9, height: 10 });
await draftPage.evaluate(async () => {
const bridge = window.vibemakeCad, snapshot = await bridge.createSnapshot(), project = new URL(location.href).searchParams.get('project');
const open = indexedDB.open('vm.cad', 1), db = await new Promise((resolve, reject) => {
open.onupgradeneeded = () => open.result.createObjectStore('records', { keyPath: 'key' });
open.onsuccess = () => resolve(open.result); open.onerror = () => reject(open.error);
});
await new Promise((resolve, reject) => {
const tx = db.transaction('records', 'readwrite'), key = JSON.stringify(['cad-browser-test-user', project, crypto.randomUUID(), 'draft']);
tx.objectStore('records').put({ key, user: 'cad-browser-test-user', project, session: 'draft-tab', kind: 'draft', updatedAt: Date.now(), snapshotId: snapshot.snapshotId, bytes: snapshot.bytes, baseVersion: 1, binding: snapshot.binding, revision: snapshot.revision });
tx.oncomplete = resolve; tx.onerror = () => reject(tx.error);
});
await bridge.releaseSnapshot(snapshot.snapshotId); db.close();
});
await draftPage.reload(); await draftPage.getByRole('dialog').waitFor(); await draftPage.locator('[data-choice=restore]').click(); await ready(draftPage);
assert.equal((await draftPage.evaluate(() => window.solidcraft.inspect({}))).bodies.length, 1);
assert.equal((await draftPage.evaluate(() => window.vibemakeCad.getState())).dirty, true); checks.push('binary-indexeddb-draft-restores');
if (artifactDir) await draftPage.screenshot({ path: resolve(artifactDir, 'draft-restore-zh.png') });
const localDrafts = (page, user, project) => page.evaluate(async ({ user, project }) => {
const { DraftStore } = await import('/js/cad/drafts.js');
return (await new DraftStore().list(user, project, 'draft')).map(({ key, snapshotId }) => ({ key, snapshotId }));
}, { user, project });
const restoredDrafts = await localDrafts(draftPage, auth.user.userCode, draftProject.cadProjectCode);
assert.ok(restoredDrafts.length > 0);
await draftPage.locator('.nav-logo').click();
await draftPage.locator('[data-choice=stay]').click();
assert.deepEqual(await localDrafts(draftPage, auth.user.userCode, draftProject.cadProjectCode), restoredDrafts);
assert.equal((await draftPage.evaluate(() => window.vibemakeCad.getState())).dirty, true);
checks.push('keep-editing-preserves-local-drafts');
await draftPage.evaluate(async ({ user, project }) => {
const { DraftStore } = await import('/js/cad/drafts.js');
const store = new DraftStore(), bytes = new Uint8Array([1, 2, 3]);
await store.put('other-owner', project, 'other-tab', 'draft', { snapshotId: 'other-owner-draft', bytes });
await store.put(user, 'other-project', 'other-tab', 'draft', { snapshotId: 'other-project-draft', bytes });
const bridge = window.vibemakeCad, capture = bridge.createSnapshot.bind(bridge);
bridge.createSnapshot = async (...args) => {
window.draftCaptureStarted = true;
await new Promise((resolve) => { window.finishDraftCapture = resolve; });
return capture(...args);
};
Object.defineProperty(document, 'hidden', { configurable: true, value: true });
document.dispatchEvent(new Event('visibilitychange'));
delete document.hidden;
}, { user: auth.user.userCode, project: draftProject.cadProjectCode });
await draftPage.waitForFunction(() => window.draftCaptureStarted);
await draftPage.locator('.nav-logo').click();
const discardClick = draftPage.locator('[data-choice=discard]').click();
await draftPage.waitForTimeout(100);
assert.equal(new URL(draftPage.url()).pathname, '/cad/editor/');
await draftPage.evaluate(() => {
Object.defineProperty(document, 'hidden', { configurable: true, value: true });
document.dispatchEvent(new Event('visibilitychange'));
delete document.hidden;
window.finishDraftCapture();
});
await discardClick;
await draftPage.waitForURL(`${base}/cad/`);
await draftPage.getByRole('heading', { name: '我的 CAD 项目' }).waitFor();
assert.deepEqual(await localDrafts(draftPage, auth.user.userCode, draftProject.cadProjectCode), []);
assert.equal((await localDrafts(draftPage, 'other-owner', draftProject.cadProjectCode)).length, 1);
assert.equal((await localDrafts(draftPage, auth.user.userCode, 'other-project')).length, 1);
checks.push('discard-clears-restored-and-in-flight-drafts-only-for-this-owner-and-project');
await draftPage.goto(`${base}/cad/editor/?project=${draftProject.cadProjectCode}`);
await ready(draftPage);
assert.equal(await draftPage.getByRole('dialog').count(), 0);
assert.equal((await draftPage.evaluate(() => window.solidcraft.inspect({}))).bodies.length, 0);
assert.equal((await draftPage.evaluate(() => window.vibemakeCad.getState())).dirty, false);
assert.deepEqual(await localDrafts(draftPage, auth.user.userCode, draftProject.cadProjectCode), []);
checks.push('discarded-draft-does-not-return-when-project-reopens');
if (artifactDir) await draftPage.screenshot({ path: resolve(artifactDir, 'discard-reopened-zh.png') });
const platformAgentResult = await runPlatformAgentBrowserChecks(browser); checks.push(...platformAgentResult.checks); errors.push(...platformAgentResult.errors);
const mobileContext = await authenticatedContext({ width: 700, height: 900 }), mobile = await mobileContext.newPage(), mobileEngineRequests = [];
mobile.on('request', (request) => { if (request.url().includes('/cad/engine.json') || request.url().includes('/cad/_assets/')) mobileEngineRequests.push(request.url()); });
await mobile.goto(url); await mobile.getByRole('heading', { name: '请在电脑端使用 VibeMake CAD' }).waitFor();
assert.deepEqual(mobileEngineRequests, []); checks.push('mobile-blocks-before-engine-download');
const signedOutContext = await browser.newContext({ viewport: { width: 1440, height: 900 } }), signedOut = await signedOutContext.newPage(), privateRequests = [];
signedOut.on('request', (request) => { if (request.url().includes('/api/cad/')) privateRequests.push(request.url()); });
await signedOut.goto(url); await signedOut.getByRole('dialog').waitFor(); await signedOut.locator('[data-close]').click(); await signedOut.waitForTimeout(400);
assert.deepEqual(privateRequests, []); assert.equal(await signedOut.evaluate(() => window.vibemakeCad), undefined);
checks.push('cancel-login-does-not-load-private-data-or-engine');
if (artifactDir) {
await mkdir(artifactDir, { recursive: true });
await writeFile(resolve(artifactDir, 'browser-results.json'), JSON.stringify({ checks, errors, url }, null, 2));
}
assert.deepEqual(errors, []);
console.log(JSON.stringify({ checks, errors }));
await Promise.all([draftContext.close(), mobileContext.close(), signedOutContext.close()]);
} finally {
await browser.close();
}