test: cover provider failure paths and untested client methods#96
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Cover the provider failure paths and the client methods that had no direct test.
Closes #91.
Coverage
AuthProvider.tsxcreateSeamlessAuthClient.tsTests: 208 to 221.
Provider failure paths now covered
Each asserts the consequence for auth state, not just that a promise rejected:
useAuthoutside a provider throwsfalsewithout disturbing the sessionfresh: falseleaves step-up status untouched, so provider state cannot record a step-up that did not happenThat last one is the interesting case: the endpoint answering successfully is not the same as the user verifying, and nothing previously tested that distinction.
Client methods now covered
getOrganization,updateOrganization,listOrganizationMembers,deleteUser, andrequestMagicLink, each asserting endpoint, method, and body. Plus a case proving a transport failure becomes an error result with status0rather than rejecting, which is a load-bearing property of the result convention that nothing exercised end to end.addOrganizationMember,updateOrganizationMember, andremoveOrganizationMemberwere covered in #95.Refactor
The
renderAndCaptureAuthhelper was nested inside one describe block. It is now hoisted to module scope with an optional seeded credentials argument, so this PR reuses it instead of adding a third copy of the same setup.Not covered, deliberately
verifyStepUpWithPasskeyandverifyStepUpWithPasskeyPrfsuccess paths (lines 277-300) still need a WebAuthn assertion mocked at the provider level. The client-level tests already cover that choreography, so the remaining gap is the provider's state write. Worth a follow-up if you want it, but it is a thinner slice than what this PR closes.Note
The suite now prints two
console.errorlines fromhandlePasskeyLoginanddeleteUser. Those are the code under test logging on purpose while its error paths run, not failures.Checks
npm run typecheck,npm run lint,npm run format:checkclean