import type { Page } from '@playwright/test';

export async function login(
	page: Page,
	username = process.env.E2E_USERNAME ?? 'admin',
	password = process.env.E2E_PASSWORD ?? 'admin123'
) {
	await page.goto('/login');
	await page.getByLabel('Benutzername').fill(username);
	await page.getByLabel('Passwort').fill(password);
	await page.getByRole('button', { name: 'Anmelden' }).click();
	await page.waitForURL('/');
}
