Skip to content

test: add UI tests for OIDC, Plan, and TRLP policies#915

Merged
emmaaroche merged 1 commit intoKuadrant:mainfrom
emmaaroche:addtional-ui-policy-tests
Apr 14, 2026
Merged

test: add UI tests for OIDC, Plan, and TRLP policies#915
emmaaroche merged 1 commit intoKuadrant:mainfrom
emmaaroche:addtional-ui-policy-tests

Conversation

@emmaaroche
Copy link
Copy Markdown
Contributor

@emmaaroche emmaaroche commented Mar 30, 2026

Description

This PR adds UI tests for OIDCPolicy, PlanPolicy, and TokenRateLimitPolicy which are available in the console plugin in OCP versions 4.20+. These tests validate UI functionality without enforcement verification due to more complex setup requirements (OIDC providers, authentication, LLMsim backend). Functional tests already provide enforcement coverage for all three policies.

Note: These tests require OCP 4.20+ and will be skipped on older versions.

Changes

New Tests

  • test_oidc_policy.py: Tests OIDCPolicy CRUD operations via UI and validates child AuthPolicy creation and deletion (main + callback)
  • test_plan_policy.py: Tests PlanPolicy CRUD operations via UI and validates child RateLimitPolicy creation and deletion
  • test_token_rate_limit_policy.py: Tests TokenRateLimitPolicy CRUD operations via UI

New Page Objects

  • oidc_policy.py: Page object for OIDCPolicy creation and list pages
  • plan_policy.py: Page object for PlanPolicy creation and list pages
  • token_rate_limit.py: Page object for TokenRateLimitPolicy creation and list pages

Additional Changes

  • policies.py: Adds navigation tabs and methods for the 3 new policy types
  • policies_new_page.py: Adds check_enforcement flag to skip enforcement validation for policies requiring a more complex setup
  • token_rate_limit.py: Adds namespace in TokenRateLimitPolicy.create_instance() metadata

Verification steps

Run the new UI policy tests in parallel:

poetry run pytest -vv -n4 \
testsuite/tests/singlecluster/ui/console_plugin/policies/test_oidc_policy.py \
testsuite/tests/singlecluster/ui/console_plugin/policies/test_plan_policy.py \
testsuite/tests/singlecluster/ui/console_plugin/policies/test_token_rate_limit_policy.py

Run all UI tests:

make ui

Summary by CodeRabbit

  • New Features

    • Console plugin UI: added list and YAML creation flows for TokenRateLimit, OIDC and Plan policies, plus new tabs for quick navigation.
  • Bug Fixes

    • TokenRateLimitPolicy creation now includes namespace metadata correctly.
  • Tests

    • Added end-to-end UI tests for TokenRateLimit, OIDC and Plan policies and made enforcement check configurable for creation flows.

@emmaaroche emmaaroche self-assigned this Mar 30, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 30, 2026

📝 Walkthrough

Walkthrough

Adds UI page objects and end-to-end console-plugin tests for TokenRateLimitPolicy, OIDCPolicy and PlanPolicy; makes BasePolicyNewPageYaml enforcement check configurable; fixes TokenRateLimitPolicy.create_instance() to set the model metadata.namespace to the cluster project.

Changes

Cohort / File(s) Summary
Policy Model Updates
testsuite/kuadrant/policy/token_rate_limit.py
Set metadata.namespace = cluster.project when creating TokenRateLimitPolicy instances.
Page Objects — Core Infrastructure
testsuite/page_objects/policies/policies_new_page.py
Added check_enforcement: bool = True to BasePolicyNewPageYaml; subclasses may disable enforcement confirmation waits.
Page Objects — Navigation Hub
testsuite/page_objects/policies/policies.py
Added tabs and navigation methods for TokenRateLimit, OIDC and Plan policy list pages; is_displayed() now validates seven tabs.
Page Objects — New Policy Types
testsuite/page_objects/policies/token_rate_limit.py, testsuite/page_objects/policies/oidc_policy.py, testsuite/page_objects/policies/plan_policy.py
New policy-type mixins, YAML creation page objects (with check_enforcement = False) and list page objects with new() navigation for TokenRateLimit, OIDC and Plan policies.
UI Tests — Lifecycle Validation
testsuite/tests/singlecluster/ui/console_plugin/policies/test_token_rate_limit_policy.py, testsuite/tests/singlecluster/ui/console_plugin/policies/test_oidc_policy.py, testsuite/tests/singlecluster/ui/console_plugin/policies/test_plan_policy.py
Added end-to-end UI tests (OCP 4.20+) that create, verify list presence, and delete policies via the console UI; tests register API finalizers and check child resource creation/deletion where applicable.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested labels

