Debian Codegraph @

www/tests/e2e/redirects.ts

raw symbols SCIP
1 import { test, expect } from './_fixtures';
2
3 test.describe('Redirects', () => {
4 // Migration guides (target pages don't exist yet, but redirect HTML should be generated)
5 const MIGRATION_REDIRECTS: [string, string][] = [
6 ['/migration-guide-hotwire-turbo', '/docs/get-started/migration-turbo'],
7 ['/migration-guide-htmx-1', '/docs/get-started/migration-htmx-1'],
8 ['/migration-guide-htmx-4', '/docs/get-started/migration-htmx-4'],
9 ['/migration-guide-htmx-2', '/docs/get-started/migration-htmx-4'],
10 ['/migration-guide-intercooler', '/docs/get-started/migration-intercooler'],
11 ['/htmx-4', '/docs/get-started/migration-htmx-4'],
12 ['/whats-new-in-htmx-4', '/docs/get-started/migration-htmx-4'],
13 ];
14
15 const SIMPLE_REDIRECTS: [string, string][] = [
16 ['/events', '/reference'],
17 ['/help', '/about'],
18 ['/server-examples', '/about'],
19 ['/examples', '/patterns'],
20 ];
21
22 // Simple redirects where the target page exists
23 for (const [from, to] of SIMPLE_REDIRECTS) {
24 test(`${from} → ${to}`, async ({ page }) => {
25 await page.goto(from);
26 await expect(page).toHaveURL(to);
27 });
28 }
29
30 // Migration redirects — only test that the redirect HTML is generated
31 // (target pages don't exist yet, so we just verify the redirect page exists)
32 for (const [from, to] of MIGRATION_REDIRECTS) {
33 test(`${from} redirect page exists`, async ({ request }) => {
34 const response = await request.get(from, { maxRedirects: 0 });
35 // Astro generates HTML with meta refresh for redirects
36 // The response should be 200 (HTML page) or 301/302
37 expect([200, 301, 302]).toContain(response.status());
38 });
39 }
40 });