test(discovery): retain saved search and tracker verifier flows with drawer

This commit is contained in:
cesnimda
2026-11-11 07:26:24 +01:00
parent 1d73367576
commit 07df0c688d
+24 -12
View File
@@ -16,7 +16,7 @@ const widths = process.env.A3_PILOT ? (trackingOnly || searchFirst ? [320, 1440]
const languages = process.env.A3_PILOT ? ['en'] : ['en', 'nb'];
const modes = process.env.A3_PILOT ? ['light'] : ['light', 'dark'];
const expectedJourneys = widths.length * languages.length * modes.length;
const out = path.resolve(import.meta.dirname, mobileFilters ? '../../docs/ui-modernisation/visual-correction/evidence/discovery-mobile-filters' : searchFirst ? '../../docs/ui-modernisation/visual-correction/evidence/discovery-search-first' : trackingOnly ? '../../docs/ui-modernisation/visual-correction/evidence/discovery-track' : visualMatrix ? '../../docs/ui-modernisation/visual-correction/evidence/discovery' : '../../docs/ui-modernisation/evidence/discovery/browser');
const out = path.resolve(import.meta.dirname, process.env.A3_EVIDENCE_DIR ?? (mobileFilters ? '../../docs/ui-modernisation/visual-correction/evidence/discovery-mobile-filters' : searchFirst ? '../../docs/ui-modernisation/visual-correction/evidence/discovery-search-first' : trackingOnly ? '../../docs/ui-modernisation/visual-correction/evidence/discovery-track' : visualMatrix ? '../../docs/ui-modernisation/visual-correction/evidence/discovery' : '../../docs/ui-modernisation/evidence/discovery/browser'));
fs.mkdirSync(out, { recursive: true });
const report = { screens: [], journeys: [], errors: [], unexpectedWrites: [], mockedWrites: [], previewRequests: [], unavailableReads: [], blockedExternal: [] };
const browser = await chromium.launch();
@@ -79,9 +79,10 @@ try {
return route.fulfill({ status: Object.hasOwn(fixtures, url.pathname) ? 200 : 404, contentType: 'application/json', body: JSON.stringify(fixtures[url.pathname] ?? {}) });
});
const scan = async state => {
if (!mobileFilters && width < 768 && ['results', 'saved'].includes(state)) {
await filters.getByRole('button', { name: language === 'en' ? 'Jump to results' : 'Gå til resultater', exact: true }).click();
assert.equal(await results.evaluate(node => node === document.activeElement), true);
if (!mobileFilters && width <= 1000 && ['results', 'saved'].includes(state)) {
if (await filters.isVisible()) await filters.getByRole('button', { name: t('jobDiscoveryJumpResults'), exact: true }).click();
else await results.focus();
await expect(results).toBeFocused();
} else await page.evaluate(() => window.scrollTo(0, 0));
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth > innerWidth + 1), false);
const result = await new AxeBuilder({ page }).withTags(['wcag2a', 'wcag2aa', 'wcag21aa', 'wcag22aa']).analyze();
@@ -131,27 +132,37 @@ try {
report.journeys.push({ width, language, mode, mobileFilterDraftSubmitAndFocus: 'PASS', breakpoint: width === 320 ? 'PASS' : 'NOT RUN', providerWrites: 'NOT RUN' });
await context.close(); continue;
}
const filters = page.getByRole('complementary', { name: language === 'en' ? 'Search filters' : 'Søkefiltre' }); await filters.waitFor();
const filters = page.getByRole('complementary', { name: language === 'en' ? 'Search filters' : 'Søkefiltre' });
const results = page.getByRole('region', { name: language === 'en' ? 'Search results' : 'Søkeresultater', exact: true }); await results.waitFor();
const role = page.getByRole('textbox', { name: language === 'en' ? 'Role or company' : 'Rolle eller bedrift', exact: true });
const openFilters = async () => {
if (width <= 1000 && !await filters.isVisible()) await page.getByRole('button', { name: t('jobDiscoveryFilters'), exact: true }).click();
await filters.waitFor();
};
await openFilters();
await filters.getByRole('button', { name: language === 'en' ? 'Jump to results' : 'Gå til resultater', exact: true }).click();
assert.equal(await results.evaluate(node => node === document.activeElement), true);
await expect(results).toBeFocused();
await results.getByRole('button', { name: t('jobDiscoveryReturnFilters'), exact: true }).click();
assert.equal(await role.evaluate(node => node === document.activeElement), true); assert.equal(searches, 0);
const left = await filters.boundingBox(), right = await results.boundingBox();
assert.ok(width > 1000 ? right.x > left.x + left.width - 2 && Math.abs(right.y - left.y) < 2 : right.y >= left.y + left.height - 2);
if (width > 1000) {
const left = await filters.boundingBox(), right = await results.boundingBox();
assert.ok(right.x > left.x + left.width - 2 && Math.abs(right.y - left.y) < 2);
}
await scan('initial');
if (searchFirst) {
const form = page.getByRole('form', { name: t('jobDiscoverySearchNav'), exact: true });
const [query, filtersAtTop] = await Promise.all([form.boundingBox(), filters.boundingBox()]);
assert.ok(query.y + query.height <= filtersAtTop.y, 'Search form is above both columns');
if (width > 1000) {
const [query, filtersAtTop] = await Promise.all([form.boundingBox(), filters.boundingBox()]);
assert.ok(query.y + query.height <= filtersAtTop.y, 'Search form is above both columns');
}
await role.fill('nurse'); await openFilters();
const source = filters.getByText(t('jobDiscoverySourceCoverage'), { exact: true });
const help = filters.getByText(t('jobDiscoverySourceHelp'), { exact: true });
await expect(help).toBeHidden();
await source.press('Enter'); await expect(help).toBeVisible(); await scan('source-context');
await source.press('Enter'); await expect(help).toBeHidden();
const municipality = filters.getByRole('textbox', { name: t('jobDiscoveryMunicipality'), exact: true });
await role.fill('nurse'); await municipality.fill('Oslo'); await municipality.press('Enter');
await municipality.fill('Oslo'); await municipality.press('Enter');
const vacancy = results.getByRole('article', { name: jobs[0].title, exact: true });
await expect(vacancy.getByText(jobs[0].sourceName, { exact: true })).toBeVisible();
await expect(vacancy.getByRole('button', { name: t('jobDiscoverySaveTracker'), exact: true })).toBeVisible();
@@ -176,7 +187,7 @@ try {
await expect(page.locator('[data-job-row-id="42"], [data-job-card-id="42"]').first()).toContainText(jobs[0].title); await scan('tracked');
assert.ok(tracked); report.journeys.push({ width, language, mode, discoveryPreviewReviewTracked: 'PASS', optionalAttachmentsSkippedWithExistingControls: 'PASS', savedSearchMutations: 'NOT RUN', externalAdvertAndProviderAccess: 'NOT RUN' }); await context.close(); continue;
}
await role.fill('nurse'); await page.getByRole('textbox', { name: language === 'en' ? 'Municipality' : 'Kommune', exact: true }).fill('Oslo');
await role.fill('nurse'); await openFilters(); await page.getByRole('textbox', { name: language === 'en' ? 'Municipality' : 'Kommune', exact: true }).fill('Oslo');
await page.getByRole('textbox', { name: language === 'en' ? 'Search name' : 'Navn på søket', exact: true }).fill('Care roles');
await page.getByRole('button', { name: language === 'en' ? 'Save search' : 'Lagre søk', exact: true }).click();
const group = page.getByRole('group', { name: 'Care roles', exact: true }); await group.waitFor();
@@ -188,6 +199,7 @@ try {
assert.equal(await results.getByRole('link', { name: language === 'en' ? 'View listing' : 'Vis stilling', exact: true }).getAttribute('href'), jobs[0].url);
await results.getByRole('button', { name: language === 'en' ? 'Dismiss' : 'Avvis', exact: true }).click();
await results.getByRole('article').waitFor({ state: 'hidden' });
await openFilters();
await group.getByRole('button', { name: language === 'en' ? 'Delete' : 'Slett', exact: true }).click();
const dialog = page.getByRole('dialog', { name: language === 'en' ? 'Delete saved search?' : 'Slette lagret søk?', exact: true });
await dialog.getByRole('button', { name: language === 'en' ? 'Delete' : 'Slett', exact: true }).click(); await group.waitFor({ state: 'hidden' });