Test case

Suggested reviewers

  • trepel
  • averevki
  • azgabur
  • silvi-t
  • zkraus

Poem

🐰 I hopped through pages, YAML in paw,
New policies sprouted where tests saw,
Token, OIDC, Plan in a row,
UI clicks, creations, and deletes on show,
A tiny rabbit cheers—tests ready to go!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly summarizes the main change: adding UI tests for three policy types (OIDC, Plan, and TRLP), which is the primary objective of the changeset.
Description check ✅ Passed The PR description comprehensively covers the purpose, lists all changes (tests, page objects, modifications), and provides clear verification steps, closely following the repository template structure.
Docstring Coverage ✅ Passed Docstring coverage is 92.31% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 30, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@testsuite/tests/singlecluster/ui/console_plugin/policies/test_plan_policy.py`:
- Around line 44-65: The assertions that check for the child RateLimitPolicy
being created and later deleted are immediate and can race with controller
reconciliation; wrap both checks in an eventual wait/polling loop (e.g., retry
until timeout) using the page helper methods instead of direct asserts: poll
rlp_list_page.is_policy_listed(policy_name) until true after creation and poll
until false after deletion. Use navigator.navigate(RateLimitListPage) to refresh
the page inside the retry, and reuse PlanPolicyListPage/list_page.delete for
delete action; fail only after the timeout so the test is resilient to
reconciliation lag.
🪄 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: CHILL

Plan: Pro

Run ID: a12823d6-78aa-4beb-bc1f-9a8470de62fe

📥 Commits

Reviewing files that changed from the base of the PR and between 1aee51b and 7c03a79.

📒 Files selected for processing (9)
  • testsuite/kuadrant/policy/token_rate_limit.py
  • testsuite/page_objects/policies/oidc_policy.py
  • testsuite/page_objects/policies/plan_policy.py
  • testsuite/page_objects/policies/policies.py
  • testsuite/page_objects/policies/policies_new_page.py
  • testsuite/page_objects/policies/token_rate_limit.py
  • testsuite/tests/singlecluster/ui/console_plugin/policies/test_oidc_policy.py
  • testsuite/tests/singlecluster/ui/console_plugin/policies/test_plan_policy.py
  • testsuite/tests/singlecluster/ui/console_plugin/policies/test_token_rate_limit_policy.py

Comment thread testsuite/page_objects/policies/oidc_policy.py Outdated
Comment thread testsuite/page_objects/policies/plan_policy.py Outdated
Comment thread testsuite/page_objects/policies/policies_new_page.py Outdated
Copy link
Copy Markdown
Contributor

@zkraus zkraus left a comment

Choose a reason for hiding this comment

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

Tests are passing for me. Code looks clean and readable.

Review touching on 2 points

  • Magic number timeout=60000 -> introduce a shared and documented constant for this withing UI tests
  • (if possible) Unify form creating Limit() in various tests (PlanPolicy vs TokenRateLimitPolicy)

Comment thread testsuite/page_objects/policies/token_rate_limit.py Outdated
Comment thread testsuite/page_objects/policies/policies_new_page.py Outdated
@emmaaroche
Copy link
Copy Markdown
Contributor Author

emmaaroche commented Apr 14, 2026

@zkraus I agree with your Repeat comment suggestion. Since there are also other existing UI tests from previous PRs that use timeout=60000, I think it makes more sense to refactor all of the existing UI tests together in a separate PR using a proper constant. I’ll open that soon, and once it is merged I can rebase this PR so these tests follow the same approach 👍

Signed-off-by: emmaaroche <eroche@redhat.com>
@emmaaroche emmaaroche force-pushed the addtional-ui-policy-tests branch from 7c03a79 to c654624 Compare April 14, 2026 14:26
coderabbitai[bot]

This comment was marked as resolved.

@emmaaroche emmaaroche requested a review from zkraus April 14, 2026 14:58
Copy link
Copy Markdown
Contributor

@zkraus zkraus left a comment

Choose a reason for hiding this comment

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

Requested changes addressed, new tests are passing.
LGTM.

@emmaaroche emmaaroche merged commit 55e7caa into Kuadrant:main Apr 14, 2026
6 checks passed
@emmaaroche emmaaroche deleted the addtional-ui-policy-tests branch April 14, 2026 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants