0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-02-23 02:13:18 +01:00
gitea/tests/e2e/utils.ts
silverwind 30b9a05082
Fix flaky logout test by waiting for navigation
The dispatchEvent('click') on Sign Out triggers a navigation. Wait
for it to complete before checking for the Sign In link.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 03:03:15 +01:00

18 lines
676 B
TypeScript

import {env} from 'node:process';
import {expect} from '@playwright/test';
import type {Page} from '@playwright/test';
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) {
await page.getByText('Sign Out').dispatchEvent('click');
await page.waitForURL('**/');
await expect(page.getByRole('link', {name: 'Sign In'})).toBeVisible();
}