mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-03 02:44:28 +02:00
The link-action handler does an async fetch POST then a form-based redirect chain which can be slow on CI. Wait for the /user/logout response to confirm session destruction, then navigate to verify. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
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 navbar.getByTitle(env.E2E_USER!).click();
|
|
await Promise.all([
|
|
page.waitForResponse((resp) => resp.url().includes('/user/logout')),
|
|
page.getByText('Sign Out').click(),
|
|
]);
|
|
await page.goto('/');
|
|
await expect(page.getByRole('link', {name: 'Sign In'})).toBeVisible();
|
|
}
|