Use server-rendered title attribute for dropdown locator

Replace JS-dependent getByLabel (aria-label set by Fomantic init) with
getByTitle targeting the avatar's server-rendered title attribute, scoped
to the navigation bar. Extract reusable clickDropdownItem helper.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
silverwind
2026-02-18 03:03:15 +01:00
co-authored by Claude Opus 4.6
parent 40446b8795
commit 5354352bee
+8 -3
View File
@@ -1,6 +1,11 @@
import {env} from 'node:process';
import {expect} from '@playwright/test';
import type {Page} from '@playwright/test';
import type {Locator, Page} from '@playwright/test';
export async function clickDropdownItem(page: Page, trigger: Locator, itemText: string) {
await trigger.click();
await page.getByText(itemText).click();
}
export async function login(page: Page) {
await page.goto('/user/login');
@@ -11,7 +16,7 @@ export async function login(page: Page) {
}
export async function logout(page: Page) {
await page.getByLabel('Profile and Settings…').click();
await page.getByText('Sign Out').click();
const navbar = page.getByRole('navigation', {name: 'Navigation Bar'});
await clickDropdownItem(page, navbar.getByTitle(env.E2E_USER!), 'Sign Out');
await expect(page.getByRole('link', {name: 'Sign In'})).toBeVisible();
}