Skip to content

test: add caniuse and w3c route tests - #501

Merged
sidvishnoi merged 31 commits into
mainfrom
test/caniuse-w3c
Aug 4, 2026
Merged

test: add caniuse and w3c route tests#501
sidvishnoi merged 31 commits into
mainfrom
test/caniuse-w3c

Conversation

@marcoscaceres

@marcoscaceres marcoscaceres commented Apr 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Tests for BROWSERS, DEFAULT_BROWSERS, SUPPORT_TITLES constants
  • Tests for sanitizeBrowsersList and getSupportTitle logic
  • Tests for w3c group handler (legacy shortnames, error handling, disambiguation)

Landing order: land after #500 and rebase onto main; both edit tests/routes/caniuse/lib/index.test.js. Suggested batch order: #499, #500, #501, #497, #529, #511 (#424 independent).

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

Adds new Jasmine test coverage around the caniuse helper logic/constants and the w3c/group route behavior, using temporary fixture data written under a per-test DATA_DIR.

Changes:

  • Adds tests for caniuse constants and createResponseBody() browser filtering/version slicing.
  • Adds tests for w3c/group route behavior (legacy shortname redirects, content negotiation, invalid type, error paths).
  • Introduces temporary on-disk fixtures for caniuse/*.json and w3c/groups.json used by the routes at module load time.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
tests/routes/w3c/group.test.js New tests for W3C group route behavior using a fixture groups.json.
tests/routes/caniuse/lib/index.test.js New tests for caniuse constants and response formatting/filtering using a fixture feature JSON.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/routes/w3c/group.test.js
Comment thread tests/routes/w3c/group.test.js Outdated
Comment thread tests/routes/w3c/group.test.js
Comment thread tests/routes/caniuse/lib/index.test.js
Comment thread tests/routes/caniuse/lib/index.test.js Outdated
Comment thread tests/routes/caniuse/lib/index.test.js Outdated

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/routes/w3c/group.test.js Outdated
Comment thread tests/routes/w3c/group.test.js Outdated
Comment thread tests/routes/w3c/group.test.js Outdated
Comment thread tests/routes/caniuse/lib/index.test.js
Comment thread tests/routes/caniuse/lib/index.test.js Outdated
@marcoscaceres
marcoscaceres force-pushed the test/caniuse-w3c branch 4 times, most recently from 1c1198f to ac73ae0 Compare April 26, 2026 01:06

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/routes/w3c/group.test.js
Comment thread tests/routes/w3c/group.test.js Outdated
Comment thread tests/routes/caniuse/lib/index.test.js

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/routes/w3c/group.test.js
Comment thread tests/routes/caniuse/lib/index.test.js Outdated

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

marcoscaceres and others added 7 commits April 27, 2026 10:31
Adds a setInterval that calls the update script daily and reloads
the in-memory groups data from disk. Follows the existing pattern
from xref's periodic cache invalidation.

Also handles missing groups.json gracefully at startup (empty store
instead of crash).

Closes #395
Replace setInterval with self-scheduling setTimeout so the next
refresh only fires after the current one completes. Add in-flight
guard for safety. On startup JSON parse failure, trigger an
immediate refreshGroups() to self-heal.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
marcoscaceres and others added 6 commits April 28, 2026 22:13
Restructured per review feedback:
- Use BackgroundTaskQueue with worker thread (matches xref/caniuse)
- Only write groups.json on successful scrape
- Add POST /w3c/update endpoint for cron-triggered refreshes
- Remove inline setTimeout/setInterval timer
Remove redundant existsSync guards (readFileSync throws into catch).
Add authGithubWebhook middleware to POST /w3c/update to prevent spam.
Add W3C_GROUPS_SECRET to .env.sample.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The reloadGroups() return value was silently discarded, so a
successful scrape followed by a failed reload would return 200.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tests valid reload (returns true, updates in-memory groups),
missing file (returns false, preserves previous data), and
corrupt JSON (returns false, preserves previous data).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@marcoscaceres

Copy link
Copy Markdown
Collaborator Author

@copilot can you resolve the merge conflicts?

@marcoscaceres
marcoscaceres marked this pull request as ready for review May 4, 2026 13:26
# Conflicts:
#	tests/utils/misc.test.js

Co-authored-by: marcoscaceres <870154+marcoscaceres@users.noreply.github.com>

Copilot AI commented May 4, 2026

Copy link
Copy Markdown
Contributor

@copilot can you resolve the merge conflicts?

Merge conflicts resolved in a1cb402. The only conflict was in tests/utils/misc.test.js — our small HTTPError-only version vs. main's comprehensive version covering env(), seconds(), ms(), getErrnoCode, and HTTPError. Kept main's version since it's a strict superset. All 159 specs pass.

@copilot Can you review this and fix any issues that come up?

Reviewed and all tests pass (159 specs, 0 failures). No issues found after the merge with main — the code review and CodeQL scan both came back clean.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.w3.org
    • Triggering command: /usr/local/bin/node node /home/REDACTED/work/respec-web-services/respec-web-services/node_modules/.bin/jasmine --config=tests/jasmine.json (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@marcoscaceres

Copy link
Copy Markdown
Collaborator Author

@copilot rebase?

The unambiguous-shortname test reached the route's live fetch to api.w3.org (flaky/offline-fragile in CI) and only asserted the status was not 409, which passed even when the request failed. Stub fetch and assert the resolved group info instead.
marcoscaceres and others added 2 commits July 2, 2026 13:50
Parameterize same-branch cases (null-returning getData inputs, seconds() parsing, validation errors) and share helpers; collapse overlapping assertions. Same coverage, fewer specs/lines.
@sidvishnoi
sidvishnoi merged commit 6e29b44 into main Aug 4, 2026
3 checks passed
@sidvishnoi
sidvishnoi deleted the test/caniuse-w3c branch August 4, 2026 09:53
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.

4 participants