Files
kokken/tests/visual-calendar-test.spec.ts
Alex Polo 570c41f465 Add comprehensive Playwright tests for calendar functionality
- Implemented tests for debugging browser cache vs server response.
- Verified calendar displays correct dates for November 2025.
- Added visual inspection screenshot for calendar layout.
- Created tests to ensure calendar fits within its container.
- Checked for correct styling of available and blocked dates.
- Debugged login form behavior and cookie handling.
- Added tests for forced browser refresh and cache verification.
- Conducted visual tests to compare actual calendar layout with expected.
- Enhanced logging for better traceability during test execution.
2025-11-07 14:09:22 +01:00

42 lines
1.6 KiB
TypeScript

import { test } from '@playwright/test';
test('Visual test - take screenshot and compare with expected layout', async ({ page }) => {
// Set basic auth header
await page.setExtraHTTPHeaders({
'Authorization': 'Basic ' + Buffer.from('brotha:makefood1').toString('base64')
});
await page.goto('http://localhost:3000/admin/availability');
await page.waitForSelector('.cook-calendar');
await page.waitForTimeout(2000);
// Get the actual table structure
const tableRows = await page.locator('.cook-calendar tbody tr').all();
console.log('=== ACTUAL CALENDAR LAYOUT ===');
for (let i = 0; i < tableRows.length; i++) {
const cells = await tableRows[i].locator('td button').allTextContents();
console.log(`Row ${i + 1}: ${cells.join(' ')}`);
}
// Get headers
const headers = await page.locator('.cook-calendar thead th').allTextContents();
console.log('Headers:', headers.join(' '));
// What we expect for November 2025:
// November 1, 2025 is Saturday, so in week starting Monday:
// ma ti on to fr lö sö
// Should be: 27 28 29 30 31 1 2
const firstRow = await tableRows[0].locator('td button').allTextContents();
console.log('\nFirst row actual:', firstRow);
console.log('First row expected: [27, 28, 29, 30, 31, 1, 2] (1 should be in 6th position - Saturday)');
if (firstRow[5] === '1') {
console.log('✅ November 1st is correctly in position 6 (Saturday)');
} else {
console.log(`❌ November 1st is in wrong position. Found "${firstRow[5]}" in position 6`);
console.log('Position of "1":', firstRow.indexOf('1'));
}
});