Skip to content

Gitops 9592 local admin UI test with playwright#1140

Open
trdoyle81 wants to merge 3 commits into
redhat-developer:masterfrom
trdoyle81:GITOPS-9592-Local-Admin-UI-test-with-Playwright
Open

Gitops 9592 local admin UI test with playwright#1140
trdoyle81 wants to merge 3 commits into
redhat-developer:masterfrom
trdoyle81:GITOPS-9592-Local-Admin-UI-test-with-Playwright

Conversation

@trdoyle81
Copy link
Copy Markdown
Member

@trdoyle81 trdoyle81 commented May 1, 2026

What type of PR is this?
/kind enhancement

What does this PR do / why we need it:
This PR is for the automated Playwright E2E UI test for the Local Admin login flow.

Have you updated the necessary documentation?

  • Documentation update is required by this PR.
  • Documentation has been updated.

Which issue(s) this PR fixes:
Fixes GITOPS-9592

Test acceptance criteria:

  • Unit Test
  • E2E Test

How to test changes / Special notes to the reviewer:
To verify the Local Admin UI test locally:

  1. Ensure you are logged into an active OpenShift cluster via your terminal (oc login...).
  2. Run the bash wrapper:
    ./run-ui-tests.sh tests/admin-login.spec.ts --project=chromium --headed
  3. The script will automatically use the CLI to fetch the GitOps cluster URLs and Admin password, bypass the SSO login, and run the Playwright test against the local admin dashboard.

@openshift-ci openshift-ci Bot added the kind/enhancement New feature or request label May 1, 2026
@openshift-ci openshift-ci Bot requested review from chetan-rns and keithchong May 1, 2026 12:12
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 1, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign chetan-rns for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@trdoyle81 trdoyle81 force-pushed the GITOPS-9592-Local-Admin-UI-test-with-Playwright branch from 7036e44 to 1addfed Compare May 8, 2026 08:08
@trdoyle81
Copy link
Copy Markdown
Member Author

/retest

Signed-off-by: Triona Doyle <bot@example.com>
@trdoyle81 trdoyle81 force-pushed the GITOPS-9592-Local-Admin-UI-test-with-Playwright branch from 1addfed to 5c28a95 Compare May 28, 2026 09:01
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a Playwright UI E2E test that extracts the Argo CD admin password and route host via oc, opens a fresh browser context, navigates to the Argo CD login page (dex=none), submits admin credentials, and asserts the sidebar is visible after login.

Changes

Argo CD Admin Login E2E Test

Layer / File(s) Summary
Credential extraction → browser login → verification
test/ui-e2e/tests/admin-login.spec.ts
New Playwright test that shells out to oc to extract admin.password and the openshift-gitops-server route host, creates an isolated browser context, navigates to https://{host}/login?dex=none, fills and submits admin credentials, and asserts sidebar visibility to confirm successful login.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly references the main change: adding a Playwright E2E test for local admin login (referenced as 'GITOPS-9592 local admin UI test with playwright').
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description clearly explains the purpose of adding a Playwright E2E UI test for Local Admin login flow and provides specific test instructions.

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


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.

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: 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 `@test/ui-e2e/tests/admin-login.spec.ts`:
- Around line 27-28: The selector for the username field is fragile: replace the
broad `page.getByRole('textbox').first()` usage (the `userField` variable) with
the more specific label-based selector used in LoginPage, e.g. use
`page.getByLabel(/Username/i)` (or call the LoginPage helper that returns the
username field) and keep the `waitFor({ state: 'visible', timeout: 20000 })` on
that specific locator so the test is resilient to additional textboxes being
added to the page.
- Around line 5-14: Wrap each execSync call (used to populate rawOutput and
routeUrl) in a try/catch and provide a timeout option (e.g., timeout in ms) to
prevent hanging; on error, throw or log a sanitized message that does not echo
the full command string but includes safe error details (error.message) so logs
don’t leak secrets/commands. After extracting password (the expression that
builds password from rawOutput), validate it is non-empty and throw a clear
error if malformed; likewise validate routeUrl.trim() is non-empty before use.
Ensure these changes target the execSync invocations and the password/routeUrl
variables in admin-login.spec.ts.
🪄 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: Enterprise

