Files
rust-discovery/tests/browser/approval.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

39 lines
3.0 KiB
TypeScript

import { test, expect } from '../../web/node_modules/@playwright/test/index.js';
import { readFileSync, statSync } from 'node:fs';
test('dev/test browser simulation: login → fixed plan → pending → explicit click → result', async ({ page }) => {
test.skip(process.env.RMM_E2E_PROFILE !== 'dev/test' || process.env.RMM_E2E_MODE !== 'execute', 'Explicit dev/test execution opt-in required; never run against production');
const file = process.env.RMM_E2E_LOGIN_FILE;
if (!file) throw new Error('Protected login JSON file required');
const stat = statSync(file);
if (!stat.isFile() || (stat.mode & 0o777) !== 0o600 || stat.uid !== process.getuid?.()) throw new Error('Login file must be owned by current user, mode 0600');
const value: unknown = JSON.parse(readFileSync(file, 'utf8'));
if (!value || typeof value !== 'object' || !('username' in value) || !('password' in value) || typeof value.username !== 'string' || typeof value.password !== 'string') throw new Error('Invalid login file');
const asset = process.env.RMM_E2E_ASSET_ID;
if (!asset) throw new Error('Explicit approved test asset required');
// No APIRequestContext, direct approval request, storageState, screenshots or traces.
await page.goto('/');
await page.getByLabel('Benutzername').fill(value.username);
await page.getByLabel('Passwort', { exact: true }).fill(value.password);
await page.getByRole('button', { name: 'Anmelden', exact: true }).click();
await expect(page.getByRole('status')).toContainText('SIMULIERT');
await expect(page.getByRole('status')).toContainText('kein menschlicher Produktions-Freigabenachweis');
await page.getByRole('checkbox', { name: `Ziel ${asset}`, exact: true }).check();
await page.getByLabel('Exakte UTF-8 Skriptbytes', { exact: false }).fill("printf '%s\\n' 'Hello World'\n");
await page.getByLabel('Erwartete stdout-Ausgabe', { exact: false }).fill('Hello World\n');
await page.getByLabel('Begründung', { exact: true }).fill('Dev/test browser simulation · Hello World');
await page.getByRole('button', { name: 'Plan erstellen · noch keine Ausführung' }).click();
const approve = page.getByRole('button', { name: 'SIMULIERT: Diesen festen Plan ausdrücklich genehmigen' });
await expect(approve).toBeDisabled();
await page.getByRole('button', { name: 'Antrag absenden · pending_approval' }).click();
await expect(page.getByText('Antrag: pending_approval', { exact: false })).toBeVisible();
await page.getByRole('checkbox', { name: 'Ich habe sämtliche festen Ziele', exact: false }).check();
await expect(approve).toBeEnabled();
await approve.click(); // The only approval path: visible, interactive UI action.
await expect(page.getByText('Antrag: approved', { exact: false })).toBeVisible();
await expect(page.getByText('Ausführung: succeeded', { exact: false })).toBeVisible({ timeout: 90000 });
await page.getByRole('button', { name: /^Job / }).first().click();
await expect(page.getByRole('heading', { name: /^Job / })).toBeVisible();
await page.getByRole('button', { name: 'Abmelden', exact: true }).click();
});