Skip to content

fix(tests): correct test commands and fix oauth-buttons failures#142

Merged
vscarpenter merged 1 commit intomainfrom
fix/test-commands-and-oauth-buttons
Feb 13, 2026
Merged

fix(tests): correct test commands and fix oauth-buttons failures#142
vscarpenter merged 1 commit intomainfrom
fix/test-commands-and-oauth-buttons

Conversation

@vscarpenter
Copy link
Owner

Summary

  • Replace bun testbun run test across all documentation — bun test invokes bun's built-in test runner (491 failures), while bun run test delegates to vitest via package.json (0 failures)
  • Fix 2 failing vitest tests in tests/ui/oauth-buttons.test.tsx by mocking @/lib/env-config and fixing window.location mock
  • Fix component bug in components/sync/oauth-buttons.tsx where the outer catch block didn't reset loading state

Test plan

  • bun run test — 89 test files, 1713 tests passed, 0 failures
  • bun typecheck — clean, no errors
  • Verify bun lint passes in CI

🤖 Generated with Claude Code

- Replace `bun test` with `bun run test` across all docs (CLAUDE.md,
  CONTRIBUTING.md, TECHNICAL.md, GSD_FEATURES_GUIDE.md, OAUTH_OIDC_GUIDE.md,
  copilot-instructions.md) — `bun test` invokes bun's built-in runner
  instead of vitest
- Add vi.mock for @/lib/env-config in oauth-buttons tests to prevent
  getEnvironmentConfig() from accessing window.location.hostname
- Fix window.location mock in redirect test to include hostname property
  and restore original location after test
- Add setLoading(null) to outer catch block in oauth-buttons.tsx to
  prevent permanent loading state on unexpected errors (e.g., malformed
  JSON from server)
- Bump version to 6.8.5

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sonarqubecloud
Copy link

@claude
Copy link

claude bot commented Feb 13, 2026

Code Review Summary

Overall Assessment: ✅ LGTM with minor observations

This PR addresses a critical documentation/testing issue and fixes real bugs. The changes are well-scoped, properly tested, and improve project quality.


Strengths

1. Clear Problem Identification

  • Correctly identified that bun test invokes Bun's built-in test runner (491 failures) instead of Vitest via bun run test (0 failures)
  • Systematic documentation updates across all relevant files

2. Comprehensive Documentation Updates

Updated 7 files with consistent messaging:

  • .github/copilot-instructions.md
  • CLAUDE.md (core project instructions)
  • CONTRIBUTING.md
  • GSD_FEATURES_GUIDE.md
  • OAUTH_OIDC_GUIDE.md
  • TECHNICAL.md

All updates include the clarifying note: (bun test invokes bun's built-in runner, not vitest)

3. Real Bug Fixes

Bug 1: Missing env-config mock in tests

  • Added proper mock for @/lib/env-config in oauth-buttons.test.tsx
  • Prevents test failures when environment config is accessed

Bug 2: Loading state not reset on error

} catch (error) {
+  setLoading(null);  // ✅ Prevents stuck loading state
  console.error("[OAuth] Flow failed:", error);

This is a legitimate UI bug fix that prevents buttons from staying in loading state after errors.

Bug 3: Incomplete window.location mock

-window.location = { href: '' } as any;
+window.location = { href: '', hostname: 'localhost' } as any;
+
+// ... test code ...
+
+// Restore original location to prevent test contamination
+window.location = originalLocation;
  • Adds hostname property to prevent runtime errors
  • Properly restores original window.location to prevent test pollution

Code Quality

✅ Follows CLAUDE.md Guidelines

  • Changes align with "Pre-commit" requirements: tests, typecheck, lint
  • Adds forgotten pre-commit check to CLAUDE.md: bun run test
  • Version bump from 6.8.4 → 6.8.5 (appropriate for bug fixes)

✅ Test Coverage

  • Modified test file includes proper setup/teardown
  • Mocks are comprehensive and realistic
  • Environment config mock provides all required fields

✅ Security

  • No security concerns introduced
  • Error handling improvements actually enhance security (prevents UI state bugs)

✅ Performance

  • No performance impact
  • Documentation changes only affect developer experience

Minor Observations

1. Git Workflow Addition to CLAUDE.md

+## Git Workflow 
+
+For git operations: when asked to commit and push, write a descriptive conventional commit message, bump the version if appropriate, and create a PR unless told otherwise. Standard workflow: commit → push → create PR.

Observation: This is a good addition for AI agent guidance, though it's slightly outside the PR's stated scope. Consider whether this should be in coding-standards.md instead for better discoverability.

2. Test File Mock Ordering

The env-config mock is placed after the oauth-config mock. Consider adding a comment explaining the mock dependency order if there is one, or explicitly stating that order doesn't matter.

3. Documentation Consistency

All documentation files now consistently use bun run test, but the PR description could mention that this affects developer onboarding (new devs might run bun test and see failures).


Recommendations

Before Merge

  • ✅ Verify bun run test passes (confirmed in PR description: 89 files, 1713 tests, 0 failures)
  • ✅ Verify bun typecheck passes (confirmed in PR description)
  • ⏳ Verify bun lint passes in CI (marked as pending in PR checklist)

Future Improvements (Not Blocking)

  1. Consider adding a pretest script in package.json to prevent accidental bun test usage:

    "scripts": {
      "pretest": "echo 'Use: bun run test (not bun test)'",
      "test": "vitest run"
    }
  2. Add a contributing guideline reminder about the distinction between bun test and bun run test


Test Plan Verification

From PR description:

  • bun run test — 89 test files, 1713 tests passed, 0 failures
  • bun typecheck — clean, no errors
  • bun lint — awaiting CI confirmation

Status: Ready to merge once lint check passes.


Final Verdict

APPROVED

This PR:

  • Fixes a confusing testing workflow issue affecting all developers
  • Resolves 2 real test failures with proper mocking
  • Fixes a UI bug in error handling
  • Maintains backward compatibility
  • Follows project coding standards
  • Includes appropriate version bump

Impact: High value for developer experience and test reliability.

Risk: Very low - documentation changes + targeted bug fixes with tests.


Review conducted per CLAUDE.md and coding-standards.md guidelines

@vscarpenter vscarpenter merged commit 4870a60 into main Feb 13, 2026
3 checks passed
@vscarpenter vscarpenter deleted the fix/test-commands-and-oauth-buttons branch February 13, 2026 22:35
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.

1 participant