2025-12-30 14:17:51 +01:00
|
|
|
import { test, expect, waitForApp } from './utils/fixtures';
|
|
|
|
|
import { clickTab, clickByLabel } from './utils/element-tracker';
|
|
|
|
|
|
|
|
|
|
async function switchToDialogsTab(page: any) {
|
|
|
|
|
// Click Dialogs tab using element registry
|
|
|
|
|
const clicked = await clickTab(page, 'Dialogs');
|
|
|
|
|
if (!clicked) {
|
|
|
|
|
await clickByLabel(page, 'Dialogs');
|
|
|
|
|
}
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.waitForTimeout(1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test.describe('Dialogs Tab Tests', () => {
|
|
|
|
|
|
2025-11-29 20:54:54 +01:00
|
|
|
test('Dialogs tab renders correctly', async ({ page, testLogger }) => {
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.goto('/minimal_test.html');
|
|
|
|
|
await waitForApp(page);
|
|
|
|
|
|
|
|
|
|
// Screenshot before switching to Dialogs tab
|
|
|
|
|
await page.screenshot({ path: 'test-results/dialogs-00-initial.png', fullPage: true });
|
|
|
|
|
|
|
|
|
|
// Switch to Dialogs tab
|
2025-12-30 14:17:51 +01:00
|
|
|
await switchToDialogsTab(page);
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.screenshot({ path: 'test-results/dialogs-01-tab-selected.png', fullPage: true });
|
|
|
|
|
|
|
|
|
|
// Verify app is still responsive
|
|
|
|
|
const isResponsive = await page.evaluate(() => {
|
|
|
|
|
return document.querySelector('#canvas') !== null;
|
|
|
|
|
});
|
|
|
|
|
expect(isResponsive).toBe(true);
|
|
|
|
|
|
|
|
|
|
// Verify no critical errors
|
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
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test.describe('wxMessageBox', () => {
|
|
|
|
|
|
2025-11-29 20:54:54 +01:00
|
|
|
test('Info message box opens and closes', async ({ page, testLogger }) => {
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.goto('/minimal_test.html');
|
|
|
|
|
await waitForApp(page);
|
|
|
|
|
|
2025-12-30 14:17:51 +01:00
|
|
|
await switchToDialogsTab(page);
|
2025-11-29 16:19:13 +01:00
|
|
|
|
2025-12-30 14:17:51 +01:00
|
|
|
// Click "Info" button using element registry
|
|
|
|
|
await clickByLabel(page, 'Info');
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.waitForTimeout(500);
|
|
|
|
|
|
|
|
|
|
await page.screenshot({ path: 'test-results/dialogs-msgbox-info-open.png', fullPage: true });
|
|
|
|
|
|
2025-11-29 20:54:54 +01:00
|
|
|
// Click OK to close
|
2025-12-30 14:17:51 +01:00
|
|
|
await clickByLabel(page, 'OK');
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.waitForTimeout(300);
|
|
|
|
|
|
|
|
|
|
await page.screenshot({ path: 'test-results/dialogs-msgbox-info-closed.png', fullPage: 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('Yes/No message box returns correct result', async ({ page, testLogger }) => {
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.goto('/minimal_test.html');
|
|
|
|
|
await waitForApp(page);
|
|
|
|
|
|
2025-12-30 14:17:51 +01:00
|
|
|
await switchToDialogsTab(page);
|
2025-11-29 16:19:13 +01:00
|
|
|
|
2025-12-30 14:17:51 +01:00
|
|
|
// Click "Yes/No" button using element registry
|
|
|
|
|
await clickByLabel(page, 'Yes/No');
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.waitForTimeout(500);
|
|
|
|
|
|
|
|
|
|
await page.screenshot({ path: 'test-results/dialogs-msgbox-yesno-open.png', fullPage: true });
|
|
|
|
|
|
2025-12-30 14:17:51 +01:00
|
|
|
// Click Yes to close
|
|
|
|
|
await clickByLabel(page, 'Yes');
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.waitForTimeout(300);
|
|
|
|
|
|
|
|
|
|
await page.screenshot({ path: 'test-results/dialogs-msgbox-yesno-closed.png', fullPage: true });
|
|
|
|
|
});
|
|
|
|
|
|
2025-11-29 20:54:54 +01:00
|
|
|
test('Error message box displays correctly', async ({ page, testLogger }) => {
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.goto('/minimal_test.html');
|
|
|
|
|
await waitForApp(page);
|
|
|
|
|
|
2025-12-30 14:17:51 +01:00
|
|
|
await switchToDialogsTab(page);
|
2025-11-29 16:19:13 +01:00
|
|
|
|
2025-12-30 14:17:51 +01:00
|
|
|
// Click "Error" button using element registry
|
|
|
|
|
await clickByLabel(page, 'Error');
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.waitForTimeout(500);
|
|
|
|
|
|
|
|
|
|
await page.screenshot({ path: 'test-results/dialogs-msgbox-error-open.png', fullPage: true });
|
|
|
|
|
|
2025-12-30 14:17:51 +01:00
|
|
|
// Close the dialog with OK
|
|
|
|
|
await clickByLabel(page, 'OK');
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.waitForTimeout(300);
|
|
|
|
|
|
|
|
|
|
await page.screenshot({ path: 'test-results/dialogs-msgbox-error-closed.png', fullPage: true });
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test.describe('wxDialog', () => {
|
|
|
|
|
|
2025-11-29 20:54:54 +01:00
|
|
|
test('Custom dialog opens and closes', async ({ page, testLogger }) => {
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.goto('/minimal_test.html');
|
|
|
|
|
await waitForApp(page);
|
|
|
|
|
|
2025-12-30 14:17:51 +01:00
|
|
|
await switchToDialogsTab(page);
|
2025-11-29 16:19:13 +01:00
|
|
|
|
2025-12-30 14:17:51 +01:00
|
|
|
// Click "Open Custom Dialog" button using element registry
|
|
|
|
|
await clickByLabel(page, 'Open Custom Dialog');
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.waitForTimeout(500);
|
|
|
|
|
|
|
|
|
|
await page.screenshot({ path: 'test-results/dialogs-custom-open.png', fullPage: true });
|
|
|
|
|
|
|
|
|
|
// Click OK to close
|
2025-12-30 14:17:51 +01:00
|
|
|
await clickByLabel(page, 'OK');
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.waitForTimeout(300);
|
|
|
|
|
|
|
|
|
|
await page.screenshot({ path: 'test-results/dialogs-custom-closed.png', fullPage: true });
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test.describe('wxTimer', () => {
|
|
|
|
|
|
2025-11-29 20:54:54 +01:00
|
|
|
test('Timer starts and increments', async ({ page, testLogger }) => {
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.goto('/minimal_test.html');
|
|
|
|
|
await waitForApp(page);
|
|
|
|
|
|
2025-12-30 14:17:51 +01:00
|
|
|
await switchToDialogsTab(page);
|
2025-11-29 16:19:13 +01:00
|
|
|
|
|
|
|
|
await page.screenshot({ path: 'test-results/dialogs-timer-initial.png', fullPage: true });
|
|
|
|
|
|
2025-12-30 14:17:51 +01:00
|
|
|
// Click "Start Timer" button using element registry
|
|
|
|
|
await clickByLabel(page, 'Start Timer');
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.waitForTimeout(500);
|
|
|
|
|
|
|
|
|
|
await page.screenshot({ path: 'test-results/dialogs-timer-started.png', fullPage: true });
|
|
|
|
|
|
|
|
|
|
// Wait for a few timer ticks
|
2025-11-29 20:54:54 +01:00
|
|
|
await page.waitForTimeout(3500);
|
2025-11-29 16:19:13 +01:00
|
|
|
|
|
|
|
|
await page.screenshot({ path: 'test-results/dialogs-timer-running.png', fullPage: true });
|
|
|
|
|
|
2025-11-29 20:54:54 +01:00
|
|
|
// Click "Stop Timer"
|
2025-12-30 14:17:51 +01:00
|
|
|
await clickByLabel(page, 'Stop Timer');
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.waitForTimeout(500);
|
|
|
|
|
|
|
|
|
|
await page.screenshot({ path: 'test-results/dialogs-timer-stopped.png', fullPage: true });
|
|
|
|
|
|
|
|
|
|
// Just verify no crashes occurred - this is a smoke test
|
|
|
|
|
expect(true).toBe(true);
|
|
|
|
|
});
|
|
|
|
|
|
2025-11-29 20:54:54 +01:00
|
|
|
test('Timer can be started and stopped multiple times', async ({ page, testLogger }) => {
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.goto('/minimal_test.html');
|
|
|
|
|
await waitForApp(page);
|
|
|
|
|
|
2025-12-30 14:17:51 +01:00
|
|
|
await switchToDialogsTab(page);
|
2025-11-29 16:19:13 +01:00
|
|
|
|
2025-12-30 14:17:51 +01:00
|
|
|
// Start timer using element registry
|
|
|
|
|
await clickByLabel(page, 'Start Timer');
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.waitForTimeout(1500);
|
|
|
|
|
|
|
|
|
|
// Stop timer
|
2025-12-30 14:17:51 +01:00
|
|
|
await clickByLabel(page, 'Stop Timer');
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.waitForTimeout(500);
|
|
|
|
|
|
|
|
|
|
// Start again
|
2025-12-30 14:17:51 +01:00
|
|
|
await clickByLabel(page, 'Start Timer');
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.waitForTimeout(1500);
|
|
|
|
|
|
|
|
|
|
// Stop again
|
2025-12-30 14:17:51 +01:00
|
|
|
await clickByLabel(page, 'Stop Timer');
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.waitForTimeout(300);
|
|
|
|
|
|
|
|
|
|
await page.screenshot({ path: 'test-results/dialogs-timer-multiple.png', fullPage: true });
|
|
|
|
|
|
|
|
|
|
// Basic smoke test - no crashes
|
|
|
|
|
expect(true).toBe(true);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2025-11-29 20:54:54 +01:00
|
|
|
test('Full Dialogs tab interaction flow', async ({ page, testLogger }) => {
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.goto('/minimal_test.html');
|
|
|
|
|
await waitForApp(page);
|
|
|
|
|
|
2025-12-30 14:17:51 +01:00
|
|
|
await switchToDialogsTab(page);
|
2025-11-29 16:19:13 +01:00
|
|
|
|
2025-12-30 14:17:51 +01:00
|
|
|
// 1. Click Info button and close
|
|
|
|
|
await clickByLabel(page, 'Info');
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.waitForTimeout(400);
|
2025-12-30 14:17:51 +01:00
|
|
|
await clickByLabel(page, 'OK');
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.waitForTimeout(200);
|
|
|
|
|
|
2025-12-30 14:17:51 +01:00
|
|
|
// 2. Click Custom Dialog button and close
|
|
|
|
|
await clickByLabel(page, 'Open Custom Dialog');
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.waitForTimeout(400);
|
2025-12-30 14:17:51 +01:00
|
|
|
await clickByLabel(page, 'OK');
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.waitForTimeout(200);
|
|
|
|
|
|
2025-12-30 14:17:51 +01:00
|
|
|
// 3. Start and stop timer
|
|
|
|
|
await clickByLabel(page, 'Start Timer');
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.waitForTimeout(2000);
|
2025-12-30 14:17:51 +01:00
|
|
|
await clickByLabel(page, 'Stop Timer');
|
2025-11-29 16:19:13 +01:00
|
|
|
await page.waitForTimeout(200);
|
|
|
|
|
|
|
|
|
|
await page.screenshot({ path: 'test-results/dialogs-full-flow.png', fullPage: true });
|
|
|
|
|
|
|
|
|
|
// Verify no crashes
|
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
|
|
|
});
|
|
|
|
|
});
|