mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-01 04:12:10 +00:00
[v10.0/forgejo] Refactor e2e tests to simplify authentication setup (#6585)
**Backport:** https://codeberg.org/forgejo/forgejo/pulls/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. #6362 first part ## Checklist The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org). ### Tests - I added test coverage for Go changes... - [ ] in their respective `*_test.go` for unit tests. - [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server. - I added test coverage for JavaScript changes... - [ ] in `web_src/js/*.test.js` if it can be unit tested. - [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)). ### Documentation - [x] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change. - [ ] I did not document these changes and I do not expect someone else to do it. ### Release notes - [x] I do not want this change to show in the release notes. - [ ] I want the title to show in the release notes with a link to this pull request. - [ ] I want the content of the `release-notes/<pull request number>.md` to be be used for the release notes instead of the title. Co-authored-by: Julian Schlarb <julian.schlarb@denktmit.de> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6585 Reviewed-by: Otto <otto@codeberg.org> Co-authored-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org> Co-committed-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
This commit is contained in:
parent
39843ee2b3
commit
05056b8aa2
19 changed files with 327 additions and 254 deletions
|
@ -4,15 +4,12 @@
|
|||
// @watch end
|
||||
|
||||
import {expect} from '@playwright/test';
|
||||
import {test, dynamic_id, save_visual, login_user, login} from './utils_e2e.ts';
|
||||
import {test, dynamic_id, 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('New repo: invalid', async ({browser}, workerInfo) => {
|
||||
const page = await login({browser}, workerInfo);
|
||||
test('New repo: invalid', async ({page}) => {
|
||||
const response = await page.goto('/repo/create');
|
||||
expect(response?.status()).toBe(200);
|
||||
// check that relevant form content is hidden or available
|
||||
|
@ -28,8 +25,7 @@ test('New repo: invalid', async ({browser}, workerInfo) => {
|
|||
await save_visual(page);
|
||||
});
|
||||
|
||||
test('New repo: initialize', async ({browser}, workerInfo) => {
|
||||
const page = await login({browser}, workerInfo);
|
||||
test('New repo: initialize', async ({page}, workerInfo) => {
|
||||
const response = await page.goto('/repo/create');
|
||||
expect(response?.status()).toBe(200);
|
||||
// check that relevant form content is hidden or available
|
||||
|
@ -62,8 +58,7 @@ test('New repo: initialize', async ({browser}, workerInfo) => {
|
|||
await save_visual(page);
|
||||
});
|
||||
|
||||
test('New repo: initialize later', async ({browser}, workerInfo) => {
|
||||
const page = await login({browser}, workerInfo);
|
||||
test('New repo: initialize later', async ({page}) => {
|
||||
const response = await page.goto('/repo/create');
|
||||
expect(response?.status()).toBe(200);
|
||||
|
||||
|
@ -97,9 +92,8 @@ test('New repo: initialize later', async ({browser}, workerInfo) => {
|
|||
await save_visual(page);
|
||||
});
|
||||
|
||||
test('New repo: from template', async ({browser}, workerInfo) => {
|
||||
test('New repo: from template', async ({page}, workerInfo) => {
|
||||
test.skip(['Mobile Safari', 'webkit'].includes(workerInfo.project.name), 'WebKit browsers seem to have CORS issues with localhost here.');
|
||||
const page = await login({browser}, workerInfo);
|
||||
const response = await page.goto('/repo/create');
|
||||
expect(response?.status()).toBe(200);
|
||||
|
||||
|
@ -114,8 +108,7 @@ test('New repo: from template', async ({browser}, workerInfo) => {
|
|||
await save_visual(page);
|
||||
});
|
||||
|
||||
test('New repo: label set', async ({browser}, workerInfo) => {
|
||||
const page = await login({browser}, workerInfo);
|
||||
test('New repo: label set', async ({page}) => {
|
||||
await page.goto('/repo/create');
|
||||
|
||||
const reponame = dynamic_id();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue