50 lines
3.7 KiB
TypeScript
50 lines
3.7 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.getByRole('link', { name: 'Aufträge', exact: true }).click();
|
|
await page.getByRole('link', { name: 'Neuer Auftrag', exact: true }).click();
|
|
await page.getByRole('button', { name: 'Weiter zum Skript' }).click();
|
|
await page.getByRole('radio', { name: 'Einmaliges Skript' }).check();
|
|
await page.getByLabel('Skriptinhalt', { exact: true }).fill("printf '%s\\n' 'Hello World'\n");
|
|
await page.getByText('Zeitfenster und Ausführungsoptionen', { exact: true }).click();
|
|
await page.getByLabel('Laufzeit je Gerät in Sekunden').fill('60');
|
|
await page.getByLabel('Erwartete Standardausgabe (optional)', { exact: true }).fill('Hello World\n');
|
|
await page.getByLabel('Begründung', { exact: true }).fill('Dev/test browser simulation · Hello World');
|
|
await page.getByRole('button', { name: 'Zusammenfassung ansehen' }).click();
|
|
const approve = page.getByRole('button', { name: 'SIMULIERT: Genehmigen' });
|
|
await expect(approve).toHaveCount(0);
|
|
await page.getByRole('button', { name: 'Zur Genehmigung einreichen' }).click();
|
|
const op = page.locator('section[data-operation-id]');
|
|
await expect(op.locator('.state-pending_approval')).toBeVisible();
|
|
await op.getByRole('button', { name: 'Antrag prüfen', exact: true }).click();
|
|
await expect(approve).toBeDisabled();
|
|
await page.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(); // The only approval path: visible, interactive UI action.
|
|
await op.getByText('Technische Auftragsdaten', { exact: true }).click();
|
|
const data = op.getByLabel('Technische Auftragsdaten', { exact: true });
|
|
await expect(data).toContainText('"approval_state": "approved"');
|
|
await expect(data).toContainText('"execution_state": "succeeded"', { timeout: 90000 });
|
|
await op.locator('button[data-job-id]').first().click();
|
|
await expect(page.getByRole('heading', { name: /^Ergebnis für / })).toBeVisible();
|
|
await page.getByRole('button', { name: 'Abmelden', exact: true }).click();
|
|
});
|