veza/apps/web/scripts/debug-story.js

33 lines
1.1 KiB
JavaScript

import { chromium } from 'playwright';
async function debugStory(storyId) {
const browser = await chromium.launch();
const page = await browser.newPage();
const storyUrl = `http://localhost:6007/iframe.html?id=${storyId}&viewMode=story`;
console.log(`Navigating to ${storyUrl}`);
const errors = [];
page.on('pageerror', err => errors.push(`PageError: ${err.message}`));
page.on('console', msg => {
if (msg.type() === 'error') errors.push(`ConsoleError: ${msg.text()}`);
});
page.on('requestfailed', request => {
errors.push(`NetworkFail: ${request.failure().errorText} ${request.url()}`);
});
try {
await page.goto(storyUrl, { waitUntil: 'networkidle' });
// Wait a bit for async errors
await page.waitForTimeout(2000);
} catch (e) {
errors.push(`NavigationError: ${e.message}`);
}
console.log('Errors found:', JSON.stringify(errors, null, 2));
await browser.close();
}
const storyId = process.argv[2] || 'components-admin-adminauditlogsview--default';
debugStory(storyId);