pcbjam/tests/e2e/calendar.spec.ts
Viktor Vaczi 64142aa8de Extend element registry and migrate all tests to semantic selectors
Phase 2 of element registry migration - eliminate hardcoded coordinates:

Element tracker additions:
- wxTreeCtrl items (clickTreeItem, findTreeItem)
- wxDataViewCtrl items and column headers
- wxPropertyGrid rows
- wxListBox items
- wxSpinButton arrows
- wxSlider thumb/track
- wxTextCtrl area
- wxSearchCtrl field
- wxAuiManager pane content areas
- wxCalendarCtrl dates

Test migrations:
- 24 test files updated to use element registry helpers
- Replaced coordinate-based clicks with semantic selectors
- Added find-hardcoded-coords.sh script for auditing

Remaining coordinates are legitimate (scroll positioning, drawing, test.fail blocks).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 14:17:51 +01:00

93 lines
3.2 KiB
TypeScript

// wxCalendarCtrl Tests - Date selection
import { test, expect, tryLoadApp } from './utils/fixtures';
import { clickByLabel, clickCalendarDate } from './utils/element-tracker';
test.describe('wxCalendarCtrl Tests', () => {
test('Calendar test app loads successfully', async ({ page, testLogger }) => {
await page.goto('/standalone/calendar/calendar_test.html');
const loaded = await tryLoadApp(page);
await page.screenshot({ path: 'test-results/calendar-01-loaded.png', fullPage: true });
expect(loaded, 'wxCalendarCtrl app should load').toBe(true);
expect(testLogger.errors.filter(e => !e.includes('favicon'))).toHaveLength(0);
});
test('Calendar dates can be selected', async ({ page, testLogger }) => {
await page.goto('/standalone/calendar/calendar_test.html');
const loaded = await tryLoadApp(page);
if (!loaded) {
test.skip();
return;
}
await page.waitForTimeout(300);
// Click on day 15 in the calendar using element registry
const clicked = await clickCalendarDate(page, 15);
expect(clicked, 'Calendar date 15 should be found and clicked').toBe(true);
await page.waitForTimeout(200);
await page.screenshot({ path: 'test-results/calendar-02-select-date.png', fullPage: true });
});
test('Calendar can navigate to next month', async ({ page, testLogger }) => {
await page.goto('/standalone/calendar/calendar_test.html');
const loaded = await tryLoadApp(page);
if (!loaded) {
test.skip();
return;
}
await page.waitForTimeout(300);
// Click Next Month button using element registry
const clicked = await clickByLabel(page, 'Next Month');
expect(clicked, 'Next Month button should be found').toBe(true);
await page.waitForTimeout(200);
await page.screenshot({ path: 'test-results/calendar-03-next-month.png', fullPage: true });
});
test('Calendar can navigate to previous month', async ({ page, testLogger }) => {
await page.goto('/standalone/calendar/calendar_test.html');
const loaded = await tryLoadApp(page);
if (!loaded) {
test.skip();
return;
}
await page.waitForTimeout(300);
// Click Previous Month button using element registry
const clicked = await clickByLabel(page, 'Previous Month');
expect(clicked, 'Previous Month button should be found').toBe(true);
await page.waitForTimeout(200);
await page.screenshot({ path: 'test-results/calendar-04-prev-month.png', fullPage: true });
});
test('Calendar can navigate to today', async ({ page, testLogger }) => {
await page.goto('/standalone/calendar/calendar_test.html');
const loaded = await tryLoadApp(page);
if (!loaded) {
test.skip();
return;
}
await page.waitForTimeout(300);
// First go to next month
const nextClicked = await clickByLabel(page, 'Next Month');
expect(nextClicked, 'Next Month button should be found').toBe(true);
await page.waitForTimeout(100);
// Click Today button using element registry
const todayClicked = await clickByLabel(page, 'Today');
expect(todayClicked, 'Today button should be found').toBe(true);
await page.waitForTimeout(200);
await page.screenshot({ path: 'test-results/calendar-05-today.png', fullPage: true });
});
});