test(admin): qualify heading hierarchy across four routes
This commit is contained in:
@@ -9,7 +9,9 @@ const compiled = ts.transpileModule(fs.readFileSync(new URL('../src/i18n/transla
|
||||
const { translations } = await import(`data:text/javascript;base64,${Buffer.from(compiled).toString('base64')}`);
|
||||
const accountOnly = Boolean(process.env.A3_ACCOUNT_FLAT);
|
||||
const adminOnly = Boolean(process.env.A3_ADMIN_FLAT);
|
||||
const out = path.resolve(import.meta.dirname, 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 adminHeadings = Boolean(process.env.A3_ADMIN_HEADINGS);
|
||||
assert.ok(!adminHeadings || adminOnly, 'Heading qualification uses the Admin fixtures.');
|
||||
const out = path.resolve(import.meta.dirname, 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();
|
||||
@@ -76,6 +78,13 @@ try {
|
||||
if (!keepScroll) { await page.evaluate(() => window.scrollTo({ top: 0, behavior: 'instant' })); await expect.poll(() => page.evaluate(() => window.scrollY)).toBe(0); }
|
||||
await page.screenshot({ path: path.join(out, `${state}-${language}-${mode}-${width}.png`), fullPage: width >= 768 && !keepScroll });
|
||||
};
|
||||
const checkHeading = async (title, subtitle) => {
|
||||
if (!adminHeadings) return;
|
||||
const heading = page.getByRole('heading', { name: t(title), exact: true });
|
||||
await expect(heading).toHaveCount(1);
|
||||
await expect(page.getByRole('heading', { name: t(title), exact: true, level: 1 })).toBeVisible();
|
||||
await expect(page.getByText(t(subtitle), { exact: true })).toBeVisible();
|
||||
};
|
||||
if (!processingOnly) {
|
||||
if (!adminOnly) {
|
||||
await page.goto('http://localhost:4338/profile');
|
||||
@@ -94,12 +103,17 @@ try {
|
||||
await page.goto('http://localhost:4338/settings/connected-accounts'); await expect(page.getByRole('heading', { name: t('connectedAccounts'), exact: true })).toBeVisible(); await scan('connections');
|
||||
}
|
||||
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 scan('last-admin');
|
||||
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 scan('audit-populated'); }
|
||||
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'); }
|
||||
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 scan('system-normal');
|
||||
systemAvailable = true; await page.reload(); await expect(page.getByText(system.environment, { exact: true })).toBeVisible(); await checkHeading('systemStatus', 'adminSystemSubtitle'); await scan('system-normal');
|
||||
if (adminHeadings) {
|
||||
const refresh = page.getByRole('button', { name: t('adminSystemRefresh'), exact: true });
|
||||
await refresh.press('Enter');
|
||||
await expect(refresh).toBeFocused();
|
||||
}
|
||||
const benchmarkHeading = page.getByRole('heading', { name: t('adminBenchmarkTitle'), exact: true });
|
||||
await benchmarkHeading.evaluate(el => window.scrollBy({ top: el.getBoundingClientRect().top - 90, behavior: 'instant' })); await scan('system-benchmark', true);
|
||||
await page.getByRole('heading', { name: t('adminBenchmarkTopFindings'), exact: true }).evaluate(el => window.scrollBy({ top: el.getBoundingClientRect().top - 90, behavior: 'instant' })); await scan('system-findings', true);
|
||||
@@ -109,6 +123,7 @@ try {
|
||||
}
|
||||
if (!accountOnly) {
|
||||
await page.goto('http://localhost:4338/admin/processing'); await expect(page.getByRole('button', { name: t('processingViewDetails').replace('{id}', operation.id), exact: true })).toBeVisible();
|
||||
await checkHeading('processingTitle', 'processingSubtitle');
|
||||
for (const key of ['processingStatus', 'processingTask', 'processingWorkerFilter', 'processingFailureCode']) {
|
||||
const control = page.getByRole('combobox', { name: t(key), exact: true });
|
||||
const label = page.locator(`label[for=${JSON.stringify(await control.getAttribute('id'))}]`);
|
||||
|
||||
Reference in New Issue
Block a user