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

74 lines
2.4 KiB
JavaScript

const {
start,
BASE,
assert,
sanitized,
} = require('./portal-visual-qa-lib.cjs');
void (async () => {
const q = await start('c37-qa18-chromium-20261010');
try {
q.phase('QA18 password → MFA → authenticated investment session');
let { ctx, page } = await q.context('investor18');
await q.login(page, 'investor18');
await q.open(page, '/investimentos');
await page
.getByRole('heading', {
name: 'Preparar um investimento',
exact: true,
})
.waitFor();
await page.reload({ waitUntil: 'domcontentloaded' });
await page
.getByRole('heading', {
name: 'Preparar um investimento',
exact: true,
})
.waitFor();
await q.shot(page, 'investments-reloaded', false);
q.proof.cookies = (await ctx.cookies(BASE)).map(
({ name, domain, path, secure, httpOnly, sameSite }) => ({
name,
domain,
path,
secure,
httpOnly,
sameSite,
}),
);
q.proof.checks.login_mfa_redirect_reload = true;
await q.logout(page);
assert.equal((await q.json(page, '/investimentos')).status, 401);
await ctx.close();
({ ctx, page } = await q.context('investor18-new-session'));
await q.login(page, 'investor18');
await q.open(page, '/investimentos');
await page
.getByRole('heading', {
name: 'Preparar um investimento',
exact: true,
})
.waitFor();
await q.shot(page, 'new-session', false);
q.proof.checks.logout_revokes_new_login_succeeds = true;
q.proof.result = 'passed';
q.proof.manual_user_context_confirmed = false;
await q.logout(page);
await ctx.close();
} 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,
checks: q.proof.checks,
receipt: q.receipt,
}),
);
if (q.proof.result !== 'passed') process.exitCode = 1;
}
})();