Skip to content

ci: adds Playwright tests - #146

Open
bmuenzenmeyer wants to merge 5 commits into
mainfrom
playwright
Open

bmuenzenmeyer wants to merge 5 commits into
mainfrom
playwright

Conversation

@bmuenzenmeyer

@bmuenzenmeyer bmuenzenmeyer commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

After the incident today (thanks @jonasgeiler by the way!) , I wanted to shore up this repo (along with the other PRs #144 #145). Playwright would have likely caught these errors (in addition to use simply looking at the preview)

You'll notice in the log below too that the coding agent noticed two other bugs. One still in production!

Edit: manual review also found the same islands problem on small viewports that led to no nav. Fixed here too.


The Playwright workflow and 13 starter tests are done and pass against a local build. I put back the https://https bug from #133, rebuilt, and 8 of the 13 tests failed, so they catch it. The patch holds 3 commits on top of main (6976605); apply it with git am learn-playwright.patch. The workflow itself hasn't run in GitHub Actions yet.

Writing the tests turned up two more bugs on main, so two of the commits are fixes. You can split those out if you'd rather send them separately.

  1. Fix: local builds are broken. Since fix: remove https:// prefix from origin to fix production build #143, a local build points its CSS and JS at https://localhost:3000, which the local server doesn't answer. The fix keeps http/https as part of origin, so production, preview and local each get the right one.
  2. Fix: the theme toggle does nothing. This has been broken since the doc-kit 2 migration (Migrate to new doc-kit packages #138). The button renders but never opens, because its JavaScript no longer loads on the page. The fix uses doc-kit's own theme toggle, which does. I confirmed this on a local build; I couldn't reach nodejs.org from here to check production.
  3. The tests and workflow.
    • Workflow (playwright.yml): ported from nodejs.org. It waits for the Vercel preview and runs Chromium against it. One change: it doesn't skip Dependabot PRs, since Migrate to new doc-kit packages #138 was a Dependabot bump. zizmor reports no problems with it.
    • Page assets: on four representative pages, every stylesheet and script must load from the site's own /learn/assets/, the site font must be applied, and nothing under /learn/ may fail to load.
    • Sitemap: the URLs must be well formed, every listed page must return 200, and the search index file must be present.
    • Navigation, theme and search: the article layout renders, sidebar links work, unknown pages return 404, dark/light switching works and persists across pages, and search finds and opens a result. The theme and search tests wait for their component to finish loading first; before that change they failed intermittently. After it, each passed 5–30 repeated runs.
    • Supporting changes: npm run serve and npm run test:e2e scripts, a Playwright config that starts the local server itself, linting set up for the test files, and a "Running the end-to-end tests" section in CONTRIBUTING.md.

Made with help from a frontier model. The core repo suggests we remove the commit data - but I am retaining it for now as it was truly helpful.

bmuenzenmeyer and others added 4 commits September 22, 2026 21:55
#143 moved the scheme into `baseURL` as a hard-coded `https://`, so local
builds now point their assets at https://localhost:3000, which `serve`
doesn't answer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AkQ47hh78xyt4wWG9GVL5t
Since the doc-kit 2 migration (#138) the navbar rendered the ui-components
ThemeToggle directly. Only islands hydrate, so the button never opened.
Use doc-kit's ThemeToggle island instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AkQ47hh78xyt4wWG9GVL5t
Ports nodejs.org's playwright.yml and adds tests for asset URLs, the
sitemap, navigation, search and the theme toggle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AkQ47hh78xyt4wWG9GVL5t
@bmuenzenmeyer
bmuenzenmeyer requested review from a team as code owners September 23, 2026 03:05
Copilot AI lite review requested due to automatic review settings September 23, 2026 03:05
@vercel

vercel Bot commented Sep 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
nodejs-learn Ready Ready Preview Sep 23, 2026 3:29am UTC

Request Review

@github-actions

Copy link
Copy Markdown

👋 Codeowner Review Request

The following codeowners have been identified for the changed files:

Team reviewers: @nodejs/web-infra @nodejs/nodejs-website

Please review the changes when you have a chance. Thank you! 🙏

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved CI permissions and telemetry handling issues, plus a sitemap origin validation gap, block approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 3 High severity

Open (3)
What changed in this PR

Adds Playwright end-to-end coverage for the Learn site, including local serving and Vercel preview CI.

Changes:

  • Adds sitemap, asset, navigation, theme, search, and 404 tests.
  • Configures Playwright, dependencies, CI, documentation, and artifact handling.
  • Updates deployment-aware URLs and the hydrated theme toggle.
File Reviewed change Findings
tests/​e2e/​sitemap.spec.mjs Sitemap and search-index checks Moderate (1 vote): validate URLs against the expected base origin.
tests/​e2e/​interactions.spec.mjs Navigation and interaction tests
tests/​e2e/​helpers.mjs Shared E2E utilities Critical (2 votes): exclude or separately allowlist /learn/_vercel/ telemetry URLs.
tests/​e2e/​assets.spec.mjs Asset validation Critical (2 votes): account for intentional /learn/_vercel/ telemetry scripts.
playwright.config.mjs Playwright and server configuration
package.json Test scripts and dependencies
package-lock.json Dependency lock updates
eslint.config.mjs E2E lint configuration
doc-kit.config.mjs Environment-specific origins
CONTRIBUTING.md E2E testing documentation
components/​Navigation/​index.jsx Hydrated theme toggle
.gitignore Playwright artifact exclusions
.github/​workflows/​playwright.yml Vercel preview CI workflow Critical (1 vote): grant pull-requests: read and deployments: read permissions.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +25 to +27
permissions:
contents: read
actions: read
Comment thread tests/e2e/assets.spec.mjs
for (const url of assetURLs) {
const { origin: assetOrigin, pathname } = new URL(url);
expect.soft(assetOrigin, url).toBe(origin);
expect.soft(pathname, url).toMatch(/^\/learn\/assets\//);
Comment thread tests/e2e/helpers.mjs

const isOurs = url => {
const { origin: o, pathname } = new URL(url);
return o === origin && pathname.startsWith('/learn/');
On small screens the sidebar collapses into a dropdown, which needs
JavaScript to open. Since the doc-kit 2 migration (#138) only islands
hydrate, so the dropdown rendered but did nothing. Register the sidebar
as an island, like Authors, and cover small screens in the e2e tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AkQ47hh78xyt4wWG9GVL5t

This branch was successfully deployed

1 active deployment
Preview d3448453 Deployed Sep 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants