mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-21 13:44:39 +03:00
40551de313
Goals: - speedup - less flakiness - best practices and more use - documentation config: - sync ports in Makefile and playwright config (otherwise, some tests fail locally because they assert the full URL including the (wrong) port) - even more generous timeouts - limit workers to one again (because I finally understand how Playwright works) - allow nested functions to group them together with the related test all: - deprecate waitForLoadState('networkidle') - it is discouraged as per https://playwright.dev/docs/api/class-page#page-wait-for-load-state - I could not find a usage that seems to require it actually (see added documentation in README) - adding an exception should be made explicitly - it does not do what you might expect anyway in most cases - only log in when necessary webauthn: - verify that login is possible after disabling key - otherwise, the cleanup was not necessary after the previous refactor to create a fresh user each issue-sidebar / WIP toggle: - split into smaller chunks - restore original state first - add missed assertion to fix race condition (not waiting before state was reached) - explicitly toggle the state to detect mismatch earlier issue-sidebar / labels: - restore original state first - better waiting for background request
84 lines
3.4 KiB
TypeScript
84 lines
3.4 KiB
TypeScript
// @watch start
|
|
// templates/repo/actions/**
|
|
// web_src/css/actions.css
|
|
// web_src/js/components/ActionRunStatus.vue
|
|
// web_src/js/components/RepoActionView.vue
|
|
// modules/actions/**
|
|
// modules/structs/workflow.go
|
|
// routers/api/v1/repo/action.go
|
|
// routers/web/repo/actions/**
|
|
// @watch end
|
|
|
|
import {expect} from '@playwright/test';
|
|
import {test, login_user, load_logged_in_context} from './utils_e2e.ts';
|
|
|
|
test.beforeAll(async ({browser}, workerInfo) => {
|
|
await login_user(browser, workerInfo, 'user2');
|
|
});
|
|
|
|
const workflow_trigger_notification_text = 'This workflow has a workflow_dispatch event trigger.';
|
|
|
|
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();
|
|
|
|
await page.goto('/user2/test_workflows/actions?workflow=test-dispatch.yml&actor=0&status=0');
|
|
|
|
await expect(page.getByText(workflow_trigger_notification_text)).toBeVisible();
|
|
|
|
const run_workflow_btn = page.locator('#workflow_dispatch_dropdown>button');
|
|
await expect(run_workflow_btn).toBeVisible();
|
|
|
|
const menu = page.locator('#workflow_dispatch_dropdown>.menu');
|
|
await expect(menu).toBeHidden();
|
|
await run_workflow_btn.click();
|
|
await expect(menu).toBeVisible();
|
|
});
|
|
|
|
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');
|
|
/** @type {import('@playwright/test').Page} */
|
|
const page = await context.newPage();
|
|
|
|
await page.goto('/user2/test_workflows/actions?workflow=test-dispatch.yml&actor=0&status=0');
|
|
|
|
await page.locator('#workflow_dispatch_dropdown>button').click();
|
|
|
|
// Remove the required attribute so we can trigger the error message!
|
|
await page.evaluate(() => {
|
|
const elem = document.querySelector('input[name="inputs[string2]"]');
|
|
elem?.removeAttribute('required');
|
|
});
|
|
|
|
await page.locator('#workflow-dispatch-submit').click();
|
|
|
|
await expect(page.getByText('Require value for input "String w/o. default".')).toBeVisible();
|
|
});
|
|
|
|
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');
|
|
/** @type {import('@playwright/test').Page} */
|
|
const page = await context.newPage();
|
|
|
|
await page.goto('/user2/test_workflows/actions?workflow=test-dispatch.yml&actor=0&status=0');
|
|
|
|
await page.locator('#workflow_dispatch_dropdown>button').click();
|
|
|
|
await page.type('input[name="inputs[string2]"]', 'abc');
|
|
await page.locator('#workflow-dispatch-submit').click();
|
|
|
|
await expect(page.getByText('Workflow run was successfully requested.')).toBeVisible();
|
|
|
|
await expect(page.locator('.run-list>:first-child .run-list-meta', {hasText: 'now'})).toBeVisible();
|
|
});
|
|
|
|
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 expect(page.locator('body')).not.toContainText(workflow_trigger_notification_text);
|
|
});
|