52 lines
3.9 KiB
TypeScript
52 lines
3.9 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('link', { name: 'Aufträge', exact: true }).click();
|
|
await page.locator('tr[data-operation-id="' + operation + '"]').getByRole('button').click();
|
|
const op = page.locator('section[data-operation-id="' + operation + '"]');
|
|
await op.getByText('Technische Auftragsdaten', { exact: true }).click();
|
|
await expect(op.getByLabel('Technische Auftragsdaten', { exact: true })).toContainText('"approval_state": "pending_approval"');
|
|
await expect(op.getByLabel('Technische Auftragsdaten', { exact: true })).toContainText('"job_count": 0');
|
|
await expect(op.getByLabel('Technische Auftragsdaten', { exact: true })).toContainText('"execution_state": null');
|
|
await op.getByRole('button', { name: 'Antrag prüfen' }).click();
|
|
const detail = page.locator('section[data-plan-id]');
|
|
await detail.getByText('Technische Plandaten', { exact: true }).click();
|
|
await expect(detail.getByLabel('Technische Plandaten', { exact: true })).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.getByLabel('Technische Plandaten', { exact: true }).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: Genehmigen', exact: true });
|
|
await expect(approve).toBeDisabled();
|
|
await detail.getByRole('checkbox', { name: 'Ich habe die Geräte, den Inhalt und die Ausführungsrechte geprüft.', exact: false }).check();
|
|
await expect(approve).toBeEnabled();
|
|
await approve.click(); // Only actual UI interaction; no request/API approval.
|
|
await op.getByText('Technische Auftragsdaten', { exact: true }).click();
|
|
await expect(op.getByLabel('Technische Auftragsdaten', { exact: true })).toContainText('"approval_state": "approved"');
|
|
await expect(op.getByLabel('Technische Auftragsdaten', { exact: true })).toContainText('"job_count": 1');
|
|
await expect(op.getByLabel('Technische Auftragsdaten', { exact: true })).toContainText('"execution_state": "succeeded"', { timeout: 90000 });
|
|
await op.locator('button[data-job-id]').click();
|
|
await expect(op.getByRole('heading', { name: /^Ergebnis für / })).toBeVisible();
|
|
await op.getByText('Technische Ausführungsdaten', { exact: true }).click();
|
|
await expect(op.getByLabel('Technische Ausführungsdaten', { exact: true })).toContainText('"postconditions_passed": true');
|
|
await page.getByRole('button', { name: 'Abmelden', exact: true }).click();
|
|
});
|