import { test } from '@playwright/test'; test('Check cookie and redirect after login', async ({ page }) => { // Go to login page await page.goto('http://localhost:3000/login'); // Fill and submit form await page.fill('#username', 'brotha'); await page.fill('#password', 'makefood1'); await page.click('button[type="submit"]'); // Wait for response await page.waitForTimeout(2000); // Check cookies const cookies = await page.context().cookies(); const authCookie = cookies.find(c => c.name === 'authToken'); console.log('Auth cookie:', authCookie ? 'Present' : 'Missing'); if (authCookie) { console.log('Cookie value length:', authCookie.value.length); console.log('Cookie secure:', authCookie.secure); console.log('Cookie httpOnly:', authCookie.httpOnly); } // Try to navigate to admin manually console.log('Trying to navigate to /admin...'); await page.goto('http://localhost:3000/admin'); await page.waitForTimeout(1000); const finalUrl = page.url(); console.log('Final URL:', finalUrl); if (finalUrl.includes('/login')) { console.log('❌ Redirected back to login - middleware issue'); } else if (finalUrl.includes('/admin')) { console.log('✅ Successfully accessed admin'); } });