Show script results directly on order details
This commit is contained in:
@@ -43,7 +43,7 @@ test('dev/test browser simulation: login → fixed plan → pending → explicit
|
||||
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 expect(op.getByLabel('stdout Textansicht')).toHaveText('Hello World');
|
||||
await page.getByRole('button', { name: 'Abmelden', exact: true }).click();
|
||||
});
|
||||
|
||||
@@ -62,6 +62,74 @@ test.afterAll(async () => {
|
||||
await server?.close();
|
||||
});
|
||||
|
||||
test('opens a single result automatically and shows each result at its own device row', async ({ page }) => {
|
||||
const operationId = randomUUID();
|
||||
const multiOperationId = randomUUID();
|
||||
const jobs = [linux, windows].map((device, index) => ({
|
||||
...device,
|
||||
job_id: randomUUID(),
|
||||
attempt_id: randomUUID(),
|
||||
state: index === 0 ? 'succeeded' : 'failed'
|
||||
}));
|
||||
const api = '/api/v1/tenants/' + tenantId;
|
||||
const resultReads = new Set<string>();
|
||||
await page.route(origin + '/auth/config', r => r.fulfill({ json: {
|
||||
dev_login_enabled: true, oidc_configured: false, oidc_login_url: null
|
||||
} }));
|
||||
await page.route(origin + '/auth/session', r => r.fulfill({ json: {
|
||||
principal, tenant_id: tenantId, permissions: auth.permissions, csrf_token: auth.csrf_token, testsimulation: true
|
||||
} }));
|
||||
await page.route(origin + '/api/v1/**', async r => {
|
||||
const pathname = new URL(r.request().url()).pathname;
|
||||
if (pathname === '/api/v1/tenants') return r.fulfill({ json: listing(auth.tenants) });
|
||||
if (pathname === '/api/v1/approvals') return r.fulfill({ json: { ...listing([]), pending_count: 0 } });
|
||||
if (pathname.startsWith(api + '/operations/')) {
|
||||
const id = pathname.slice((api + '/operations/').length);
|
||||
if (id === operationId || id === multiOperationId) return r.fulfill({ json: {
|
||||
operation_id: id, customer_name: 'Nord', title: script.name, approval_state: 'approved',
|
||||
execution_state: id === operationId ? 'succeeded' : 'partially_succeeded',
|
||||
targets: [linux, windows], jobs: id === operationId ? [jobs[0]] : jobs
|
||||
} });
|
||||
}
|
||||
const job = jobs.find(item => pathname === api + '/jobs/' + item.job_id);
|
||||
if (job) {
|
||||
const success = job.state === 'succeeded';
|
||||
resultReads.add(job.job_id);
|
||||
return r.fulfill({ json: { ...job, result: {
|
||||
exit_code: success ? 0 : 1, output_truncated: false,
|
||||
stdout: success ? [...Buffer.from('Linux\n')] : [],
|
||||
stderr: success ? [] : [...Buffer.from('Fehler auf Windows\n')]
|
||||
} } });
|
||||
}
|
||||
return r.fulfill({ status: 404, json: { code: 'UNEXPECTED_FIXTURE_REQUEST' } });
|
||||
});
|
||||
|
||||
const openOrder = (id: string) => page.goto(origin + '/#auftraege/ansehen/' + tenantId + '/' + id);
|
||||
await openOrder(operationId);
|
||||
await expect(page.getByRole('heading', { name: 'Ergebnis für test-linux' })).toBeVisible();
|
||||
await expect(page.getByLabel('stdout Textansicht')).toHaveText('Linux');
|
||||
await expect(page.getByText('Exitcode 0', { exact: true })).toBeVisible();
|
||||
expect([...resultReads]).toEqual([jobs[0].job_id]);
|
||||
|
||||
await page.setViewportSize({ width: 390, height: 844 });
|
||||
resultReads.clear();
|
||||
await openOrder(multiOperationId);
|
||||
const linuxButton = page.getByRole('button', { name: 'Ergebnis anzeigen für test-linux' });
|
||||
const windowsButton = page.getByRole('button', { name: 'Ergebnis anzeigen für test-windows' });
|
||||
await expect(linuxButton).toBeVisible();
|
||||
await expect(windowsButton).toBeVisible();
|
||||
expect(resultReads.size).toBe(0);
|
||||
await linuxButton.click();
|
||||
const linuxRow = page.getByRole('listitem').filter({ has: page.getByRole('button', { name: 'Ergebnis schließen für test-linux' }) });
|
||||
await expect(linuxRow.getByLabel('stdout Textansicht')).toHaveText('Linux');
|
||||
await windowsButton.click();
|
||||
await expect(linuxButton).toHaveAttribute('aria-expanded', 'false');
|
||||
await expect(page.getByLabel('stderr Textansicht')).toHaveText('Fehler auf Windows');
|
||||
await page.getByRole('button', { name: 'Ergebnis schließen für test-windows' }).click();
|
||||
await expect(page.getByRole('region', { name: 'Gespeichertes Konsolenergebnis' })).toHaveCount(0);
|
||||
expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(390);
|
||||
});
|
||||
|
||||
for (const library of [true, false]) {
|
||||
test(
|
||||
library
|
||||
|
||||
@@ -43,7 +43,6 @@ test('preserved real VM: pending fixed Hello World → UI click → confirmed re
|
||||
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');
|
||||
|
||||
Reference in New Issue
Block a user