You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(test): adapt tests for buildCommand auth guard (#615)
## Summary
Fixes the ~200 test failures caused by the auth guard added in #611.
Meant to be merged into #612 so both the CI hang (dsn-cache timing +
telemetry beforeExit) and the auth guard breakage ship together.
## Problem
`buildCommand`'s new auth guard calls `getAuthConfig()` before every
command. Test environments had no auth token set, so all command tests
hit `AuthError("not_authenticated")` before the func body ran.
## Changes
**Global fix (test/preload.ts):**
- Set a fake `SENTRY_AUTH_TOKEN` in the test preload so the auth guard
passes for all tests. Real API calls are blocked by the global fetch
mock.
**Framework tests (test/lib/command.test.ts):**
- Add `auth: false` to all 29 test commands — these test flag handling,
telemetry, and output rendering, not authentication.
**Auth-specific tests (logout, refresh, whoami, project list):**
- Tests that verify unauthenticated behavior or `SENTRY_TOKEN` priority
now explicitly save/clear/restore `SENTRY_AUTH_TOKEN`.
## Test plan
- 215 tests across the 7 most-affected files pass with 0 failures
- `bun test test/commands` — 1209 pass
- Lint and typecheck pass
---------
Co-authored-by: Miguel Betegón <miguelbetegongarcia@gmail.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
0 commit comments