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
commit 68d690b6b9
19 changed files with 327 additions and 254 deletions

View file

@ -250,16 +250,18 @@ test('For anyone', async ({page}) => {
If you need a user account, you can use something like:
~~~js
import {test, login_user, login} from './utils_e2e.ts';
import {test} from './utils_e2e.ts';
test.beforeAll(async ({browser}, workerInfo) => {
await login_user(browser, workerInfo, 'user2'); // or another user
});
// reuse user2 token from scope `shared`
test.use({user: 'user2', authScope: 'shared'})
test('For signed users only', async ({browser}, workerInfo) => {
const page = await login({browser}, workerInfo);
test('For signed users only', async ({page}) => {
})
~~~
users are created in [utils_e2e_test.go](utils_e2e_test.go)
### Run tests very selectively
Browser testing can take some time.