test(admin): qualify recent audit filters and disclosure
This commit is contained in:
@@ -12,6 +12,7 @@ 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 auditSearch = Boolean(process.env.A3_AUDIT_SEARCH);
|
||||
const auditFilters = Boolean(process.env.A3_AUDIT_FILTERS);
|
||||
const userAlignmentOnly = Boolean(process.env.A3_ADMIN_USER_ALIGNMENT);
|
||||
const userTwoFactorOnly = Boolean(process.env.A3_ADMIN_USER_2FA);
|
||||
const usersOnly = userAlignmentOnly || userTwoFactorOnly;
|
||||
@@ -19,9 +20,10 @@ 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(!auditSearch || auditDateOnly, 'Audit search uses the populated Audit fixture.');
|
||||
assert.ok(!auditFilters || auditSearch, 'Audit filters extend the recent search journey.');
|
||||
assert.ok(!usersOnly || (adminOnly && !adminHeadings && !auditDateOnly && !(userTwoFactorOnly && userAlignmentOnly)), 'Admin Users verification uses a single scope.');
|
||||
assert.ok(!systemRefreshOnly || (adminOnly && !adminHeadings && !auditDateOnly && !usersOnly), 'System refresh qualification uses its own scope.');
|
||||
const out = path.resolve(import.meta.dirname, auditSearch ? '../../docs/ui-modernisation/visual-correction/evidence/audit-search' : userTwoFactorOnly ? '../../docs/ui-modernisation/visual-correction/evidence/admin-user-2fa' : 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');
|
||||
const out = path.resolve(import.meta.dirname, auditFilters ? '../../docs/ui-modernisation/visual-correction/evidence/audit-filters' : auditSearch ? '../../docs/ui-modernisation/visual-correction/evidence/audit-search' : userTwoFactorOnly ? '../../docs/ui-modernisation/visual-correction/evidence/admin-user-2fa' : 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();
|
||||
@@ -155,7 +157,8 @@ try {
|
||||
populatedAudit = true;
|
||||
await page.goto('http://localhost:4338/admin/audit');
|
||||
const table = page.getByRole('table', { name: t('adminAuditTitle'), exact: true });
|
||||
await expect(table.getByRole('cell', { name: 'Applied -> Interview Synthetic audit event', exact: true })).toBeVisible();
|
||||
const disclosure = table.getByText(t('adminAuditEventDetails'), { exact: true });
|
||||
await expect(disclosure).toBeVisible();
|
||||
if (auditSearch) {
|
||||
const input = page.getByRole('searchbox', { name: t('adminAuditSearch'), exact: true });
|
||||
await expect(input).toHaveAccessibleDescription(t('adminAuditSearchScope'));
|
||||
@@ -170,6 +173,27 @@ try {
|
||||
await input.press('Backspace');
|
||||
await expect(table.getByText('StatusChanged', { exact: true })).toBeVisible();
|
||||
}
|
||||
if (auditFilters) {
|
||||
await page.getByRole('combobox', { name: t('adminAuditEventType'), exact: true }).selectOption('StatusChanged');
|
||||
const from = page.getByLabel(t('adminAuditFromDate'), { exact: true });
|
||||
const through = page.getByLabel(t('adminAuditThroughDate'), { exact: true });
|
||||
await from.fill('2026-11-04');
|
||||
await through.fill('2026-11-03');
|
||||
await expect(through).toHaveAttribute('aria-invalid', 'true');
|
||||
await expect(page.getByText(t('adminAuditInvalidRange'), { exact: true })).toBeVisible();
|
||||
await through.fill('2026-11-04');
|
||||
await expect(disclosure).toBeVisible();
|
||||
const note = table.getByText('Synthetic audit event', { exact: true });
|
||||
await expect(note).toBeHidden();
|
||||
await disclosure.press('Enter');
|
||||
await expect(note).toBeVisible();
|
||||
await expect(table.getByText(t('adminAuditNewValue'), { exact: true })).toBeVisible();
|
||||
await disclosure.scrollIntoViewIfNeeded();
|
||||
await scan('audit-expanded', true);
|
||||
await disclosure.press('Enter');
|
||||
await expect(note).toBeHidden();
|
||||
await page.getByRole('region', { name: t('adminAuditTitle'), exact: true }).evaluate(node => { node.scrollLeft = 0; });
|
||||
}
|
||||
const heading = table.getByRole('columnheader', { name: t('adminAuditAt'), exact: true });
|
||||
const dateCell = table.getByRole('row').nth(1).getByRole('cell').first();
|
||||
const wordsStayOnOneLine = element => {
|
||||
@@ -218,7 +242,7 @@ try {
|
||||
if (!accountOnly) {
|
||||
await page.goto('http://localhost:4338/admin/users'); await expect(page.getByRole('button', { name: t('adminUsersRemoveAdmin'), exact: true })).toBeDisabled(); await expect(page.getByRole('button', { name: t('adminUsersDelete'), exact: true })).toBeDisabled(); await checkHeading('users', 'adminUsersSubtitle'); await scan('last-admin');
|
||||
await page.goto('http://localhost:4338/admin/audit'); await expect(page.getByText(t('adminAuditNoEvents'), { exact: true })).toBeVisible(); await scan('audit-empty');
|
||||
if (adminOnly) { populatedAudit = true; await page.reload(); await expect(page.getByRole('cell', { name: 'Applied -> Interview Synthetic audit event', exact: true })).toBeVisible(); await checkHeading('auditLog', 'adminAuditSubtitle'); await scan('audit-populated'); }
|
||||
if (adminOnly) { populatedAudit = true; await page.reload(); await expect(page.getByText(t('adminAuditEventDetails'), { exact: true })).toBeVisible(); await checkHeading('auditLog', 'adminAuditSubtitle'); await scan('audit-populated'); }
|
||||
await page.goto('http://localhost:4338/admin/system'); await expect(page.getByText(t('adminSystemLoadFailed'), { exact: true })).toBeVisible(); await scan('system-unavailable');
|
||||
if (adminOnly) {
|
||||
systemAvailable = true; await page.reload(); await expect(page.getByText(system.environment, { exact: true })).toBeVisible(); await checkHeading('systemStatus', 'adminSystemSubtitle'); await scan('system-normal');
|
||||
@@ -250,7 +274,7 @@ 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 * (auditSearch ? 2 : systemRefreshOnly ? 3 : usersOnly || 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 * (auditFilters || systemRefreshOnly ? 3 : auditSearch ? 2 : usersOnly || 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 {
|
||||
|
||||
Reference in New Issue
Block a user