Skip to content

fix: Fix test mocking by deferring env var access#115

Merged
gpailler merged 1 commit intoScoopInstaller:mainfrom
z-Fng:fix-ci
Mar 21, 2026
Merged

fix: Fix test mocking by deferring env var access#115
gpailler merged 1 commit intoScoopInstaller:mainfrom
z-Fng:fix-ci

Conversation

@z-Fng
Copy link
Copy Markdown
Member

@z-Fng z-Fng commented Mar 20, 2026

Changes

  • Move VITE_APP_AZURESEARCH_* from module level to function body.
  • Allows vi.stubEnv() to properly override environment variables in tests.
  • Resolves timing issue where GitHub Actions empty string env prevented mocking.

Summary by CodeRabbit

  • Refactor
    • Optimized environment variable retrieval timing for improved request handling.

- Move VITE_APP_AZURESEARCH_* from module level to function body
- Allows vi.stubEnv() to properly override environment variables in tests
- Resolves timing issue where GitHub Actions empty string env prevented mocking
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 20, 2026

Walkthrough

Environment variable reads for Azure Search configuration were relocated from module initialization scope into the fetchDataAsync function body. This changes the timing of when these values are retrieved from module load time to request execution time, while maintaining identical validation and usage patterns.

Changes

Cohort / File(s) Summary
Lazy environment variable initialization
src/components/SearchProcessor.tsx
Moved VITE_APP_AZURESEARCH_URL and VITE_APP_AZURESEARCH_KEY environment variable destructuring from module scope into fetchDataAsync function body to defer resolution until request execution time.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A rabbit's ode to timely delays
Variables once eager, now wise—
They wait for the moment, the perfect request,
No longer rushing at module sunrise,
Patient and poised, they find their best!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: Fix test mocking by deferring env var access' accurately describes the main change: moving environment variable access from module scope to function scope to enable proper test mocking.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can disable poems in the walkthrough.

Disable the reviews.poem setting to disable the poems in the walkthrough.

@gpailler gpailler merged commit cc5a0a3 into ScoopInstaller:main Mar 21, 2026
4 checks passed
@z-Fng z-Fng deleted the fix-ci branch March 21, 2026 09:57
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.

2 participants