Gitops 9592 local admin UI test with playwright#1140
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
7036e44 to
1addfed
Compare
|
/retest |
Signed-off-by: Triona Doyle <bot@example.com>
1addfed to
5c28a95
Compare
📝 WalkthroughWalkthroughAdds a Playwright UI E2E test that extracts the Argo CD admin password and route host via ChangesArgo CD Admin Login E2E Test
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ 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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
test/ui-e2e/tests/admin-login.spec.ts
Signed-off-by: Triona Doyle <tekton@example.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/ui-e2e/tests/admin-login.spec.ts (1)
30-52: ⚡ Quick winEnsure 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/finallyso 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
📒 Files selected for processing (1)
test/ui-e2e/tests/admin-login.spec.ts
…ly on failure Signed-off-by: Triona Doyle <tekton@example.com>
|
/test v4.14-kuttl-parallel |
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?
Which issue(s) this PR fixes:
Fixes GITOPS-9592
Test acceptance criteria:
How to test changes / Special notes to the reviewer:
To verify the Local Admin UI test locally:
oc login...)../run-ui-tests.sh tests/admin-login.spec.ts --project=chromium --headed