0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-02-22 17:33:16 +01:00
gitea/tests/e2e/utils.ts
silverwind 5354352bee
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>
2026-02-18 03:03:15 +01:00

23 lines
906 B
TypeScript

import {env} from 'node:process';
import {expect} 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');
await page.getByLabel('Username or Email Address').fill(env.E2E_USER!);
await page.getByLabel('Password').fill(env.E2E_PASSWORD!);
await page.getByRole('button', {name: 'Sign In'}).click();
await expect(page.getByRole('link', {name: 'Sign In'})).toBeHidden();
}
export async function logout(page: Page) {
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();
}