chore: refactor test files to test public components only#400
Conversation
|
Warning Review limit reached
Next review available in: 24 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR refactors test files across ChangesTest consolidation and cleanup
Estimated code review effort: 3 (Moderate) | ~25 minutes Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 7
🧹 Nitpick comments (1)
packages/react/src/components/auth0/my-organization/__tests__/sso-provider-edit.test.tsx (1)
724-742: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winStrengthen the error handling test assertions.
The test "should handle error gracefully" only asserts that the loading text disappears, which duplicates
waitForComponentToLoadlogic rather than using the helper. It doesn't verify any error state or message is rendered to the user. Consider usingwaitForComponentToLoad()and adding an assertion for the error UI (e.g., an error message or error boundary fallback) to make the test name meaningful.♻️ Proposed improvement
it('should handle error gracefully', async () => { const apiService = mockCoreClient.getMyOrganizationApiClient().organization; apiService.identityProviders.get = vi .fn() .mockRejectedValue(new Error('Provider not found')); renderWithProviders(<SsoProviderEdit {...createMockSsoProviderEditProps()} />); - await waitFor( - () => { - expect(screen.queryByText('Loading...')).not.toBeInTheDocument(); - }, - { timeout: 3000 }, - ); + await waitForComponentToLoad(); + + // Add assertion for error state visible to the user + // e.g., expect(screen.getByText(/error/i)).toBeInTheDocument(); });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/react/src/components/auth0/my-organization/__tests__/sso-provider-edit.test.tsx` around lines 724 - 742, The "should handle error gracefully" test in SsoProviderEdit only checks that the loading state disappears, which repeats generic loading behavior instead of validating error handling. Update the test to use waitForComponentToLoad() for the async settle step, then add an assertion against the actual error UI rendered by SsoProviderEdit (such as an error message, fallback state, or error boundary output) so the test name matches its behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@packages/react/src/components/auth0/my-organization/__tests__/domain-table.test.tsx`:
- Around line 746-765: The customMessages test in DomainTable only checks that
the table renders, so it does not verify the provided header title is actually
used. Update the test in the customMessages describe block to assert the
rendered text includes the passed title from createMockDomainTableProps, or
rename it to make clear it is only a smoke test; use DomainTable,
createMockDomainTableProps, and the customMessages.header.title prop to locate
the assertion.
- Around line 733-743: The pagination test in DomainTable currently only checks
that the table renders, so it does not verify the behavior described by its
name. Update the test in the pagination block of the domain-table suite to
assert pagination-specific UI from DomainTable (such as navigation buttons, page
controls, or page indicators) after renderWithProviders and
waitForComponentToLoad, or rename the test so it matches the actual assertion if
you intend to keep it as a simple render check.
In
`@packages/react/src/components/auth0/my-organization/__tests__/organization-member-management.test.tsx`:
- Around line 772-792: The dark mode test in OrganizationMemberManagement only
checks that the header renders, so it never verifies the provided styling class
is applied. Update the test to assert the root element receives the
dark-mode-root class from the styling.classes mapping, using the same approach
as the existing styling test in the OrganizationMemberManagement test suite,
while keeping the current renderWithProviders and waitForComponentToLoad flow.
- Around line 486-612: The empty-state, pagination, and error-handling tests in
OrganizationMemberManagement only verify API calls and don’t assert the UI
behavior the test names describe. Update the affected tests to check the
rendered outcome after the mocked organization.members.list and
organization.invitations.list calls resolve/reject, such as the empty-state
message, pagination controls, or error banner. Use the existing helpers and
selectors in OrganizationMemberManagement, renderWithProviders,
waitForComponentToLoad, and screen to assert what the user actually sees.
- Around line 614-650: The “close modal after creation” test in
OrganizationMemberManagement currently only verifies that
organization.invitations.create is called, so it does not actually assert the
modal closes; update this test to check that the invitation create modal is
dismissed after a successful submission. Reuse the existing modal title matcher
(/invitation\.create\.title/i) and add a post-submit assertion that it is no
longer present in the document, keeping the test aligned with its name and
behavior.
- Around line 338-461: Several tests in OrganizationMemberManagement are named
as action/behavior coverage but only assert setup or tab loading, so either
rename them to match the actual checks or add the missing user interactions and
expectations. In the invitation actions cases, use the relevant action UI to
trigger revoke/resend and assert the mocked
organization.invitations.delete/create calls plus the ComponentAction
onBefore/onAfter callbacks; in the member actions cases, interact with the view
details/assign roles/remove controls and verify the corresponding behavior
instead of only checking members.list or tab state. Refer to
OrganizationMemberManagement, createMockComponentProps, and the
revokeInvitationAction/resendInvitationAction/viewMemberDetailsAction/assignRolesAction/removeFromOrganizationAction
test cases when updating the assertions.
- Around line 421-422: The test file has a duplicate `const assignRolesAction`
declaration inside `organization-member-management.test.tsx`, which causes a
compile-time identifier redeclaration error. Remove the repeated declaration in
the `it('should handle assign roles action'...)` test and keep only one
`assignRolesAction` constant, making sure any subsequent uses in that test refer
to the single existing variable.
---
Nitpick comments:
In
`@packages/react/src/components/auth0/my-organization/__tests__/sso-provider-edit.test.tsx`:
- Around line 724-742: The "should handle error gracefully" test in
SsoProviderEdit only checks that the loading state disappears, which repeats
generic loading behavior instead of validating error handling. Update the test
to use waitForComponentToLoad() for the async settle step, then add an assertion
against the actual error UI rendered by SsoProviderEdit (such as an error
message, fallback state, or error boundary output) so the test name matches its
behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: b1594762-cf5e-483a-bd93-a923213cbbb1
📒 Files selected for processing (26)
packages/react/src/components/auth0/my-account/__tests__/user-mfa-management.test.tsxpackages/react/src/components/auth0/my-account/shared/mfa/__tests__/delete-factor-confirmation.test.tsxpackages/react/src/components/auth0/my-account/shared/mfa/__tests__/empty-state.test.tsxpackages/react/src/components/auth0/my-account/shared/mfa/__tests__/error-state.test.tsxpackages/react/src/components/auth0/my-account/shared/mfa/__tests__/factors-list.test.tsxpackages/react/src/components/auth0/my-account/shared/mfa/__tests__/otp-verification-form.test.tsxpackages/react/src/components/auth0/my-account/shared/mfa/__tests__/user-mfa-setup-form.test.tsxpackages/react/src/components/auth0/my-organization/__tests__/domain-table.test.tsxpackages/react/src/components/auth0/my-organization/__tests__/organization-details-edit.test.tsxpackages/react/src/components/auth0/my-organization/__tests__/organization-member-detail.test.tsxpackages/react/src/components/auth0/my-organization/__tests__/organization-member-management.test.tsxpackages/react/src/components/auth0/my-organization/__tests__/sso-provider-create.test.tsxpackages/react/src/components/auth0/my-organization/__tests__/sso-provider-edit.test.tsxpackages/react/src/components/auth0/my-organization/__tests__/sso-provider-table.test.tsxpackages/react/src/components/auth0/my-organization/shared/domain-management/domain-create/__tests__/domain-create-modal.test.tsxpackages/react/src/components/auth0/my-organization/shared/domain-management/domain-delete/__tests__/domain-delete-modal.test.tsxpackages/react/src/components/auth0/my-organization/shared/domain-management/domain-verify/__tests__/domain-verify-modal.test.tsxpackages/react/src/components/auth0/my-organization/shared/idp-management/sso-provider-delete/__tests__/provider-delete-modal.test.tsxpackages/react/src/components/auth0/my-organization/shared/idp-management/sso-provider-edit/sso-provisioning/__tests__/sso-provisioning-details.test.tsxpackages/react/src/components/auth0/my-organization/shared/idp-management/sso-provider-remove/__tests__/provider-remove-modal.test.tsxpackages/react/src/components/auth0/my-organization/shared/idp-management/sso-provider-remove/__tests__/provider-remove.test.tsxpackages/react/src/components/auth0/my-organization/shared/organization-management/organization-details/__tests__/branding-details.test.tsxpackages/react/src/components/auth0/my-organization/shared/organization-management/organization-details/__tests__/organization-details.test.tsxpackages/react/src/components/auth0/my-organization/shared/organization-management/organization-details/__tests__/setting-details.test.tsxpackages/react/src/hooks/__tests__/use-toast-provider.test.tspackages/react/src/hooks/my-organization/__tests__/use-sso-domain-tab.test.ts
💤 Files with no reviewable changes (19)
- packages/react/src/components/auth0/my-organization/shared/idp-management/sso-provider-remove/tests/provider-remove.test.tsx
- packages/react/src/hooks/tests/use-toast-provider.test.ts
- packages/react/src/components/auth0/my-organization/shared/organization-management/organization-details/tests/organization-details.test.tsx
- packages/react/src/components/auth0/my-organization/shared/idp-management/sso-provider-remove/tests/provider-remove-modal.test.tsx
- packages/react/src/components/auth0/my-account/shared/mfa/tests/delete-factor-confirmation.test.tsx
- packages/react/src/components/auth0/my-organization/shared/domain-management/domain-create/tests/domain-create-modal.test.tsx
- packages/react/src/components/auth0/my-organization/shared/idp-management/sso-provider-delete/tests/provider-delete-modal.test.tsx
- packages/react/src/components/auth0/my-account/shared/mfa/tests/empty-state.test.tsx
- packages/react/src/components/auth0/my-account/shared/mfa/tests/otp-verification-form.test.tsx
- packages/react/src/components/auth0/my-account/shared/mfa/tests/error-state.test.tsx
- packages/react/src/hooks/my-organization/tests/use-sso-domain-tab.test.ts
- packages/react/src/components/auth0/my-organization/shared/organization-management/organization-details/tests/branding-details.test.tsx
- packages/react/src/components/auth0/my-account/tests/user-mfa-management.test.tsx
- packages/react/src/components/auth0/my-account/shared/mfa/tests/user-mfa-setup-form.test.tsx
- packages/react/src/components/auth0/my-organization/shared/domain-management/domain-verify/tests/domain-verify-modal.test.tsx
- packages/react/src/components/auth0/my-organization/shared/domain-management/domain-delete/tests/domain-delete-modal.test.tsx
- packages/react/src/components/auth0/my-organization/shared/organization-management/organization-details/tests/setting-details.test.tsx
- packages/react/src/components/auth0/my-organization/shared/idp-management/sso-provider-edit/sso-provisioning/tests/sso-provisioning-details.test.tsx
- packages/react/src/components/auth0/my-account/shared/mfa/tests/factors-list.test.tsx
- Fix pagination test to verify table renders with domain data - Fix customMessages test to use regex for flexible matching - Fix member actions tests to verify API calls and table rendering - Fix empty states tests to verify empty message UI elements - Fix close modal test to verify modal closes after creation - Fix styling test to verify custom class is applied Addresses CodeRabbit review feedback about weak/misleading assertions. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #400 +/- ##
==========================================
+ Coverage 88.63% 89.86% +1.22%
==========================================
Files 203 203
Lines 17135 17201 +66
Branches 2273 2392 +119
==========================================
+ Hits 15187 15457 +270
+ Misses 1948 1744 -204 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Refactors test files across my-organization components to test only the main public block components instead of internal View subcomponents, and adds coverage to compensate for removed View tests.
Why
: anytype annotations and uses proper typing patternsWhat
Key changes:
: anytypes with proper mock types andReturnType<typeof vi.fn>patterns/header\.title/iinstead of'header.title')mockCore(),initMockCoreClient(),mockToast()Files changed (26 files):
organization-member-detail.test.tsx- Removed 27 View tests, added coverage for member data, error states, actionsorganization-member-management.test.tsx- Refactored with proper mocking, added modal and action testsorganization-details-edit.test.tsx- Removed View tests, added form rendering and error handling testsdomain-table.test.tsx- Removed View tests, added table rendering and pagination testssso-provider-create.test.tsx- Removed View tests, added header, strategy, and validation testssso-provider-edit.test.tsx- Removed View tests, added header, error handling, and form testssso-provider-table.test.tsx- Removed View tests, added table display and error handling testsPackages
packages/corepackages/reactexamplesTesting
Checklist
Contributing
Summary by CodeRabbit
Tests
Refactor