The Unified and Autonomous Development Platform
refactor: Enhance login function in e2e tests for better readability and reliability
Robin Shenc9d6f761ab39
diff --git a/e2e-test/tests/helpers.js b/e2e-test/tests/helpers.jsindex 071e161f26..a3863f6605 100644--- a/e2e-test/tests/helpers.js+++ b/e2e-test/tests/helpers.js@@ -7,10 +7,20 @@ import { expect } from '@playwright/test';*/export async function login(page, userName, password) {await page.goto('~login');- await page.getByPlaceholder('Login name or email address', { exact: true }).fill(userName);- await page.locator('form input[type="password"]').fill(password);- await page.getByRole('button', { name: 'Sign in' }).click();- await page.waitForURL((url) => !url.pathname.includes('~login'));+ const form = page.locator('form');+ const userNameInput = form.locator('input[name="userName"]');+ const passwordInput = form.locator('input[name="password"]');++ await expect(form).toBeVisible();+ await userNameInput.fill(userName);+ await passwordInput.fill(password);+ await expect(userNameInput).toHaveValue(userName);+ await expect(passwordInput).toHaveValue(password);++ await Promise.all([+ page.waitForURL((url) => !url.pathname.includes('~login')),+ form.getByRole('button', { name: 'Sign in' }).click(),+ ]);}/**