Skip to content

feat(admin-ui): add test files for all helpers and utility files across the system (#2891)#2894

Merged
duttarnab merged 5 commits into
mainfrom
admin-ui-issue-2891
Jun 26, 2026
Merged

feat(admin-ui): add test files for all helpers and utility files across the system (#2891)#2894
duttarnab merged 5 commits into
mainfrom
admin-ui-issue-2891

Conversation

@faisalsiddique4400

@faisalsiddique4400 faisalsiddique4400 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

feat(admin-ui): add test files for all helpers and utility files across the system (#2891)

Summary

This PR expands automated test coverage across the Admin UI by adding test files for helper and utility modules throughout the codebase.

The objective is to ensure shared business logic, data transformations, validation helpers, formatting utilities, and common helper functions are covered by automated tests. This improves confidence in core functionality, reduces regression risk, and strengthens the overall Jest test suite.


Fix Summary

  • Added test files for helper modules across the application
  • Added test files for utility modules across the application
  • Increased coverage for shared business logic and reusable functions
  • Added validation coverage for common utility methods
  • Added coverage for data transformation and formatting helpers
  • Added edge-case and error-handling scenarios where applicable
  • Improved consistency of test coverage across shared modules
  • Established testing patterns for future helper and utility development
  • Reduced the number of untested helper and utility files in the codebase
  • Improved long-term maintainability and regression protection

Verification

npm run test:all
npm run check:all

passes successfully.

  • Verified newly added helper test suites execute successfully
  • Verified newly added utility test suites execute successfully
  • Verified existing test suites continue to pass
  • Verified helper and utility logic behaves as expected
  • Verified no regressions introduced by the additional coverage
  • Verified lint and type-check pass successfully

🔗 Ticket

Closes: #2891

Summary by CodeRabbit

  • Tests
    • Added broad unit test coverage across admin UI utilities and plugin helpers.
    • Verified date, string, paging, menu, query, validation, formatting, and error-handling behaviors.
    • Added coverage for audit logging, webhook, settings, asset, client, and user-management helpers.
    • Expanded checks for constants, payload building, file download flow, and data transformation utilities.
    • Improved confidence in edge cases such as missing values, invalid input, and fallback behavior.

…ss the system (#2891)

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

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds 30+ new Jest test files across the admin-ui codebase, covering app-level utilities (Util, dayjsUtils, errorHandler, regex, pagingUtils, menuFilters, queryUtils, etc.), audit logging helpers (logAuditUserAction, buildPayload, logAuditAction, enhanceJsonConfigAuditPayload), admin plugin helpers and validation schemas, auth-server plugin utilities, SSA date/file utilities, and user-management constants. No production code is modified.

Changes

Admin UI Unit Test Coverage Expansion

Layer / File(s) Summary
Core app utility tests
admin-ui/app/utils/__tests__/Util.test.ts, admin-ui/app/utils/__tests__/dayjsUtils.test.ts, admin-ui/app/utils/__tests__/errorHandler.test.ts, admin-ui/app/utils/__tests__/licenseUtils.test.ts, admin-ui/app/utils/__tests__/menuFilters.test.ts, admin-ui/app/utils/__tests__/pagingUtils.test.ts, admin-ui/app/utils/__tests__/placeholderUtils.test.ts, admin-ui/app/utils/__tests__/queryUtils.test.ts, admin-ui/app/utils/__tests__/regex.test.ts, admin-ui/app/utils/__tests__/stringUtils.test.ts, admin-ui/app/utils/__tests__/buttonUtils.test.ts, admin-ui/app/utils/validation/__tests__/commitMessage.test.ts
New Jest suites for UUID/scope/date/string formatting, date comparison/parsing, error message precedence, license field display, menu health/auth filtering, paging size persistence, placeholder interpolation, React Query defaults, ~40 regex patterns, key candidate generation, and commit message length validation.
Audit logging utility tests
admin-ui/app/utils/__tests__/AuditLogger.test.ts, admin-ui/app/utils/__tests__/auditAction.test.ts, admin-ui/plugins/scripts/components/helper/__tests__/auditUtils.test.ts, admin-ui/plugins/auth-server/redux/utils/__tests__/auditHelpers.test.ts
New test suites for logAuditUserAction (audit record construction, identity defaults, status forwarding), buildPayload (in-place mutation, null/array payload handling), logAuditAction (audit init, error handling, rejection coercion), and enhanceJsonConfigAuditPayload (patch-based message derivation for delete/create/update/fallback).
Admin plugin helper tests
admin-ui/plugins/admin/helper/__tests__/assets.test.ts, admin-ui/plugins/admin/helper/__tests__/settings.test.ts, admin-ui/plugins/admin/helper/__tests__/webhook.test.ts, admin-ui/plugins/admin/components/MAU/utils/__tests__/dataAugmentation.test.ts, admin-ui/plugins/admin/components/MAU/utils/__tests__/formatters.test.ts, admin-ui/plugins/admin/components/Health/utils/__tests__/formatters.test.ts
New test suites for buildAssetInitialValues (defaults, field mapping, fallbacks), buildSettingsInitialValues (cedarlingLogType default, additionalParameters filtering), webhook helpers (toWebhookEntries, hasHttpBody, isLastHeaderComplete, buildWebhookInitialValues), MAU data augmentation (formatDateForApi, transformRawStatEntry, augmentMauData), MAU formatters (formatMonth, formatNumber, calculatePercentChange), and formatServiceName.
Admin plugin validation schema tests
admin-ui/plugins/admin/helper/validations/__tests__/assetValidation.test.ts, admin-ui/plugins/admin/helper/validations/__tests__/settingsValidation.test.ts, admin-ui/plugins/admin/helper/validations/__tests__/webhookValidation.test.ts
New test suites for getAssetValidationSchema (create vs edit mode, fileName/service/document rules), getSettingsValidationSchema (sessionTimeoutInMins bounds, additionalParameters key-value constraints), and getWebhookValidationSchema (HTTP method, URL, conditional body, header rules).
Auth-server plugin utility tests
admin-ui/plugins/auth-server/common/__tests__/Constants.test.ts, admin-ui/plugins/auth-server/components/Authentication/Acrs/helper/__tests__/acrUtils.test.ts, admin-ui/plugins/auth-server/components/ConfigApiProperties/utils/__tests__/typeGuards.test.ts, admin-ui/plugins/auth-server/components/ConfigApiProperties/utils/__tests__/useConfigApiActions.test.ts, admin-ui/plugins/auth-server/components/ConfigApiProperties/utils/__tests__/valueUtils.test.ts, admin-ui/plugins/auth-server/components/Ssa/utils/__tests__/dateFormatters.test.ts, admin-ui/plugins/auth-server/components/Ssa/utils/__tests__/fileDownload.test.ts, admin-ui/plugins/auth-server/utils/__tests__/clientUtils.test.ts
New test suites for SCOPE_TYPES constants, ACR helpers (displayOrDash, getPropertiesConfig, isDefaultAuthNMethod, transformConfigurationProperties, buildAgamaFlowsArray, buildDropdownOptions), ConfigAPI type guards and getter helpers, useConfigApiActions audit hook, JSON-patch value removal utilities, SSA date formatters (formatExpirationDate, toEpochSecondsFromDayjs), JWT file download (Blob URL lifecycle, filename pattern), and client utility helpers (validators, grant types, dynamic list helpers).
User-management constants tests
admin-ui/plugins/user-management/common/__tests__/Constants.test.ts
New test suite asserting exact string values for user-management attribute name constants, STANDARD_FORM_FIELDS array contents, and RESERVED_STANDARD_CLAIMS length.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • GluuFederation/flex#2424: Introduces the useAgamaActions audit hook backed by logAuditUserAction, which is now directly exercised by the new AuditLogger.test.ts suite.
  • GluuFederation/flex#2717: Implements buildKeyCandidates and the related regex helpers in admin-ui/app/utils, which are the subject of the new stringUtils.test.ts and regex.test.ts suites.
  • GluuFederation/flex#2791: Introduces the toApiDatetime implementation and API_DATETIME format constant in dayjsUtils, now covered by the new dayjsUtils.test.ts suite.

Suggested labels

kind-enhancement

Suggested reviewers

  • duttarnab
  • moabu
  • syntrydy

Poem

🐰 Hop, hop, hooray, the tests are here today!
Each helper and util, no longer left to chance,
From regex to webhooks, they all get to dance.
The audit logs checked, the schemas all tried,
With Jest on my side, no bug can hide! 🎉

🚥 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 summarizes the main change: adding test files for helpers and utilities across admin-ui.
Linked Issues check ✅ Passed The PR adds Jest tests across admin-ui helper and utility modules, matching the issue's request for broader test coverage.
Out of Scope Changes check ✅ Passed The changes are limited to new test files and do not introduce unrelated code or features.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch admin-ui-issue-2891

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 24, 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: 2

🤖 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/plugins/auth-server/components/Authentication/Acrs/helper/__tests__/acrUtils.test.ts`:
- Around line 90-92: The test named for the non-array guard in acrUtils.test.ts
is using an empty array, so it does not cover the invalid-input branch in
buildAgamaFlowsArray. Update this test to pass a true non-array value and keep
the assertion for an empty result, so the guard path in buildAgamaFlowsArray is
actually exercised.

In `@admin-ui/plugins/user-management/common/__tests__/Constants.test.ts`:
- Around line 38-45: The Constants.test currently only checks partial membership
for RESERVED_STANDARD_CLAIMS, so it can miss accidental changes to the
unasserted entries. Tighten the test in the Constants.test suite by replacing
the piecemeal contains/length checks with a single exact equality assertion
against the full expected array, using STANDARD_FORM_FIELDS and the reserved
symbols like USER_PASSWORD_ATTR and uid as the reference points.
🪄 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: ccea8001-719b-4eba-a826-c915d2c382d6

📥 Commits

Reviewing files that changed from the base of the PR and between fe348f1 and 7ecf218.

📒 Files selected for processing (34)
  • admin-ui/app/utils/__tests__/AuditLogger.test.ts
  • admin-ui/app/utils/__tests__/Util.test.ts
  • admin-ui/app/utils/__tests__/auditAction.test.ts
  • admin-ui/app/utils/__tests__/buttonUtils.test.ts
  • admin-ui/app/utils/__tests__/dayjsUtils.test.ts
  • admin-ui/app/utils/__tests__/errorHandler.test.ts
  • admin-ui/app/utils/__tests__/licenseUtils.test.ts
  • admin-ui/app/utils/__tests__/menuFilters.test.ts
  • admin-ui/app/utils/__tests__/pagingUtils.test.ts
  • admin-ui/app/utils/__tests__/placeholderUtils.test.ts
  • admin-ui/app/utils/__tests__/queryUtils.test.ts
  • admin-ui/app/utils/__tests__/regex.test.ts
  • admin-ui/app/utils/__tests__/stringUtils.test.ts
  • admin-ui/app/utils/validation/__tests__/commitMessage.test.ts
  • admin-ui/plugins/admin/components/Health/utils/__tests__/formatters.test.ts
  • admin-ui/plugins/admin/components/MAU/utils/__tests__/dataAugmentation.test.ts
  • admin-ui/plugins/admin/components/MAU/utils/__tests__/formatters.test.ts
  • admin-ui/plugins/admin/helper/__tests__/assets.test.ts
  • admin-ui/plugins/admin/helper/__tests__/settings.test.ts
  • admin-ui/plugins/admin/helper/__tests__/webhook.test.ts
  • admin-ui/plugins/admin/helper/validations/__tests__/assetValidation.test.ts
  • admin-ui/plugins/admin/helper/validations/__tests__/settingsValidation.test.ts
  • admin-ui/plugins/admin/helper/validations/__tests__/webhookValidation.test.ts
  • admin-ui/plugins/auth-server/common/__tests__/Constants.test.ts
  • admin-ui/plugins/auth-server/components/Authentication/Acrs/helper/__tests__/acrUtils.test.ts
  • admin-ui/plugins/auth-server/components/ConfigApiProperties/utils/__tests__/typeGuards.test.ts
  • admin-ui/plugins/auth-server/components/ConfigApiProperties/utils/__tests__/useConfigApiActions.test.ts
  • admin-ui/plugins/auth-server/components/ConfigApiProperties/utils/__tests__/valueUtils.test.ts
  • admin-ui/plugins/auth-server/components/Ssa/utils/__tests__/dateFormatters.test.ts
  • admin-ui/plugins/auth-server/components/Ssa/utils/__tests__/fileDownload.test.ts
  • admin-ui/plugins/auth-server/redux/utils/__tests__/auditHelpers.test.ts
  • admin-ui/plugins/auth-server/utils/__tests__/clientUtils.test.ts
  • admin-ui/plugins/scripts/components/helper/__tests__/auditUtils.test.ts
  • admin-ui/plugins/user-management/common/__tests__/Constants.test.ts

Comment thread admin-ui/plugins/user-management/common/__tests__/Constants.test.ts
@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

@duttarnab duttarnab merged commit 565d176 into main Jun 26, 2026
6 checks passed
@duttarnab duttarnab deleted the admin-ui-issue-2891 branch June 26, 2026 09:36
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 helpers and the utils files across the system.

3 participants