mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-31 20:02:09 +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:
parent
a2eb249766
commit
68d690b6b9
19 changed files with 327 additions and 254 deletions
|
@ -5,13 +5,9 @@
|
|||
// @watch end
|
||||
|
||||
import {expect, type Page} from '@playwright/test';
|
||||
import {test, save_visual, login_user, login} from './utils_e2e.ts';
|
||||
import {save_visual, test} from './utils_e2e.ts';
|
||||
import {accessibilityCheck} from './shared/accessibility.ts';
|
||||
|
||||
test.beforeAll(async ({browser}, workerInfo) => {
|
||||
await login_user(browser, workerInfo, 'user2');
|
||||
});
|
||||
|
||||
async function assertSelectedLines(page: Page, nums: string[]) {
|
||||
const pageAssertions = async () => {
|
||||
expect(
|
||||
|
@ -81,20 +77,23 @@ test('Readable diff', async ({page}, workerInfo) => {
|
|||
}
|
||||
});
|
||||
|
||||
test('Username highlighted in commits', async ({browser}, workerInfo) => {
|
||||
const page = await login({browser}, workerInfo);
|
||||
await page.goto('/user2/mentions-highlighted/commits/branch/main');
|
||||
// check first commit
|
||||
await page.getByRole('link', {name: 'A commit message which'}).click();
|
||||
await expect(page.getByRole('link', {name: '@user2'})).toHaveCSS('background-color', /(.*)/);
|
||||
await expect(page.getByRole('link', {name: '@user1'})).toHaveCSS('background-color', 'rgba(0, 0, 0, 0)');
|
||||
await accessibilityCheck({page}, ['.commit-header'], [], []);
|
||||
await save_visual(page);
|
||||
// check second commit
|
||||
await page.goto('/user2/mentions-highlighted/commits/branch/main');
|
||||
await page.locator('tbody').getByRole('link', {name: 'Another commit which mentions'}).click();
|
||||
await expect(page.getByRole('link', {name: '@user2'})).toHaveCSS('background-color', /(.*)/);
|
||||
await expect(page.getByRole('link', {name: '@user1'})).toHaveCSS('background-color', 'rgba(0, 0, 0, 0)');
|
||||
await accessibilityCheck({page}, ['.commit-header'], [], []);
|
||||
await save_visual(page);
|
||||
test.describe('As authenticated user', () => {
|
||||
test.use({user: 'user2'});
|
||||
|
||||
test('Username highlighted in commits', async ({page}) => {
|
||||
await page.goto('/user2/mentions-highlighted/commits/branch/main');
|
||||
// check first commit
|
||||
await page.getByRole('link', {name: 'A commit message which'}).click();
|
||||
await expect(page.getByRole('link', {name: '@user2'})).toHaveCSS('background-color', /(.*)/);
|
||||
await expect(page.getByRole('link', {name: '@user1'})).toHaveCSS('background-color', 'rgba(0, 0, 0, 0)');
|
||||
await accessibilityCheck({page}, ['.commit-header'], [], []);
|
||||
await save_visual(page);
|
||||
// check second commit
|
||||
await page.goto('/user2/mentions-highlighted/commits/branch/main');
|
||||
await page.locator('tbody').getByRole('link', {name: 'Another commit which mentions'}).click();
|
||||
await expect(page.getByRole('link', {name: '@user2'})).toHaveCSS('background-color', /(.*)/);
|
||||
await expect(page.getByRole('link', {name: '@user1'})).toHaveCSS('background-color', 'rgba(0, 0, 0, 0)');
|
||||
await accessibilityCheck({page}, ['.commit-header'], [], []);
|
||||
await save_visual(page);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue