102 lines
6.1 KiB
JavaScript
102 lines
6.1 KiB
JavaScript
// The workflow canvas at phone width: no page scroll, a clean topbar, lanes
|
|
// inside the canvas, zoom controls below the graph, step and run dialogs
|
|
// that fit, YAML without page scroll, and a pinned run header that stays
|
|
// visible.
|
|
const assert = require('node:assert/strict');
|
|
|
|
module.exports = async ({ page, go, shot, settled }) => {
|
|
await page.setViewportSize({ width: 390, height: 844 });
|
|
// The list is a page at phone width: rows open the workflow, and the
|
|
// enabled switch is on the row and on the workflow page.
|
|
await go('/workflows');
|
|
const row = page.getByRole('link', { name: /^implement/ });
|
|
await row.waitFor();
|
|
const listWidth = await page.evaluate(() => ({ scrollWidth: document.documentElement.scrollWidth, width: innerWidth }));
|
|
assert.equal(listWidth.scrollWidth, listWidth.width, 'workflow list scrolls horizontally');
|
|
await shot('list');
|
|
await page.getByRole('switch', { name: 'implement enabled' }).waitFor();
|
|
await row.click();
|
|
await page.waitForURL(/\/workflows\/implement$/);
|
|
await page.locator('.workflow-canvas').waitFor();
|
|
await page.getByRole('switch', { name: 'implement enabled' }).waitFor();
|
|
await go('/workflows?workflow=implement');
|
|
assert.match(page.url(), /\/workflows\/implement$/, 'legacy ?workflow= link did not reach the workflow page');
|
|
for (const workflow of ['implement', 'feasibility']) {
|
|
await go(`/workflows/${workflow}`);
|
|
const canvas = page.locator('.workflow-canvas');
|
|
await canvas.waitFor();
|
|
const dimensions = await page.evaluate(() => ({
|
|
height: innerHeight, width: innerWidth,
|
|
scrollHeight: document.documentElement.scrollHeight,
|
|
scrollWidth: document.documentElement.scrollWidth,
|
|
}));
|
|
assert.equal(dimensions.scrollHeight, dimensions.height, 'workflow page scrolls vertically');
|
|
assert.equal(dimensions.scrollWidth, dimensions.width, 'workflow page scrolls horizontally');
|
|
const topbar = page.locator('header').first();
|
|
const bar = await topbar.boundingBox();
|
|
assert.equal(bar.y, 0, 'blank band above topbar');
|
|
assert.equal(await topbar.evaluate(el => getComputedStyle(el).backdropFilter), 'none');
|
|
assert.ok(!await canvas.getByText('Works on a repository', { exact: true }).count());
|
|
const run = page.getByRole('button', { name: new RegExp(`^(Run|Test) ${workflow}$`) });
|
|
assert.ok(await run.isVisible(), 'Run hidden on phone');
|
|
const box = await canvas.boundingBox();
|
|
const start = await page.locator('.vue-flow__node[data-id="start"]').boundingBox();
|
|
assert.ok(start.y >= box.y && start.y < box.y + box.height, 'start is outside initial viewport');
|
|
const nodes = await page.locator('.vue-flow__node').evaluateAll(elements => elements.map(el => ({
|
|
left: el.getBoundingClientRect().left, right: el.getBoundingClientRect().right,
|
|
})));
|
|
assert.ok(nodes.every(node => node.left >= box.x && node.right <= box.x + box.width), 'branch lanes clipped horizontally');
|
|
const controls = await page.getByRole('group', { name: 'Zoom', exact: true }).boundingBox();
|
|
const covered = await page.locator('.vue-flow__node').evaluateAll((elements, c) => elements.some((el) => {
|
|
const r = el.getBoundingClientRect();
|
|
return r.left < c.x + c.width && r.right > c.x && r.top < c.y + c.height && r.bottom > c.y;
|
|
}), controls);
|
|
assert.ok(!covered, 'zoom controls cover a step');
|
|
await shot(workflow);
|
|
const step = page.locator('.vue-flow__node').filter({ hasText: 'Prepare worktree' }).first();
|
|
assert.match(await step.innerText(), /^\d+\.\s+Prepare worktree$/);
|
|
await step.click();
|
|
const dialog = page.locator('[role="dialog"][data-slot="dialog-content"]');
|
|
await dialog.waitFor();
|
|
const dialogBox = await dialog.boundingBox();
|
|
assert.ok(dialogBox.x >= 0 && dialogBox.x + dialogBox.width <= 390, 'step editor exceeds phone width');
|
|
const input = dialog.getByRole('textbox').first();
|
|
if (await input.count()) assert.ok(await input.evaluate(el => el.getBoundingClientRect().height) >= 24, 'step form scaled down');
|
|
await shot(`${workflow}-step`);
|
|
await page.keyboard.press('Escape');
|
|
await run.click();
|
|
await page.locator('[role="dialog"][data-slot="dialog-content"]').waitFor();
|
|
await shot(`${workflow}-run`);
|
|
await page.keyboard.press('Escape');
|
|
}
|
|
// YAML must not make the page scroll at phone width.
|
|
await go('/workflows/feasibility');
|
|
await page.getByRole('tab', { name: 'History', exact: true }).click();
|
|
await settled();
|
|
const yamlPage = await page.evaluate(() => ({
|
|
scrollHeight: document.documentElement.scrollHeight, height: innerHeight,
|
|
}));
|
|
assert.equal(yamlPage.scrollHeight, yamlPage.height, 'YAML causes page scroll');
|
|
await page.getByRole('tab', { name: 'Canvas', exact: true }).first().click();
|
|
// A pinned historical run keeps its header visible on the canvas.
|
|
const response = await page.request.get(new URL('/api/control-plane/resources/workflow-definitions', page.url()).href);
|
|
const resource = await response.json();
|
|
const snapshot = resource.resource.value.definitions.find(entry => entry.id === 'feasibility').yaml;
|
|
await page.route('**/api/tasks?*', route => {
|
|
const workflow = new URL(route.request().url()).searchParams.get('workflow');
|
|
return workflow === 'feasibility'
|
|
? route.fulfill({ json: [{ id: 999999, workflow, title: 'Historical run', status: 'failed', workflow_definition_yaml: snapshot }] })
|
|
: route.continue();
|
|
});
|
|
await page.route('**/api/tasks/999999/*?*', route => route.fulfill({ json: {} }));
|
|
await page.route('**/api/tasks/999999/debug', route => route.fulfill({ json: {} }));
|
|
await page.route('**/api/tasks/999999/attempts', route => route.fulfill({ json: { attempts: [{ attempt: 1, stages: [] }] } }));
|
|
await go('/workflows/feasibility');
|
|
const picker = page.getByRole('combobox', { name: 'Run shown on the canvas' });
|
|
await picker.waitFor();
|
|
assert.match(await picker.innerText(), /Run #999999/);
|
|
const root = await page.locator('.vue-flow__node[data-id="workflow"]').boundingBox();
|
|
const pinnedCanvas = await page.locator('.workflow-canvas').boundingBox();
|
|
assert.ok(root.y >= pinnedCanvas.y, 'historical workflow header clipped above canvas');
|
|
};
|