2025-11-29 20:54:54 +01:00
|
|
|
import { test, expect, MAIN_CANVAS, tryLoadApp, getCanvasBox } from './utils/fixtures';
|
2025-11-29 16:19:13 +01:00
|
|
|
|
2025-11-29 18:42:27 +01:00
|
|
|
test.describe('wxDialog/wxMessageBox Tests', () => {
|
2025-11-29 20:54:54 +01:00
|
|
|
test('Dialog test app loads successfully', async ({ page, testLogger }) => {
|
2025-11-29 18:42:27 +01:00
|
|
|
await page.goto('/standalone/dialog/dialog_test.html');
|
|
|
|
|
const loaded = await tryLoadApp(page);
|
|
|
|
|
|
|
|
|
|
await page.screenshot({ path: 'test-results/dialog-01-loaded.png', fullPage: true });
|
2025-11-29 16:19:13 +01:00
|
|
|
|
2025-11-29 20:54:54 +01:00
|
|
|
const hasStartupLog = testLogger.consoleLogs.some(log =>
|
2025-11-29 16:19:13 +01:00
|
|
|
log.includes('DIALOG_TEST') && log.includes('started successfully')
|
|
|
|
|
);
|
|
|
|
|
|
2025-11-29 18:42:27 +01:00
|
|
|
expect(loaded, 'Canvas should be visible').toBe(true);
|
2025-11-29 20:54:54 +01:00
|
|
|
expect(testLogger.errors.filter(e => !e.includes('favicon'))).toHaveLength(0);
|
2025-11-29 16:19:13 +01:00
|
|
|
});
|
|
|
|
|
|
2025-11-29 20:54:54 +01:00
|
|
|
test('Info dialog button can be clicked', async ({ page, testLogger }) => {
|
2025-11-29 18:42:27 +01:00
|
|
|
await page.goto('/standalone/dialog/dialog_test.html');
|
|
|
|
|
const loaded = await tryLoadApp(page);
|
|
|
|
|
if (!loaded) {
|
|
|
|
|
test.skip();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-29 20:54:54 +01:00
|
|
|
const box = await getCanvasBox(page);
|
2025-11-29 18:42:27 +01:00
|
|
|
|
|
|
|
|
// Info Dialog button is first in the wxMessageBox row
|
|
|
|
|
const centerX = box.width / 2;
|
|
|
|
|
await page.mouse.click(box.x + centerX - 110, box.y + 115);
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.waitForTimeout(500);
|
|
|
|
|
|
2025-11-29 18:42:27 +01:00
|
|
|
await page.screenshot({ path: 'test-results/dialog-02-info-clicked.png', fullPage: true });
|
2025-11-29 16:19:13 +01:00
|
|
|
|
2025-11-29 20:54:54 +01:00
|
|
|
const hasInfoEvent = testLogger.consoleLogs.some(log =>
|
2025-11-29 16:19:13 +01:00
|
|
|
log.includes('Opening Info dialog')
|
|
|
|
|
);
|
2025-11-29 18:42:27 +01:00
|
|
|
|
|
|
|
|
expect(hasInfoEvent, 'Info dialog should open').toBe(true);
|
2025-11-29 16:19:13 +01:00
|
|
|
});
|
|
|
|
|
|
2025-11-29 20:54:54 +01:00
|
|
|
test('Yes/No dialog button can be clicked', async ({ page, testLogger }) => {
|
2025-11-29 18:42:27 +01:00
|
|
|
await page.goto('/standalone/dialog/dialog_test.html');
|
|
|
|
|
const loaded = await tryLoadApp(page);
|
|
|
|
|
if (!loaded) {
|
|
|
|
|
test.skip();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-29 20:54:54 +01:00
|
|
|
const box = await getCanvasBox(page);
|
2025-11-29 18:42:27 +01:00
|
|
|
|
|
|
|
|
// Yes/No Dialog button is second (center) in the wxMessageBox row
|
|
|
|
|
const centerX = box.width / 2;
|
|
|
|
|
await page.mouse.click(box.x + centerX, box.y + 115);
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.waitForTimeout(500);
|
|
|
|
|
|
2025-11-29 18:42:27 +01:00
|
|
|
await page.screenshot({ path: 'test-results/dialog-03-yesno-clicked.png', fullPage: true });
|
2025-11-29 16:19:13 +01:00
|
|
|
|
2025-11-29 20:54:54 +01:00
|
|
|
const hasYesNoEvent = testLogger.consoleLogs.some(log =>
|
2025-11-29 16:19:13 +01:00
|
|
|
log.includes('Opening Yes/No dialog')
|
|
|
|
|
);
|
2025-11-29 18:42:27 +01:00
|
|
|
expect(hasYesNoEvent, 'Yes/No dialog should open').toBe(true);
|
2025-11-29 16:19:13 +01:00
|
|
|
});
|
|
|
|
|
|
2025-11-29 20:54:54 +01:00
|
|
|
test('Error dialog button can be clicked', async ({ page, testLogger }) => {
|
2025-11-29 18:42:27 +01:00
|
|
|
await page.goto('/standalone/dialog/dialog_test.html');
|
|
|
|
|
const loaded = await tryLoadApp(page);
|
|
|
|
|
if (!loaded) {
|
|
|
|
|
test.skip();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-29 20:54:54 +01:00
|
|
|
const box = await getCanvasBox(page);
|
2025-11-29 18:42:27 +01:00
|
|
|
|
|
|
|
|
// Error Dialog button is third (rightmost) in the wxMessageBox row
|
|
|
|
|
const centerX = box.width / 2;
|
|
|
|
|
await page.mouse.click(box.x + centerX + 110, box.y + 115);
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.waitForTimeout(500);
|
|
|
|
|
|
2025-11-29 18:42:27 +01:00
|
|
|
await page.screenshot({ path: 'test-results/dialog-04-error-clicked.png', fullPage: true });
|
2025-11-29 16:19:13 +01:00
|
|
|
|
2025-11-29 20:54:54 +01:00
|
|
|
const hasErrorEvent = testLogger.consoleLogs.some(log =>
|
2025-11-29 16:19:13 +01:00
|
|
|
log.includes('Opening Error dialog')
|
|
|
|
|
);
|
2025-11-29 18:42:27 +01:00
|
|
|
expect(hasErrorEvent, 'Error dialog should open').toBe(true);
|
2025-11-29 16:19:13 +01:00
|
|
|
});
|
|
|
|
|
|
2025-11-29 20:54:54 +01:00
|
|
|
test('Custom dialog button can be clicked', async ({ page, testLogger }) => {
|
2025-11-29 18:42:27 +01:00
|
|
|
await page.goto('/standalone/dialog/dialog_test.html');
|
|
|
|
|
const loaded = await tryLoadApp(page);
|
|
|
|
|
if (!loaded) {
|
|
|
|
|
test.skip();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-29 20:54:54 +01:00
|
|
|
const box = await getCanvasBox(page);
|
2025-11-29 18:42:27 +01:00
|
|
|
|
|
|
|
|
// Custom Dialog button is first in the wxDialog row (row 2)
|
|
|
|
|
const centerX = box.width / 2;
|
|
|
|
|
await page.mouse.click(box.x + centerX - 60, box.y + 175);
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.waitForTimeout(500);
|
|
|
|
|
|
2025-11-29 18:42:27 +01:00
|
|
|
await page.screenshot({ path: 'test-results/dialog-05-custom-clicked.png', fullPage: true });
|
2025-11-29 16:19:13 +01:00
|
|
|
|
2025-11-29 18:42:27 +01:00
|
|
|
expect(true).toBe(true);
|
2025-11-29 16:19:13 +01:00
|
|
|
});
|
|
|
|
|
});
|