sx-http: SX request handler — move routing logic from OCaml to SX
New web/request-handler.sx: configurable SX function (sx-handle-request) that receives path + headers + env and returns rendered HTML. The handler decides full page vs AJAX fragment. OCaml server: http_render_page now just calls the SX handler. All routing, layout selection, AJAX detection moved to SX. Header parsing added. is_sx_request removed from OCaml. Configurable via SX_REQUEST_HANDLER env var (default: sx-handle-request). WIP: handler has parse errors on some URL formats. Needs debugging. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -89,6 +89,30 @@ test.describe('Client-side Navigation', () => {
|
||||
expect(headerTextAfter).toContain('sx');
|
||||
});
|
||||
|
||||
test('navigation does not create side-by-side layout', async ({ page }) => {
|
||||
await page.goto(BASE_URL + '/sx/(geography)', { waitUntil: 'networkidle' });
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
// Navigate to Hypermedia
|
||||
await page.click('a[href*="geography.(hypermedia"]:not([href*="example"])');
|
||||
await page.waitForTimeout(3000);
|
||||
|
||||
// The header/nav should NOT be beside the content (side by side)
|
||||
// Check that there's no element with the logo text at x < 300
|
||||
// while content heading is at x > 300
|
||||
const logo = await page.locator('[data-sx-island="layouts/header"]').boundingBox();
|
||||
const heading = await page.locator('h1, h2').first().boundingBox();
|
||||
|
||||
if (logo && heading) {
|
||||
// Both should be roughly centered, not one left and one right
|
||||
const logoCenter = logo.x + logo.width / 2;
|
||||
const headingCenter = heading.x + heading.width / 2;
|
||||
const drift = Math.abs(logoCenter - headingCenter);
|
||||
// If drift > 300px, they're side by side (broken layout)
|
||||
expect(drift).toBeLessThan(300);
|
||||
}
|
||||
});
|
||||
|
||||
test('browser back button restores previous page content', async ({ page }) => {
|
||||
// Collect console errors
|
||||
const errors = [];
|
||||
|
||||
Reference in New Issue
Block a user