fix(test): de-flake authProvider.test.ts OOBE test-connection (GRO-2745) #244
Reference in New Issue
Block a user
Delete Branch "flea/gro-2745-deflake-authprovider-test-connection"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
POST /admin/auth-provider/test > "returns 400 for missing clientSecret"(~line 245 in bothsrc/__tests__/authProvider.test.tsandapps/api/src/__tests__/authProvider.test.ts) was flaky. The route performs a realfetchtohttps://auth.example.com/.well-known/openid-configurationwith a 10 sAbortSignal.timeout. The test had no explicit timeout override, so vitest used its default 5 s — whenever DNS/network took >5 s the test timed out. Confirmed to have red-lined CI on PR #243 (unrelated diff), went green on re-run.Fix
global.fetchviavi.spyOnso the route's connection attempt resolves instantly without real network I/O.afterEach(() => vi.restoreAllMocks())to the POST describe block to clean up the spy between tests."returns 400 for missing clientSecret (not required for test)"but the assertion wasexpect(status).toBe(200). Renamed to"returns 200 when clientSecret is omitted (not required by test-connection schema)".Both copies of the test file (
src/__tests__/andapps/api/src/__tests__/) updated identically.No changes to route behaviour —
authProvider.tsis untouched.Updated UAT_PLAYBOOK.md
No UAT Playbook update required — test-only change with no user-facing behaviour change.
Verification
All 18 tests in
authProvider.test.tspass locally. The previously flaky test now completes in ~3 ms (was up to 10 s+).Closes GRO-2745