2025-12-29 12:11:33 +01:00
|
|
|
// wxLogError Dialog Tests - Tests wxLogDialog error handling for KiCad
|
|
|
|
|
// Uses element registry for semantic element identification
|
2026-07-07 10:50:24 +02:00
|
|
|
import { test, expect, waitForWxApp, clickByLabel } from './utils/fixtures';
|
|
|
|
|
import { stableShot } from './utils/element-tracker';
|
2025-12-15 14:34:43 +01:00
|
|
|
|
|
|
|
|
test.describe('wxLogError Dialog Tests', () => {
|
|
|
|
|
|
|
|
|
|
test('LogError test app loads successfully', async ({ page, testLogger }) => {
|
|
|
|
|
await page.goto('/standalone/logerror/logerror_test.html');
|
|
|
|
|
|
2026-07-07 10:50:24 +02:00
|
|
|
// Wait for app to initialize (canvas visible + registry populated, loud)
|
|
|
|
|
await waitForWxApp(page);
|
2025-12-15 14:34:43 +01:00
|
|
|
|
|
|
|
|
// Verify canvas is visible
|
|
|
|
|
const canvas = page.locator('#canvas');
|
|
|
|
|
await expect(canvas).toBeVisible();
|
|
|
|
|
|
|
|
|
|
// Take screenshot of initial state
|
2026-07-07 10:50:24 +02:00
|
|
|
await stableShot(page, 'logerror-01-initial.png', { fullPage: true });
|
2025-12-15 14:34:43 +01:00
|
|
|
|
|
|
|
|
// Check for successful initialization log
|
|
|
|
|
const initLog = testLogger.consoleLogs.find(l =>
|
|
|
|
|
l.includes('[LOGERROR_TEST]')
|
|
|
|
|
);
|
|
|
|
|
expect(initLog).toBeTruthy();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('Trigger single error shows dialog', async ({ page, testLogger }) => {
|
|
|
|
|
await page.goto('/standalone/logerror/logerror_test.html');
|
|
|
|
|
|
2026-07-07 10:50:24 +02:00
|
|
|
await waitForWxApp(page);
|
2025-12-15 14:34:43 +01:00
|
|
|
|
|
|
|
|
// Take screenshot before clicking
|
2026-07-07 10:50:24 +02:00
|
|
|
await stableShot(page, 'logerror-02-before-error.png', { fullPage: true });
|
2025-12-15 14:34:43 +01:00
|
|
|
|
|
|
|
|
// Click "Trigger Error" button
|
2025-12-29 12:11:33 +01:00
|
|
|
await clickByLabel(page, 'Trigger Error');
|
2026-07-07 10:50:24 +02:00
|
|
|
|
|
|
|
|
// Wait deterministically for the wxLogError console event
|
|
|
|
|
await expect.poll(
|
|
|
|
|
() => testLogger.consoleLogs.some(l =>
|
|
|
|
|
l.includes('[wxLog][ERROR]') && l.includes('Error loading editor')
|
|
|
|
|
),
|
|
|
|
|
{ message: 'expected [wxLog][ERROR] "Error loading editor" after Trigger Error' }
|
|
|
|
|
).toBe(true);
|
2025-12-15 14:34:43 +01:00
|
|
|
|
2025-12-29 12:11:33 +01:00
|
|
|
// Click "Flush Log (Show Dialog)" to show the dialog
|
|
|
|
|
await clickByLabel(page, 'Flush Log (Show Dialog)');
|
2025-12-15 14:34:43 +01:00
|
|
|
|
2026-07-07 10:50:24 +02:00
|
|
|
// Take screenshot showing the error dialog (stableShot stabilizes)
|
|
|
|
|
await stableShot(page, 'logerror-03-single-error-dialog.png', { fullPage: true });
|
2025-12-15 14:34:43 +01:00
|
|
|
|
|
|
|
|
// Check console for wxLog messages
|
|
|
|
|
const wxLogMessages = testLogger.consoleLogs.filter(l =>
|
|
|
|
|
l.includes('[wxLog]')
|
|
|
|
|
);
|
|
|
|
|
console.log('wxLog messages:', wxLogMessages);
|
|
|
|
|
|
|
|
|
|
// Verify wxLogError message appeared in console
|
|
|
|
|
const errorLog = testLogger.consoleLogs.find(l =>
|
|
|
|
|
l.includes('[wxLog][ERROR]') && l.includes('Error loading editor')
|
|
|
|
|
);
|
|
|
|
|
expect(errorLog).toBeTruthy();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('Trigger multiple errors shows Details dropdown', async ({ page, testLogger }) => {
|
|
|
|
|
await page.goto('/standalone/logerror/logerror_test.html');
|
|
|
|
|
|
2026-07-07 10:50:24 +02:00
|
|
|
await waitForWxApp(page);
|
2025-12-15 14:34:43 +01:00
|
|
|
|
|
|
|
|
// Click "Trigger Multiple" button
|
2025-12-29 12:11:33 +01:00
|
|
|
await clickByLabel(page, 'Trigger Multiple');
|
2026-07-07 10:50:24 +02:00
|
|
|
|
|
|
|
|
// Wait deterministically for the multiple wxLogError console events
|
|
|
|
|
await expect.poll(
|
|
|
|
|
() => testLogger.consoleLogs.filter(l => l.includes('[wxLog][ERROR]')).length >= 3,
|
|
|
|
|
{ message: 'expected at least 3 [wxLog][ERROR] messages after Trigger Multiple' }
|
|
|
|
|
).toBe(true);
|
2025-12-15 14:34:43 +01:00
|
|
|
|
2025-12-29 12:11:33 +01:00
|
|
|
// Click "Flush Log (Show Dialog)" to show the dialog with Details dropdown
|
|
|
|
|
await clickByLabel(page, 'Flush Log (Show Dialog)');
|
2025-12-15 14:34:43 +01:00
|
|
|
|
2026-07-07 10:50:24 +02:00
|
|
|
// Take screenshot showing the dialog with Details (stableShot stabilizes)
|
|
|
|
|
await stableShot(page, 'logerror-04-multiple-errors-dialog.png', { fullPage: true });
|
2025-12-15 14:34:43 +01:00
|
|
|
|
|
|
|
|
// Verify multiple wxLogError messages appeared in console
|
|
|
|
|
const errorLogs = testLogger.consoleLogs.filter(l =>
|
|
|
|
|
l.includes('[wxLog][ERROR]')
|
|
|
|
|
);
|
|
|
|
|
console.log('Error logs:', errorLogs);
|
|
|
|
|
|
|
|
|
|
// Should have at least 3 error messages
|
|
|
|
|
expect(errorLogs.length).toBeGreaterThanOrEqual(3);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('wxLog console logging works for all levels', async ({ page, testLogger }) => {
|
|
|
|
|
await page.goto('/standalone/logerror/logerror_test.html');
|
|
|
|
|
|
2026-07-07 10:50:24 +02:00
|
|
|
await waitForWxApp(page);
|
2025-12-15 14:34:43 +01:00
|
|
|
|
|
|
|
|
// Click "Mixed Levels" button to log error, warning, and message
|
2025-12-29 12:11:33 +01:00
|
|
|
await clickByLabel(page, 'Mixed Levels');
|
2026-07-07 10:50:24 +02:00
|
|
|
|
|
|
|
|
// Wait deterministically for all three log-level console events
|
|
|
|
|
await expect.poll(
|
|
|
|
|
() => {
|
|
|
|
|
const logs = testLogger.consoleLogs;
|
|
|
|
|
return logs.some(l => l.includes('[wxLog][ERROR]') && l.includes('error message'))
|
|
|
|
|
&& logs.some(l => l.includes('[wxLog][WARNING]') && l.includes('warning message'))
|
|
|
|
|
&& logs.some(l => l.includes('[wxLog][INFO]') && l.includes('info message'));
|
|
|
|
|
},
|
|
|
|
|
{ message: 'expected [wxLog] ERROR/WARNING/INFO messages after Mixed Levels' }
|
|
|
|
|
).toBe(true);
|
2025-12-15 14:34:43 +01:00
|
|
|
|
|
|
|
|
// Take screenshot
|
2026-07-07 10:50:24 +02:00
|
|
|
await stableShot(page, 'logerror-05-mixed-levels.png', { fullPage: true });
|
2025-12-15 14:34:43 +01:00
|
|
|
|
|
|
|
|
// Verify each log level appeared in console
|
|
|
|
|
const errorLog = testLogger.consoleLogs.find(l =>
|
|
|
|
|
l.includes('[wxLog][ERROR]') && l.includes('error message')
|
|
|
|
|
);
|
|
|
|
|
const warningLog = testLogger.consoleLogs.find(l =>
|
|
|
|
|
l.includes('[wxLog][WARNING]') && l.includes('warning message')
|
|
|
|
|
);
|
|
|
|
|
const infoLog = testLogger.consoleLogs.find(l =>
|
|
|
|
|
l.includes('[wxLog][INFO]') && l.includes('info message')
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
console.log('Error log:', errorLog);
|
|
|
|
|
console.log('Warning log:', warningLog);
|
|
|
|
|
console.log('Info log:', infoLog);
|
|
|
|
|
|
|
|
|
|
expect(errorLog).toBeTruthy();
|
|
|
|
|
expect(warningLog).toBeTruthy();
|
|
|
|
|
expect(infoLog).toBeTruthy();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|