fix(api): correct authProvider unit test mocks #213
Reference in New Issue
Block a user
Delete Branch "fix/gro-388-auth-provider-tests"
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?
Summary
Fixes all 5 failing unit tests in
authProvider.test.tsby correcting the Drizzle ORM mock to match the actual API surface used by the route handlers.Changes
.into()call — Drizzle'sdb.insert(table).values()doesn't chain through.into().returning())returnbeforec.json()to fix "Context is not finalized" errors in Hono/admin/auth-provider(exact) and/admin/auth-provider/*(wildcard) to ensure all subpaths are guardedTest Plan
authProvider.test.tspasscc @cpfarhood
QA Review: Request Changes
PR: fix/api: correct authProvider unit test mocks (PR #213)
CI Status: Lint & Typecheck: FAILURE (Typecheck step)
Issue
The step in the CI workflow is failing. The Test step passes, but type checking does not.
Action Required
Please fix the Typecheck failure and ensure all CI checks pass before requesting re-review.
cc @cpfarhood
QA Review: Request Changes
PR: fix/api: correct authProvider unit test mocks (PR #213)
CI Status: Lint and Typecheck: FAILURE
Issue
The Typecheck step in CI is failing. The Test step passes, but type checking does not.
Action Required
Please fix the Typecheck failure and ensure all CI checks pass before requesting re-review.
cc @cpfarhood
QA Review: APPROVED ✅
All CI checks pass (Lint, Typecheck, Test, E2E, Build, Build & Push).
Verified implementation against GRO-388 definition of done:
cc @cpfarhood
QA Review: APPROVED
All CI checks pass (Lint, Typecheck, Test, E2E, Build, Build & Push).
Verified implementation against GRO-388 definition of done:
Note: Deploy PR step fails with known infra issue (CD job immutability bug, unrelated to this PR).
cc @cpfarhood
CTO Review: Changes Required
1. Non-atomic upsert (correctness issue)
authProvider.tsPUT handler deletes all rows then inserts without a transaction:If the insert fails after the delete, auth provider config is permanently lost. Wrap in a transaction:
2. Rebase on main
Branch is BEHIND main and includes devFetch.ts + Services.tsx changes already merged via PR #211. Rebase on main to drop these extraneous commits.
3. Minor: missing newline at EOF
Both
authProvider.tsandauthProvider.test.tslack trailing newlines.Everything else looks good — route structure, Zod validation, secret encryption, RBAC middleware, test coverage.
CTO Review: Changes Required
CI is red — Lint/Typecheck and Test steps are failing.
Issue: Syntax error in test mock
In
authProvider.test.ts, thetransactionmock has a syntax error on theinsert→values→returningclosure:The
)after the object literal closes the arrow function body prematurely. Fix: change)),to}),.Everything else looks good
Fix the syntax error, push, and route through QA once CI is green.
PR Ready for Re-review
CI is green (Lint, Typecheck, Test, Build, Build & Push Docker Images, E2E Tests all pass).
Fix applied: Corrected the transaction mock syntax error in
authProvider.test.ts— changed)),to}),on the values-returning arrow function.Note: Deploy PR step fails with known infra issue (CD job immutability bug GRO-311, unrelated to this PR).
Requesting QA re-review.
cc @cpfarhood
CTO Review: Approved
All prior feedback addressed:
db.transaction())),→}),)requireSuperUser()Deploy PR failure is the known CD job immutability bug (GRO-311), unrelated.
cc @cpfarhood