Skip to content

Conversation

@emmaaroche
Copy link
Contributor

@emmaaroche emmaaroche commented Nov 17, 2025

Description

This PR adds Playwright-based UI tests for the Policies page of the Kuadrant console plugin. The tests cover creating, listing, and deleting each policy type (Auth, DNS, RateLimit, TLS) within this page and are compatible with both PatternFly v5 and v6.

UI tests for additional console plugin pages and functionality will be introduced in future PRs.

Related issue: #556

Changes

New Features

  • UI Testing Framework: Added pytest-playwright dependency and ui pytest marker for browser-based testing

  • Page Objects:
    Added reusable page object classes under testsuite/page_objects/ to model the console plugin’s Policies views:

    • nav_bar.py and navigator.py for console navigation
    • Policy-specific page objects for the create and list pages:
      auth_policy.py, dns_policy.py, rate_limit_policy.py, tls_policy.py, along with the shared base class policies.py
  • Tests:
    Added under testsuite/tests/singlecluster/ui/console_plugin/policies/:

    • test_auth_policy.py - UI test for creating (YAML), listing, and deleting an AuthPolicy
    • test_rate_limit_policy.py - UI test for creating (YAML), listing, and deleting a RateLimitPolicy
    • test_dns_policy.py - UI tests for creating (form/YAML), listing, and deleting a DNSPolicy
    • test_tls_policy.py - UI tests for creating (form/YAML), listing, and deleting a TLSPolicy
    • conftest.py - Test configuration with browser setup, login automation, and console plugin enablement checks

Infrastructure Changes

  • Configuration: Updated Makefile and config/settings.local.yaml.tpl to support UI testing

Verification steps

Run the UI tests:

make ui

Run the UI tests and see browser session happening during the test:

 make ui flags="--headed --slowmo 1000" 

These tests require:

  • OpenShift cluster (tested on OCP 4.17 through to 4.20) with the Kuadrant / RHCL console plugin enabled
  • Valid HTPasswd credentials configured
  • Browser dependencies installed via playwright install

@emmaaroche emmaaroche self-assigned this Nov 17, 2025
@emmaaroche emmaaroche added the Test case New test case label Nov 17, 2025
Copy link
Contributor

@azgabur azgabur left a comment

Choose a reason for hiding this comment

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

WIP review, will check test cases later

Copy link
Contributor

@azgabur azgabur left a comment

Choose a reason for hiding this comment

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

DnsPolicy and TlsPolicy tests require separate Gateway as they attach to a specific Gateway + TlsPolicy needs different listener. I would separate the ui tests similrly that is now in singlecluster module. gateway tests which test dns/tls and gateway attachment tests, these should have gateway module scoped. And others which can keep the session gateway created in tests/conftest.py This can be achieved just by having module gateway with conftest simillar to that in gateway/conftest in singlecluster. This can also be a root problem of the errors Alex seen #815 (comment)

Makefile Outdated
@ touch .make-poetry-sync-no-dev

.make-playwright-install: .make-poetry-sync-no-dev
@if poetry run playwright install --check >/dev/null 2>&1; then \
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm 🤔

error: unknown option '--check'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My mistake, I thought that flag checked whether the Playwright browsers were already installed, and since make ui didn’t throw errors I assumed it worked 😅 I’ve removed it now 👍

Comment on lines 20 to 29
@pytest.fixture(scope="module")
def authorization():
"""Override parent authorization fixture - prevents unnecessary resource creation"""
return None


@pytest.fixture(scope="module")
def rate_limit():
"""Override parent rate limit fixture- prevents unnecessary resource creation"""
return None
Copy link
Contributor

Choose a reason for hiding this comment

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

I think instead of removing these fixtures you can override commit fixture to not do anything. You can than later use these fixtures in tests.

assert list_page.is_policy_listed(policy_name), f"AuthPolicy '{policy_name}' not found in list"

# Verify AuthPolicy created via UI enforces as expected
response = client.get("/get")
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing wait_for_ready before attempting request. Maybe the wait can be UI-based? There are columns "Accepted" and "Enforced".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The policy is already being waited on inside create_yaml():

self.page.wait_for_selector("text=AuthPolicy has been accepted", timeout=60000)

If you would like I can add a wait for enforced too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update - in new changes i have added a wait for enforced too



@pytest.mark.parametrize("create_method", ["form", "yaml"])
def test_tls_policy_ui(request, navigator, cluster, blame, gateway, cluster_issuer, create_method, client):
Copy link
Contributor

Choose a reason for hiding this comment

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

TlsPolicy tests requires presence of DnsPolicy as well. As well has Gateway having TLS listener. These are missing in this test. These could be made using API

Signed-off-by: emmaaroche <eroche@redhat.com>
Copy link
Contributor

@averevki averevki left a comment

Choose a reason for hiding this comment

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

LGTM, nice pages abstraction 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Test case New test case

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants