Files
pulse/tests/ui/quick-command.ui.js
T
jaredandClaude Opus 5.5 040ad028c0
CI / UI screenshots (before/after) (push) Skipped
CI / Lint (eslint) (push) Successful in 25s
CI / Test (jest) (push) Successful in 25s
CI / Security (npm audit) (push) Successful in 21s
CI / Scan (secrets, workflows, shell) (push) Successful in 2m0s
CI / Integration (api) (push) Successful in 2m23s
CI / Lint (eslint) (pull_request) Successful in 24s
CI / Test (jest) (pull_request) Successful in 32s
CI / Security (npm audit) (pull_request) Successful in 39s
CI / UI (playwright) (push) Successful in 2m6s
CI / Deploy (push) Skipped
CI / Deploy worker (push) Skipped
CI / Notify (push) Skipped
CI / Integration (api) (pull_request) Successful in 2m13s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 2m46s
CI / UI screenshots (before/after) (pull_request) Successful in 27s
CI / UI (playwright) (pull_request) Successful in 3m5s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
Safer workflow conditions; Pulse is admin-only
- Workflow conditions (step.condition and route `if`) are now parsed and
  interpreted by lib/condition.js instead of being run with Node's vm
  module. The language covers what workflows use: state/params lookups,
  parseInt/parseFloat/Number/String/Boolean, a few string methods, the
  usual operators with JavaScript semantics. Conditions can only read the
  workflow's own data. Every condition in the production workflows gives
  the same result as before (differential test, 150 random states each).
- Creating and updating a workflow rejects conditions that don't parse
  (400 with the step and the error).
- Creating a workflow requires admin, like editing already did.
- Only the admin group may use Pulse (pages, API and live WebSocket);
  employees get 403. Gandalf and workers use API keys and are unaffected.
- The live-update UI test finds its execution's row by id instead of
  counting rows (the list is capped at 50).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 22:05:42 -05:00

66 lines
2.9 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();
const result = page.locator('#qc-result');
await expect(result).toContainText('Command sent successfully');
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);
});
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
await page.locator('#qc-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 ${token()}`);
await page.locator('#qc-execute-btn').click();
const result = page.locator('#qc-result');
await expect(result).toContainText('Success: 3');
await expect(result).toContainText('Failed: 0');
await expect(result.locator('tbody tr')).toHaveCount(3);
});
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();
});