test(browser) : enhance test coverage for http and auth params utilities#223
Open
KavishkaVenuka wants to merge 10 commits intoasgardeo:mainfrom
Open
test(browser) : enhance test coverage for http and auth params utilities#223KavishkaVenuka wants to merge 10 commits intoasgardeo:mainfrom
KavishkaVenuka wants to merge 10 commits intoasgardeo:mainfrom
Conversation
- Add comprehensive test cases for hasAuthParamsInUrl utility - Add extensive test coverage for http utility including: - Request method testing with various HTTP methods - RequestAll method testing for batch operations - Edge case handling - Error scenarios - Integration tests - Concurrent request handling This change improves the test coverage and reliability of the browser package's utilities.
- Add comprehensive test suite for getActiveTheme utility - Implement test cases for: - Explicit theme mode detection - System theme preference handling - Class-based theme detection - Edge case scenarios - Theme mode fallbacks - Improve test organization with proper describe blocks - Add proper setup/teardown for window.matchMedia mocks - Include tests for all theme modes: light, dark, system, and class-based
- Add comprehensive test cases for AsgardeoBrowserConfig type - Implement storage type validation tests - Add required and optional field validation - Improve test organization with proper describe blocks - Add runtime validation for invalid storage types - Use type-safe assertions and constants
…coverage Add tests for the default export and subclassing behavior of AsgardeoBrowserClient: - verify default export is a class - ensure a concrete subclass can be instantiated - assert inheritance from AsgardeoJavaScriptClient - validate initialize and getConfiguration behavior - cover core method stubs: isLoading, isSignedIn, getUser, getUserProfile, organizations APIs, getAccessToken, exchangeToken - exercise signIn/signOut/signUp overloads with stubbed returns Tests are colocated under src/__tests__/AsgardeoBrowserClient.test.ts to match package conventions Refs: @asgardeo/browser unit test coverage task
brionmario
reviewed
Oct 31, 2025
packages/browser/jest.config.js
Outdated
Member
There was a problem hiding this comment.
Hey @KavishkaVenuka,
Could you please explain why we need a Jest Config?
brionmario
reviewed
Oct 31, 2025
packages/browser/package.json
Outdated
| "prettier": "^2.6.2", | ||
| "rimraf": "^6.0.1", | ||
| "typescript": "~5.7.2", | ||
| "typescript": "~5.7.3", |
Member
There was a problem hiding this comment.
Any reason for this version bump?
brionmario
reviewed
Oct 31, 2025
| "access": "public" | ||
| } | ||
| } | ||
| } No newline at end of file |
Member
|
@KavishkaVenuka Please find few overall comments on the PR:
|
Author
|
Hi @brionmario sir, I’ve removed the Jest config and fixed other issues as requested. Please review when you have a moment. |
add and normalize license headers in test files add missing type annotations to satisfy @typescript-eslint/typedef reorder object keys to comply with sort-keys in mocks and assertions adjust matchMedia mocks and expectation objects to meet lint rules normalize line endings to LF to satisfy prettier/prettier on windows add targeted eslint disables for test-only patterns (class-methods-use-this, no-underscore-dangle, typedef where necessary) recreate placeholder utils test file with correct header and local disables format all browser test files using package prettier config
…ig tests remove @types/jest from lockfile and align Vitest-related entries bump/resolve @vitest/browser and @vitest/coverage-v8 to match vitest 3.1.3 add explicit types and safe casting in src/models/__tests__/config.test.ts keep formatting consistent with repo Prettier config
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.
This change improves the test coverage and reliability of the browser package's utilities.
Purpose
-This PR enhances the test coverage for utilities in the browser package by adding comprehensive test suites for both hasAuthParamsInUrl and HTTP utilities. The changes focus on improving code reliability and ensuring robust error handling.
###Key Improvements:
-Enhanced test coverage for hasAuthParamsInUrl utility
###URL parameter validation
-Edge case handling
-Special character testing
-Parameter positioning scenarios
###Comprehensive HTTP utility test coverage
-Various HTTP method validations (GET, POST, PUT, DELETE)
-Batch operation testing via RequestAll method
-Concurrent request handling scenarios
-Error case validation
-Integration test scenarios
-Edge case handling for various request states
###Related Issues
-N/A
###Related PRs
-N/A
###Checklist
-Followed the [CONTRIBUTING] guidelines
-Manual test round performed and verified
-Unit tests provided in:
---->[hasAuthParamsInURL.test.ts]
---->packages/browser/src/utils/tests/http.test.ts
-Documentation provided (No documentation updates required as this is test-only changes)
###Security checks
-Followed secure coding standards in [http://wso2.com/technical-reports/wso2-secure-engineering-guidelines]
-Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets
###Additional Notes
-All test cases follow the project's testing conventions
-Tests are designed to be maintainable and readable
-No production code changes were made, only test improvements