Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions app/e2e/athlete-404.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { test, expect } from "@playwright/test";

// Regression guard for the athlete-page soft-404. A loading.tsx at
// app/src/app/athlete/[slug]/ created an implicit Suspense boundary that made
// Next stream the shell with a 200 status before the page's notFound() ran, so
// a nonexistent athlete returned HTTP 200 with the not-found UI (a soft 404 —
// bad for SEO). Removing that loading.tsx lets Next resolve notFound() before
// flushing the status. These assertions fail (miss returns 200) if it comes back.

test("nonexistent athlete returns a real 404 status", async ({ page }) => {
const res = await page.goto("/athlete/no-such-person--zz-x");
expect(res?.status()).toBe(404);
await expect(page.getByText("Page not found")).toBeVisible();
});

test("existing athlete returns 200 and renders the profile", async ({ page }) => {
// Rootul Patel is present in the committed athlete index (see
// athlete-search.spec.ts, which relies on the same athlete).
const res = await page.goto("/athlete/rootul-patel--us-m");
expect(res?.status()).toBe(200);
await expect(page.getByText("Rootul Patel")).toBeVisible();
});
35 changes: 0 additions & 35 deletions app/src/app/athlete/[slug]/loading.tsx

This file was deleted.

8 changes: 8 additions & 0 deletions app/src/app/athlete/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ import AthleteRaceList from "@/components/AthleteRaceList";
// Web APIs only, no fs/zlib (see @/lib/athlete-shards).
export const runtime = "edge";

// NOTE: deliberately no loading.tsx for this segment. A loading.tsx creates an
// implicit Suspense boundary that makes Next stream the shell with a 200 status
// before this page runs, so notFound() for a nonexistent athlete could only
// produce a soft 404 (HTTP 200 with the not-found UI) — bad for SEO. Without
// it, Next resolves the page (and notFound()) before flushing the status, so
// missing athletes return a real 404. See e2e/athlete-404.spec.ts. The shard
// fetch is fast on the edge, so the lost skeleton costs little.

interface PageProps {
params: Promise<{ slug: string }>;
}
Expand Down