test(i18n): qualify singular counts across table and board

This commit is contained in:
cesnimda
2026-11-04 09:26:58 +01:00
parent 9bfc51b067
commit 8fef819c4e
92 changed files with 2154 additions and 8 deletions
@@ -6,10 +6,12 @@ import fs from 'node:fs';
import path from 'node:path';
const visualMatrix = Boolean(process.env.A3_VISUAL_MATRIX);
const flatWorkspace = Boolean(process.env.A3_FLAT_WORKSPACE);
const matchingCountOnly = Boolean(process.env.A3_MATCHING_COUNT);
assert.ok(!matchingCountOnly || !flatWorkspace, 'Count presentation does not repeat workspace qualification.');
assert.ok(!flatWorkspace || visualMatrix, 'Flat workspace qualification uses the visual matrix.');
const widths = visualMatrix ? [320, 360, 390, 430, 768, 1024, 1280, 1440, 1920] : [320, 390, 768, 1440];
const widths = visualMatrix || matchingCountOnly ? [320, 360, 390, 430, 768, 1024, 1280, 1440, 1920] : [320, 390, 768, 1440];
const configurations = process.env.A3_PILOT ? [[320, 'en', 'light']] : widths.flatMap(width => ['en', 'nb'].flatMap(language => ['light', 'dark'].map(mode => [width, language, mode])));
const out = path.resolve(import.meta.dirname, flatWorkspace ? '../../docs/ui-modernisation/visual-correction/evidence/applications-flat' : visualMatrix ? '../../docs/ui-modernisation/visual-correction/evidence/applications' : '../../docs/ui-modernisation/evidence/applications/browser');
const out = path.resolve(import.meta.dirname, matchingCountOnly ? '../../docs/ui-modernisation/visual-correction/evidence/matching-count' : flatWorkspace ? '../../docs/ui-modernisation/visual-correction/evidence/applications-flat' : visualMatrix ? '../../docs/ui-modernisation/visual-correction/evidence/applications' : '../../docs/ui-modernisation/evidence/applications/browser');
fs.mkdirSync(out, { recursive: true });
const report = { screens: [], journeys: [], aliases: [], focusChecks: [], errors: [], unexpectedWrites: [], mockedWrites: [], unavailableReads: [], blockedExternal: [] };
const browser = await chromium.launch();
@@ -20,12 +22,13 @@ try {
const page = await context.newPage(); page.on('pageerror', error => report.errors.push(error.message));
await page.addInitScript(({ language, mode }) => { localStorage.setItem('uiLanguage', language); localStorage.setItem('jobtracker.themeMode', mode); }, { language, mode });
const jobs = ['Community nurse', 'Primary teacher', 'Electrical engineer'].map((jobTitle, index) => ({ id: 42 + index, version: 7, jobTitle, company: { id: 1, name: 'Fjord Care' }, companyId: 1, status: 'Saved', location: 'Oslo', countryCode: 'NO', source: 'nav', salary: null, dateApplied: null, savedAt: '2026-10-01T09:00:00Z', deadline: '2026-11-12', followUpAt: null, tags: 'Care coordination', description: 'Recorded source advertisement.', isDeleted: false, needsFollowUp: false, workflowSignal: null }));
if (matchingCountOnly) jobs.splice(1);
await page.route('**/*', route => {
const req = route.request(), url = new URL(req.url());
if (url.origin !== 'http://localhost:4338' && !(url.origin === 'http://localhost:5202' && url.pathname.startsWith('/api/'))) { report.blockedExternal.push(url.origin); return route.abort(); }
if (!url.pathname.startsWith('/api/')) return route.continue();
const answer = data => route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(data) });
if (req.method() === 'PATCH' && url.pathname === '/api/jobapplications/42/status') {
if (!matchingCountOnly && req.method() === 'PATCH' && url.pathname === '/api/jobapplications/42/status') {
const { status } = req.postDataJSON(); assert.equal(status, 'Waiting'); jobs[0].status = status;
report.mockedWrites.push({ width, language, mode, status }); return answer({});
}
@@ -56,6 +59,13 @@ try {
await page.goto('http://localhost:4338/jobs');
const search = page.getByRole('textbox', { name: language === 'en' ? 'Search' : 'Søk', exact: true }); await search.waitFor();
await page.locator('[data-job-row-id="42"], [data-job-card-id="42"]').first().waitFor();
if (matchingCountOnly) {
const label = language === 'en' ? '1 matching job' : '1 jobb samsvarer';
await expect(page.getByText(label, { exact: true })).toBeVisible(); await scan('table');
await page.getByRole('link', { name: language === 'en' ? 'Board' : 'Tavle', exact: true }).click();
await expect(page.locator('[data-kanban-card-id="42"]')).toBeVisible(); await expect(page.getByText(label, { exact: true })).toBeVisible(); await scan('board');
report.journeys.push({ width, language, mode, singularTableAndBoard: 'PASS', mutationsDetailAliases: 'NOT RUN' }); await context.close(); continue;
}
await scan('table');
if (flatWorkspace) {
await page.keyboard.press('Tab');
@@ -121,7 +131,7 @@ try {
}
await context.close();
}
assert.equal(report.screens.length, configurations.length * (flatWorkspace ? 6 : visualMatrix ? 4 : 3)); assert.equal(report.journeys.length, configurations.length); assert.equal(report.mockedWrites.length, configurations.length); assert.equal(report.aliases.length, visualMatrix ? 3 : 0);
assert.equal(report.screens.length, configurations.length * (matchingCountOnly ? 2 : flatWorkspace ? 6 : visualMatrix ? 4 : 3)); assert.equal(report.journeys.length, configurations.length); assert.equal(report.mockedWrites.length, matchingCountOnly ? 0 : configurations.length); assert.equal(report.aliases.length, visualMatrix && !matchingCountOnly ? 3 : 0);
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 table/board/detail journeys,${report.screens.length} axe scans/captures;${report.mockedWrites.length} mocked status writes.`);