Skip to content

Fix unreliable login form submission in Playwright UI smoke tests#146

Merged
vharseko merged 2 commits into
copilot/add-playwright-ui-smoke-testsfrom
copilot/fix-login-button-click-issue
Apr 7, 2026
Merged

Fix unreliable login form submission in Playwright UI smoke tests#146
vharseko merged 2 commits into
copilot/add-playwright-ui-smoke-testsfrom
copilot/fix-login-button-click-issue

Conversation

Copilot AI commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

The page.click("[type=submit], .btn-primary") selector was not reliably targeting the login button in the OpenIDM Admin UI, causing the form to never submit and leaving the #login field visible post-attempt.

Changes

  • Both login tests (Admin UI login with openidm-admin succeeds, Admin UI - Dashboard page loads after login): replace button selector click with page.press("#password", "Enter") to submit via native form submission
  • Add waitForTimeout(2000) before waitForFunction in both tests to allow the SPA to begin processing the login before asserting post-login state
// Before
await page.click("[type=submit], .btn-primary");
await page.waitForFunction(() => { ... }, { timeout: 30000 });

// After
await page.press("#password", "Enter");
await page.waitForTimeout(2000);
await page.waitForFunction(() => { ... }, { timeout: 30000 });
Original prompt

Failing Job

The Playwright UI smoke test "Admin UI login with openidm-admin succeeds" is failing in CI (workflow run: https://github.com/OpenIdentityPlatform/OpenIDM/actions/runs/24074275491/job/70219158366, PR #145).

Error

expect(received).toBe(expected) // Object.is equality
Expected: false
Received: true

At e2e/ui-smoke-test.spec.mjs:33:

const loginField = await page.$("#login");
const isLoginVisible = loginField ? await loginField.isVisible() : false;
expect(isLoginVisible).toBe(false);

The #login field is still visible after the login attempt, meaning the login form didn't actually submit and the UI stayed on the login page.

Root Cause

The login button click on line 23 is not reliably clicking the actual submit button:

await page.click("[type=submit], .btn-primary");

The CSS selector list [type=submit], .btn-primary may not match the actual login button in the OpenIDM Admin UI, or may match a different element first.

Required Fix

In e2e/ui-smoke-test.spec.mjs, update both the "Admin UI login with openidm-admin succeeds" test (line 17) and the "Admin UI - Dashboard page loads after login" test (line 67) to use a more reliable form submission approach. Replace:

await page.click("[type=submit], .btn-primary");

with pressing Enter on the password field:

await page.press("#password", "Enter");

This submits the form directly via the password field, which is more reliable than trying to find and click the correct button element. The page.press("#password", "Enter") approach works because the #password field is inside a <form> element — pressing Enter on an input inside a form triggers form submission.

Additionally, after pressing Enter, add a brief wait for the page to transition before checking login state. Use:

await page.waitForTimeout(2000);

before the waitForFunction call, to give the SPA time to start processing the login.

Specifically, the changes needed are:

Test "Admin UI login with openidm-admin succeeds" (around line 23):

  • Change await page.click("[type=submit], .btn-primary"); to await page.press("#password", "Enter");
  • Optionally add a small waitForTimeout(2000) before the waitForFunction block

Test "Admin UI - Dashboard page loads after login" (around line 72):

  • Change await page.click("[type=submit], .btn-primary"); to await page.press("#password", "Enter");
  • Optionally add a small waitForTimeout(2000) before the waitForFunction block

No other files need to change.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Please find a solution for this failing job. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.

Assistant:

I'll start by fetching the job logs and the workflow definition to understand the failure.

Assistant: The failing test is Admin UI login with openidm-admin succeeds in the Playwright e2e test file. Let me look at the test file and the workflow definition.

Assistant: ## Failing Test: "Admin UI login with openidm-admin succeeds"

The job fails in the Playwright UI Smoke Tests step. Specifically, the test at e2e/ui-smoke-test.spec.mjs:17"Admin UI login with openidm-admin succeeds" — fails on both the initial run and the retry with:

expect(received).toBe(expected) // Object.is equality
Expected: false
Received: true

This means the #login field is still visible after the login attempt, indicating the login didn't actually succeed and the UI remained on the login page.

Root Cause

The test (lines 21–33) fills in credentials, clicks submit, then waits for a post-login element (#content, .navbar, or #wrapper) to appear. The issue is on line 23:

await page.click("[type=submit], .btn-primary");

The selector [type=submit], .btn-primary is a CSS selector list. Playwright's page.click() may match the first element in the DOM that matches either selector — which might not be the actual login button. If the OpenIDM Admin UI login button doesn't match either of these selectors exactly (or if there's another element matching first), the click has no effect and the login form stays visible.

Solution

Update the click selector to more precisely target the login button. Inspect what the actual Admin UI renders — it's typically an input or button inside the login form. A more robust approach:

// e2e/ui-smoke-test.spec.mjs - line 17 test
test("Admin UI login with openidm-admin succeeds", async ({ page }) => {
    await page.goto(`${BASE_URL}/admin/`);
    await page.waitForSelector("#login", { timeou...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

*This pull request was created from Copilot chat.*
>

Copilot AI changed the title [WIP] Fix login button click issue in Admin UI smoke test Fix unreliable login form submission in Playwright UI smoke tests Apr 7, 2026
Copilot AI requested a review from vharseko April 7, 2026 13:39
@vharseko vharseko marked this pull request as ready for review April 7, 2026 15:36
@vharseko vharseko merged commit 64903b1 into copilot/add-playwright-ui-smoke-tests Apr 7, 2026
14 checks passed
@vharseko vharseko deleted the copilot/fix-login-button-click-issue branch April 7, 2026 15:36
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.

2 participants