Skip to content

[quality] fix vitest include pattern regression and restore corrupted test files#19735

Open
clubanderson wants to merge 1 commit into
mainfrom
quality/fix-vitest-include-pattern
Open

[quality] fix vitest include pattern regression and restore corrupted test files#19735
clubanderson wants to merge 1 commit into
mainfrom
quality/fix-vitest-include-pattern

Conversation

@clubanderson

Copy link
Copy Markdown
Collaborator

Test Improvement

Fixes a regression where the vitest include pattern fix from #19726 was lost when vite.config.ts was restored in #19730.

Changes

  1. vitest include pattern — change netlify/functions/__tests__/*.{test,spec}.{ts,tsx} to netlify/functions/**/__tests__/*.{test,spec}.{ts,tsx} (recursive glob enables discovery of _shared/__tests__/)

  2. Restore corrupted test filesjwt-validation.test.ts and read-capped-request.test.ts contained 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 to vitest 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

vitest run netlify/functions/_shared/__tests__/cors.test.ts → 28 passed ✅
vitest run netlify/functions/_shared/__tests__/jwt-validation.test.ts → 25 passed ✅
vitest run netlify/functions/_shared/__tests__/read-capped-request.test.ts → 17 passed ✅

Filed by quality agent (hold-gated mode). Human review required.

- 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>
Copilot AI review requested due to automatic review settings June 26, 2026 14:39
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Jun 26, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign eeshaansa for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@netlify

netlify Bot commented Jun 26, 2026

Copy link
Copy Markdown

Deploy Preview for kubestellarconsole ready!

Name Link
🔨 Latest commit a8c2f12
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/6a3e8f17d7698a0008a1b460
😎 Deploy Preview https://deploy-preview-19735.console-deploy-preview.kubestellar.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@clubanderson clubanderson added hold Blocked — do not touch quality testing and removed dco-signoff: yes Indicates the PR's author has signed the DCO. labels Jun 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

👋 Hey @clubanderson — thanks for opening this PR!

🤖 This project is developed exclusively using AI coding assistants.

Please do not attempt to code anything for this project manually.
All contributions should be authored using an AI coding tool such as:

This ensures consistency in code style, architecture patterns, test coverage,
and commit quality across the entire codebase.


This is an automated message.

@github-actions

Copy link
Copy Markdown
Contributor

🐝 Hi @clubanderson! I'm kubestellar-hive[bot], an automation bot for this repo.

Trusted users — org members and contributors with write access — can mention @kubestellar-hive in a comment to trigger repo automation.
On issues, that mention queues an automated fix attempt. On pull requests, it records extra context for existing automation.
This is not an interactive Q&A bot, so mentions should be treated as requests for automation rather than a conversation.

Automation may take a moment to start, and follow-up happens through workflow activity rather than chat replies.

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

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 include pattern to recursively discover netlify/functions/**/__tests__/*.{test,spec}.{ts,tsx} (including _shared/__tests__).
  • Restore jwt-validation.test.ts with actual JWT validation unit tests.
  • Restore read-capped-request.test.ts with 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'
@@ -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'
@clubanderson

Copy link
Copy Markdown
Collaborator Author

Superseded by #19741 which applied the same vitest include pattern fix (netlify/functions/**/__tests__/) and restored the corrupted test files. This PR can be closed.

@ZachDreamZ ZachDreamZ left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two fixes, both correct:

  1. vitest glob: → — enables recursive discovery of _shared/tests/. Without this, 14 test files were invisible to vitest.

  2. 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.

@kubestellar-prow

Copy link
Copy Markdown
Contributor

@ZachDreamZ: changing LGTM is restricted to collaborators

Details

In response to this:

Two fixes, both correct:

  1. vitest glob: → — enables recursive discovery of _shared/tests/. Without this, 14 test files were invisible to vitest.

  2. 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.

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.

@ZachDreamZ

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hold Blocked — do not touch quality size/L Denotes a PR that changes 100-499 lines, ignoring generated files. testing tier/2-standard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants