diff --git a/tests/playwright/navigation.spec.js b/tests/playwright/navigation.spec.js index 89dbb444..b8c1c299 100644 --- a/tests/playwright/navigation.spec.js +++ b/tests/playwright/navigation.spec.js @@ -89,6 +89,64 @@ test.describe('Client-side Navigation', () => { expect(headerTextAfter).toContain('sx'); }); + test('browser back button works after navigation', async ({ page }) => { + await page.goto(BASE_URL + '/sx/(geography)', { waitUntil: 'networkidle' }); + await page.waitForTimeout(2000); + + // Note the initial URL and content + const initialUrl = page.url(); + const initialText = await page.locator('h1, h2').first().textContent(); + + // Navigate forward + const cekLink = page.locator('a:has-text("CEK Machine")'); + if (await cekLink.count() > 0) { + await cekLink.first().click(); + await page.waitForTimeout(3000); + + // Should be on a different page + const navUrl = page.url(); + expect(navUrl).not.toBe(initialUrl); + + // Go back + await page.goBack(); + await page.waitForTimeout(3000); + + // URL should return to original + expect(page.url()).toContain('geography'); + + // Content should show Geography page content (not blank, not broken) + const bodyText = await page.textContent('body'); + expect(bodyText.length).toBeGreaterThan(100); + + // Should not show raw SX + const mainContent = await page.locator('#main-panel, main').first().textContent(); + expect(mainContent).not.toContain('(~shared:layout'); + } + }); + + test('back button preserves layout (no side-by-side)', async ({ page }) => { + await page.goto(BASE_URL + '/sx/(geography)', { waitUntil: 'networkidle' }); + await page.waitForTimeout(2000); + + // Navigate forward + await page.click('a[href*="geography.(reactive"]:not([href*="runtime"])'); + await page.waitForTimeout(3000); + + // Go back + await page.goBack(); + await page.waitForTimeout(3000); + + // Check layout is vertical — heading should be within top part of page + const heading = await page.locator('h1, h2').first().boundingBox(); + if (heading) { + expect(heading.y).toBeLessThan(500); + const viewport = page.viewportSize(); + if (viewport) { + expect(heading.x).toBeLessThan(viewport.width * 0.5); + } + } + }); + test('full page width is used (no side-by-side split)', async ({ page }) => { await page.goto(BASE_URL + '/sx/(geography)', { waitUntil: 'networkidle' });