Files
supabase/e2e/docs/README.md
Alexis Aguilar b66682ee07 ci(docs): scan only the guides production serves in the daily accessibility scan (#54499)
## Problem

The daily Docs Accessibility Scan builds its page list from
`apps/docs/content/guides` on `master`, then loads each page from
production. When production runs behind `master`, every guide merged
since the last production deploy returns 404 and fails the scan, even
though the guide is fine.

On 2026-12-02, the scan failed on 8 guides this way. A deployment freeze
had moved docs production to a temporary `release` branch, so guides
merged to `master` that day weren't deployed. The same thing can happen
outside a freeze, when a guide merges minutes before the scan runs.

## Solution

The scan now tests only the guides production serves. It keeps the
guides from the repo list that also appear in the production sitemap,
`https://supabase.com/docs/sitemap.xml`.

- **Why the sitemap.** The docs build generates `sitemap.xml` from
`content/guides` on every production deploy, leaving out guides the nav
turns off. It isn't cached between builds, so it always lists what
production serves. It needs no new credentials. Today it lists every one
of the 609 guides the scan tests, plus the federated sections the scan
already skips.
- **How it's wired.** `run-e2e-docs.ts --all` filters the list when
`DOCS_E2E_DEPLOYED_ONLY` is set, using the `/docs/sitemap.xml` of the
site in `PLAYWRIGHT_BASE_URL`, so the page list and the scanned site
can't come from different sites. `docs-a11y-scan.yml` sets it. Runs
without the variable behave as before. The filter lives in
`e2e/docs/utils/production-pages.ts`, with unit tests.
- **Skipped guides are listed.** Each guide missing from the sitemap
prints "Skipping `<page>`: not in `<sitemap URL>`." in the run log, and
shows as a warning on the run page even when the scan passes. It's
scanned on the first run after its deploy.
- **Skipped guides keep their earlier results in the alert.** The runner
passes the skipped guides to the a11y failures reporter from #54444,
which lists each one as unchecked. A guide with an open failure that
drops out of the sitemap keeps that failure open, instead of posting as
fixed and then as new when it returns.
- **A real 404 still fails.** A live guide that starts returning 404 is
still in the sitemap, so it's still scanned and still fails.
- **A broken sitemap fails the run.** The run fails when the sitemap
can't be read, lists no guides, or is missing more than a tenth of the
repo's guides. A partial sitemap can't silently shrink the scan.
- **Wrapped tags.** The sitemap's formatter wraps long `<loc>` tags
across lines, as `<loc\n >url</loc\n>`. The parser handles that. A
line-based parse misses about 10 guides.

The workflow header comment and `e2e/docs/README.md` say where the page
list comes from.

### Behavior changes to review

1. **A guide whose nav entry is turned off is skipped, not failed.** The
docs build leaves it out of the sitemap, and production returns 404 for
it. That matches production. It also means turning off a live guide's
nav entry by mistake doesn't fail the scan. The guide shows as a warning
on the run page instead.
2. **Interaction with the failure alert from #54444.** The alert reports
a guide that returns 404 as an `http-404` failure. With this change,
only a guide production should serve can produce that failure. A skipped
guide keeps whatever failures it already had open, so a guide whose nav
entry is turned off stays in the list until it's back or deleted.

## Limitations

- A guide skipped for about two weeks or more loses its commit
attribution if it fails when it returns. The alert reads only the last
500 deployed commits, so it can't tell which commit production was
running when the guide was last checked, and says so.
- `getting-started/features` is in the sitemap even though a static
redirect sends it elsewhere. The scan already skips redirected guides,
so it doesn't affect the scan.

## Review instructions

1. Run `pnpm -C e2e/docs test` and confirm all 63 tests pass.
2. List the scan's tests against the live sitemap:
   ```bash
cd e2e/docs && CI=1 PLAYWRIGHT_BASE_URL=https://supabase.com
DOCS_E2E_DEPLOYED_ONLY=1 \
pnpm run e2e:docs:all --grep @a11y --list | grep -E
'Resolved|Skipping|Total'
   ```
Expect every guide resolved and nothing skipped while production matches
`master`.
3. Run step 2 with `PLAYWRIGHT_BASE_URL=https://example.com`, a site
with no docs sitemap. Expect the run to fail with the sitemap URL and
its status.
4. Add a temporary guide that isn't on production, such as
`apps/docs/content/guides/zz-temp-probe.mdx`, and run step 2 with
`DOCS_A11Y_FAILURES_FILE=/tmp/a11y.json`. Expect "Skipping
/docs/guides/zz-temp-probe", and both `/docs/guides/zz-temp-probe` and
`/docs/guides/zz-temp-probe: http` under `unchecked` in
`/tmp/a11y.json`. Delete the guide afterward.

Verified locally:

- Unit tests, typecheck, oxfmt, and actionlint on the changed workflow.
The unit tests also pass in a copy of the repo with no installed
packages, as CI runs them. The only actionlint warning is the existing
blacksmith runner label.
- Mutation probes on the wrapped-tag parsing, the trailing-slash trim,
the guides-only filter, the missing-share guard, and each of the three
ways a sitemap fails the run: an error status, no guides, and a site
that can't be reached. Unit tests cover all three with a local
`node:http` server.
- A copy of the production sitemap with the 8 guides from the 2026-12-02
run removed. The run skipped exactly those 8 and resolved the rest.
- A temporary guide that's in the sitemap but returns 404 on production.
The scan failed it with "Expected a successful response … got 404".
- Review step 4, after rebasing onto #54444. The skipped guide reached
the reporter as unchecked under its page and status keys. A mutation
probe that drops the skipped guides from the reporter fails the new
test.
- A sitemap with no guides, and one that can't be reached. Both failed
the run before Playwright started.

Resolves
[DOCS-1839](https://linear.app/supabase/issue/DOCS-1839/scan-only-the-pages-production-serves-in-the-daily-docs-accessibility)

## Checklist

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
2026-12-03 17:03:53 -07:00

12 KiB

Docs E2E tests

This guide explains how to run Playwright end-to-end checks against docs pages this repo owns.

Use this suite when you change guides or shared partials under apps/docs/content. It loads each in-scope page, checks that the article renders, and verifies that docs-owned links in the article resolve. For links with an anchor, it also checks that the target page's article has an element with that id or an a[name] with that value, including same-page #anchor links.

This page covers:

Set up

  1. From this directory, install the Playwright Chromium browser once:

    cd e2e/docs
    pnpm exec playwright install chromium
    

Run the tests

By default, pnpm e2e:docs tests pages affected by your current changes: commits since origin/master, plus staged and unstaged working-tree files. If nothing in scope changed, the command exits successfully without starting Playwright.

  1. From the repository root, point the suite at a deployed docs site and run it:

    PLAYWRIGHT_BASE_URL=https://supabase.com pnpm e2e:docs
    
  2. Optional: open Playwright UI mode for the same scoped run:

    PLAYWRIGHT_BASE_URL=https://supabase.com pnpm e2e:docs:ui
    

You can also run from e2e/docs with pnpm run e2e:docs.

Choose a target URL

Tests use PLAYWRIGHT_BASE_URL. When unset, they default to the local docs dev server at http://localhost:3001.

Prefer a deployed site for day-to-day checks. Use the local server only when you need unpublished content that production does not serve yet.

Deployed site

PLAYWRIGHT_BASE_URL=https://supabase.com pnpm e2e:docs

For a protected Vercel preview, also set VERCEL_AUTOMATION_BYPASS_SECRET.

Local docs server

  1. From the repository root, start docs in a separate terminal:

    pnpm dev:docs
    
  2. Run the suite without PLAYWRIGHT_BASE_URL, or set it to http://localhost:3001.

The local server needs a full monorepo install and credentials for some content.

Local runs are unreliable for pages whose docs-owned links point into /docs/reference/* or /docs/guides/auth/server-side/*: reference pages can take over a minute to compile on first request in dev mode, which exceeds the suite's per-test timeout, and server-side auth guides have a known local-only routing issue that 404s even though the page serves correctly in production. Prefer a deployed site for pages that link into either of those sections.

Override which pages run

Leave DOCS_E2E_PAGE_PATHS unset to keep the default changed-files scope.

To test specific pages instead of the git diff:

DOCS_E2E_PAGE_PATHS=/docs/guides/getting-started/quickstarts/nextjs \
  PLAYWRIGHT_BASE_URL=https://supabase.com pnpm e2e:docs

To compare against a different base ref:

DOCS_E2E_BASE_REF=origin/develop \
  PLAYWRIGHT_BASE_URL=https://supabase.com pnpm e2e:docs

DOCS_E2E_PAGE_PATHS accepts a comma- or newline-separated list of /docs/... paths.

Run every in-scope page

To test every guide instead of a changed-files scope — for example, a periodic full-site check — run:

PLAYWRIGHT_BASE_URL=https://supabase.com pnpm e2e:docs:all

This ignores DOCS_E2E_PAGE_PATHS and tests every page listed by pnpm -C e2e/docs resolve-docs-scope across the whole guides tree — several hundred pages as of this writing. Expect a long run. A list that long runs on three workers, and --workers overrides that.

Run this against a deployed site, not the local dev server — see Local docs server for why local runs are unreliable for pages linking into reference docs or server-side auth guides.

To test only the guides a deployed site serves, set DOCS_E2E_DEPLOYED_ONLY=1 when you run every page. The suite reads the site's /docs/sitemap.xml and skips each guide missing from it, such as a guide merged after the last deploy. The output lists each skipped guide, and GitHub Actions also shows it as a warning:

PLAYWRIGHT_BASE_URL=https://supabase.com DOCS_E2E_DEPLOYED_ONLY=1 pnpm e2e:docs:all

The run fails instead when the sitemap can't be read, or when more than a tenth of the guides are missing from it. The variable applies only to a run with --all, so the default pnpm e2e:docs scope ignores it.

What the suite covers

In scope

Changed path Behavior
apps/docs/content/guides/**/*.mdx Test /docs/guides/<slug>, excluding federated sections
apps/docs/content/_partials/** Test owned pages that include that partial

Out of scope

  • Federated guide sections: graphql, database/extensions/wrappers, ai/python, deployment/terraform, deployment/ci
  • Reference docs under /docs/reference
  • Non-docs routes such as /dashboard and /ui, which the link checker skips
  • Guides that the nav disables, listed in NAV_DISABLED_PAGES in utils/resolve-docs-scope.ts, because their HTML page returns 404
  • Guides that apps/docs/lib/redirects/static-redirects.json redirects elsewhere, because they have no docs article to test
  • In a run with --all and DOCS_E2E_DEPLOYED_ONLY=1, guides missing from the deployed site's sitemap
  • Guides with no MDX file, such as the CLI and self-hosting config pages that the docs app builds from config files, because the suite only resolves MDX guides. This is a known limitation.

Limits

The suite tests every in-scope page, with no cap, and doesn't stop early on failures, so a run reports every page with a broken link. Past 20 pages it runs on three workers instead of one.

To inspect the resolved list without running Playwright, replicate the same scope pnpm e2e:docs uses by default: commits since origin/master, plus staged and unstaged working-tree changes.

{
  git diff --name-only --diff-filter=ACMR origin/master...HEAD
  git diff --name-only --diff-filter=ACMR
  git diff --name-only --diff-filter=ACMR --cached
} | pnpm -C e2e/docs resolve-docs-scope

Accessibility scans

The @a11y-tagged test scans each in-scope page with @axe-core/playwright. It reports WCAG 2.1 A/AA violations in the main article, and fails on the rules in ENFORCED_RULES in utils/axe-rules.ts, which it checks across the whole page. The scans are slow, so Docs E2E runs skip them. Instead, the Docs Accessibility Scan workflow (.github/workflows/docs-a11y-scan.yml) scans every MDX guide that production serves, daily at 05:17 UTC. The scan skips each guide merged after the last production deploy, as Run every in-scope page describes. To start the scan by hand, run gh workflow run docs-a11y-scan.yml.

When the daily scan finds a new failure or a fix, it posts to the docs alerts channel in Slack. See Failure alerts.

To run the scan locally:

PLAYWRIGHT_BASE_URL=https://supabase.com pnpm e2e:docs:a11y

Which pages get scanned comes from your branch, but the content comes from whatever you point PLAYWRIGHT_BASE_URL at. Production won't have your edits and will 404 on a page you just added, so use your pull request's preview to scan your own content.

EXCLUDED_RULES in utils/axe-rules.ts lists the rules the scan skips. color-contrast is most of the scan time and finds nothing inside an article, since docs contrast comes from shared tokens and chrome. The rest target <html>, <head>, and <body>, which an article-scoped scan can't reach.

Cross-origin frames are skipped, so a third-party embed isn't reported as ours.

Not covered: /docs/reference/*, shared chrome, and most of WCAG. Keyboard navigation, focus management, and screen reader behavior need manual testing.

Debug failures

  1. Open the HTML report after a run:

    pnpm -C e2e/docs exec playwright show-report
    
  2. Inspect traces and screenshots under test-results/ for failed runs.

How CI uses this suite

The workflow at .github/workflows/docs-e2e.yml runs on pull requests that touch owned docs content, partials, or e2e/docs.

  1. When e2e/docs or e2e/shared changed, run the harness unit tests (pnpm -C e2e/docs test).
  2. Diff the pull request against its base branch and resolve in-scope page paths.
  3. Skip Playwright when nothing in scope changed.
  4. When apps/docs changed, wait for the Vercel docs preview and set PLAYWRIGHT_BASE_URL to that preview. If Vercel skipped the head commit's build as not affected, the newest ready preview from an earlier commit of the pull request is used instead. When no preview resolves, skip rather than test against production.
  5. Run the suite with DOCS_E2E_PAGE_PATHS set to the resolved list, without the @a11y accessibility scans.

Draft pull requests stay skipped until you mark them ready for review. Manual workflow_dispatch runs require a page_paths input and accept an optional base_url, which defaults to production.

Failure alerts

.github/workflows/docs-master-alert.yml keeps a list of open failures for each of the following workflows when they run on master:

  • Docs Accessibility Scan, with one failure per page and axe rule
  • Docs Production Smoke Tests, with one failure per test
  • Docs E2E Tests, which runs on master only when started by hand
  • [Docs] Update last-changed dates
  • Update JS Client Libraries Docs
  • Update Mgmt Api Docs
  • docs_sync
  • Ingest Docs Content for Search V2

For the workflows without their own results, each failed job or step is one failure.

When The alert
A failure is added Posts it with the commit that introduced it, or the possible commits
A failure is fixed Posts the fix
The list doesn't change Posts nothing
A page or test times out, a page doesn't render, or a job or step is skipped Keeps its earlier result
A guide isn't in production's sitemap, so the scan skips it Keeps its earlier result
A page returns an error status, such as 404 Counts a failure for that status in place of any earlier one, and keeps the page's earlier scan results
No smoke test passes and some time out Counts one failure for the run
A run fails before it reports results Posts that the run failed, and keeps the list as it was

For the scan, a new failure names the deployed commit that touched the page or a partial it includes. When no single commit did, the alert lists the possible commits as unconfirmed.