test: add GitHub REST utils and respec size handler tests#500
test: add GitHub REST utils and respec size handler tests#500marcoscaceres wants to merge 5 commits into
Conversation
4befb8e to
cbbfbc7
Compare
There was a problem hiding this comment.
Pull request overview
Adds/expands Jasmine coverage for GitHub REST pagination/SSRF validation and the routes/respec/size handlers, to improve regression protection around URL safety, pagination behavior, and size-report persistence/deduplication.
Changes:
- Adds a new test suite for
routes/respec/sizecovering auth, input validation, file writes, truncation, dedup buffer behavior, and GET headers/body. - Expands
github/lib/utils/resttests with additional cases for endpoint validation, pagination link handling, page limits, request headers, and HTTP errors.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| tests/routes/respec/size.test.js | New tests for Respec size GET/PUT handlers including env setup, file persistence, and dedup buffer behavior. |
| tests/routes/github/lib/utils/rest.test.js | Expanded tests for GitHub REST request generator covering SSRF guard, pagination, error handling, and request headers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
cbbfbc7 to
f5981a8
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 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.
f5981a8 to
d0d4ac3
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 1 comment.
💡 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 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 no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot Please address and fix any outstanding commo |
Fixed in ccffa9a. The last outstanding issue was the page-limit test silently triggering |
|
@copilot Can you review this and fix any issues that come up? |
|
@copilot Can you confirm all your feedback has been addressed? Please resolve the threads that have been addressed and fix anything outstanding. |
All feedback has been addressed. The final cleanup in 89e5652 removes the duplicate
Reviewed — found and fixed a leftover issue in |
| process.env.DATA_DIR = DATA_DIR; | ||
| process.env.RESPEC_GH_ACTION_SECRET = TEST_SECRET; |
There was a problem hiding this comment.
How about we use jasmine helpers and set all fake variables there?
There was a problem hiding this comment.
Then we won't need dynamic imports etc. likely.
There was a problem hiding this comment.
Done. Moved the fake env vars into tests/helpers/env.js: it now sets RESPEC_GH_ACTION_SECRET and an isolated throwaway DATA_DIR (a fresh mkdtemp dir, removed on exit) before any spec loads, so size.test.js and rest.test.js import statically — no more dynamic import or manual env save/restore.
One knock-on: the caniuse tests hardcoded os.tmpdir()/caniuse, which only matched the module's DATA_DIR while the helper defaulted DATA_DIR to os.tmpdir(). With the isolated temp dir they now write fixtures under process.env.DATA_DIR instead, which also clears up some stale-data flakiness those tests had.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sets DATA_DIR (isolated throwaway dir) and RESPEC_GH_ACTION_SECRET in tests/helpers/env.js so the size and rest test modules import statically instead of juggling env vars around a dynamic import.
The caniuse tests hardcoded os.tmpdir()/caniuse, which only matched the module's DATA_DIR back when the helper defaulted DATA_DIR to os.tmpdir(). Now that the helper uses an isolated temp DATA_DIR, point the fixtures at process.env.DATA_DIR so the module finds them. Also removes stale-data flakiness from a shared os.tmpdir()/caniuse.
89e5652 to
b89b8b9
Compare
Summary