Files
Investidor-V2/tools/investmoz-private-association-browser.mjs
T
nala 1106509116
tests / ci (push) Canceled after 0s
vrsao 2
2026-10-08 14:02:01 +02:00

71 lines
2.8 KiB
JavaScript

import { createRequire } from 'node:module';
import fs from 'node:fs';
const require = createRequire(import.meta.url);
const {
chromium,
} = require('C:/Users/macbook/AppData/Local/Temp/investmoz-visual-qa-tools-20261004/node_modules/playwright');
const base = process.env.INVESTMOZ_E2E_BASE ?? 'http://127.0.0.1:8011';
const email = process.env.INVESTMOZ_E2E_EMAIL;
const password = process.env.INVESTMOZ_E2E_PASSWORD;
const dossierId = process.env.INVESTMOZ_E2E_DOSSIER_ID;
const submissionId = process.env.INVESTMOZ_E2E_SUBMISSION_ID;
if (![email, password, dossierId, submissionId].every(Boolean))
throw new Error(
'Set the isolated fixture credentials and IDs in INVESTMOZ_E2E_* environment variables.',
);
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
const errors = [];
const posts = [];
page.on('pageerror', (error) => errors.push(error.message));
page.on('request', (request) => {
if (
request.method() === 'POST' &&
new URL(request.url()).pathname === '/investidor/manifestacoes'
)
posts.push(request.url());
});
await page.goto(`${base}/login`, { waitUntil: 'networkidle' });
await page.locator('input[type=email]').fill(email);
await page.locator('input[type=password]').fill(password);
await page.locator('button[type=submit]').click();
await page.waitForURL('**/dashboard');
const response = await page.goto(`${base}/carteira/${dossierId}`, {
waitUntil: 'networkidle',
});
const evidence = {
testedAt: new Date().toISOString(),
loginSucceeded: true,
dossierHttpStatus: response.status(),
existingDraftVisible:
(await page
.getByRole('link', { name: /Continuar rascunho/ })
.count()) === 1,
};
page.once('dialog', (dialog) => dialog.dismiss());
await page.getByRole('button', { name: /Preparar manif/ }).click();
await page.waitForTimeout(400);
evidence.cancelledConfirmationKeepsDossierPage =
new URL(page.url()).pathname === `/carteira/${dossierId}`;
evidence.cancelledConfirmationSentNoCreateRequest = posts.length === 0;
evidence.publicDossierRemainsVisible =
(await page
.getByRole('heading', { name: 'Dossier sintetico de ensaio' })
.count()) === 1;
await page.screenshot({
path: 'docs/investmoz/pilot/private-dossier-association-browser-2026-10-04.png',
fullPage: true,
});
await page.getByRole('link', { name: /Continuar rascunho/ }).click();
await page.waitForURL(`**/investidor/manifestacoes/${submissionId}`);
evidence.existingDraftContinues = new URL(page.url()).pathname.endsWith(
submissionId,
);
evidence.pageErrors = errors;
await browser.close();
fs.writeFileSync(
'docs/investmoz/pilot/private-dossier-association-browser-2026-10-04.json',
JSON.stringify(evidence, null, 2) + '\n',
);
console.log(JSON.stringify(evidence, null, 2));