44 lines
2.1 KiB
JavaScript
44 lines
2.1 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
|
||
|
|
});
|