Skip to content

The Unified and Autonomous Development Platform

refactor: Update login input selectors for accessibility improvements

Robin Shenf12ebfd4fc91
diff --git a/e2e-test/tests/helpers.js b/e2e-test/tests/helpers.js
index 261a41bd71..25e1b004ba 100644
--- a/e2e-test/tests/helpers.js
+++ b/e2e-test/tests/helpers.js
@@ -5,7 +5,7 @@
*/
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.getByRole('textbox', { name: 'Login name or email address' }).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'));
diff --git a/e2e-test/tests/login-redirect.spec.js b/e2e-test/tests/login-redirect.spec.js
index 8b06151c59..3b0016ee52 100644
--- a/e2e-test/tests/login-redirect.spec.js
+++ b/e2e-test/tests/login-redirect.spec.js
@@ -39,7 +39,7 @@ test('restores a private issue comment fragment after login', async ({ page, api
expect(await page.evaluate(key => sessionStorage.getItem(key), storageKey)).toBe(target.hash);
// Submit the intercepted login form without navigating away from it.
- await page.getByPlaceholder('Login name or email address', { exact: true }).fill(admin.name);
+ await page.getByRole('textbox', { name: 'Login name or email address' }).fill(admin.name);
await page.locator('form input[type="password"]').fill(admin.password);
await page.getByRole('button', { name: 'Sign in', exact: true }).click();
await expect(page).toHaveURL(target.href);
@@ -89,7 +89,7 @@ for (const existingSession of [false, true]) {
await page.goto(target);
await expect(page).toHaveURL(/\/~login(?:[;?#]|$)/);
- const userName = page.getByPlaceholder('Login name or email address', { exact: true });
+ const userName = page.getByRole('textbox', { name: 'Login name or email address' });
const password = page.locator('form input[type="password"]');
const signIn = page.getByRole('button', { name: 'Sign in', exact: true });
await expect(signIn).toBeVisible();
@@ -158,7 +158,7 @@ test('replacing the login session closes old WebSockets and rejects the old cook
expect(replacementCookie?.value).toBeTruthy();
expect(replacementCookie.value).not.toBe(originalCookie.value);
- await loginTab.getByPlaceholder('Login name or email address', { exact: true }).fill(admin.name);
+ await loginTab.getByRole('textbox', { name: 'Login name or email address' }).fill(admin.name);
await loginTab.locator('form input[type="password"]').fill(admin.password);
await loginTab.getByRole('button', { name: 'Sign in', exact: true }).click();
await expect(loginTab.getByRole('button', { name: 'Save Settings', exact: true })).toBeVisible();