1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-08-01 17:38:33 +00:00

chore(e2e): simplify authentication setup (#6400)

Replaced manual login and context loading across tests with Playwright's `test.use` configuration for user authentication. This simplifies test setup, improves readability, and reduces repetition.

For #6362

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6400
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: Julian Schlarb <julian.schlarb@denktmit.de>
Co-committed-by: Julian Schlarb <julian.schlarb@denktmit.de>
This commit is contained in:
Julian Schlarb 2025-01-05 05:17:04 +00:00 committed by Gusted
parent a2eb249766
commit 68d690b6b9
19 changed files with 327 additions and 254 deletions

View file

@ -7,16 +7,13 @@
// @watch end
import {expect} from '@playwright/test';
import {test, save_visual, login_user, login} from './utils_e2e.ts';
import {test, save_visual} from './utils_e2e.ts';
import {validate_form} from './shared/forms.ts';
test.beforeAll(async ({browser}, workerInfo) => {
await login_user(browser, workerInfo, 'user2');
});
test.use({user: 'user2'});
test('repo webhook settings', async ({browser}, workerInfo) => {
test('repo webhook settings', async ({page}, workerInfo) => {
test.skip(workerInfo.project.name === 'Mobile Safari', 'Cannot get it to work - as usual');
const page = await login({browser}, workerInfo);
const response = await page.goto('/user2/repo1/settings/hooks/forgejo/new');
expect(response?.status()).toBe(200);
@ -35,9 +32,8 @@ test('repo webhook settings', async ({browser}, workerInfo) => {
});
test.describe('repo branch protection settings', () => {
test('form', async ({browser}, workerInfo) => {
test.skip(workerInfo.project.name === 'Mobile Safari', 'Cannot get it to work - as usual');
const page = await login({browser}, workerInfo);
test('form', async ({page}, {project}) => {
test.skip(project.name === 'Mobile Safari', 'Cannot get it to work - as usual');
const response = await page.goto('/user2/repo1/settings/branches/edit');
expect(response?.status()).toBe(200);
@ -56,8 +52,7 @@ test.describe('repo branch protection settings', () => {
await save_visual(page);
});
test.afterEach(async ({browser}, workerInfo) => {
const page = await login({browser}, workerInfo);
test.afterEach(async ({page}) => {
// delete the rule for the next test
await page.goto('/user2/repo1/settings/branches/');
await page.waitForLoadState('domcontentloaded');