gridly icon indicating copy to clipboard operation
gridly copied to clipboard

πŸ§ͺ [testing improvement] Add test coverage for auth providers configuration

Open AdityaKodez opened this issue 8 months ago β€’ 3 comments

🎯 What: The testing gap addressed The getEnabledSocialProvidersConfig function in lib/auth-providers.ts was untested because it depended on a statically initialized providerEnv object that read process.env at module load time. This made manipulating environment variables in standard Node.js tests difficult.

By refactoring providerEnv into a lazily evaluated getProviderEnv(provider) function, the module becomes entirely testable using native Node testing hooks (process.env reassignment).

πŸ“Š Coverage: What scenarios are now tested

  • Empty configuration when no provider secrets are present.
  • Single provider (GitHub) returning correct configuration.
  • Empty strings correctly evaluated as missing secrets.
  • Multiple configurations returned when multiple providers (GitHub, Discord) are enabled.

✨ Result: The improvement in test coverage lib/auth-providers.ts is now covered by standard node:test tests. Also added a npm run test script to package.json that reliably executes these TypeScript tests with --conditions=react-server and tsx integration to gracefully bypass Next.js specific alias issues.


PR created automatically by Jules for task 12198110488065936914 started by @AdityaKodez

Summary by CodeRabbit

  • Tests

    • Added comprehensive test suite for authentication provider configuration validation, covering scenarios with no providers, single providers, and multiple providers enabled.
  • Chores

    • Added test runner infrastructure and refactored authentication provider configuration logic for improved maintainability.

AdityaKodez avatar Mar 08 '26 14:03 AdityaKodez

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
gridly Ready Ready Preview, Comment Mar 8, 2026 2:20pm

vercel[bot] avatar Mar 08 '26 14:03 vercel[bot]

[!IMPORTANT] Review skipped

Bot user detected.

To trigger a single review, invoke the @beetle command.

βš™οΈ Settings

Severity Threshold: Medium β€” Balanced feedback β€” medium and high severity issues only. β€” Change in Settings Custom Rules: Define your own review rules β€” Set Custom Rules PR Summary: Configure PR summary β€” Change in Settings

πŸ“– User Guide
  • Once repos are connected, PR analysis is automatically enabled. You can disable analysis for this repo from beetleai.dev/analysis
  • Comment @beetle on any PR to start analysis manually
  • Comment @beetle stop to stop any ongoing analysis

Follow us: Beetle Β· X Β· LinkedIn

beetle-ai[bot] avatar Mar 08 '26 14:03 beetle-ai[bot]

πŸ“ Walkthrough

Walkthrough

Adds a comprehensive test suite for authentication provider configuration helpers and refactors the provider environment variable lookup from a static mapping to a dynamic function. The package.json is updated with TypeScript test support via tsx.

Changes

Cohort / File(s) Summary
Test Infrastructure
package.json
Added test script leveraging tsx for TypeScript support and added tsx as a devDependency (^4.21.0).
Auth Provider Tests
lib/auth-providers.test.ts
New comprehensive test suite validating behavior when no providers, single providers (GitHub), or multiple providers (GitHub and Discord) are configured. Tests verify configuration object structure and provider array ordering.
Auth Provider Refactoring
lib/auth-providers.ts
Replaced static providerEnv object with a getProviderEnv(provider) function that returns provider-specific environment variables via switch statement. Updated parseProviderSecrets to use the new function; no public API changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 We've hopped through the code with tests held high,
Provider configs now dance and comply,
TypeScript flows with tsx in hand,
A refactored realm, neat and grand! ✨

πŸš₯ Pre-merge checks | βœ… 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
βœ… Passed checks (2 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check βœ… Passed The title accurately describes the main change: adding test coverage for auth providers configuration. However, it includes an emoji (πŸ§ͺ) and a bracketed tag ([testing improvement]) that could be considered noise, though the core message is clear and directly related to the changeset.

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

✨ Finishing Touches
  • [ ] πŸ“ Generate docstrings (stacked PR)
  • [ ] πŸ“ Generate docstrings (commit on current branch)
πŸ§ͺ Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment
  • [ ] Commit unit tests in branch testing-improvement-auth-providers-12198110488065936914

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.

coderabbitai[bot] avatar Mar 08 '26 14:03 coderabbitai[bot]