Skip to content

test: add caniuse and w3c route tests#501

Open
marcoscaceres wants to merge 27 commits intomainfrom
test/caniuse-w3c
Open

test: add caniuse and w3c route tests#501
marcoscaceres wants to merge 27 commits intomainfrom
test/caniuse-w3c

Conversation

@marcoscaceres
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)

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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
Comment thread tests/routes/caniuse/lib/index.test.js Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 3 commits April 27, 2026 18:07
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@marcoscaceres
Copy link
Copy Markdown
Collaborator Author

@copilot can you resolve any unaddressed concerns

- Fix typo in SUPPORT_TITLES constant: "needs to enabled" → "needs to be enabled"
- Guard afterAll in group.test.js: only rm/restore if tmpDir/origDataDir are set
- Guard afterAll in caniuse index.test.js: same pattern
- Move HTTPError tests from group.test.js to tests/utils/misc.test.js
- Replace getSupportTitle reimplementation with actual HTML output assertions
  via createResponseBody({format: "html"}) using fixture data with compound
  and unknown support keys

Agent-Logs-Url: https://github.com/speced/respec-web-services/sessions/89d0a0b8-62d6-4426-ad6a-ed304d3b1ce1
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 27, 2026

@copilot can you resolve any unaddressed concerns

Addressed all remaining concerns in 35dc30a:

  • Typo fix: SUPPORT_TITLES "d" key now reads "needs to be enabled" (fixed in source + test)
  • afterAll guards: Both test files now guard rm(tmpDir, ...) and env restore behind if (tmpDir) / if (origDataDir !== undefined) checks
  • HTTPError tests moved: Extracted from group.test.js into a new tests/utils/misc.test.js
  • getSupportTitle tests replaced: The reimplementation was removed; tests now call createResponseBody({ format: "html" }) with fixture data (including a compound ["y","x"] entry and an unknown ["z"] entry) and assert the rendered HTML contains the expected title="..." attributes

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 Can you review this and fix any issues that come up?

marcoscaceres and others added 13 commits April 27, 2026 19:26
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>
@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>
Copy link
Copy Markdown
Contributor

Copilot AI commented May 4, 2026

@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:

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.

3 participants