test(apply): cover refreshStaleEnvDefaults regression suite#107
test(apply): cover refreshStaleEnvDefaults regression suite#107tonychang04 wants to merge 1 commit intomainfrom
Conversation
Adds 13 tests exercising the env-merge path that 0.1.68 introduced. Verifies: - KEY → value extraction including URL-style values - refresh fires when user value matches manifest default and platform has a different real value - refresh skips when user customized (value differs from default) - refresh skips when platform value equals default (self-hosted helper returns null) - multiple keys: only stale ones get refreshed, customized stay
WalkthroughThis PR expands test coverage for the auth-providers ChangesAuth Helpers Test Coverage
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/auth-providers/apply.test.ts (1)
119-124: ⚡ Quick winStrengthen replacement assertions to prove stale values are removed.
Current checks mainly use
toContain, so an implementation that appends refreshed lines but leaves old placeholders could still pass for some keys. Add explicit negative assertions for stale values in the multi-key case.Proposed assertion hardening
const { updated, refreshed } = refreshStaleEnvDefaults(existing, defaults, platform); expect(refreshed.sort()).toEqual(['DATABASE_URL', 'INSFORGE_JWT_SECRET']); expect(updated).toContain('DATABASE_URL=postgresql://cloud@host/db?sslmode=require'); + expect(updated).not.toContain('DATABASE_URL=postgresql://postgres:postgres@127.0.0.1:5432/insforge'); expect(updated).toContain('BETTER_AUTH_SECRET=user-set-this-already'); expect(updated).toContain('INSFORGE_JWT_SECRET=real-jwt-secret-from-platform'); + expect(updated).not.toContain('INSFORGE_JWT_SECRET=replace-with-output-of-cli-secrets-get-JWT_SECRET');🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/auth-providers/apply.test.ts` around lines 119 - 124, The test for refreshStaleEnvDefaults should assert that stale placeholder lines are removed, not just that new lines were added; update the test in apply.test.ts to add negative assertions for the original stale values present in the existing fixture (e.g., the old DATABASE_URL placeholder and the old INSFORGE_JWT_SECRET placeholder) by adding expect(updated).not.toContain(...) checks alongside the current positive checks so refreshStaleEnvDefaults is proven to replace, not merely append, those entries.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/auth-providers/apply.test.ts`:
- Around line 119-124: The test for refreshStaleEnvDefaults should assert that
stale placeholder lines are removed, not just that new lines were added; update
the test in apply.test.ts to add negative assertions for the original stale
values present in the existing fixture (e.g., the old DATABASE_URL placeholder
and the old INSFORGE_JWT_SECRET placeholder) by adding
expect(updated).not.toContain(...) checks alongside the current positive checks
so refreshStaleEnvDefaults is proven to replace, not merely append, those
entries.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a0453a95-4f9a-497b-94bf-be315ecc3e36
📒 Files selected for processing (1)
src/auth-providers/apply.test.ts
Summary
Adds 13 unit tests for the env-merge logic that 0.1.68 introduced. Acts as regression guard against the fix — if anyone changes the matching/replace logic, tests will catch behavioral drift.
Coverage
All 13 pass locally (
npx vitest run src/auth-providers/apply.test.ts→Tests 13 passed (13)).🤖 Generated with Claude Code
Summary by cubic
Add 13 unit tests for the env-merge path introduced in 0.1.68, covering
extractEnvPairsandrefreshStaleEnvDefaults. Tests ensure we only replace values that still equal the manifest default when the platform has a real value, keep user customizations, and handle multiple keys.Written for commit fd0f80a. Summary will update on new commits.
Summary by CodeRabbit