CI / Lint (eslint) (pull_request) Successful in 20s
CI / Test (jest) (pull_request) Successful in 21s
CI / Security (npm audit) (pull_request) Successful in 15s
CI / Integration (api) (pull_request) Successful in 2m43s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 2m44s
CI / UI (playwright) (pull_request) Successful in 2m35s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
CI / UI screenshots (before/after) (pull_request) Successful in 1m54s
A shared output block (Pulse.output.render) now draws every command output in Executions and Quick Command: - ANSI escape codes (colours, cursor moves, titles, charset switches) are stripped, so systemctl, ls --color and docker read cleanly. - Copy and .txt use the full, clean text; .txt downloads it as a file. - Wrap turns long-line wrapping on or off for every block, remembered. - Output over 25 lines starts at 24rem high with an Expand button. - Over 100,000 characters, the display is cut with a notice saying how much is hidden; Copy and .txt still include all of it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
206 lines
10 KiB
JavaScript
206 lines
10 KiB
JavaScript
'use strict';
|
|
|
|
// End to end: browser -> server -> a real worker over the authenticated
|
|
// WebSocket -> result stored -> shown in the UI.
|
|
const { test, expect } = require('./fixtures');
|
|
|
|
const token = () => `ui-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
|
|
test('a quick command runs on a worker and its output shows in Executions', async ({ page }) => {
|
|
const marker = token();
|
|
await page.goto('/quick');
|
|
await page.locator('#qc-worker').selectOption({ label: 'node-02 (online)' });
|
|
await page.locator('#qc-command').fill(`echo ${marker}`);
|
|
await page.locator('#qc-execute-btn').click();
|
|
|
|
// The output shows right under the form (#5), with a link to the full record.
|
|
const result = page.locator('#qc-result');
|
|
await expect(result.locator('.qc-run-status')).toHaveText(/Completed/);
|
|
await expect(result.locator('pre.qc-out')).toHaveText(marker);
|
|
await expect(result).toContainText('node-02');
|
|
await result.getByRole('link', { name: 'view in Executions' }).click();
|
|
|
|
await expect(page).toHaveURL(/\/executions/);
|
|
const detail = page.locator('#ex-detail-body');
|
|
await expect(detail).toContainText(marker);
|
|
await expect(detail).toContainText(/completed/i);
|
|
|
|
// The list row says what ran and where, not just "[Quick Command]" (#15).
|
|
await page.keyboard.press('Escape');
|
|
await expect(page.locator('#ex-list-manual .ex-row').filter({ hasText: `echo ${marker}` }).first()).toContainText('@ node-02');
|
|
});
|
|
|
|
test('a failing command is reported as failed with its stderr', async ({ page }) => {
|
|
const marker = token();
|
|
await page.goto('/quick');
|
|
await page.locator('#qc-worker').selectOption({ label: 'node-01 (online)' });
|
|
await page.locator('#qc-command').fill(`echo ${marker} >&2; exit 3`);
|
|
await page.locator('#qc-command').press('Control+Enter'); // the documented shortcut
|
|
|
|
const result = page.locator('#qc-result');
|
|
await expect(result.locator('.qc-run-status')).toHaveText(/Failed \(exit 3\)/);
|
|
await expect(result.locator('pre.qc-out-err')).toHaveText(marker);
|
|
await result.getByRole('link', { name: 'view in Executions' }).click();
|
|
const detail = page.locator('#ex-detail-body');
|
|
await expect(detail).toContainText(marker);
|
|
await expect(detail).toContainText(/failed/i);
|
|
});
|
|
|
|
test('multi-worker mode sends the command to every selected worker', async ({ page }) => {
|
|
await page.goto('/quick');
|
|
await page.locator('label[for="qc-mode-multi"], #qc-mode-multi').first().click();
|
|
await page.getByRole('button', { name: /select all/i }).click();
|
|
await page.locator('#qc-command').fill('echo "$WORKER_NAME says hi"');
|
|
await page.locator('#qc-execute-btn').click();
|
|
|
|
// One card per worker, each with its own output (#5).
|
|
const result = page.locator('#qc-result');
|
|
await expect(result).toContainText('Sent to 3 workers');
|
|
const runs = result.locator('.qc-run');
|
|
await expect(runs).toHaveCount(3);
|
|
for (const n of ['node-01', 'node-02', 'node-03']) {
|
|
const card = runs.filter({ hasText: n });
|
|
await expect(card.locator('.qc-run-status')).toHaveText(/Completed/);
|
|
await expect(card.locator('pre.qc-out')).toHaveText(`${n} says hi`);
|
|
}
|
|
});
|
|
|
|
test('Executions updates live when a command starts elsewhere', async ({ page, request }) => {
|
|
await page.goto('/executions');
|
|
await page.waitForLoadState('networkidle');
|
|
|
|
// Start a command through the API, not this page: only the WebSocket can tell it.
|
|
const workers = await (await request.get('/api/workers')).json();
|
|
const node3 = workers.find(w => w.name === 'node-03');
|
|
const res = await request.post(`/api/workers/${node3.id}/command`, { data: { command: `echo ${token()}` } });
|
|
expect(res.ok()).toBeTruthy();
|
|
const { execution_id: id } = await res.json();
|
|
|
|
// Its own row appears without a reload (by id, so it works however full the list is).
|
|
await expect(page.locator(`#ex-list-manual .ex-row[data-execution-id="${id}"]`)).toBeVisible();
|
|
});
|
|
|
|
test('searching Executions finds a run by its command (#16)', async ({ page, request }) => {
|
|
const marker = token();
|
|
const workers = await (await request.get('/api/workers')).json();
|
|
const node1 = workers.find(w => w.name === 'node-01');
|
|
const { execution_id: id } = await (await request.post(`/api/workers/${node1.id}/command`, { data: { command: `echo ${marker}` } })).json();
|
|
|
|
await page.goto('/executions');
|
|
await page.locator('#ex-search').fill(marker);
|
|
const rows = page.locator('#ex-list-manual .ex-row');
|
|
await expect(rows).toHaveCount(1);
|
|
await expect(rows.first()).toHaveAttribute('data-execution-id', id);
|
|
});
|
|
|
|
test('Quick Command remembers the mode and workers after a reload (#31)', async ({ page }) => {
|
|
await page.goto('/quick');
|
|
await page.locator('#qc-mode-multi').check();
|
|
const boxes = page.locator('#qc-worker-list label');
|
|
await boxes.filter({ hasText: 'node-02' }).locator('input').check();
|
|
await boxes.filter({ hasText: 'node-03' }).locator('input').check();
|
|
await page.locator('#qc-command').fill('true');
|
|
await page.locator('#qc-execute-btn').click();
|
|
await expect(page.locator('#qc-result')).toContainText('Sent to 2 workers');
|
|
|
|
await page.reload();
|
|
await expect(page.locator('#qc-mode-multi')).toBeChecked();
|
|
await expect(boxes.filter({ hasText: 'node-02' }).locator('input')).toBeChecked();
|
|
await expect(boxes.filter({ hasText: 'node-03' }).locator('input')).toBeChecked();
|
|
await expect(boxes.filter({ hasText: 'node-01' }).locator('input')).not.toBeChecked();
|
|
|
|
// Single mode remembers its worker too.
|
|
await page.locator('#qc-mode-single').check();
|
|
const node3 = await page.locator('#qc-worker option', { hasText: 'node-03' }).getAttribute('value');
|
|
await page.locator('#qc-worker').selectOption(node3);
|
|
await page.locator('#qc-command').fill('true'); // the reload emptied it
|
|
await page.locator('#qc-execute-btn').click();
|
|
await expect(page.locator('#qc-result .qc-run-status')).toHaveText(/Completed/);
|
|
await page.reload();
|
|
await expect(page.locator('#qc-mode-single')).toBeChecked();
|
|
await expect(page.locator('#qc-worker option:checked')).toContainText('node-03');
|
|
});
|
|
|
|
test('a live update keeps the rows brought in with Load More (#17)', async ({ page, request }) => {
|
|
const workers = await (await request.get('/api/workers')).json();
|
|
const id = workers.find(w => w.name === 'node-01').id;
|
|
const send = () => request.post(`/api/workers/${id}/command`, { data: { command: 'true' } });
|
|
for (let i = 0; i < 60; i++) await send();
|
|
|
|
await page.goto('/executions');
|
|
const rows = page.locator('#ex-list-manual .ex-row');
|
|
await expect(rows).toHaveCount(50);
|
|
await page.getByRole('button', { name: 'Load More Executions' }).click();
|
|
await expect.poll(() => rows.count()).toBeGreaterThan(50);
|
|
const shown = await rows.count();
|
|
|
|
// A live event: the list refreshes with the new run on top, and still shows
|
|
// as many rows as before rather than dropping back to the first 50.
|
|
const marker = `live-${Date.now().toString(36)}`;
|
|
await request.post(`/api/workers/${id}/command`, { data: { command: `echo ${marker}` } });
|
|
await expect(rows.first()).toContainText(marker, { timeout: 10_000 });
|
|
await expect(rows).toHaveCount(shown);
|
|
});
|
|
|
|
test('the result still shows when the live update is missed (#5)', async ({ page }) => {
|
|
// No live connection at all: the page has to find the result by polling.
|
|
await page.routeWebSocket(/.*/, () => { /* never connects to the server */ });
|
|
const marker = token();
|
|
await page.goto('/quick');
|
|
await page.locator('#qc-worker').selectOption({ label: 'node-03 (online)' });
|
|
await page.locator('#qc-command').fill(`echo ${marker}`);
|
|
await page.locator('#qc-execute-btn').click();
|
|
|
|
const result = page.locator('#qc-result');
|
|
await expect(result.locator('.qc-run-status')).toHaveText(/Running/);
|
|
await expect(result.locator('pre.qc-out')).toHaveText(marker, { timeout: 15_000 });
|
|
await expect(result.locator('.qc-run-status')).toHaveText(/Completed/);
|
|
});
|
|
|
|
test('only the worker picker for the chosen mode is shown', async ({ page }) => {
|
|
await page.goto('/quick');
|
|
await page.locator('#qc-mode-single').check();
|
|
await expect(page.locator('#qc-single-mode')).toBeVisible();
|
|
await expect(page.locator('#qc-multi-mode')).toBeHidden();
|
|
await page.locator('#qc-mode-multi').check();
|
|
await expect(page.locator('#qc-multi-mode')).toBeVisible();
|
|
await expect(page.locator('#qc-single-mode')).toBeHidden();
|
|
});
|
|
|
|
test('output is readable: colours stripped, Copy / Wrap / Expand / .txt (#27)', async ({ page, context }) => {
|
|
await context.grantPermissions(['clipboard-read', 'clipboard-write']);
|
|
await page.goto('/quick');
|
|
await page.locator('#qc-mode-single').check();
|
|
await page.locator('#qc-worker').selectOption({ label: 'node-01 (online)' });
|
|
await page.locator('#qc-command').fill(`printf '\\033[1;32mgreen\\033[0m plain\\n'; seq 1 40`);
|
|
await page.locator('#qc-execute-btn').click();
|
|
|
|
const block = page.locator('#qc-result .pl-out').first();
|
|
const pre = block.locator('pre');
|
|
await expect(pre).toContainText('green plain');
|
|
expect(await pre.textContent()).not.toContain('\u001b'); // no raw escape codes
|
|
|
|
// 41 lines: starts collapsed, Expand shows everything.
|
|
await expect(pre).toHaveClass(/is-tall/);
|
|
await block.getByRole('button', { name: 'Expand' }).click();
|
|
await expect(pre).toHaveClass(/is-expanded/);
|
|
await expect(block.getByRole('button', { name: 'Collapse' })).toBeVisible();
|
|
|
|
// Wrap toggles long-line wrapping, and the choice sticks.
|
|
await block.getByRole('button', { name: 'Wrap' }).click();
|
|
await expect(pre).toHaveClass(/is-nowrap/);
|
|
await block.getByRole('button', { name: 'Wrap' }).click();
|
|
await expect(pre).not.toHaveClass(/is-nowrap/);
|
|
|
|
// Copy gives the full, clean text.
|
|
await block.getByRole('button', { name: 'Copy' }).click();
|
|
const copied = await page.evaluate(() => navigator.clipboard.readText());
|
|
expect(copied.startsWith('green plain\n1\n2\n')).toBe(true);
|
|
expect(copied.trim().endsWith('40')).toBe(true);
|
|
|
|
// .txt downloads the same text.
|
|
const [dl] = await Promise.all([page.waitForEvent('download'), block.getByRole('button', { name: '.txt' }).click()]);
|
|
expect(dl.suggestedFilename()).toMatch(/^pulse-[0-9a-f]{8}\.txt$/);
|
|
expect(require('fs').readFileSync(await dl.path(), 'utf8')).toBe(copied);
|
|
});
|