test: add caniuse and w3c route tests - #501
Conversation
edc7b8d to
e977ed7
Compare
There was a problem hiding this comment.
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
caniuseconstants andcreateResponseBody()browser filtering/version slicing. - Adds tests for
w3c/grouproute behavior (legacy shortname redirects, content negotiation, invalid type, error paths). - Introduces temporary on-disk fixtures for
caniuse/*.jsonandw3c/groups.jsonused 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.
e977ed7 to
907c25f
Compare
There was a problem hiding this comment.
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.
1c1198f to
ac73ae0
Compare
ac73ae0 to
9c450d3
Compare
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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>
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>
|
@copilot can you resolve the merge conflicts? |
# Conflicts: # tests/utils/misc.test.js Co-authored-by: marcoscaceres <870154+marcoscaceres@users.noreply.github.com>
Merge conflicts resolved in a1cb402. The only conflict was in
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:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@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.
Parameterize same-branch cases (null-returning getData inputs, seconds() parsing, validation errors) and share helpers; collapse overlapping assertions. Same coverage, fewer specs/lines.
Summary
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).