[quality] fix vitest include pattern regression and restore corrupted test files#19735
[quality] fix vitest include pattern regression and restore corrupted test files#19735clubanderson wants to merge 1 commit into
Conversation
- Change netlify/functions/__tests__/* to netlify/functions/**/__tests__/* in vitest include pattern (enables discovery of _shared/__tests__/ tests) - Restore jwt-validation.test.ts (25 tests) and read-capped-request.test.ts (17 tests) which were corrupted by shell expansion in commit 44606f5 - The config restore in d7740cc reverted the include fix from #19726; this re-applies only the one-line pattern change Fixes regression from #19730 where vite.config.ts restore lost the include fix. Signed-off-by: Quality Agent <quality-agent@kubestellar.io>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
✅ Deploy Preview for kubestellarconsole ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
👋 Hey @clubanderson — thanks for opening this PR!
This is an automated message. |
|
🐝 Hi @clubanderson! I'm Trusted users — org members and contributors with write access — can mention Automation may take a moment to start, and follow-up happens through workflow activity rather than chat replies. |
There was a problem hiding this comment.
Pull request overview
This PR restores Vitest test discovery for Netlify Functions by fixing a regressed include glob in web/vite.config.ts, and replaces two corrupted _shared/__tests__ files (previously containing literal $(cat ...) text) with real test implementations so they run in CI.
Changes:
- Update Vitest
includepattern to recursively discovernetlify/functions/**/__tests__/*.{test,spec}.{ts,tsx}(including_shared/__tests__). - Restore
jwt-validation.test.tswith actual JWT validation unit tests. - Restore
read-capped-request.test.tswith actual request body size-capping unit tests.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| web/vite.config.ts | Fixes Vitest include glob so _shared/__tests__ tests are discovered and executed. |
| web/netlify/functions/_shared/tests/read-capped-request.test.ts | Replaces corrupted placeholder with real tests for request body size limiting utilities. |
| web/netlify/functions/_shared/tests/jwt-validation.test.ts | Replaces corrupted placeholder with real tests for JWT/bearer-token validation helpers. |
| @@ -1 +1,220 @@ | |||
| $(cat jwt-validation.test.ts) No newline at end of file | |||
| // @vitest-environment node | |||
| import { describe, it, expect, vi, beforeEach } from 'vitest' | |||
|
Superseded by #19741 which applied the same vitest include pattern fix ( |
ZachDreamZ
left a comment
There was a problem hiding this comment.
Two fixes, both correct:
-
vitest glob: → — enables recursive discovery of _shared/tests/. Without this, 14 test files were invisible to vitest.
-
Restores jwt-validation.test.ts and read-capped-request.test.ts that contained literal strings from shell expansion failure. Replacement test code is thorough — JWT tests cover alg:none attack, expiry, secret validation, bearer parsing. Request body tests cover size enforcement across buffer/text/json paths.
LGTM.
|
@ZachDreamZ: changing LGTM is restricted to collaborators DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
Clarifying my approval: the vitest glob change adds recursive matching (doublestar before tests) so the _shared subdirectory tests are now discovered. The two corrupted files had literal dollar-sign-cat shell artifacts from commit 44606f5 — now replaced with proper test code covering JWT validation (alg:none attack, expiry, bearer parsing) and request body size enforcement. |
Test Improvement
Fixes a regression where the vitest include pattern fix from #19726 was lost when vite.config.ts was restored in #19730.
Changes
vitest include pattern — change
netlify/functions/__tests__/*.{test,spec}.{ts,tsx}tonetlify/functions/**/__tests__/*.{test,spec}.{ts,tsx}(recursive glob enables discovery of_shared/__tests__/)Restore corrupted test files —
jwt-validation.test.tsandread-capped-request.test.tscontained literal$(cat ...)strings from shell expansion failure in commit 44606f5. Replaced with actual test code (42 tests total).Impact
Before this PR: 14 test files in
netlify/functions/_shared/__tests__/were invisible tovitest run— they never executed in CI, giving false confidence in test coverage.After this PR: All
_shared/__tests__/tests (including cors, rate-limit, identity-demo-request, fetchWithRetry, etc.) are now discovered and executed.Verification
Filed by quality agent (hold-gated mode). Human review required.