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-18 03:03:16 +01:00
co-authored by Claude Opus 4.6
parent 6ce62bc545
commit 408b2596ab
2 changed files with 4 additions and 8 deletions
+1 -5
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);
+3 -3
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();
}