test(admin): qualify status refresh and document diagnostics

This commit is contained in:
cesnimda
2026-11-10 12:42:57 +01:00
parent 4981a24238
commit 13c9c65352
128 changed files with 4723 additions and 8 deletions
@@ -12,10 +12,12 @@ const adminOnly = Boolean(process.env.A3_ADMIN_FLAT);
const adminHeadings = Boolean(process.env.A3_ADMIN_HEADINGS);
const auditDateOnly = Boolean(process.env.A3_AUDIT_DATE);
const userAlignmentOnly = Boolean(process.env.A3_ADMIN_USER_ALIGNMENT);
const systemRefreshOnly = Boolean(process.env.A3_SYSTEM_REFRESH);
assert.ok(!adminHeadings || adminOnly, 'Heading qualification uses the Admin fixtures.');
assert.ok(!auditDateOnly || (adminOnly && !adminHeadings), 'Audit timestamp qualification uses its own scope.');
assert.ok(!userAlignmentOnly || (adminOnly && !adminHeadings && !auditDateOnly), 'Admin Users alignment uses its own scope.');
const out = path.resolve(import.meta.dirname, userAlignmentOnly ? '../../docs/ui-modernisation/visual-correction/evidence/admin-user-alignment' : auditDateOnly ? '../../docs/ui-modernisation/visual-correction/evidence/audit-date' : adminHeadings ? '../../docs/ui-modernisation/visual-correction/evidence/admin-headings' : adminOnly ? '../../docs/ui-modernisation/visual-correction/evidence/admin-flat' : accountOnly ? '../../docs/ui-modernisation/visual-correction/evidence/account-flat' : '../../docs/ui-modernisation/evidence/account-admin/browser');
assert.ok(!systemRefreshOnly || (adminOnly && !adminHeadings && !auditDateOnly && !userAlignmentOnly), 'System refresh qualification uses its own scope.');
const out = path.resolve(import.meta.dirname, systemRefreshOnly ? '../../docs/ui-modernisation/visual-correction/evidence/system-status-refresh' : userAlignmentOnly ? '../../docs/ui-modernisation/visual-correction/evidence/admin-user-alignment' : auditDateOnly ? '../../docs/ui-modernisation/visual-correction/evidence/audit-date' : adminHeadings ? '../../docs/ui-modernisation/visual-correction/evidence/admin-headings' : adminOnly ? '../../docs/ui-modernisation/visual-correction/evidence/admin-flat' : accountOnly ? '../../docs/ui-modernisation/visual-correction/evidence/account-flat' : '../../docs/ui-modernisation/evidence/account-admin/browser');
fs.mkdirSync(out, { recursive: true });
const report = { screens: [], journeys: [], errors: [], unexpectedWrites: [], exportDenials: [], unavailableReads: [], blockedExternal: [] };
const browser = await chromium.launch();
@@ -89,6 +91,38 @@ try {
await expect(page.getByRole('heading', { name: t(title), exact: true, level: 1 })).toBeVisible();
await expect(page.getByText(t(subtitle), { exact: true })).toBeVisible();
};
if (systemRefreshOnly) {
await page.goto('http://localhost:4338/admin/system');
const loadError = page.getByText(t('adminSystemLoadFailed'), { exact: true });
const staleError = page.getByText(t('adminSystemRefreshFailed'), { exact: true });
const time = page.getByText(t('adminSystemStatusReceivedAt') + ':', { exact: true }).locator('..').locator('time');
await expect(loadError).toBeVisible();
await expect(time).toHaveCount(0);
await scan('system-unavailable');
systemAvailable = true;
const refresh = page.getByRole('button', { name: t('adminSystemRefresh'), exact: true });
await refresh.press('Enter');
await expect(time).toBeVisible();
const firstRead = await time.getAttribute('datetime');
assert.ok(firstRead && Number.isFinite(Date.parse(firstRead)));
await scan('system-normal');
systemAvailable = false;
await refresh.press('Enter');
await expect(staleError).toBeVisible();
await expect(time).toHaveAttribute('datetime', firstRead);
await expect(page.getByText(system.environment, { exact: true })).toBeVisible();
const benchmarkError = await page.getByText(t('adminSystemBenchmarkLoadFailed'), { exact: true }).boundingBox();
assert.ok((await time.boundingBox()).y < benchmarkError.y, 'The stale timestamp stays above ancillary errors.');
await scan('system-stale');
systemAvailable = true;
await staleError.locator('xpath=ancestor::*[@role="alert"]').getByRole('button', { name: t('retry'), exact: true }).press('Enter');
await expect(staleError).toHaveCount(0);
await expect(time).not.toHaveAttribute('datetime', firstRead);
assert.ok(Date.parse(await time.getAttribute('datetime')) > Date.parse(firstRead));
report.journeys.push({ width, language, mode, lastSuccessfulReadPreservedAndRenewed: 'PASS' });
await context.close();
continue;
}
if (userAlignmentOnly) {
await page.goto('http://localhost:4338/admin/users');
await expect(page.getByRole('button', { name: t('adminUsersRemoveAdmin'), exact: true })).toBeDisabled();
@@ -194,10 +228,10 @@ try {
}
report.journeys.push({ width, language, mode, draftPreservedAcrossKeyboardSections: processingOnly || adminOnly ? 'NOT RUN' : 'PASS', revocationAndDeletionCancelled: processingOnly || adminOnly ? 'NOT RUN' : 'PASS', recentExportDenial: processingOnly || adminOnly ? 'NOT RUN' : 'PASS', lastAdminActionsDisabled: processingOnly || accountOnly ? 'NOT RUN' : 'PASS', processingKeyboardAndOwnerLink: accountOnly ? 'NOT RUN' : 'PASS', processingFilterLabelsAndDurationGeometry: accountOnly ? 'NOT RUN' : 'PASS', populatedAdminReadStates: adminOnly ? 'PASS' : 'NOT RUN' }); await context.close();
}
assert.equal(report.screens.length, configurations.length * (userAlignmentOnly || auditDateOnly || processingOnly ? 1 : accountOnly ? 7 : adminOnly ? 9 : 8)); assert.equal(report.journeys.length, configurations.length); assert.equal(report.exportDenials.length, processingOnly || adminOnly ? 0 : configurations.length);
assert.equal(report.screens.length, configurations.length * (systemRefreshOnly ? 3 : userAlignmentOnly || auditDateOnly || processingOnly ? 1 : accountOnly ? 7 : adminOnly ? 9 : 8)); assert.equal(report.journeys.length, configurations.length); assert.equal(report.exportDenials.length, processingOnly || adminOnly ? 0 : configurations.length);
assert.deepEqual(report.errors, []); assert.deepEqual(report.unexpectedWrites, []); assert.ok(report.blockedExternal.every(origin => origin === 'https://fonts.googleapis.com'));
console.log(`PASS:${report.journeys.length} controlled journeys,${report.screens.length} axe scans/captures; no mutation requests.`);
} finally {
fs.writeFileSync(path.join(out, processingOnly ? 'PROCESSING.json' : process.env.A3_PILOT ? 'PILOT.json' : 'BROWSER.json'), JSON.stringify({ ...report, limits: ['Every API response is synthetic. In admin-only mode all mutations are blocked and account flows are NOT RUN; otherwise account export is a controlled 403 and confirmations are cancelled.', userAlignmentOnly ? 'Only the Users table alignment, mobile layout and last-administrator disabled actions are exercised.' : auditDateOnly ? 'Only the populated audit table, timestamp geometry and keyboard scrolling are exercised.' : adminOnly ? 'System and audit populated states are synthetic read fixtures; no probe, maintenance, settings save, undo, restore or provider action executed.' : 'System monitor is unavailable and audit empty; detailed success/action scenarios are unit tests, not live qualification.', 'No real credentials, provider activation, model, native device, integrated security, production or release acceptance.'] }, null, 2));
fs.writeFileSync(path.join(out, processingOnly ? 'PROCESSING.json' : process.env.A3_PILOT ? 'PILOT.json' : 'BROWSER.json'), JSON.stringify({ ...report, limits: ['Every API response is synthetic. In admin-only mode all mutations are blocked and account flows are NOT RUN; otherwise account export is a controlled 403 and confirmations are cancelled.', systemRefreshOnly ? 'Only initial unavailable, successful, stale and recovered System Status reads are exercised. No diagnostic action executed.' : userAlignmentOnly ? 'Only the Users table alignment, mobile layout and last-administrator disabled actions are exercised.' : auditDateOnly ? 'Only the populated audit table, timestamp geometry and keyboard scrolling are exercised.' : adminOnly ? 'System and audit populated states are synthetic read fixtures; no probe, maintenance, settings save, undo, restore or provider action executed.' : 'System monitor is unavailable and audit empty; detailed success/action scenarios are unit tests, not live qualification.', 'No real credentials, provider activation, model, native device, integrated security, production or release acceptance.'] }, null, 2));
await browser.close();
}