Run ID: c4376cc4-8089-44a0-b74a-90121ab983b8

📥 Commits

Reviewing files that changed from the base of the PR and between 3b6fb22 and 5c28a95.

📒 Files selected for processing (1)
  • test/ui-e2e/tests/admin-login.spec.ts

Comment thread test/ui-e2e/tests/admin-login.spec.ts Outdated
Comment thread test/ui-e2e/tests/admin-login.spec.ts Outdated
Signed-off-by: Triona Doyle <tekton@example.com>
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.

🧹 Nitpick comments (1)
test/ui-e2e/tests/admin-login.spec.ts (1)

30-52: ⚡ Quick win

Ensure browser context is always closed via finally.

If any step throws before Line 51, the manually created context can remain open and make UI suites flaky/resource-heavy. Wrap the test body after context creation in try/finally so cleanup always runs.

Proposed patch
   //Fresh context to avoid any cached state issues
   const context = await browser.newContext({ 
     storageState: { cookies: [], origins: [] },
     ignoreHTTPSErrors: true 
   });
-  
-  //Navigate and wait for the page to be loaded
-  const page = await context.newPage();
-  const loginUrl = `https://${routeUrl}/login?dex=none`;
-  await page.goto(loginUrl, { waitUntil: 'load' });
-
-  const userField = page.getByLabel(/username/i);
-  await userField.waitFor({ state: 'visible', timeout: 20000 });
-
-  //Fill and Sign In
-  await userField.fill('admin');
-  await page.locator('input[type="password"]').fill(password);
-  await page.getByRole('button', { name: /sign in/i }).click();
-
-  //Verify we're logged in
-  await expect(page.locator('.sidebar, [data-testid="sidebar"]').first()).toBeVisible({ timeout: 20000 });
-
-  await context.close();
+  try {
+    //Navigate and wait for the page to be loaded
+    const page = await context.newPage();
+    const loginUrl = `https://${routeUrl}/login?dex=none`;
+    await page.goto(loginUrl, { waitUntil: 'load' });
+
+    const userField = page.getByLabel(/username/i);
+    await userField.waitFor({ state: 'visible', timeout: 20000 });
+
+    //Fill and Sign In
+    await userField.fill('admin');
+    await page.locator('input[type="password"]').fill(password);
+    await page.getByRole('button', { name: /sign in/i }).click();
+
+    //Verify we're logged in
+    await expect(page.locator('.sidebar, [data-testid="sidebar"]').first()).toBeVisible({ timeout: 20000 });
+  } finally {
+    await context.close();
+  }
 });

As per coding guidelines, "-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity."

🤖 Prompt for 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.

In `@test/ui-e2e/tests/admin-login.spec.ts` around lines 30 - 52, The test creates
a Playwright context via browser.newContext (variable context) but may exit
early and never close it; wrap the steps after creating context (newContext,
newPage, navigation, interactions, assertions) in a try/finally and call await
context.close() in the finally block to guarantee cleanup even on failure;
locate the context/newPage usage and the final await context.close() in the
admin-login.spec.ts test and move the close into the finally to ensure resources
are always released.
🤖 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.

Nitpick comments:
In `@test/ui-e2e/tests/admin-login.spec.ts`:
- Around line 30-52: The test creates a Playwright context via
browser.newContext (variable context) but may exit early and never close it;
wrap the steps after creating context (newContext, newPage, navigation,
interactions, assertions) in a try/finally and call await context.close() in the
finally block to guarantee cleanup even on failure; locate the context/newPage
usage and the final await context.close() in the admin-login.spec.ts test and
move the close into the finally to ensure resources are always released.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 344270e1-6309-46cb-8ea0-97c83f75b53c

📥 Commits

Reviewing files that changed from the base of the PR and between 5c28a95 and c0d3b2b.

📒 Files selected for processing (1)
  • test/ui-e2e/tests/admin-login.spec.ts

…ly on failure

Signed-off-by: Triona Doyle <tekton@example.com>
@trdoyle81
Copy link
Copy Markdown
Member Author

/test v4.14-kuttl-parallel

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

Labels

kind/enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant