import { expect, test } from '@playwright/test'; import { WebsiteAuthManager } from '../../shared/website/WebsiteAuthManager'; import { ConsoleErrorCapture } from '../../shared/website/ConsoleErrorCapture'; const WEBSITE_BASE_URL = process.env.PLAYWRIGHT_BASE_URL || 'http://localhost:3000'; test.describe('Client-side Navigation', () => { test('navigation from dashboard to leagues and back', async ({ browser, request }) => { const auth = await WebsiteAuthManager.createAuthContext(browser, request, 'auth'); const capture = new ConsoleErrorCapture(auth.page); try { // Start at dashboard await auth.page.goto(`${WEBSITE_BASE_URL}/dashboard`); expect(auth.page.url()).toContain('/dashboard'); // Click on Leagues in sidebar or navigation // Using href-based selector for stability as requested const leaguesLink = auth.page.locator('a[href="/leagues"]').first(); await leaguesLink.click(); // Assert URL change await auth.page.waitForURL(/\/leagues/); expect(auth.page.url()).toContain('/leagues'); // Click on Dashboard back const dashboardLink = auth.page.locator('a[href="/dashboard"]').first(); await dashboardLink.click(); // Assert URL change await auth.page.waitForURL(/\/dashboard/); expect(auth.page.url()).toContain('/dashboard'); // Assert no runtime errors during navigation capture.setAllowlist(['hydration', 'warning:']); if (capture.hasUnexpectedErrors()) { throw new Error(`Found unexpected console errors during navigation:\n${capture.format()}`); } } finally { await auth.context.close(); } }); });