forked from kevadesu/forgejo
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
|
@ -4,11 +4,9 @@
|
|||
// @watch end
|
||||
|
||||
import {expect, type Locator} from '@playwright/test';
|
||||
import {test, save_visual, login_user, load_logged_in_context} from './utils_e2e.ts';
|
||||
import {save_visual, test} from './utils_e2e.ts';
|
||||
|
||||
test.beforeAll(async ({browser}, workerInfo) => {
|
||||
await login_user(browser, workerInfo, 'user2');
|
||||
});
|
||||
test.use({user: 'user2'});
|
||||
|
||||
const assertReactionCounts = (comment: Locator, counts: unknown) =>
|
||||
expect(async () => {
|
||||
|
@ -26,6 +24,7 @@ const assertReactionCounts = (comment: Locator, counts: unknown) =>
|
|||
]),
|
||||
),
|
||||
);
|
||||
// eslint-disable-next-line playwright/no-standalone-expect
|
||||
return expect(reactions).toStrictEqual(counts);
|
||||
}).toPass();
|
||||
|
||||
|
@ -35,10 +34,7 @@ async function toggleReaction(menu: Locator, reaction: string) {
|
|||
await menu.locator(`[role=menuitem][data-reaction-content="${reaction}"]`).click();
|
||||
}
|
||||
|
||||
test('Reaction Selectors', async ({browser}, workerInfo) => {
|
||||
const context = await load_logged_in_context(browser, workerInfo, 'user2');
|
||||
const page = await context.newPage();
|
||||
|
||||
test('Reaction Selectors', async ({page}) => {
|
||||
const response = await page.goto('/user2/repo1/issues/1');
|
||||
expect(response?.status()).toBe(200);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue