Files
Investidor-V2/tools/portal-keyboard-visual-qa.cjs
nala 287e991486
tests / ci (push) Waiting to run
oportunidades 7
2026-10-13 11:40:29 +02:00

56 lines
2.0 KiB
JavaScript

const { start, assert, sanitized } = require('./portal-visual-qa-lib.cjs');
void (async () => {
const q = await start('keyboard-chromium-20261010');
let page, _ctx;
try {
({ page, ctx: _ctx } = await q.context('anonymous', 390));
q.proof.pages = [];
for (const route of [
'/agronegocio',
'/turismo',
'/manifestar-interesse',
]) {
await q.open(page, route);
await page.getByRole('heading').first().waitFor();
await page.keyboard.press('Tab');
const focus = await page.evaluate(() => ({
text: document.activeElement.textContent.trim(),
href: document.activeElement.getAttribute('href'),
width: document.activeElement.getBoundingClientRect().width,
}));
assert.equal(focus.href, '#portal-content');
assert(focus.width > 10);
await page.keyboard.press('Enter');
assert.equal(
await page.evaluate(() => document.activeElement.id),
'portal-content',
);
q.proof.pages.push({
route,
skip_link_first: true,
visible_on_focus: true,
keyboard_target_reached: true,
});
await q.shot(page, route.replace(/\W/g, '_') + '-keyboard', false);
}
q.proof.checks.keyboard_skip_links = true;
q.proof.screen_reader_tested = false;
q.proof.result = 'passed';
} catch (e) {
q.proof.result = 'failed';
q.proof.error = sanitized(e);
} finally {
q.proof.finished_at = new Date().toISOString();
q.save();
await q.browser.close();
console.log(
JSON.stringify({
result: q.proof.result,
pages: q.proof.pages?.length,
receipt: q.receipt,
}),
);
if (q.proof.result !== 'passed') process.exitCode = 1;
}
})();