integration: return HTTP 404 for unmatched URLs and close remaining browser-gate gaps

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-25 18:45:28 +02:00
parent 34367181d2
commit 271df12334
8 changed files with 77 additions and 16 deletions

View File

@@ -13,9 +13,13 @@ export function pagePath(routeId: RouteId, locale: AppLocale): string {
return routePath(routeId, locale);
}
export async function readHtml(request: APIRequestContext, path: string): Promise<string> {
export async function readHtml(
request: APIRequestContext,
path: string,
expectedStatus: number,
): Promise<string> {
const response = await request.get(path);
expect(response.status(), `GET ${path} failed`).toBeLessThan(400);
expect(response.status(), `GET ${path} status`).toBe(expectedStatus);
return response.text();
}
@@ -42,7 +46,8 @@ export async function expectHead(
? '/en/missing-route'
: '/missing-route'
: pagePath(routeId, locale);
const html = await readHtml(request, path);
const expectedStatus = routeId === 'notFound' ? 404 : 200;
const html = await readHtml(request, path, expectedStatus);
const metadata = buildRouteMetadata(routeId, locale, SITE_CONTENT_DATA);
expect(html, `${path} title`).toContain(`<title>${metadata.title}</title>`);
@@ -78,11 +83,11 @@ export async function expectHead(
expect(html).toContain('name="twitter:description"');
}
export async function expectNoOverflow(page: Page): Promise<void> {
export async function expectNoOverflow(page: Page, route: string, width: number): Promise<void> {
const overflow = await page.evaluate(
() => document.documentElement.scrollWidth <= window.innerWidth + 1,
);
expect(overflow, `horizontal overflow at ${page.url()}`).toBe(true);
expect(overflow, `horizontal overflow at ${width}px on ${route}`).toBe(true);
}
export async function jsonLdGraph(page: Page): Promise<unknown> {