mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
Closes DOCS-1254 ## Problem The docs E2E link check only confirms that a docs-owned link resolves to a page. It strips the `#anchor` first, so a link to a renamed or removed heading still passes. For example, on production today: - `guides/auth/redirect-urls` links to `reference/javascript/auth-signinwithoauth#sign-in-using-a-third-party-provider-with-redirect`, which is a tab value, not an element id. - `guides/database/import-data` links to `guides/platform/database-size#disk-management`, a heading that no longer exists. A full run found 58 broken anchor links on 53 guide pages. See the [snapshot](https://app.notion.com/p/4015004b775f81538b15c28286177d31). DOCS-1516 tracks the fixes. ## Solution For each docs-owned link on a changed page: - **Link to another page with an anchor:** the target page must have an element with that `id`, or an `a[name]` with that value. The ids come from the HTML that the existing status fetch already returns, so there are no extra requests. Each target page is fetched once per run and cached. - **Same-page `#anchor`:** checked against the loaded page. - **Failures:** each one is a soft assertion that names the page, the link, and the missing anchor. A link that doesn't resolve reports only its status, not a second anchor failure. Pages with a lot of links still finish in time. For example, the Personal access tokens guide links to over 200 API reference pages, and checking every one for anchors made its test time out. The check now downloads a linked page only when one of its links points to a section. The link filtering moved into a pure `docsOwnedLinkTargets` function with `node:test` coverage. `e2e/docs` gains a `test` script that runs it along with the existing scope tests. This complements #52100, which catches the opposite direction: unchanged pages that link to a heading the PR removes. ## Manual testing 1. Run the unit tests: ```bash pnpm -C e2e/docs test ``` 2. Run the suite against production for a page with a broken anchor and a page without one: ```bash cd e2e/docs DOCS_E2E_PAGE_PATHS=/docs/guides/auth/redirect-urls,/docs/guides/platform/ipv4-address \ PLAYWRIGHT_BASE_URL=https://supabase.com \ pnpm exec playwright test --grep-invert @a11y ``` **Note:** A separate PR is cleaning up our anchor links. You can also break a link locally and test. 3. Confirm `redirect-urls` fails, naming `#sign-in-using-a-third-party-provider-with-redirect`, and `ipv4-address` passes.
25 lines
904 B
JSON
25 lines
904 B
JSON
{
|
|
"name": "e2e-docs",
|
|
"version": "1.0.0",
|
|
"private": true,
|
|
"type": "module",
|
|
"scripts": {
|
|
"e2e:docs": "node --experimental-strip-types scripts/run-e2e-docs.ts",
|
|
"e2e:docs:all": "node --experimental-strip-types scripts/run-e2e-docs.ts --all",
|
|
"e2e:docs:a11y": "node --experimental-strip-types scripts/run-e2e-docs.ts --grep @a11y",
|
|
"e2e:ui": "node --experimental-strip-types scripts/run-e2e-docs.ts --ui",
|
|
"e2e:docs:local-smoke": "playwright test --config=playwright.local-smoke.config.ts",
|
|
"test": "node --test --experimental-strip-types 'utils/*.test.ts'",
|
|
"resolve-docs-scope": "node --experimental-strip-types scripts/resolve-docs-scope.ts"
|
|
},
|
|
"dependencies": {
|
|
"@playwright/test": "^1.59.1",
|
|
"e2e-shared": "workspace:*"
|
|
},
|
|
"devDependencies": {
|
|
"@axe-core/playwright": "^4.12.1",
|
|
"@types/node": "catalog:",
|
|
"axe-core": "^4.12.1"
|
|
}
|
|
}
|