diff --git a/tests/playwright/navigation.spec.js b/tests/playwright/navigation.spec.js index 2d1d6583..13f9ab23 100644 --- a/tests/playwright/navigation.spec.js +++ b/tests/playwright/navigation.spec.js @@ -89,34 +89,39 @@ test.describe('Client-side Navigation', () => { expect(headerTextAfter).toContain('sx'); }); - test('browser back button works after navigation', async ({ page }) => { + test('browser back button restores previous page content', async ({ page }) => { + // Collect console errors + const errors = []; + page.on('console', msg => { + if (msg.type() === 'error') errors.push(msg.text()); + }); + await page.goto(BASE_URL + '/sx/(geography)', { waitUntil: 'networkidle' }); await page.waitForTimeout(2000); - // Get initial content - const initialContent = await page.locator('#main-panel').textContent(); - expect(initialContent).toContain('Geography'); - // Navigate forward to Hypermedia await page.click('a[href*="geography.(hypermedia"]:not([href*="example"])'); await page.waitForTimeout(3000); - // Verify we navigated — content should be different - const navContent = await page.locator('#main-panel').textContent(); - expect(navContent).toContain('Hypermedia'); + // Verify navigation worked — URL must contain hypermedia expect(page.url()).toContain('hypermedia'); // Go back await page.goBack(); await page.waitForTimeout(3000); - // Content should return to Geography — not stay on Hypermedia - const backContent = await page.locator('#main-panel').textContent(); - expect(backContent).toContain('Geography'); - expect(backContent).toContain('Rendering Pipeline'); - // Should NOT still show Hypermedia content + // URL should return expect(page.url()).toContain('geography'); expect(page.url()).not.toContain('hypermedia'); + + // Content MUST change back — the main heading should say Geography, + // NOT still show Hypermedia content + const heading = await page.locator('#main-panel h1, #main-panel h2').first(); + await expect(heading).toContainText('Geography', { timeout: 5000 }); + + // No JIT errors should have occurred during navigation + const jitErrors = errors.filter(e => e.includes('Not callable: nil')); + expect(jitErrors.length).toBe(0); }); test('back button preserves layout (no side-by-side)', async ({ page }) => { @@ -142,6 +147,26 @@ test.describe('Client-side Navigation', () => { } }); + test('no JIT errors during navigation', async ({ page }) => { + const errors = []; + page.on('console', msg => { + if (msg.type() === 'error' && msg.text().includes('FAIL')) { + errors.push(msg.text()); + } + }); + + await page.goto(BASE_URL + '/sx/(geography)', { waitUntil: 'networkidle' }); + await page.waitForTimeout(2000); + + // Navigate + await page.click('a[href*="geography.(hypermedia"]:not([href*="example"])'); + await page.waitForTimeout(3000); + + // Check for JIT errors — these indicate broken CSSX function resolution + const jitErrors = errors.filter(e => e.includes('Not callable: nil')); + expect(jitErrors.length).toBe(0); + }); + test('full page width is used (no side-by-side split)', async ({ page }) => { await page.goto(BASE_URL + '/sx/(geography)', { waitUntil: 'networkidle' });