Skip to content

feat(admin-ui): add test files for all standalone components across the system#2912

Merged
duttarnab merged 4 commits into
mainfrom
admin-ui-issue-2896
Jun 30, 2026
Merged

feat(admin-ui): add test files for all standalone components across the system#2912
duttarnab merged 4 commits into
mainfrom
admin-ui-issue-2896

Conversation

@faisalsiddique4400

@faisalsiddique4400 faisalsiddique4400 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

feat(admin-ui): add test files for all standalone components across the system (#2896)

Summary

This PR expands the Admin UI test suite by adding test files for standalone components that previously had no dedicated test coverage.

The goal is to improve confidence in reusable UI components, reduce regression risk, and strengthen the overall Jest test suite by ensuring standalone components are independently validated across the application.


Fix Summary

  • Added test files for standalone components that previously had no test coverage
  • Increased unit test coverage across shared and reusable UI components
  • Added rendering and interaction tests for standalone components
  • Added validation for component props, default behavior, and conditional rendering where applicable
  • Improved consistency of component testing across Admin UI modules and plugins
  • Established a foundation for future component enhancements and regression testing
  • Aligned standalone component tests with existing Jest testing patterns

Verification

npm run test:all
npm run check:all

passes successfully.

  • Verified all newly added standalone component test files execute successfully
  • Verified existing test suites remain unaffected
  • Verified component rendering and interactions behave as expected
  • Verified lint and type-check pass successfully
  • Verified no regressions introduced by the additional test coverage

🔗 Ticket

Closes: #2896

Summary by CodeRabbit

  • Tests
    • Expanded automated coverage across the admin UI and plugins, including cards, layout, navigation, themes, menus, profile pages, dashboards, loaders, dialogs, and footer/header components.
    • Added broader checks for accessibility, theme switching, routing behavior, local storage persistence, and error handling.
  • Bug Fixes
    • Strengthened validation around URL handling and reserved claim definitions.
    • Improved reliability of stored settings and fallback behaviors for theme, logging, and storage-related features.

…he system (#2896)

Signed-off-by: faisalsiddique4400 <faisalsiddique10886@gmail.com>
Signed-off-by: faisalsiddique4400 <faisalsiddique10886@gmail.com>
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@faisalsiddique4400, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 11 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7936384b-23e0-40d8-8132-5158a716ca42

📥 Commits

Reviewing files that changed from the base of the PR and between 05e7798 and 556216a.

📒 Files selected for processing (12)
  • admin-ui/app/components/GluuPageContent/__tests__/GluuPageContent.test.tsx
  • admin-ui/app/components/Layout/__tests__/LayoutNavbar.test.tsx
  • admin-ui/app/components/SidebarMenu/__tests__/SidebarMenuItem.test.tsx
  • admin-ui/app/context/theme/__tests__/config.test.ts
  • admin-ui/app/context/theme/__tests__/themeContext.test.tsx
  • admin-ui/app/routes/Apps/Gluu/__tests__/GluuInputEditor.test.tsx
  • admin-ui/app/routes/Apps/Gluu/__tests__/GluuText.test.tsx
  • admin-ui/app/routes/Apps/Gluu/__tests__/ThemeDropdown.test.tsx
  • admin-ui/app/routes/Apps/Gluu/components/__tests__/UserIcon.test.tsx
  • admin-ui/app/routes/Apps/Profile/__tests__/ProfilePage.test.tsx
  • admin-ui/app/routes/Dashboards/Chart/__tests__/TooltipDesign.test.tsx
  • admin-ui/app/utils/__tests__/tooltipManager.test.ts
📝 Walkthrough

Walkthrough

Adds Jest/React Testing Library test files for approximately 30 UI components, hooks, context providers, route pages, and utility modules across admin-ui. One existing Constants.test.ts assertion is updated to use strict equality with explicit ordering for RESERVED_STANDARD_CLAIMS.

Changes

Test Coverage Additions

Layer / File(s) Summary
Utility tests
admin-ui/app/utils/__tests__/storage.test.ts, admin-ui/app/utils/__tests__/logLevel.test.ts, admin-ui/app/utils/__tests__/customColors.test.ts, admin-ui/app/utils/__tests__/tooltipManager.test.ts
New suites for storage (get/set/JSON/remove/clear with error-path coverage), logLevel (defaults, validation, localStorage error handling), customColors (hexToRgb, getLoadingOverlayRgba, getCustomColorsAsCssVars), and tooltipManager (mouseover/mouseout/focus lifecycle and listener registration).
Theme context and navbar hook tests
admin-ui/app/context/theme/__tests__/config.test.ts, admin-ui/app/context/theme/__tests__/themeContext.test.tsx, admin-ui/app/routes/Apps/Gluu/hooks/__tests__/useNavbarTheme.test.ts
New suites for getThemeColor (light/dark palette, fallback), ThemeProvider/useTheme (guard throw, state dispatch, localStorage persistence, documentElement class), and useNavbarTheme (returned values, injected CSS variable, unmount cleanup).
Navigation helper and hook tests
admin-ui/app/helpers/__tests__/navigation.test.ts, admin-ui/app/routes/Apps/Gluu/hooks/__tests__/usePageTitle.test.ts
New suites for ROUTES constants, useAppNavigation (navigateToRoute, navigateBack with/without history), and usePageTitle (default, stored, and updated title).
Shared component tests
admin-ui/app/components/Card/__tests__/Card.test.tsx, admin-ui/app/components/CardHeader/__tests__/CardHeader.test.tsx, admin-ui/app/components/GluuPageContent/__tests__/GluuPageContent.test.tsx, admin-ui/app/components/GluuSpinner/__tests__/GluuSpinner.test.tsx, admin-ui/app/components/Layout/__tests__/LayoutNavbar.test.tsx, admin-ui/app/components/Wizard/__tests__/WizardStep.test.tsx, admin-ui/app/components/Notifications/__tests__/Notifications.test.tsx, admin-ui/app/components/SidebarMenu/__tests__/SidebarMenuItem.test.tsx, admin-ui/app/routes/components/LogoThemed/__tests__/LogoThemed.test.tsx, admin-ui/plugins/admin/components/Webhook/__tests__/WebhookURLChecker.test.ts
New suites for Card, CardHeader, GluuPageContent, GluuSpinner, LayoutNavbar, WizardStep (classes, icons, click), Notifications (theme-driven icon filter), SidebarMenuItem (routing, active state, caret, dark theme icon), LogoThemed (theme filter, sizing, className), and WebhookURLChecker (URL validation rules).
Route-level page and component tests
admin-ui/app/routes/Apps/Gluu/__tests__/*, admin-ui/app/routes/Apps/Gluu/components/__tests__/UserIcon.test.tsx, admin-ui/app/routes/Apps/Profile/__tests__/ProfilePage.test.tsx, admin-ui/app/routes/Dashboards/.../__tests__/*, admin-ui/app/routes/components/.../__tests__/*, admin-ui/plugins/user-management/common/__tests__/Constants.test.ts
New suites for Gluu404Error, GluuInfo, GluuLoader, GluuStatusMessage, GluuText, ThemeDropdown (dispatch, localStorage persistence, merge), UserIcon (avatar fallback, error), ProfilePage (name/email/section labels, Edit navigation), TooltipDesign, StatusIndicator, UserInfoItem, DropdownProfile (logout dispatch and navigation), FooterAuth, HeaderAuth, FooterText; updated RESERVED_STANDARD_CLAIMS assertion to strict deep-equality.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • GluuFederation/flex#2893: Also adds Jest + React Testing Library tests for the WizardStep component.
  • GluuFederation/flex#2901: Modifies themeContext.tsx adding getStoredTheme(), which is directly exercised by the new themeContext.test.tsx in this PR.

Suggested labels

comp-admin-ui, kind-feature

Suggested reviewers

  • duttarnab
  • moabu

Poem

🐇 Hop hop, tests abound!
Every component, now found.
Themes checked, tooltips traced,
No bug goes un-chased.
The warren is safe, tests aground! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly states the PR adds test files for standalone components, matching the main change.
Linked Issues check ✅ Passed The added component and utility test files align with issue #2896's request for standalone component coverage across the system.
Out of Scope Changes check ✅ Passed The changes stay within test-file additions and a small related test update, with no obvious unrelated code.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch admin-ui-issue-2896

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mo-auto mo-auto added comp-admin-ui Component affected by issue or PR kind-feature Issue or PR is a new feature request labels Jun 30, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 11

🤖 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 `@admin-ui/app/components/GluuPageContent/__tests__/GluuPageContent.test.tsx`:
- Around line 40-49: The no-maxWidth test only verifies child text rendering and
does not protect the intended DOM shape. Tighten the existing GluuPageContent
test so it asserts the no-maxWidth branch in GluuPageContent directly, using the
component’s rendered container/inner wrapper behavior to confirm children are
mounted without the extra wrapper that appears when maxWidth is set.

In `@admin-ui/app/components/Layout/__tests__/LayoutNavbar.test.tsx`:
- Around line 32-42: The LayoutNavbar test currently leaves the console.error
spy unrestored if the render assertion throws before cleanup runs. Update the
test around the LayoutNavbar "throws when given more than one child" case so the
spy is always restored, either by wrapping the expect(render(...)).toThrow()
call in a try/finally or by moving the mock cleanup into an afterEach hook for
this test file.

In `@admin-ui/app/components/SidebarMenu/__tests__/SidebarMenuItem.test.tsx`:
- Around line 81-90: The active-state test is not exercising the active branch
because the mocked entries key does not match the generated entry id and the
assertion only checks the always-present structural class. Update the
SidebarMenuItem test to use a matching entry id in the renderItem entries mock
so the component resolves an active entry, then assert the active class behavior
via sidebarMenuActiveClass on the rendered li instead of only checking
sidebar-menu__entry.

In `@admin-ui/app/context/theme/__tests__/config.test.ts`:
- Line 8: The ThemeConfig tests are using identity checks that are too strict;
update the assertions in config.test.ts to avoid relying on object reuse from
themeConfig. Replace the toBe/not.toBe expectations around getThemeColor()
results with toEqual, toMatchObject, or field-level assertions so the tests
still pass if configs are cloned while preserving the same values.

In `@admin-ui/app/context/theme/__tests__/themeContext.test.tsx`:
- Around line 42-49: The theme context test is hardcoding the localStorage key
instead of using the shared storage key constant, so update the assertion in
themeContext.test.tsx to reference STORAGE_KEYS.INIT_THEME alongside useTheme
and THEME_LIGHT. This keeps the test aligned with the provider’s storage
contract and avoids duplicating the key value in the test.

In `@admin-ui/app/routes/Apps/Gluu/__tests__/GluuText.test.tsx`:
- Around line 38-46: The GluuText test only checks that some inline color is
set, which can miss regressions in the actual theme mapping. Update the test in
GluuText.test.tsx so it asserts the exact expected theme color used by GluuText,
ideally by reading the same theme source or token that AppTestWrapper provides,
and compare the element style against that specific value instead of just
checking it is non-empty.

In `@admin-ui/app/routes/Apps/Gluu/__tests__/ThemeDropdown.test.tsx`:
- Around line 54-60: The ThemeDropdown tests are hardcoding the persistence key
instead of using the shared storage contract. Update the assertions in
ThemeDropdown.test.tsx to reference STORAGE_KEYS.USER_CONFIG, matching the key
used by ThemeDropdown for reading and writing userConfig so the tests stay
aligned if the constant changes.

In `@admin-ui/app/routes/Apps/Gluu/components/__tests__/UserIcon.test.tsx`:
- Around line 16-28: The UserIcon tests only assert that a fallback image
exists, but they should verify the exact shared fallback value. Update the tests
around UserIcon to compare the rendered img src against DEFAULT_AVATAR_URL when
avatarUrl is null and after fireEvent.error(img), so the contract is checked
precisely instead of allowing any non-empty placeholder.

In `@admin-ui/app/routes/Apps/Profile/__tests__/ProfilePage.test.tsx`:
- Around line 134-141: The missing-surname test in ProfilePage is only verifying
the section renders, so it does not actually protect the dash fallback behavior.
Update the existing test around renderPage and screen.getByText to assert the
surname row shows a dash when mockUseProfileDetails returns surname as
undefined, using the ProfilePage rendering path and the personal information
labels to locate the exact row.

In `@admin-ui/app/routes/Dashboards/Chart/__tests__/TooltipDesign.test.tsx`:
- Around line 28-34: Update the TooltipDesign test so it asserts the mapped
label produced by the labelMap branch in renderTooltip, not just the payload
value; the current getByText(/42/) check in the “renders a mapped label with its
value when active” case can pass even if the "mau" mapping breaks. Use the
existing renderTooltip helper and TooltipDesign/labelMap-related output to
verify the translated label text appears alongside the value, so a regression in
the mau mapping is caught.

In `@admin-ui/app/utils/__tests__/tooltipManager.test.ts`:
- Around line 11-13: The tooltipManager test cleanup only clears the DOM, but
the module-level registry and listening state in tooltipManager.ts can still
leak between cases. Update the shared test cleanup in afterEach to also dispose
any registered tooltip listeners and reset tooltipManager state, using the
tooltipManager helpers and the listener disposer references used by the tests so
leaked callbacks cannot survive failed expectations.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 78f9966d-6708-41db-a67d-9da30b79e95e

📥 Commits

Reviewing files that changed from the base of the PR and between e8156ae and 05e7798.

📒 Files selected for processing (35)
  • admin-ui/app/components/Card/__tests__/Card.test.tsx
  • admin-ui/app/components/CardHeader/__tests__/CardHeader.test.tsx
  • admin-ui/app/components/GluuPageContent/__tests__/GluuPageContent.test.tsx
  • admin-ui/app/components/GluuSpinner/__tests__/GluuSpinner.test.tsx
  • admin-ui/app/components/Layout/__tests__/LayoutNavbar.test.tsx
  • admin-ui/app/components/Notifications/__tests__/Notifications.test.tsx
  • admin-ui/app/components/SidebarMenu/__tests__/SidebarMenuItem.test.tsx
  • admin-ui/app/components/Wizard/__tests__/WizardStep.test.tsx
  • admin-ui/app/context/theme/__tests__/config.test.ts
  • admin-ui/app/context/theme/__tests__/themeContext.test.tsx
  • admin-ui/app/helpers/__tests__/navigation.test.ts
  • admin-ui/app/routes/Apps/Gluu/__tests__/Gluu404Error.test.tsx
  • admin-ui/app/routes/Apps/Gluu/__tests__/GluuInfo.test.tsx
  • admin-ui/app/routes/Apps/Gluu/__tests__/GluuLoader.test.tsx
  • admin-ui/app/routes/Apps/Gluu/__tests__/GluuStatusMessage.test.tsx
  • admin-ui/app/routes/Apps/Gluu/__tests__/GluuText.test.tsx
  • admin-ui/app/routes/Apps/Gluu/__tests__/ThemeDropdown.test.tsx
  • admin-ui/app/routes/Apps/Gluu/components/__tests__/UserIcon.test.tsx
  • admin-ui/app/routes/Apps/Gluu/hooks/__tests__/useNavbarTheme.test.ts
  • admin-ui/app/routes/Apps/Gluu/hooks/__tests__/usePageTitle.test.ts
  • admin-ui/app/routes/Apps/Profile/__tests__/ProfilePage.test.tsx
  • admin-ui/app/routes/Dashboards/Chart/__tests__/TooltipDesign.test.tsx
  • admin-ui/app/routes/Dashboards/components/__tests__/StatusIndicator.test.tsx
  • admin-ui/app/routes/Dashboards/components/__tests__/UserInfoItem.test.tsx
  • admin-ui/app/routes/components/Dropdowns/__tests__/DropdownProfile.test.tsx
  • admin-ui/app/routes/components/LogoThemed/__tests__/LogoThemed.test.tsx
  • admin-ui/app/routes/components/Pages/__tests__/FooterAuth.test.tsx
  • admin-ui/app/routes/components/Pages/__tests__/HeaderAuth.test.tsx
  • admin-ui/app/routes/components/__tests__/FooterText.test.tsx
  • admin-ui/app/utils/__tests__/customColors.test.ts
  • admin-ui/app/utils/__tests__/logLevel.test.ts
  • admin-ui/app/utils/__tests__/storage.test.ts
  • admin-ui/app/utils/__tests__/tooltipManager.test.ts
  • admin-ui/plugins/admin/components/Webhook/__tests__/WebhookURLChecker.test.ts
  • admin-ui/plugins/user-management/common/__tests__/Constants.test.ts

Comment thread admin-ui/app/components/GluuPageContent/__tests__/GluuPageContent.test.tsx Outdated
Comment thread admin-ui/app/components/Layout/__tests__/LayoutNavbar.test.tsx Outdated
Comment thread admin-ui/app/components/SidebarMenu/__tests__/SidebarMenuItem.test.tsx Outdated
Comment thread admin-ui/app/context/theme/__tests__/config.test.ts Outdated
Comment thread admin-ui/app/context/theme/__tests__/themeContext.test.tsx
Comment thread admin-ui/app/routes/Apps/Gluu/__tests__/ThemeDropdown.test.tsx
Comment thread admin-ui/app/routes/Apps/Profile/__tests__/ProfilePage.test.tsx Outdated
Comment thread admin-ui/app/routes/Dashboards/Chart/__tests__/TooltipDesign.test.tsx Outdated
Comment thread admin-ui/app/utils/__tests__/tooltipManager.test.ts
@sonarqubecloud

Copy link
Copy Markdown

@duttarnab duttarnab merged commit d3f0ced into main Jun 30, 2026
8 checks passed
@duttarnab duttarnab deleted the admin-ui-issue-2896 branch June 30, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-admin-ui Component affected by issue or PR kind-feature Issue or PR is a new feature request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(admin-ui): Add test files for all the standalone components across the system.

3 participants