- 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.
89 lines
3.5 KiB
TypeScript
89 lines
3.5 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
test('Verify calendar shows correct dates for November 2025', 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');
|
|
|
|
// Tjek månedsnavn
|
|
const monthHeader = await page.locator('text=november 2025');
|
|
await expect(monthHeader).toBeVisible();
|
|
console.log('✅ Month header shows November 2025');
|
|
|
|
// Find alle dage i kalenderen
|
|
const dayElements = await page.locator('.cook-calendar .rdp-day').all();
|
|
console.log(`Found ${dayElements.length} day elements`);
|
|
|
|
// Extract dag numre og deres position
|
|
const dayData = [];
|
|
for (let i = 0; i < dayElements.length; i++) {
|
|
const dayText = await dayElements[i].textContent();
|
|
const classes = await dayElements[i].getAttribute('class');
|
|
const isOutside = classes?.includes('rdp-day_outside') || false;
|
|
|
|
dayData.push({
|
|
index: i,
|
|
text: dayText?.trim(),
|
|
isOutside: isOutside
|
|
});
|
|
}
|
|
|
|
console.log('Calendar days:', dayData.slice(0, 10)); // First 10 days
|
|
|
|
// Find første dag i november (1)
|
|
const firstNovemberDay = dayData.find(day => day.text === '1' && !day.isOutside);
|
|
if (firstNovemberDay) {
|
|
console.log(`✅ First day of November (1) found at position ${firstNovemberDay.index}`);
|
|
|
|
// November 1, 2025 er en lørdag (weekday 6, men vi starter ugen på mandag så position 5)
|
|
// Så 1. november skulle være på position 5 (if we count from 0: Ma=0, Ti=1, On=2, To=3, Fr=4, Lø=5)
|
|
const expectedPosition = 5; // Saturday in week starting Monday
|
|
const actualPosition = firstNovemberDay.index % 7;
|
|
|
|
console.log(`November 1st is at grid position ${actualPosition}, expected ${expectedPosition}`);
|
|
|
|
if (actualPosition === expectedPosition) {
|
|
console.log('✅ November 1st is correctly positioned on Saturday');
|
|
} else {
|
|
console.log(`❌ November 1st position is wrong. Expected ${expectedPosition}, got ${actualPosition}`);
|
|
}
|
|
} else {
|
|
console.log('❌ Could not find November 1st');
|
|
}
|
|
|
|
// Find 5. november (today)
|
|
const fifthNovemberDay = dayData.find(day => day.text === '5' && !day.isOutside);
|
|
if (fifthNovemberDay) {
|
|
console.log(`✅ November 5th (today) found at position ${fifthNovemberDay.index}`);
|
|
|
|
// November 5, 2025 er en onsdag (position 2 if week starts Monday)
|
|
const expectedPosition = 2; // Wednesday
|
|
const actualPosition = fifthNovemberDay.index % 7;
|
|
|
|
console.log(`November 5th is at grid position ${actualPosition}, expected ${expectedPosition}`);
|
|
|
|
if (actualPosition === expectedPosition) {
|
|
console.log('✅ November 5th is correctly positioned on Wednesday');
|
|
} else {
|
|
console.log(`❌ November 5th position is wrong. Expected ${expectedPosition}, got ${actualPosition}`);
|
|
}
|
|
}
|
|
|
|
// Tjek at vi har 30 dage i november
|
|
const novemberDays = dayData.filter(day => !day.isOutside);
|
|
console.log(`November has ${novemberDays.length} days visible`);
|
|
|
|
// Vis de første par uger for debugging
|
|
console.log('\nFirst two weeks layout:');
|
|
for (let week = 0; week < 2; week++) {
|
|
const weekDays = dayData.slice(week * 7, (week + 1) * 7);
|
|
const weekString = weekDays.map(day =>
|
|
(day.isOutside ? `(${day.text})` : day.text || 'X').padStart(4, ' ')
|
|
).join(' ');
|
|
console.log(`Week ${week + 1}: ${weekString}`);
|
|
}
|
|
}); |