sx-http: fix AJAX fragment extraction + proper back button test

AJAX fragment: extract #main-panel with matching close tag (depth
tracking) instead of taking everything to end of file. Prevents
shell closing tags from breaking the DOM swap.

Back button test: verifies content actually changes — checks for
"Geography" and "Rendering Pipeline" after going back, not just
that body has >100 chars. Tests forward nav content change too.

7/7 navigation tests pass including back button content verification.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-28 21:02:46 +00:00
parent 1bbecad861
commit 58d6a6de07
2 changed files with 49 additions and 26 deletions

View File

@@ -93,35 +93,30 @@ test.describe('Client-side Navigation', () => {
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();
// Get initial content
const initialContent = await page.locator('#main-panel').textContent();
expect(initialContent).toContain('Geography');
// Navigate forward
const cekLink = page.locator('a:has-text("CEK Machine")');
if (await cekLink.count() > 0) {
await cekLink.first().click();
await page.waitForTimeout(3000);
// Navigate forward to Hypermedia
await page.click('a[href*="geography.(hypermedia"]:not([href*="example"])');
await page.waitForTimeout(3000);
// Should be on a different page
const navUrl = page.url();
expect(navUrl).not.toBe(initialUrl);
// Verify we navigated — content should be different
const navContent = await page.locator('#main-panel').textContent();
expect(navContent).toContain('Hypermedia');
expect(page.url()).toContain('hypermedia');
// Go back
await page.goBack();
await page.waitForTimeout(3000);
// 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');
}
// 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
expect(page.url()).toContain('geography');
expect(page.url()).not.toContain('hypermedia');
});
test('back button preserves layout (no side-by-side)', async ({ page }) => {