-
Couldn't load subscription status.
- Fork 40
chore: improve unit test coverage in @asgardeo/javascript SDK #204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…seUrl to reflect actual behavior
…for invalid URLs and network failures
…for invalid URLs and network failures
…ow for invalid URLs and network failures
|
Hey @PasanMadhuranga, Also, there's an error in the |
Thanks a lot @brionmario! ❤️ I really appreciate the feedback. I’ll check the test run error in the |
|
Shall we fix the test suite errors. |
Hi @brionmario ! I’ve fixed the test suite errors and also added a changeset. |
🦋 Changeset detectedThe changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. |
|
Tests are passing now. |
Purpose
This PR improves unit test coverage for the @asgardeo/javascript SDK, addressing the gaps identified in issue #154.
Summary of Work Done
Fixed and stabilized existing failing tests.
Refined and expanded unit tests in:
src/api/__tests__/src/errors/__tests__/Added coverage for additional code paths, edge cases, and error handling scenarios to improve reliability and regression detection.
Conducted a manual verification round to ensure all tests pass consistently.
Bug Fixes Implemented During Testing
While increasing coverage, a few logic issues were identified and fixed to align with expected SDK behavior.
The following commits address these issues:
113a180chore(javascript): use numeric ordering for log levels instead of string comparison539acf3fix(javascript): handle network and parsing errors gracefully in getUserInfo446de46fix(javascript): improve error handling in ExecuteEmbeddedSignInFlow for invalid URLs and network failures0c7ec47fix(javascript): improve error handling in executeEmbeddedSignUpFlow for invalid URLs and network failuresf0e4d8bfix(javascript): improve error handling in initializeEmbeddedSignInFlow for invalid URLs and network failuresObservations and Potential Issues
During implementing tests, several inconsistencies and potential bugs were noted that may need team clarification or adjustment:
1.
updateMeProfile.tsIssue:
requestConfigcan override the explicitly defined HTTP method.Suggestion:
Spread
requestConfigafter defining headers and method to ensure the HTTP method cannot be unintentionally overridden.2. Multiple API files
Files:
createOrganization.ts,executeEmbeddedSignInFlow.ts,executeEmbeddedSignUpFlow.ts,getBrandingPreference.ts,getMeOrganizations.ts,getOrganization.ts,getSchemas.ts,getScim2Me.ts,getUserInfo.ts,updateOrganization.tsIssue:
Content-TypeandAcceptheaders can be overridden byrequestConfig.headers.Suggestion:
Reverse the merge order if the intention is to enforce standard headers:
3.
getAllOrganizations.ts,initializeEmbeddedSignInFlow.ts,updateMeProfile.tsIssue:
Opposite header precedence. Here,
requestConfig.headersis overridden byContent-TypeandAccept.This creates inconsistent behavior across API utilities.
4.
AsgardeoAPIError.tsIssue:
toString()renders"undefined"forstatusTextwhen not provided.Next Steps
utils.Related Issues
@asgardeo/javascriptSDK #154Related PRs
Checklist
Security checks