mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## 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)
63 lines
1.7 KiB
TypeScript
63 lines
1.7 KiB
TypeScript
import { defineConfig } from '@playwright/test'
|
|
|
|
import { parsePagePaths } from '../shared/paths.ts'
|
|
|
|
const IS_CI = !!process.env.CI
|
|
|
|
const PAGE_COUNT = parsePagePaths(process.env.DOCS_E2E_PAGE_PATHS).length
|
|
|
|
const A11Y_FAILURES_FILE = process.env.DOCS_A11Y_FAILURES_FILE
|
|
const SKIPPED_PAGES = parsePagePaths(process.env.DOCS_E2E_SKIPPED_PAGES)
|
|
|
|
export default defineConfig({
|
|
testDir: './features',
|
|
testMatch: /.*\.spec\.ts/,
|
|
timeout: 60_000,
|
|
forbidOnly: IS_CI,
|
|
retries: IS_CI ? 2 : 0,
|
|
expect: {
|
|
timeout: 15_000,
|
|
},
|
|
fullyParallel: false,
|
|
workers: PAGE_COUNT > 20 ? 3 : 1,
|
|
use: {
|
|
baseURL: process.env.PLAYWRIGHT_BASE_URL || 'http://localhost:3001',
|
|
browserName: 'chromium',
|
|
headless: true,
|
|
navigationTimeout: 30_000,
|
|
screenshot: 'only-on-failure',
|
|
trace: 'retain-on-failure',
|
|
video: 'off',
|
|
extraHTTPHeaders: process.env.VERCEL_AUTOMATION_BYPASS_SECRET
|
|
? {
|
|
'x-vercel-protection-bypass': process.env.VERCEL_AUTOMATION_BYPASS_SECRET,
|
|
'x-vercel-set-bypass-cookie': 'true',
|
|
}
|
|
: undefined,
|
|
},
|
|
projects: [
|
|
{
|
|
name: 'Features',
|
|
testDir: './features',
|
|
testMatch: /.*\.spec\.ts/,
|
|
use: {
|
|
browserName: 'chromium',
|
|
},
|
|
},
|
|
],
|
|
reporter: [
|
|
['list'],
|
|
['html', { open: 'never', outputFolder: './playwright-report' }],
|
|
...(IS_CI ? [] : [['json', { outputFile: './test-results/test-results.json' }] as const]),
|
|
...(A11Y_FAILURES_FILE
|
|
? [
|
|
[
|
|
'./utils/a11y-failures-reporter.ts',
|
|
{ outputFile: A11Y_FAILURES_FILE, skippedPages: SKIPPED_PAGES },
|
|
] as const,
|
|
]
|
|
: []),
|
|
],
|
|
outputDir: './test-results',
|
|
})
|