Skip to content

Commit 46b49d0

Browse files
committed
adding console.log to the playwright test
1 parent 7a61c2b commit 46b49d0

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

‎.github/workflows/playwright-matrix.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ jobs:
229229
run: |
230230
# Playwright's OS dependencies come from Ubuntu's own repos
231231
# so these third-party sources are unnecessary here and safe to remove.
232-
# Scoped to sources.list.d so /etc/apt/sources.list (Ubuntu's own repos)
232+
# Scoped to sources.list.d so /etc/apt/sources.list (Ubuntu's own repos)
233233
# can never be removed.
234234
sudo grep -rl 'dl\.google\.com' /etc/apt/sources.list.d/ 2>/dev/null \
235235
| sudo xargs -r rm -fv || true

‎tests/playwright/specs/ai-designer.spec.js‎

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,42 @@ test.describe('AI Page Designer', () => {
2020
await auth.navigateToAdminPage(page, 'admin.php?page=web#/ai-designer');
2121
await page.waitForSelector('#wppw-app-rendered', { timeout: 15000 });
2222

23-
if (await mount.count()) {
23+
// Wait properly rather than checking instantaneously: the AI Designer
24+
// page is a React.lazy() import, so the mount appears a beat after
25+
// #wppw-app-rendered. A bare count() here retries on that race and
26+
// makes the diagnostic below fire before the page had a fair chance.
27+
try {
28+
await mount.waitFor({ state: 'attached', timeout: 15000 });
2429
break;
30+
} catch (e) {
31+
// Genuinely absent after waiting -- fall through and record why.
2532
}
33+
34+
// TEMPORARY DIAGNOSTIC -- remove once the first-run capability failure
35+
// is understood. Three readings taken at the moment of failure:
36+
// db - what the options table actually holds
37+
// page - what this rendered document received
38+
// refetch- a fresh server request on this same context/session,
39+
// which distinguishes a stale browser cache from the server
40+
// genuinely returning no capabilities for this session.
41+
const dbCaps = await newfold.logCapabilities();
42+
const pageCaps = await page.evaluate(
43+
() => window.NewfoldRuntime && window.NewfoldRuntime.capabilities
44+
);
45+
let refetchCaps = 'n/a';
46+
try {
47+
const res = await page.request.get(page.url().split('#')[0]);
48+
const html = await res.text();
49+
const m = html.match(/capabilities":(\[\]|\{[^}]*\})/);
50+
refetchCaps = m ? m[1] : 'not-found-in-html';
51+
} catch (e) {
52+
refetchCaps = `error: ${e.message}`;
53+
}
54+
55+
console.log(`[aipd-diag] attempt=${attempt} url=${page.url()}`);
56+
console.log(`[aipd-diag] db = ${JSON.stringify(dbCaps)}`);
57+
console.log(`[aipd-diag] page = ${JSON.stringify(pageCaps)}`);
58+
console.log(`[aipd-diag] refetch = ${refetchCaps}`);
2659
}
2760

2861
await expect(mount).toBeVisible({ timeout: 15000 });

0 commit comments

Comments
 (0)