Skip to content

test: let the suite target a local respec-web-services and specref - #5445

Draft
marcoscaceres wants to merge 7 commits into
mainfrom
feat/local-service-worker
Draft

test: let the suite target a local respec-web-services and specref#5445
marcoscaceres wants to merge 7 commits into
mainfrom
feat/local-service-worker

Conversation

@marcoscaceres

Copy link
Copy Markdown
Contributor

Adds two environment variables, RESPEC_SERVICES_BASE and SPECREF_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 under src/ 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.

marcoscaceres and others added 5 commits August 28, 2026 10:09
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>
@marcoscaceres marcoscaceres changed the title Let the test suite target a local respec-web-services and specref Sep 1, 2026

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.

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 serviceOrigins to 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.

Comment thread tests/spec/respec-test-sw.js
…t worker

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants