Skip to content

Add browser coverage for human-readable routes - #252

Merged
MattIPv4 merged 14 commits into
cdnjs:masterfrom
snowyukitty:test/human-output-browser
Aug 16, 2026
Merged

Add browser coverage for human-readable routes#252
MattIPv4 merged 14 commits into
cdnjs:masterfrom
snowyukitty:test/human-output-browser

Conversation

@snowyukitty

@snowyukitty snowyukitty commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Type of Change

  • Tests: Add route-adjacent Playwright coverage for the human-readable API and library-version routes.
  • Something else: Install the lockfile-matched Playwright Chromium build and run the browser suite in CI.

What issue does this relate to?

Fixes #188

What should this PR do?

  • Start a local Worker from a worker-scoped @playwright/test server fixture using Wrangler's createTestHarness(), and reset the harness after each test.
  • Use the harness's dynamically allocated loopback URL as Playwright's baseURL and navigate directly to /api and /libraries/backbone.js/1.1.0.
  • Configure WEBSITE_BASE for the dynamic local origin according to the Worker's prefix-based website detection.
  • Assert the hydrated API documentation and library file filter with native Playwright locators and assertions.
  • Keep browser coverage beside the corresponding route specs.
  • Avoid a Vite browser-test server, reverse proxy, iframe, and external API-origin inheritance.

What are the acceptance criteria?

  • npm test
  • npm run test:browser
  • npm run lint
  • npm run types
  • npm run format
  • npx wrangler deploy --dry-run

This changes test infrastructure and coverage only; it does not change production behavior or the rendered UI, so before/after screenshots are not applicable.

@MattIPv4 MattIPv4 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for working on this! Instead of unstable_dev, I wonder if we can use the new createTestHarness designed for use w/ Playwright etc.? https://developers.cloudflare.com/changelog/post/2026-07-21-integration-test-harness/

Comment thread src/routes/human.browser.spec.ts Outdated
@snowyukitty

Copy link
Copy Markdown
Contributor Author

Addressed both suggestions: the browser suite now uses createTestHarness(), and the assertions live in route-adjacent api.browser.spec.ts and library.browser.spec.ts files. I also incorporated current master (through #261) and kept the browser setup aligned with the WEBSITE_BASE route contract.

Fresh current-base checks pass: Chromium 2/2 twice, unit tests 485/485, types, lint, focused formatting, a Wrangler dry run, and git diff --check. Thanks!

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds real-browser coverage for human-readable routes through a local Worker and Vite proxy, plus cross-platform island bundling support.

Changes:

  • Adds Playwright browser tests for API documentation and library filtering.
  • Configures local Worker lifecycle, proxying, and dynamic ports.
  • Normalizes Vite paths and runs browser tests in CI.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
vitest.config.ts Excludes browser specs from unit tests.
vitest.browser.setup.ts Manages the browser-test Worker lifecycle.
vitest.browser.config.ts Configures Playwright, proxying, and ports.
vite.client.config.ts Normalizes island module paths.
src/utils/spec/browser.ts Provides the iframe route helper.
src/routes/library.browser.spec.ts Tests library-page hydration and filtering.
src/routes/api.browser.spec.ts Tests hydrated API documentation.
package.json Adds browser tooling and test command.
package-lock.json Locks new browser dependencies.
.github/workflows/ci.yml Installs Chromium and runs browser tests.

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

Comment thread vitest.browser.setup.ts Outdated

@MattIPv4 MattIPv4 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👋 Thanks for getting this updated. Having explored this more locally, and how the proxy that Vite provides works, I'm a bit concerned by the security model here as we do testing of remote origins in our CI -- it seems it would be possible for a remote origin we're testing to use the Vite proxy to access files on disk etc.

I wonder if we'd be better off using regular ol' Playwright? I think the setup would be similar using createTestHarness, but wouldn't need the proxy setup nor the iframe, as we'd be able to hit the local/remote worker URL via direct page navigation?

Comment thread src/utils/spec/playwright.ts
Comment thread src/utils/spec/playwright.ts

@MattIPv4 MattIPv4 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@MattIPv4
MattIPv4 merged commit c4be3a3 into cdnjs:master Aug 16, 2026
4 checks passed
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.

Add browser testing for human output

3 participants