CI / Lint (eslint) (pull_request) Successful in 20s
CI / Test (jest) (pull_request) Successful in 22s
CI / Security (npm audit) (pull_request) Successful in 13s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 2m32s
CI / Integration (api) (pull_request) Successful in 3m24s
CI / UI screenshots (before/after) (pull_request) Successful in 6s
CI / UI (playwright) (pull_request) Successful in 1m53s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
The server answered a bad goto or condition with "Invalid workflow definition" and put the details in a problems array, which the UI never shows (lt.api keeps only `error`). The error now names them, e.g. "Invalid workflow definition: step check: no step with id "notify"" (up to five, then "and N more"); problems stays for API clients. The rest of #25 was already fixed by the UI rewrite; regression tests now cover the server's reason in the form and Escape closing the Run dialog. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
124 lines
6.3 KiB
JavaScript
124 lines
6.3 KiB
JavaScript
'use strict';
|
|
|
|
const { test, expect } = require('./fixtures');
|
|
|
|
test('create a workflow in the UI, run it on all workers, and see it complete', async ({ page }) => {
|
|
const id = `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 6)}`;
|
|
const name = `UI test ${id}`;
|
|
const definition = {
|
|
steps: [
|
|
{ id: 'hello', name: 'Say hello', type: 'execute', command: `echo wf-${id}`, targets: ['all'] },
|
|
{ id: 'host', name: 'Hostname', type: 'execute', command: 'hostname', targets: ['all'] },
|
|
],
|
|
};
|
|
|
|
await page.goto('/workflows');
|
|
await page.getByRole('button', { name: '+ Create Workflow' }).click();
|
|
await page.locator('#wf-create-name').fill(name);
|
|
await page.locator('#wf-create-description').fill('Created by the Playwright UI tests');
|
|
await page.locator('#wf-create-definition').fill(JSON.stringify(definition, null, 2));
|
|
await page.locator('#wf-create-form').getByRole('button', { name: 'Create' }).click();
|
|
|
|
const row = page.locator('#wf-list tr', { hasText: name });
|
|
await expect(row).toBeVisible();
|
|
await row.getByRole('button', { name: 'Execute' }).click();
|
|
await page.locator('#wf-run-form').getByRole('button', { name: /Run/ }).click();
|
|
|
|
await expect(page).toHaveURL(/\/executions\?open=|\/executions$/);
|
|
const detail = page.locator('#ex-detail-body');
|
|
// Both steps ran on all three workers, and the execution finished.
|
|
await expect(detail).toContainText(`wf-${id}`);
|
|
await expect(detail).toContainText(/completed/i, { timeout: 20_000 });
|
|
});
|
|
|
|
test('an invalid workflow definition is rejected with a message', async ({ page, problems }) => {
|
|
await page.goto('/workflows');
|
|
await page.getByRole('button', { name: '+ Create Workflow' }).click();
|
|
await page.locator('#wf-create-name').fill('Broken definition');
|
|
await page.locator('#wf-create-definition').fill('{ not json');
|
|
await page.locator('#wf-create-form').getByRole('button', { name: 'Create' }).click();
|
|
|
|
await expect(page.locator('#wf-create-error')).toBeVisible();
|
|
await expect(page.locator('#wf-list tr', { hasText: 'Broken definition' })).toHaveCount(0);
|
|
expect(problems).toEqual([]); // rejected in the browser, so no failed request either
|
|
});
|
|
|
|
test('a definition the server rejects shows the server\'s reason (#25)', async ({ page, problems }) => {
|
|
await page.goto('/workflows');
|
|
await page.getByRole('button', { name: '+ Create Workflow' }).click();
|
|
await page.locator('#wf-create-name').fill(`Bad goto ${Date.now()}`);
|
|
await page.locator('#wf-create-definition').fill(JSON.stringify({ steps: [
|
|
{ id: 'check', type: 'execute', command: 'true', goto: 'nope' },
|
|
] }));
|
|
await page.locator('#wf-create-form').getByRole('button', { name: 'Create' }).click();
|
|
await expect(page.locator('#wf-create-error')).toContainText('no step with id "nope"');
|
|
// The 400 (and the browser's console line for it) is the point of this test.
|
|
expect(problems.every(p => /400/.test(p))).toBe(true);
|
|
problems.length = 0;
|
|
});
|
|
|
|
test('Escape closes the Run dialog (#25)', async ({ page, request }) => {
|
|
const name = `UI esc ${Date.now()}`;
|
|
await request.post('/api/workflows', { data: { name, definition: { steps: [{ id: 'a', type: 'execute', command: 'true' }] } } });
|
|
await page.goto('/workflows');
|
|
await page.locator('#wf-list tr', { hasText: name }).getByRole('button', { name: 'Execute' }).click();
|
|
await expect(page.locator('#wf-run-modal')).toBeVisible();
|
|
await page.keyboard.press('Escape');
|
|
await expect(page.locator('#wf-run-modal')).toBeHidden();
|
|
});
|
|
|
|
test('a run waiting on a prompt shows as waiting, and the Waiting filter finds it (#3)', async ({ page, request }) => {
|
|
const created = await request.post('/api/workflows', { data: { name: `UI wait ${Date.now()}`, definition: { steps: [
|
|
{ id: 'ask', type: 'prompt', message: 'Proceed?', options: ['Yes'] },
|
|
] } } });
|
|
const wf = (await created.json()).id;
|
|
const ex = (await (await request.post('/api/executions', { data: { workflow_id: wf } })).json()).id;
|
|
|
|
await page.goto('/executions');
|
|
const row = page.locator(`#ex-list-manual .ex-row[data-execution-id="${ex}"]`);
|
|
await expect(row.locator('td[data-label="Status"]')).toHaveText('waiting');
|
|
await page.locator('#ex-status').selectOption('waiting');
|
|
await expect(row).toBeVisible();
|
|
|
|
await request.post(`/api/executions/${ex}/respond`, { data: { response: 'Yes' } });
|
|
});
|
|
|
|
test('the Create Workflow dialog starts with the example definition (#12)', async ({ page }) => {
|
|
await page.goto('/workflows');
|
|
await page.getByRole('button', { name: '+ Create Workflow' }).click();
|
|
const def = JSON.parse(await page.locator('#wf-create-definition').inputValue());
|
|
expect(Array.isArray(def.steps) && def.steps.length).toBeTruthy();
|
|
});
|
|
|
|
test('a workflow without parameters can still be dry-run (#13)', async ({ page, request }) => {
|
|
const name = `UI noparams ${Date.now()}`;
|
|
await request.post('/api/workflows', { data: { name, definition: { steps: [
|
|
{ id: 'a', type: 'execute', command: 'echo hi', targets: ['node-01'] },
|
|
] } } });
|
|
await page.goto('/workflows');
|
|
await page.locator('#wf-list tr', { hasText: name }).getByRole('button', { name: 'Execute' }).click();
|
|
await expect(page.locator('#wf-run-dryrun')).toBeVisible();
|
|
await page.locator('#wf-run-dryrun').check();
|
|
await page.locator('#wf-run-form').getByRole('button', { name: /Run/ }).click();
|
|
await expect(page.locator('#ex-detail-body')).toContainText(/dry run/i);
|
|
});
|
|
|
|
test('a workflow execution re-runs as the whole workflow with its parameters (#18)', async ({ page, request }) => {
|
|
const name = `UI rerun ${Date.now()}`;
|
|
const wf = (await (await request.post('/api/workflows', { data: { name, definition: {
|
|
params: [{ name: 'who', required: true }],
|
|
steps: [{ id: 'a', type: 'execute', command: 'echo hello {{who}}', targets: ['node-01'] }],
|
|
} } })).json()).id;
|
|
const first = (await (await request.post('/api/executions', { data: { workflow_id: wf, params: { who: 'world' } } })).json()).id;
|
|
|
|
await page.goto(`/executions?open=${first}`);
|
|
await expect(page.locator('#ex-detail-body')).toContainText('hello world');
|
|
await page.getByRole('button', { name: /Re-run Workflow/ }).click();
|
|
await page.getByRole('button', { name: 'RE-RUN', exact: true }).click();
|
|
|
|
await expect.poll(async () => {
|
|
const list = await (await request.get('/api/executions?hide_internal=true&limit=20')).json();
|
|
return list.executions.filter(e => e.workflow_id === wf).length;
|
|
}).toBe(2);
|
|
});
|