[CHORE] Add playwright eslint plugin

- Add https://github.com/playwright-community/eslint-plugin-playwright
as a linter for the playwright tests.
- `no-networkidle` and `no-conditional-in-test` are disabled as fixing
those doesn't seem to really improve testing quality for our use case.
- Some non-recommended linters are enabled to ensure consistency (the
prefer rules).
This commit is contained in:
Gusted 2024-07-22 20:03:32 +02:00
parent d405143919
commit 40baa96fc3
No known key found for this signature in database
GPG key ID: FD821B732837125F
11 changed files with 66 additions and 20 deletions

View file

@ -8,7 +8,7 @@ test.beforeAll(async ({browser}, workerInfo) => {
const workflow_trigger_notification_text = 'This workflow has a workflow_dispatch event trigger.';
test('Test workflow dispatch present', async ({browser}, workerInfo) => {
test('workflow dispatch present', async ({browser}, workerInfo) => {
const context = await load_logged_in_context(browser, workerInfo, 'user2');
/** @type {import('@playwright/test').Page} */
const page = await context.newPage();
@ -26,7 +26,7 @@ test('Test workflow dispatch present', async ({browser}, workerInfo) => {
await expect(menu).toBeVisible();
});
test('Test workflow dispatch error: missing inputs', async ({browser}, workerInfo) => {
test('workflow dispatch error: missing inputs', async ({browser}, workerInfo) => {
test.skip(workerInfo.project.name === 'Mobile Safari', 'Flaky behaviour on mobile safari; see https://codeberg.org/forgejo/forgejo/pulls/3334#issuecomment-2033383');
const context = await load_logged_in_context(browser, workerInfo, 'user2');
@ -38,11 +38,8 @@ test('Test workflow dispatch error: missing inputs', async ({browser}, workerInf
await page.locator('#workflow_dispatch_dropdown>button').click();
await page.waitForTimeout(1000);
// Remove the required attribute so we can trigger the error message!
await page.evaluate(() => {
// eslint-disable-next-line no-undef
const elem = document.querySelector('input[name="inputs[string2]"]');
elem?.removeAttribute('required');
});
@ -53,7 +50,7 @@ test('Test workflow dispatch error: missing inputs', async ({browser}, workerInf
await expect(page.getByText('Require value for input "String w/o. default".')).toBeVisible();
});
test('Test workflow dispatch success', async ({browser}, workerInfo) => {
test('workflow dispatch success', async ({browser}, workerInfo) => {
test.skip(workerInfo.project.name === 'Mobile Safari', 'Flaky behaviour on mobile safari; see https://codeberg.org/forgejo/forgejo/pulls/3334#issuecomment-2033383');
const context = await load_logged_in_context(browser, workerInfo, 'user2');
@ -64,7 +61,6 @@ test('Test workflow dispatch success', async ({browser}, workerInfo) => {
await page.waitForLoadState('networkidle');
await page.locator('#workflow_dispatch_dropdown>button').click();
await page.waitForTimeout(1000);
await page.type('input[name="inputs[string2]"]', 'abc');
await page.locator('#workflow-dispatch-submit').click();
@ -75,7 +71,7 @@ test('Test workflow dispatch success', async ({browser}, workerInfo) => {
await expect(page.locator('.run-list>:first-child .run-list-meta', {hasText: 'now'})).toBeVisible();
});
test('Test workflow dispatch box not available for unauthenticated users', async ({page}) => {
test('workflow dispatch box not available for unauthenticated users', async ({page}) => {
await page.goto('/user2/test_workflows/actions?workflow=test-dispatch.yml&actor=0&status=0');
await page.waitForLoadState('networkidle');