chore: refactor test files to test public components only#427
Conversation
📝 WalkthroughWalkthroughThis PR updates organization component tests to target primary components, adds coverage for loading, forms, actions, pagination, errors, and refresh behavior, and removes non-functional section comments across related MFA, domain, SSO, organization, and hook test files. ChangesOrganization and account test suites
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #427 +/- ##
=======================================
Coverage ? 89.80%
=======================================
Files ? 236
Lines ? 17632
Branches ? 2499
=======================================
Hits ? 15835
Misses ? 1797
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (8)
packages/react/src/components/auth0/my-organization/__tests__/organization-member-management.test.tsx (2)
764-786: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicate
stylingtest block.This
describe('styling', ...)and its single test duplicate the earlierstyling.classesblock at lines 192-214 (same styling shape, same custom class, same assertion). Consider removing one to avoid duplicated coverage that could silently diverge.♻️ Proposed fix to remove the duplicate block
- describe('styling', () => { - it('should apply custom class when styling.classes are provided', async () => { - const styling = { - variables: { - common: {}, - light: {}, - dark: {}, - }, - classes: { - 'OrganizationMemberManagement-root': 'custom-root-class', - }, - }; - - renderWithProviders( - <OrganizationMemberManagement {...createMockComponentProps({ styling })} />, - ); - - await waitForComponentToLoad(); - - expect(document.querySelector('.custom-root-class')).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__/organization-member-management.test.tsx` around lines 764 - 786, Remove the later duplicate describe('styling') block and its custom-class test from organization-member-management.test.tsx, keeping the earlier styling.classes coverage unchanged.
521-564: 🎯 Functional Correctness | 🔵 TrivialPagination tests don't verify pagination behavior.
These mock a
nextcursor but only assert basic table/data presence identical to the non-paginated rendering tests — no assertion on pagination controls or a second page fetch. See consolidated comment for a related instance indomain-table.test.tsx.🤖 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__/organization-member-management.test.tsx` around lines 521 - 564, Strengthen the pagination tests in the pagination describe block by asserting the next-page behavior rather than only initial rendering. Verify pagination controls are shown when the mocked response includes response.next, trigger the control, and assert the corresponding members.list or invitations.list mock is called again with the next cursor; keep the existing data-rendering assertions.packages/react/src/components/auth0/my-organization/__tests__/sso-provider-table.test.tsx (1)
848-858: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winMissing negative case for
hideHeader.Only
hideHeader: falseis covered. Since the removedSsoProviderTableViewsuite previously verified header hiding, add ahideHeader: truecase forSsoProviderTableto avoid a coverage regression on this toggle.✅ Suggested addition
describe('hideHeader', () => { describe('when is false', () => { it('should render the header', async () => { renderTable(); await waitForComponentToLoad(); expect(screen.getByText(/header.title/i)).toBeInTheDocument(); }); }); + + describe('when is true', () => { + it('should not render the header', async () => { + renderTable({ hideHeader: true }); + + await waitForComponentToLoad(); + + expect(screen.queryByText(/header.title/i)).not.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-table.test.tsx` around lines 848 - 858, Add a `hideHeader: true` test alongside the existing `hideHeader: false` case in the `hideHeader` describe block for `SsoProviderTable`. Render the table, wait for it to load, and assert that the header text is not present, preserving the existing positive-case coverage.packages/react/src/components/auth0/my-organization/__tests__/organization-details-edit.test.tsx (2)
1-1: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win"Error handling" tests don't verify an error was actually surfaced. Both tests mock a rejected fetch but only assert the loading indicator eventually disappears — an assertion equally true for a successful load, so these tests would pass even if the error path silently rendered nothing.
packages/react/src/components/auth0/my-organization/__tests__/organization-details-edit.test.tsx#L571-587: assert an actual error indicator/message (or that the form falls back to an empty/default state) instead of onlyqueryByRole('progressbar')absence.packages/react/src/components/auth0/my-organization/__tests__/sso-provider-edit.test.tsx#L869-884: assert an actual error indicator/message instead of only "Loading..." absence.🤖 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__/organization-details-edit.test.tsx` at line 1, Strengthen the rejected-fetch tests in organization-details-edit and sso-provider-edit so they verify the error outcome, not merely that loading ends. After mocking fetch rejection, assert the rendered error indicator/message (or the documented empty/default form state for organization-details-edit), while retaining the existing loading-disappearance checks if useful.
571-587: 🎯 Functional Correctness | 🔵 TrivialError test doesn't verify an error was actually surfaced.
This only asserts the progressbar disappears, which would be equally true on a successful load. See consolidated comment for a related instance in
sso-provider-edit.test.tsx.🤖 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__/organization-details-edit.test.tsx` around lines 571 - 587, Strengthen the “when organization details fail to load” test in the error handling suite by asserting the user-visible error state after the rejected organizationDetails.get call. Keep the existing progressbar assertion, and verify a specific error message, alert, or other established error indicator rather than only confirming loading completed.packages/react/src/components/auth0/my-organization/__tests__/domain-table.test.tsx (2)
1-1: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win"Pagination" tests don't exercise pagination behavior. Both suites mock a next-page cursor but only re-assert the same basic table/data presence already covered by the non-paginated rendering tests, so they wouldn't catch a pagination regression (e.g., missing "load more"/next-page control, or a second fetch never firing).
packages/react/src/components/auth0/my-organization/__tests__/domain-table.test.tsx#L733-745: assert an actual pagination-specific behavior (e.g., a "next page" control/fetch), not just that the table renders with the first page's domain.packages/react/src/components/auth0/my-organization/__tests__/organization-member-management.test.tsx#L521-564: same — verify pagination controls or a subsequent-page fetch rather than re-checking single-page table presence.🤖 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__/domain-table.test.tsx` at line 1, Strengthen the pagination tests in the domain-table and organization-member-management suites so they verify pagination-specific behavior, not merely initial table or data rendering. In the relevant tests, use the mocked next-page cursor to assert that the load-more/next-page control is rendered and/or activating it triggers the subsequent fetch and displays the next-page results, while preserving the existing first-page setup.
733-745: 🎯 Functional Correctness | 🔵 TrivialPagination test doesn't exercise pagination.
This test mocks no page/next-cursor data and only re-asserts basic table rendering — identical in substance to the "table rendering" tests above. It doesn't validate any pagination-specific behavior (e.g., page controls, fetching a second page). See consolidated comment for a related instance.
🤖 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__/domain-table.test.tsx` around lines 733 - 745, The pagination test for DomainTable currently only verifies basic table rendering and must exercise paginated behavior. Update the test setup to provide page or next-cursor data, then assert pagination-specific UI or behavior such as rendering controls and fetching or displaying a second page; keep the existing table-data assertion as appropriate.packages/react/src/components/auth0/my-organization/__tests__/sso-provider-edit.test.tsx (1)
869-884: 🎯 Functional Correctness | 🔵 TrivialError test doesn't verify an error was actually surfaced.
Only asserts "Loading..." disappears, which is equally true on a successful load. See consolidated comment for a related instance in
organization-details-edit.test.tsx.🤖 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 869 - 884, The “when provider fails to load” test only verifies that loading ends and does not assert error handling. Update the test around SsoProviderEdit and the mocked identityProviders.get rejection to verify the expected error UI or message is surfaced, while retaining the loading completion check if needed.
🤖 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 747-765: Strengthen the assertion in the customMessages test for
DomainTable so it specifically requires “Custom Domain Title” to be rendered.
Remove the alternative default-key match, while preserving the existing
table-rendering and loading checks.
---
Nitpick comments:
In
`@packages/react/src/components/auth0/my-organization/__tests__/domain-table.test.tsx`:
- Line 1: Strengthen the pagination tests in the domain-table and
organization-member-management suites so they verify pagination-specific
behavior, not merely initial table or data rendering. In the relevant tests, use
the mocked next-page cursor to assert that the load-more/next-page control is
rendered and/or activating it triggers the subsequent fetch and displays the
next-page results, while preserving the existing first-page setup.
- Around line 733-745: The pagination test for DomainTable currently only
verifies basic table rendering and must exercise paginated behavior. Update the
test setup to provide page or next-cursor data, then assert pagination-specific
UI or behavior such as rendering controls and fetching or displaying a second
page; keep the existing table-data assertion as appropriate.
In
`@packages/react/src/components/auth0/my-organization/__tests__/organization-details-edit.test.tsx`:
- Line 1: Strengthen the rejected-fetch tests in organization-details-edit and
sso-provider-edit so they verify the error outcome, not merely that loading
ends. After mocking fetch rejection, assert the rendered error indicator/message
(or the documented empty/default form state for organization-details-edit),
while retaining the existing loading-disappearance checks if useful.
- Around line 571-587: Strengthen the “when organization details fail to load”
test in the error handling suite by asserting the user-visible error state after
the rejected organizationDetails.get call. Keep the existing progressbar
assertion, and verify a specific error message, alert, or other established
error indicator rather than only confirming loading completed.
In
`@packages/react/src/components/auth0/my-organization/__tests__/organization-member-management.test.tsx`:
- Around line 764-786: Remove the later duplicate describe('styling') block and
its custom-class test from organization-member-management.test.tsx, keeping the
earlier styling.classes coverage unchanged.
- Around line 521-564: Strengthen the pagination tests in the pagination
describe block by asserting the next-page behavior rather than only initial
rendering. Verify pagination controls are shown when the mocked response
includes response.next, trigger the control, and assert the corresponding
members.list or invitations.list mock is called again with the next cursor; keep
the existing data-rendering assertions.
In
`@packages/react/src/components/auth0/my-organization/__tests__/sso-provider-edit.test.tsx`:
- Around line 869-884: The “when provider fails to load” test only verifies that
loading ends and does not assert error handling. Update the test around
SsoProviderEdit and the mocked identityProviders.get rejection to verify the
expected error UI or message is surfaced, while retaining the loading completion
check if needed.
In
`@packages/react/src/components/auth0/my-organization/__tests__/sso-provider-table.test.tsx`:
- Around line 848-858: Add a `hideHeader: true` test alongside the existing
`hideHeader: false` case in the `hideHeader` describe block for
`SsoProviderTable`. Render the table, wait for it to load, and assert that the
header text is not present, preserving the existing positive-case coverage.
🪄 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: 963415c3-6716-4ea5-9b90-b38bd849a015
📒 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-modal.test.tsx
- packages/react/src/components/auth0/my-account/shared/mfa/tests/delete-factor-confirmation.test.tsx
- packages/react/src/components/auth0/my-account/shared/mfa/tests/factors-list.test.tsx
- packages/react/src/components/auth0/my-account/shared/mfa/tests/otp-verification-form.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/organization-details.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/idp-management/sso-provider-delete/tests/provider-delete-modal.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-create/tests/domain-create-modal.test.tsx
- packages/react/src/components/auth0/my-account/shared/mfa/tests/empty-state.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/error-state.test.tsx
- packages/react/src/components/auth0/my-organization/shared/organization-management/organization-details/tests/branding-details.test.tsx
- packages/react/src/components/auth0/my-organization/shared/idp-management/sso-provider-remove/tests/provider-remove.test.tsx
- packages/react/src/components/auth0/my-organization/shared/domain-management/domain-delete/tests/domain-delete-modal.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/setting-details.test.tsx
- packages/react/src/components/auth0/my-account/tests/user-mfa-management.test.tsx
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