Files
tianxuan/tests/debug_playwright.mjs
T
TianXuan Developer d81171cc1d test: Playwright E2E test for simple-analysis v2 + fix template JS syntax
- Fix extra closing brace in simple_analysis.html that broke all inline JS
- Add Playwright E2E test covering upload→filter→cluster→map→edges
- Add debug support script for Playwright issue isolation
- Use small 20-row test CSV for fast test execution
- All 31 assertions pass: page load, CSV upload, advanced filter,
  HDBSCAN clustering, Leaflet map, edge relationships

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-23 12:08:24 +08:00

56 lines
1.7 KiB
JavaScript

/**
* Minimal Playwright test — debug the "missing ) after argument list" error.
*/
import { chromium } from 'file:///C:/Users/Zjz/AppData/Roaming/npm/node_modules/@playwright/mcp/node_modules/playwright/index.mjs';
const BASE = 'http://127.0.0.1:8000';
async function main() {
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage();
// Track ALL errors
page.on('pageerror', err => {
console.log('PAGE_ERROR:', err.message);
console.log(' Stack:', err.stack?.substring(0, 200));
});
page.on('console', msg => {
if (msg.type() === 'error') {
const text = msg.text();
console.log('CONSOLE_ERROR:', text.substring(0, 300));
// Try to get the stack trace
try {
const stack = msg.stackTrace?.();
if (stack && stack.length > 0) {
console.log(' At:', stack[0].url?.substring(0, 100), stack[0].lineNumber, stack[0].columnNumber);
}
} catch(e) {}
}
});
page.on('weberror', err => {
console.log('WEB_ERROR:', err.message);
});
console.log('Loading page...');
await page.goto(`${BASE}/simple/`, { waitUntil: 'load', timeout: 15000 });
console.log('Waiting for scripts to settle...');
await new Promise(r => setTimeout(r, 2000));
// Check if key functions exist
const exists = await page.evaluate(() => ({
typeofSA: typeof SA,
typeofGoStep: typeof goStep,
typeofHandleFiles: typeof handleFiles,
typeofShowError: typeof showError,
typeofEscapeHtml: typeof escapeHtml,
leafletExists: typeof L !== 'undefined',
chartExists: typeof Chart !== 'undefined',
}));
console.log('Window globals:', JSON.stringify(exists, null, 2));
await browser.close();
}
main().catch(e => console.error(e));