test: let the suite target a local respec-web-services and specref - #5445
Draft
marcoscaceres wants to merge 7 commits into
Draft
test: let the suite target a local respec-web-services and specref#5445marcoscaceres wants to merge 7 commits into
marcoscaceres wants to merge 7 commits into
Conversation
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>
A respec-web-services or specref change can currently reach production without ever meeting this suite, which resolves cross-references, group data, caniuse, baseline and bibliography against the deployed services and has no way to point anywhere else. Setting RESPEC_SERVICES_BASE or SPECREF_BASE now sends every one of those requests to a local copy instead. Co-authored-by: Claude <noreply@anthropic.com>
…ig points Co-authored-by: Claude <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enables the integration test suite (tests/spec) to redirect requests that would normally go to https://respec.org and https://api.specref.org toward locally running service instances, controlled via RESPEC_SERVICES_BASE and SPECREF_BASE. It does so via a test-only service worker that rewrites matching request origins, allowing end-to-end validation of service changes without modifying ReSpec runtime code under src/.
Changes:
- Add a service worker–based request rewrite layer for the spec test harness, configured per
makeRSDoc()to prevent cross-test leakage. - Add URL rewrite + validation helpers and an end-to-end spec test suite covering rewrite behavior, cache-seeding behavior, and failure modes.
- Wire Karma to expose
serviceOriginsto the browser context based on environment variables and proxy the service worker +/spec/imports.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/spec/SpecHelper.js | Registers/configures the service worker per document and blocks Cache API usage while redirects are enabled. |
| tests/spec/service-origin-rewrite.js | Implements URL origin rewriting and validates replacement origins. |
| tests/spec/respec-test-sw.js | Service worker that rewrites mapped requests and forwards them to replacement origins. |
| tests/spec/respec-cache-helper.js | Clears caches once per run and disables cache seeding while redirects are active. |
| tests/spec/karma.conf.cjs | Ensures the rewrite helper and service worker script are available to the browser. |
| tests/spec/core/service-origin-rewrite-spec.js | Adds unit + end-to-end coverage for rewriting, 502 behavior, and cache interactions. |
| tests/karma.conf.base.cjs | Adds proxies for the service worker and a /spec/ route; exposes serviceOrigins from env vars. |
| .github/copilot-instructions.md | Documents how to run the suite against local respec-web-services and specref instances. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…t worker Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds two environment variables,
RESPEC_SERVICES_BASEandSPECREF_BASE, that send the suite's respec.org and specref requests to locally running copies, so a change to either service can be checked against this suite before it deploys. A service worker does the redirecting, so nothing undersrc/changes and nothing new is exposed to spec authors.Written with Claude and reviewed by Gemini. Locally, in Chrome, the unit and integration suites pass with the variables unset and again with them pointed back at production.