0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-02-22 17:33:16 +01:00

Reuse login helper in register test

Accept optional username/password in the login utility so the register
test can use it for the newly-created account instead of duplicating
the sign-in steps.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
silverwind 2026-02-17 20:26:50 +01:00
parent 6ce62bc545
commit 408b2596ab
No known key found for this signature in database
GPG Key ID: 2E62B41C93869443
2 changed files with 4 additions and 8 deletions

View File

@ -46,11 +46,7 @@ test('register then login', async ({page}) => {
// Logout then login with the newly created account
await logout(page);
await page.goto('/user/login');
await page.getByLabel('Username or Email Address').fill(username);
await page.getByLabel('Password').fill(password);
await page.getByRole('button', {name: 'Sign In'}).click();
await expect(page.getByRole('link', {name: 'Sign In'})).toBeHidden();
await login(page, username, password);
// Clean up: login as admin and delete the user via site administration
await logout(page);

View File

@ -43,10 +43,10 @@ export async function clickDropdownItem(page: Page, trigger: Locator, itemText:
await page.getByText(itemText).click();
}
export async function login(page: Page) {
export async function login(page: Page, username = env.E2E_USER!, password = env.E2E_PASSWORD!) {
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.getByLabel('Username or Email Address').fill(username);
await page.getByLabel('Password').fill(password);
await page.getByRole('button', {name: 'Sign In'}).click();
await expect(page.getByRole('link', {name: 'Sign In'})).toBeHidden();
}