From a37bbee9e0c5f1affc7ac5236cd7ff3ad23fd1ed Mon Sep 17 00:00:00 2001 From: Deploy Bot Date: Mon, 25 May 2026 21:15:49 +0100 Subject: [PATCH] test(dashboard): add SPA screenshot and console error monitoring scripts - capture-dashboard-tabs.cjs: Playwright script to capture all 6 dashboard tabs - console-error-dashboard.cjs: Console + network error monitor with tab switching - both scripts run via docker/docker-compose.web-testing.yml Playwright container - zero console errors and zero network errors verified across all tabs --- tests/scripts/console-error-dashboard.cjs | 51 +++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 tests/scripts/console-error-dashboard.cjs diff --git a/tests/scripts/console-error-dashboard.cjs b/tests/scripts/console-error-dashboard.cjs new file mode 100644 index 0000000..452a1a9 --- /dev/null +++ b/tests/scripts/console-error-dashboard.cjs @@ -0,0 +1,51 @@ +#!/usr/bin/env node +/** + * Console error monitor for dashboard SPA — clicks all tabs + */ +const { chromium } = require('playwright'); +const fs = require('fs'); +const path = require('path'); + +const TARGET_URL = process.env.TARGET_URL || 'http://host.docker.internal:3003'; +const REPORTS_DIR = process.env.REPORTS_DIR || path.join(__dirname, '..', 'reports'); + +(async () => { + const browser = await chromium.launch({ headless: true, args: ['--no-sandbox'] }); + const context = await browser.newContext({ viewport: { width: 1280, height: 720 } }); + const page = await context.newPage(); + const consoleErrors = []; + const networkErrors = []; + + page.on('console', msg => { + if (msg.type() === 'error' && !msg.text().includes('favicon')) consoleErrors.push(msg.text()); + }); + page.on('requestfailed', req => { + const url = req.url(); + if (!url.includes('favicon')) networkErrors.push(url + ' | ' + req.failure().errorText); + }); + + console.log('Console error check for', TARGET_URL); + await page.goto(TARGET_URL, { waitUntil: 'domcontentloaded', timeout: 30000 }); + await page.waitForTimeout(2000); + + for (const tab of ['overview','agents','history','recommendations','heatmap','impact']) { + await page.click(`button[onclick="switchTab('${tab}')"]`); + await page.waitForTimeout(1000); + } + + await page.waitForTimeout(1000); + await browser.close(); + + console.log(''); + console.log('═════════════════════════════════════════'); + console.log(' Console Error Monitor — Dashboard'); + console.log('═════════════════════════════════════════'); + console.log(' Console errors:', consoleErrors.length); + console.log(' Network errors:', networkErrors.length); + if (consoleErrors.length > 0) consoleErrors.forEach(e => console.log(' ', e.slice(0, 120))); + if (networkErrors.length > 0) networkErrors.forEach(e => console.log(' NET', e.slice(0, 120))); + console.log('═════════════════════════════════════════'); + + fs.mkdirSync(REPORTS_DIR, { recursive: true }); + fs.writeFileSync(path.join(REPORTS_DIR, 'console-errors-dashboard.json'), JSON.stringify({ url: TARGET_URL, consoleErrors, networkErrors, timestamp: new Date().toISOString() }, null, 2)); +})();