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

Use env vars directly in e2e login helper, remove user parameter

Import env from node:process, remove the user argument from login()
and read E2E_USER and E2E_PASSWORD directly from the environment.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
silverwind 2026-02-15 11:31:22 +01:00
parent 68acbd3ad4
commit f604702a77
No known key found for this signature in database
GPG Key ID: 2E62B41C93869443
2 changed files with 5 additions and 4 deletions

View File

@ -10,7 +10,7 @@ test('homepage', async ({page}) => {
test('logged in user', async ({browser}) => {
const context = await browser.newContext();
const page = await context.newPage();
await login(page, 'e2e');
await login(page);
const response = await page.goto('/');
expect(response?.status()).toBe(200);
});

View File

@ -1,10 +1,11 @@
import {env} from 'node:process';
import {expect} from '@playwright/test';
import type {Page} from '@playwright/test';
export async function login(page: Page, user: string = process.env.E2E_USER) {
export async function login(page: Page) {
await page.goto('/user/login');
await page.getByLabel('Username or Email Address').fill(user);
await page.getByLabel('Password').fill(process.env.E2E_PASSWORD);
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();
}