Follow the new order and review screens in development browser checks
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
// Actual UI only. No page.request, fetch injection, approval API or DB access.
|
||||
const fs = require('node:fs');
|
||||
const { readTechnicalData, technicalData } = require('./review-data.cjs');
|
||||
const path = require('node:path');
|
||||
const crypto = require('node:crypto');
|
||||
const { isDeepStrictEqual } = require('node:util');
|
||||
@@ -50,13 +51,13 @@ function checkWindowsHello(job, planBytes) {
|
||||
assert(session.testsimulation === true && session.approval_origin === 'dev_test_browser_simulation' && session.principal === expected.expected_principal);
|
||||
await page.getByRole('status').filter({ hasText: 'SIMULIERT' }).waitFor();
|
||||
await page.getByRole('link', { name: 'Aufträge', exact: true }).click();
|
||||
await page.getByRole('button', { name: expected.operation_id, exact: true }).click();
|
||||
const op = page.locator('section').filter({ has: page.getByRole('heading', { name: 'Antrag / Ausführung ' + expected.operation_id, exact: true }) });
|
||||
const pending = JSON.parse(await op.locator('pre').first().innerText());
|
||||
await page.locator('tr[data-operation-id="' + expected.operation_id + '"]').getByRole('button').click();
|
||||
const op = page.locator('section[data-operation-id="' + expected.operation_id + '"]');
|
||||
const pending = await readTechnicalData(op, 'Technische Auftragsdaten');
|
||||
assert(pending.approval_state === 'pending_approval' && pending.job_count === 0 && pending.execution_state === null);
|
||||
await op.getByRole('button', { name: 'Unveränderlichen Plan zur Prüfung öffnen', exact: true }).click();
|
||||
const detail = page.locator('section').filter({ has: page.getByRole('heading', { name: 'Unveränderlicher Plan / Genehmigungsdetail', exact: true }) });
|
||||
const rendered = JSON.parse(await detail.getByLabel('Alle festen Zielpreviews, exakte Skriptinhalte/Hashes, Parameter, Rechte, Fristen, Rollout und Nachbedingungen', { exact: true }).innerText());
|
||||
await op.getByRole('button', { name: 'Antrag prüfen', exact: true }).click();
|
||||
const detail = page.locator('section[data-plan-id]');
|
||||
const rendered = await readTechnicalData(detail, 'Technische Plandaten');
|
||||
assert(rendered.plan_hash === expected.plan.plan_hash && crypto.createHash('sha256').update(Buffer.from(rendered.plan_payload_bytes)).digest('hex') === expected.plan.plan_hash);
|
||||
assert(JSON.stringify(rendered.plan_payload_bytes) === JSON.stringify(expected.plan.plan_payload_bytes));
|
||||
assert(rendered.jobs.length === 1 && rendered.resolved_targets.length === 1);
|
||||
@@ -70,16 +71,19 @@ function checkWindowsHello(job, planBytes) {
|
||||
assert(expected.stage === 'pending_approval' && expected.preapproval.jobs === 0
|
||||
&& expected.preapproval.outbox === 0 && expected.preapproval.permits === 0);
|
||||
assert(pending.plan_id === rendered.plan_id && pending.operation_id === expected.operation_id);
|
||||
await detail.getByLabel('Feste PowerShell-Prozessprofile', { exact: true })
|
||||
.getByText('Asset: ' + payload.asset_id + ' · Windows PowerShell5.1 · agent_service · RemoteSigned · nur Jobprozess', { exact: true }).waitFor();
|
||||
const script = detail.getByLabel('Skriptinhalt', { exact: true });
|
||||
await script.getByText('Windows PowerShell 5.1 · RemoteSigned für diesen Prozess', { exact: true }).waitFor();
|
||||
await script.getByText('Ausführungsdetails und Prüfsummen', { exact: true }).click();
|
||||
await script.getByText(payload.asset_id, { exact: true }).waitFor();
|
||||
await script.getByText('Profil', { exact: false }).filter({ hasText: 'agent_service' }).waitFor();
|
||||
}
|
||||
else if (expected.case === 'hello' || expected.case === 'cancel_queued') assert(payload.action.action === 'run_script' && payload.action.interpreter === 'posix_sh' && payload.action.script_utf8 === "printf '%s\\n' 'Hello World'\n" && payload.action.expected_stdout === 'Hello World\n');
|
||||
else assert(payload.action.action === 'refresh_inventory' && payload.action.scope === 'linux.base');
|
||||
const approve = detail.getByRole('button', { name: 'SIMULIERT: Diesen festen Plan ausdrücklich genehmigen', exact: true });
|
||||
const approve = detail.getByRole('button', { name: 'SIMULIERT: Genehmigen', exact: true });
|
||||
assert(await approve.isDisabled());
|
||||
await detail.getByRole('checkbox', { name: 'Ich habe sämtliche festen Ziele', exact: false }).check();
|
||||
await detail.getByRole('checkbox', { name: 'Ich habe die Geräte, den Inhalt und die Ausführungsrechte geprüft.', exact: false }).check();
|
||||
await approve.click();
|
||||
await op.locator('p.warning').filter({ hasText: 'Antrag: approved' }).waitFor();
|
||||
await (await technicalData(op, 'Technische Auftragsdaten')).filter({ hasText: '"approval_state": "approved"' }).waitFor();
|
||||
await page.getByRole('button', { name: 'Abmelden', exact: true }).click();
|
||||
} finally { await browser.close(); }
|
||||
})().catch(error => { console.log('CLOUD_UI_INCOMPLETE:' + error.constructor.name); process.exitCode = 1; });
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Read only through actual UI clicks; inspect its normal HTTP response.
|
||||
const fs = require('node:fs');
|
||||
const { readTechnicalData } = require('./review-data.cjs');
|
||||
const path = require('node:path');
|
||||
const assert = require('node:assert/strict');
|
||||
const { chromium } = require('../../web/node_modules/playwright');
|
||||
@@ -31,15 +32,15 @@ function privateJson(file) {
|
||||
await page.getByLabel('Kunde', { exact: true }).selectOption(expected.tenant_id);
|
||||
assert.equal(await page.getByLabel('Kunde', { exact: true }).inputValue(), expected.tenant_id);
|
||||
await page.getByRole('link', { name: 'Aufträge', exact: true }).click();
|
||||
await page.getByRole('button', { name: expected.operation_id, exact: true }).click();
|
||||
const op = page.locator('section').filter({ has: page.getByRole('heading', { name: 'Antrag / Ausführung ' + expected.operation_id, exact: true }) });
|
||||
await page.locator('tr[data-operation-id="' + expected.operation_id + '"]').getByRole('button').click();
|
||||
const op = page.locator('section[data-operation-id="' + expected.operation_id + '"]');
|
||||
const response = page.waitForResponse(r => new URL(r.url()).pathname === `/api/v1/tenants/${expected.tenant_id}/jobs/${expected.job_id}` && r.status() === 200);
|
||||
await op.getByRole('button', { name: 'Job ' + expected.job_id + ' · succeeded', exact: true }).click();
|
||||
await op.locator('button[data-job-id="' + expected.job_id + '"]').click();
|
||||
const http = await (await response).json();
|
||||
const detail = page.locator('article').filter({ has: page.getByRole('heading', { name: 'Job ' + expected.job_id, exact: true }) });
|
||||
await detail.locator('pre').waitFor();
|
||||
const rendered = JSON.parse(await detail.locator('pre').innerText());
|
||||
assert.deepEqual(http, expected.result); assert.deepEqual(rendered, expected.result);
|
||||
const detail = page.locator('article[data-job-id="' + expected.job_id + '"]');
|
||||
|
||||
const rendered = await readTechnicalData(detail, 'Technische Ausführungsdaten');
|
||||
assert.equal(http.state, 'succeeded'); assert.deepEqual(http, expected.result); assert.deepEqual(rendered, expected.result);
|
||||
const observation = JSON.parse(Buffer.from(rendered.result.stdout).toString('utf8'));
|
||||
assert.equal(observation.data.unit, 'rmm-mvp-test.service'); assert.equal(observation.data.json_lines.length, 4);
|
||||
fs.writeFileSync(path.join(path.dirname(file), 'read-evidence.json'), JSON.stringify({ verified: true, http, rendered }), { mode: 0o600, flag: 'wx' });
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// Read the data shown by the interactive dev/test WebUI.
|
||||
async function technicalData(region, label) {
|
||||
const summary = region.getByText(label, { exact: true });
|
||||
const pre = region.getByLabel(label, { exact: true });
|
||||
await summary.waitFor();
|
||||
if (!await pre.isVisible()) await summary.click();
|
||||
await pre.waitFor();
|
||||
return pre;
|
||||
}
|
||||
|
||||
async function readTechnicalData(region, label) {
|
||||
const data = await technicalData(region, label);
|
||||
return JSON.parse(await data.innerText());
|
||||
}
|
||||
|
||||
module.exports = { technicalData, readTechnicalData };
|
||||
Reference in New Issue
Block a user