test(admin): qualify recent audit search and responsive feedback
This commit is contained in:
@@ -11,15 +11,17 @@ const accountOnly = Boolean(process.env.A3_ACCOUNT_FLAT);
|
||||
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 userAlignmentOnly = Boolean(process.env.A3_ADMIN_USER_ALIGNMENT);
|
||||
const userTwoFactorOnly = Boolean(process.env.A3_ADMIN_USER_2FA);
|
||||
const usersOnly = userAlignmentOnly || userTwoFactorOnly;
|
||||
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(!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, 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, 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();
|
||||
@@ -27,7 +29,7 @@ const processingOnly = Boolean(process.env.A3_PROCESSING_ONLY);
|
||||
assert.ok(!(processingOnly && accountOnly), 'Account and processing qualification are distinct scopes.');
|
||||
assert.ok(!adminOnly || !(processingOnly || accountOnly), 'Admin qualification is a distinct scope.');
|
||||
try {
|
||||
const configurations = process.env.A3_PILOT ? (userAlignmentOnly ? [[1440, 'en', 'light']] : auditDateOnly ? [[768, 'nb', 'dark']] : adminOnly ? [[320, 'en', 'light'], [1440, 'en', 'light']] : [[320, 'en', 'light']]) : (accountOnly || adminOnly ? [320, 360, 390, 430, 768, 1024, 1280, 1440, 1920] : [320, 390, 768, 1440]).flatMap(width => ['en', 'nb'].flatMap(language => ['light', 'dark'].map(mode => [width, language, mode])));
|
||||
const configurations = process.env.A3_PILOT ? (userAlignmentOnly ? [[1440, 'en', 'light']] : auditSearch ? [[320, 'nb', 'dark']] : auditDateOnly ? [[768, 'nb', 'dark']] : adminOnly ? [[320, 'en', 'light'], [1440, 'en', 'light']] : [[320, 'en', 'light']]) : (accountOnly || adminOnly ? [320, 360, 390, 430, 768, 1024, 1280, 1440, 1920] : [320, 390, 768, 1440]).flatMap(width => ['en', 'nb'].flatMap(language => ['light', 'dark'].map(mode => [width, language, mode])));
|
||||
for (const [width, language, mode] of configurations) {
|
||||
console.log(`Checking ${width}/${language}/${mode}`);
|
||||
const t = key => { assert.ok(translations[language][key], key); return translations[language][key]; };
|
||||
@@ -154,6 +156,20 @@ try {
|
||||
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();
|
||||
if (auditSearch) {
|
||||
const input = page.getByRole('searchbox', { name: t('adminAuditSearch'), exact: true });
|
||||
await expect(input).toHaveAccessibleDescription(t('adminAuditSearchScope'));
|
||||
await input.pressSequentially('42');
|
||||
await expect(table.getByText('StatusChanged', { exact: true })).toBeVisible();
|
||||
await input.fill('Synthetic audit event');
|
||||
const empty = page.getByText(t('adminAuditNoMatches'), { exact: true });
|
||||
await expect(empty).toBeVisible();
|
||||
assert.ok(await empty.evaluate(node => node.scrollWidth <= node.clientWidth && node.getBoundingClientRect().right <= innerWidth), 'Empty search feedback fits the viewport.');
|
||||
await scan('audit-no-matches');
|
||||
await input.press('ControlOrMeta+a');
|
||||
await input.press('Backspace');
|
||||
await expect(table.getByText('StatusChanged', { exact: true })).toBeVisible();
|
||||
}
|
||||
const heading = table.getByRole('columnheader', { name: t('adminAuditAt'), exact: true });
|
||||
const dateCell = table.getByRole('row').nth(1).getByRole('cell').first();
|
||||
const wordsStayOnOneLine = element => {
|
||||
@@ -179,7 +195,7 @@ try {
|
||||
await expect(region).toBeFocused();
|
||||
await expect.poll(() => region.evaluate(node => node.scrollLeft)).toBeGreaterThan(0);
|
||||
}
|
||||
report.journeys.push({ width, language, mode, auditTimestampReadable: 'PASS', headerHeight: headerBounds.height, eventHeight: eventBounds.height, keyboardScroll: requiresScroll ? 'PASS' : 'NOT REQUIRED', auditMutations: 'NOT RUN' });
|
||||
report.journeys.push({ width, language, mode, auditSearch: auditSearch ? 'PASS' : 'NOT RUN', auditTimestampReadable: 'PASS', headerHeight: headerBounds.height, eventHeight: eventBounds.height, keyboardScroll: requiresScroll ? 'PASS' : 'NOT REQUIRED', auditMutations: 'NOT RUN' });
|
||||
await context.close(); continue;
|
||||
}
|
||||
if (!processingOnly) {
|
||||
@@ -234,7 +250,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 * (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 * (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.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