Skip to content

test(admin-ui): license flow test cases (#2904)#2906

Merged
duttarnab merged 4 commits into
mainfrom
admin-ui-issue-2904
Jun 26, 2026
Merged

test(admin-ui): license flow test cases (#2904)#2906
duttarnab merged 4 commits into
mainfrom
admin-ui-issue-2904

Conversation

@faisalsiddique4400

@faisalsiddique4400 faisalsiddique4400 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

test(admin-ui): license flow test cases (#2904)

Summary

This PR adds comprehensive Jest test coverage for the Admin UI License flow, including mocked API interactions for every stage of the license lifecycle.

The tests validate configuration verification, SSA upload, license activation, MAU threshold enforcement, trial license generation, and failure scenarios to ensure the License workflow behaves correctly under both successful and error conditions.


Fix Summary

  • Added comprehensive test coverage for the complete License flow
  • Mocked all license-related Config API endpoints
  • Added tests covering:
    • Configuration validation
    • SSA upload flow
    • Active license verification
    • License retrieval
    • Trial license generation
    • License activation
    • MAU threshold validation
  • Added success and failure path coverage for each API endpoint
  • Verified correct handling of:
    • licenseKey returned by the retrieve endpoint
    • license-key returned by the trial endpoint
  • Added tests covering:
    • valid license flow
    • missing configuration flow
    • invalid SSA handling
    • license retrieval failure
    • activation failure
    • trial license flow
    • MAU threshold exceeded flow
    • API error handling
    • network failure scenarios
  • Mocked prerequisite token retrieval required by license API requests
  • Improved confidence in License verification behavior and future regression detection

Verification

npm run test:all
npm run check:all

passes successfully.

  • Verified all License flow test cases pass successfully
  • Verified mocked API sequence matches the production License workflow
  • Verified success and failure scenarios for every License endpoint
  • Verified MAU threshold validation behavior
  • Verified trial and activation flows
  • Verified no regressions in existing test suites

🔗 Ticket

Closes: #2904

Summary by CodeRabbit

  • Tests
    • Expanded automated coverage for license, authentication, and redirect flows.
    • Added checks for key UI states such as loading, error messages, disabled/enabled actions, and file selection feedback.
    • Improved validation of list behavior, including labels, placeholders, styling, and error display handling.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

An error occurred during the review process. Please try again later.

📝 Walkthrough

Walkthrough

Adds tests for the license reducer and listener, license-gated UI wrappers, SSA upload interactions, and GluuDynamicList behavior.

Changes

Admin UI license-flow tests

Layer / File(s) Summary
License slice tests
admin-ui/app/redux/features/__tests__/licenseSlice.test.ts
licenseSlice tests cover initial state, license/config action reducers, SSA upload state, trial/retrieval flags, threshold updates, and error fields.
License listener tests
admin-ui/app/redux/listeners/__tests__/licenseListener.test.ts
Listener tests cover config checks, SSA upload token setup, license-present thresholds, retrieval-and-activation flows, and trial-license activation flows.
License gate tests
admin-ui/app/utils/__tests__/ApiKeyRedirect.test.tsx, admin-ui/app/utils/__tests__/AppAuthProvider.test.tsx
UI tests cover redirect loading, timeout suppression, backend-down rendering, unauthenticated fallback, and MAU-exceeded modal rendering.
UploadSSA tests
admin-ui/app/utils/__tests__/UploadSSA.test.tsx
UploadSSA tests cover disabled submit state, error display, selected-file dispatch payloads, and filename rendering.

Admin UI DynamicList tests

Layer / File(s) Summary
DynamicList tests
admin-ui/app/components/GluuDynamicList/__tests__/GluuDynamicList.test.tsx
GluuDynamicList tests cover add-button validation, label and pair placeholders, wrapper props, row keys, and whitespace-only error suppression.

Sequence Diagram(s)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

  • GluuFederation/flex issue 2900: Adds tests in the same admin-ui license state, listener, and component areas referenced by the issue.

Possibly related PRs

Suggested labels

kind-enhancement

Suggested reviewers

  • duttarnab
  • moabu

Poem

🐰 I hopped through reducers with a twitchy nose,
Listeners listened while the license flow grows.
Buttons learned patience, loaders learned to glow,
And DynamicList danced in a tidy row.
Carrot crumbs of coverage! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The GluuDynamicList test additions are generic component coverage and are not clearly tied to the license flow scope. Move the shared component coverage to a separate PR or explain how each assertion directly supports the license flow.
✅ Passed checks (4 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 Admin UI license flow test cases.
Linked Issues check ✅ Passed The new tests cover the Admin UI license flow with mocked APIs and success/failure paths, matching #2904.
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-2904

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.

Base automatically changed from admin-ui-issue-2891 to main June 26, 2026 09:36
@mo-auto mo-auto added area-CI Indicates work required in automatic builds or CI infrastructure comp-admin-ui Component affected by issue or PR labels Jun 26, 2026
Signed-off-by: faisalsiddique4400 <faisalsiddique10886@gmail.com>
Signed-off-by: faisalsiddique4400 <faisalsiddique10886@gmail.com>

@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: 3

🤖 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/GluuDynamicList/__tests__/GluuDynamicList.test.tsx`:
- Around line 188-192: The whitespace-only error test is vacuous because it
never queries the actual rendered error from GluuDynamicList. Update the
GluuDynamicList.test.tsx case to target the real error output from
renderList/showError handling, using the component’s rendered error node or
accessible query instead of the unrelated literal “Bad input”. Verify a
non-empty error renders first, then assert the whitespace-only errorMessage is
suppressed and that the assertion reflects error rendering rather than the empty
items state.

In `@admin-ui/app/redux/listeners/__tests__/licenseListener.test.ts`:
- Around line 59-63: The listener tests in licenseListener.test.ts currently
only assert final slice state and miss the token/bootstrap and request-shape
contract. Update the affected cases around the listener setup and adminuiPostSsa
calls to verify fetchApiTokenWithDefaultScopes is invoked, that the returned
access_token is passed through to the API client, and that forwarded request
data such as the SSA JWT is included in the adminuiPostSsa arguments. Use the
existing test helpers and mockedFetchToken/store setup to assert these boundary
interactions in the relevant license listener flows.
- Line 42: The test helper flush in licenseListener.test.ts is a timing guess
and should be removed in favor of waiting for the actual Redux state change.
Update the affected tests around the listener dispatch flows to assert on the
observed store state or expected action effects using a retry/wait pattern tied
to the specific state transition, rather than setTimeout(0). Use the existing
test cases and listener-triggering helpers in licenseListener.test.ts to locate
each flush call and replace it with deterministic assertions that only pass once
the listener chain has completed.
🪄 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: 49ee5e52-caea-472e-be0f-b9c126a9ff80

📥 Commits

Reviewing files that changed from the base of the PR and between 565d176 and 710a0cc.

📒 Files selected for processing (13)
  • admin-ui/app/components/CustomInput/__tests__/CustomInput.test.tsx
  • admin-ui/app/components/GluuDatePicker/__tests__/GluuDatePicker.test.tsx
  • admin-ui/app/components/GluuDropdown/__tests__/GluuDropdown.test.tsx
  • admin-ui/app/components/GluuDynamicList/__tests__/GluuDynamicList.test.tsx
  • admin-ui/app/components/GluuSearchToolbar/__tests__/GluuSearchToolbar.test.tsx
  • admin-ui/app/components/Sidebar/__tests__/Sidebar.test.tsx
  • admin-ui/app/redux/features/__tests__/licenseSlice.test.ts
  • admin-ui/app/redux/listeners/__tests__/licenseListener.test.ts
  • admin-ui/app/routes/Apps/Gluu/__tests__/GluuInputEditor.test.tsx
  • admin-ui/app/routes/Apps/Gluu/__tests__/GluuThemeFormFooter.test.tsx
  • admin-ui/app/utils/__tests__/ApiKeyRedirect.test.tsx
  • admin-ui/app/utils/__tests__/AppAuthProvider.test.tsx
  • admin-ui/app/utils/__tests__/UploadSSA.test.tsx

Comment thread admin-ui/app/components/GluuDynamicList/__tests__/GluuDynamicList.test.tsx Outdated
Comment thread admin-ui/app/redux/listeners/__tests__/licenseListener.test.ts Outdated
Comment thread admin-ui/app/redux/listeners/__tests__/licenseListener.test.ts
Signed-off-by: faisalsiddique4400 <faisalsiddique10886@gmail.com>
Signed-off-by: faisalsiddique4400 <faisalsiddique10886@gmail.com>
@sonarqubecloud

Copy link
Copy Markdown

@duttarnab duttarnab merged commit 3b5135f into main Jun 26, 2026
9 checks passed
@duttarnab duttarnab deleted the admin-ui-issue-2904 branch June 26, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CI Indicates work required in automatic builds or CI infrastructure comp-admin-ui Component affected by issue or PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(admin-ui): license flow test cases

3 participants