Files
rust-discovery/tests/browser/vm-jobs.spec.ts
T
BuTzZ 6c3203d725
Rust development slice / linux (push) Failing after 1m10s
feat: snapshot Linux-first RMM MVP and pause handover
2026-11-12 22:06:25 +01:00

47 lines
3.3 KiB
TypeScript

import { test, expect } from '../../web/node_modules/@playwright/test/index.js';
import { createHash } from 'node:crypto';
import { login } from './helpers';
test('preserved real VM: pending fixed Hello World → UI click → confirmed result', async ({ page }) => {
test.skip(process.env.RMM_E2E_PROFILE !== 'dev/test' || process.env.RMM_E2E_MODE !== 'vm-hello', 'Explicit VM Hello-World simulation required');
const asset = process.env.RMM_E2E_ASSET_ID;
const operation = process.env.RMM_E2E_OPERATION_ID;
if (!asset || !operation) throw new Error('Fixed VM asset and existing pending operation required');
await login(page);
await page.getByRole('button', { name: operation, exact: true }).click();
const op = page.locator('section').filter({ has: page.getByRole('heading', { name: `Antrag / Ausführung ${operation}`, exact: true }) });
await expect(op.locator('p.warning')).toContainText('Antrag: pending_approval');
await expect(op.locator('pre').first()).toContainText('"job_count": 0');
await expect(op.locator('pre').first()).toContainText('"execution_state": null');
await op.getByRole('button', { name: 'Unveränderlichen Plan zur Prüfung öffnen' }).click();
const detail = page.locator('section').filter({ has: page.getByRole('heading', { name: 'Unveränderlicher Plan / Genehmigungsdetail', exact: true }) });
await expect(detail.locator('pre')).toBeVisible();
// Inspect the complete rendered immutable preview, not a separately fetched
// or caller-supplied payload. Refuse all root/package/reboot/extra-target jobs.
const plan = JSON.parse(await detail.locator('pre').innerText());
expect(plan.resolved_targets).toHaveLength(1);
expect(plan.resolved_targets[0].asset_id).toBe(asset);
expect(plan.jobs).toHaveLength(1);
const payload = plan.jobs[0].payload;
expect(payload.asset_id).toBe(asset);
expect(payload.execution_identity).toBe('agent_service');
expect(payload.action).toEqual({ action: 'run_script', interpreter: 'posix_sh', script_utf8: "printf '%s\\n' 'Hello World'\n", arguments: [], expected_stdout: 'Hello World\n' });
expect(payload.max_runtime_seconds).toBeLessThanOrEqual(60);
expect(payload.max_output_bytes).toBeLessThanOrEqual(65536);
expect(Date.parse(payload.start_before)).toBeGreaterThan(Date.now());
expect(createHash('sha256').update(Buffer.from(plan.plan_payload_bytes)).digest('hex')).toBe(plan.plan_hash);
await expect(detail).toContainText(plan.plan_hash);
const approve = detail.getByRole('button', { name: 'SIMULIERT: Diesen festen Plan ausdrücklich genehmigen', exact: true });
await expect(approve).toBeDisabled();
await detail.getByRole('checkbox', { name: 'Ich habe sämtliche festen Ziele', exact: false }).check();
await expect(approve).toBeEnabled();
await approve.click(); // Only actual UI interaction; no request/API approval.
await expect(op.locator('p.warning')).toContainText('Antrag: approved');
await expect(op.locator('pre').first()).toContainText('"job_count": 1');
await expect(op.locator('p.warning')).toContainText('Ausführung: succeeded', { timeout: 90000 });
await op.getByRole('button', { name: /^Job / }).click();
await expect(op.getByRole('heading', { name: /^Job / })).toBeVisible();
await expect(op.locator('article pre')).toContainText('"postconditions_passed": true');
await page.getByRole('button', { name: 'Abmelden', exact: true }).click();
});