2025-12-29 12:11:33 +01:00
|
|
|
// wxLogError Dialog Tests - Tests wxLogDialog error handling for KiCad
|
|
|
|
|
// Uses element registry for semantic element identification
|
|
|
|
|
import { test, expect, waitForRegistry, clickByLabel } from './utils/fixtures';
|
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');
|
|
|
|
|
|
|
|
|
|
// Wait for app to initialize
|
|
|
|
|
await page.waitForFunction(() => {
|
2025-12-27 16:39:04 +01:00
|
|
|
return (document.querySelector('#canvas') as HTMLElement)?.style.display === 'block';
|
2025-12-15 14:34:43 +01:00
|
|
|
}, { timeout: 30000 });
|
|
|
|
|
|
|
|
|
|
// Verify canvas is visible
|
|
|
|
|
const canvas = page.locator('#canvas');
|
|
|
|
|
await expect(canvas).toBeVisible();
|
|
|
|
|
|
|
|
|
|
// Take screenshot of initial state
|
|
|
|
|
await page.screenshot({
|
|
|
|
|
path: 'test-results/logerror-01-initial.png',
|
|
|
|
|
fullPage: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 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');
|
|
|
|
|
|
|
|
|
|
await page.waitForFunction(() => {
|
2025-12-27 16:39:04 +01:00
|
|
|
return (document.querySelector('#canvas') as HTMLElement)?.style.display === 'block';
|
2025-12-15 14:34:43 +01:00
|
|
|
}, { timeout: 30000 });
|
|
|
|
|
|
2025-12-29 12:11:33 +01:00
|
|
|
await waitForRegistry(page);
|
2025-12-15 14:34:43 +01:00
|
|
|
|
|
|
|
|
// Take screenshot before clicking
|
|
|
|
|
await page.screenshot({
|
|
|
|
|
path: 'test-results/logerror-02-before-error.png',
|
|
|
|
|
fullPage: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Click "Trigger Error" button
|
2025-12-29 12:11:33 +01:00
|
|
|
await clickByLabel(page, 'Trigger Error');
|
2025-12-15 14:34:43 +01:00
|
|
|
await page.waitForTimeout(500);
|
|
|
|
|
|
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
|
|
|
await page.waitForTimeout(1000);
|
|
|
|
|
|
|
|
|
|
// Take screenshot showing the error dialog
|
|
|
|
|
await page.screenshot({
|
|
|
|
|
path: 'test-results/logerror-03-single-error-dialog.png',
|
|
|
|
|
fullPage: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 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');
|
|
|
|
|
|
|
|
|
|
await page.waitForFunction(() => {
|
2025-12-27 16:39:04 +01:00
|
|
|
return (document.querySelector('#canvas') as HTMLElement)?.style.display === 'block';
|
2025-12-15 14:34:43 +01:00
|
|
|
}, { timeout: 30000 });
|
|
|
|
|
|
2025-12-29 12:11:33 +01:00
|
|
|
await waitForRegistry(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');
|
2025-12-15 14:34:43 +01:00
|
|
|
await page.waitForTimeout(500);
|
|
|
|
|
|
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
|
|
|
await page.waitForTimeout(1000);
|
|
|
|
|
|
|
|
|
|
// Take screenshot showing the dialog with Details
|
|
|
|
|
await page.screenshot({
|
|
|
|
|
path: 'test-results/logerror-04-multiple-errors-dialog.png',
|
|
|
|
|
fullPage: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 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');
|
|
|
|
|
|
|
|
|
|
await page.waitForFunction(() => {
|
2025-12-27 16:39:04 +01:00
|
|
|
return (document.querySelector('#canvas') as HTMLElement)?.style.display === 'block';
|
2025-12-15 14:34:43 +01:00
|
|
|
}, { timeout: 30000 });
|
|
|
|
|
|
2025-12-29 12:11:33 +01:00
|
|
|
await waitForRegistry(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');
|
2025-12-15 14:34:43 +01:00
|
|
|
await page.waitForTimeout(500);
|
|
|
|
|
|
|
|
|
|
// Take screenshot
|
|
|
|
|
await page.screenshot({
|
|
|
|
|
path: 'test-results/logerror-05-mixed-levels.png',
|
|
|
|
|
fullPage: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 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();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|