Preserve slow custom-app overlays through their loading deadline

This commit is contained in:
archipelago
2026-10-06 13:01:44 -04:00
parent a49d4d7128
commit e8683aa5b1
6 changed files with 107 additions and 18 deletions
+13 -7
View File
@@ -11,7 +11,9 @@ const { chromium, expect } = require(process.env.PLAYWRIGHT_MODULE || '@playwrig
(bytes[0] === 127 || bytes[0] === 10 || (bytes[0] === 192 && bytes[1] === 168) || (bytes[0] === 172 && bytes[1] >= 16 && bytes[1] <= 31) || (bytes[0] === 100 && bytes[1] >= 64 && bytes[1] <= 127)));
if (!privateHost || !['http:', 'https:'].includes(url.protocol) || url.username || url.password || url.pathname !== '/' || url.search || url.hash) throw new Error('Refusing non-private node origin');
const browser = await chromium.connectOverCDP(process.env.BROWSER_CDP || 'http://127.0.0.1:32911');
for (const width of [390, 1440]) {
for (const mode of ['session', 'overlay']) for (const width of [390, 1440]) {
const port = mode === 'session' ? 7778 : 19999;
const fixtureUrl = new URL(origin); fixtureUrl.port = String(port);
const context = await browser.newContext({ viewport: { width, height: 900 }, serviceWorkers: 'block' });
let releaseDocument;
const heldDocument = new Promise(resolve => { releaseDocument = resolve; });
@@ -23,7 +25,7 @@ const { chromium, expect } = require(process.env.PLAYWRIGHT_MODULE || '@playwrig
localStorage.setItem('neode-auth', 'true');
localStorage.setItem('lnd-seed-backup-prompt-snooze-until', String(Date.now() + 3600000));
});
await context.route('**:7778/**', async route => {
await context.route('**:' + port + '/**', async route => {
if (route.request().resourceType() !== 'document') return route.abort();
documentRequests++;
await heldDocument;
@@ -36,8 +38,12 @@ const { chromium, expect } = require(process.env.PLAYWRIGHT_MODULE || '@playwrig
return route.continue();
});
const page = await context.newPage();
await page.goto(origin + '/dashboard/app-session/indeedhub', { waitUntil: 'domcontentloaded' });
const frame = page.locator('iframe[src*="7778"]');
await page.goto(origin + (mode === 'session' ? '/dashboard/app-session/indeedhub' : '/dashboard/apps'), { waitUntil: 'domcontentloaded' });
if (mode === 'overlay') {
await page.waitForFunction(() => document.querySelector('#app')?.__vue_app__?.config.globalProperties.$pinia?._s.has('appLauncher'));
await page.evaluate(url => document.querySelector('#app').__vue_app__.config.globalProperties.$pinia._s.get('appLauncher').open({ url, title: 'Custom app' }), fixtureUrl.href);
}
const frame = page.locator('iframe[src*="' + port + '"]');
await expect(frame).toHaveCount(1, { timeout: 30000 });
await frame.evaluate(el => { window.__qualificationFrame = el; });
const notice = page.getByRole('status').filter({ hasText: 'is taking longer to load' });
@@ -45,11 +51,11 @@ const { chromium, expect } = require(process.env.PLAYWRIGHT_MODULE || '@playwrig
expect(await frame.evaluate(el => el === window.__qualificationFrame)).toBe(true);
await expect(page.getByRole('button', { name: 'Close companion modal', exact: true })).toHaveCount(0);
releaseDocument();
await expect(page.frameLocator('iframe[src*="7778"]').locator('#ready')).toHaveText('Delayed app ready', { timeout: 15000 });
await expect(page.frameLocator('iframe[src*="' + port + '"]').locator('#ready')).toHaveText('Delayed app ready', { timeout: 15000 });
await expect(notice).toHaveCount(0);
expect(await frame.evaluate(el => el === window.__qualificationFrame)).toBe(true);
// Modify readiness only in this isolated browser's store, never the node.
for (const ready of [false, true]) {
if (mode === 'session') for (const ready of [false, true]) {
await page.evaluate(ready => {
const app = document.querySelector('#app').__vue_app__.config.globalProperties.$pinia._s.get('app');
app.data['package-data'].indeedhub['ui-ready'] = ready;
@@ -59,7 +65,7 @@ const { chromium, expect } = require(process.env.PLAYWRIGHT_MODULE || '@playwrig
expect(await frame.evaluate(el => el === window.__qualificationFrame)).toBe(true);
}
expect(documentRequests).toBe(1);
console.log(JSON.stringify({ node, width, result: 'PASS', delayedBeyondDeadline: true, sameIframeRetained: true, readinessFlapRetained: true, companionOfferDeferred: true, documentRequests }));
console.log(JSON.stringify({ node, mode, width, result: 'PASS', delayedBeyondDeadline: true, sameIframeRetained: true, readinessFlapRetained: mode === 'session' ? true : 'not-applicable', companionOfferDeferred: true, documentRequests }));
} finally {
releaseDocument();
await context.close();