60 lines
2.0 KiB
JavaScript
60 lines
2.0 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 = 'http://127.0.0.1:8000';
|
|
const browser = await chromium.launch({ headless: true });
|
|
const page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
|
|
const errors = [];
|
|
page.on('pageerror', (e) => errors.push(e.message));
|
|
const evidence = {
|
|
base,
|
|
testedAt: new Date().toISOString(),
|
|
records: [],
|
|
errors,
|
|
};
|
|
for (const [route, key] of [
|
|
['/oportunidades', 'all'],
|
|
['/oportunidades?province=Nampula', 'province'],
|
|
['/oportunidades?sector=agronegocio', 'sector'],
|
|
]) {
|
|
const r = await page.goto(base + route, { waitUntil: 'networkidle' });
|
|
evidence.records.push({
|
|
key,
|
|
route,
|
|
status: r.status(),
|
|
cards: await page.locator('article').count(),
|
|
unvalidatedNotice: await page
|
|
.getByText(/não regista data de validação documental/i)
|
|
.count(),
|
|
});
|
|
}
|
|
const detail = await page.goto(
|
|
base +
|
|
'/oportunidades/inv-mz-agr-001-unidade-de-processamento-agricola-em-nampula',
|
|
{ waitUntil: 'networkidle' },
|
|
);
|
|
evidence.detail = {
|
|
status: detail.status(),
|
|
title: await page.title(),
|
|
unvalidatedNotice:
|
|
(await page
|
|
.getByText(/não regista data de validação documental/i)
|
|
.count()) === 1,
|
|
publishedIntentActionRequiresLogin: false,
|
|
};
|
|
await page
|
|
.getByRole('link', { name: 'Entrar para preparar manifestação' })
|
|
.click();
|
|
await page.waitForURL('**/login');
|
|
evidence.detail.publishedIntentActionRequiresLogin =
|
|
new URL(page.url()).pathname === '/login';
|
|
evidence.pageErrors = errors;
|
|
await browser.close();
|
|
const out =
|
|
'docs/investmoz/pilot/authorized-opportunity-filter-browser-2026-10-04.json';
|
|
fs.writeFileSync(out, JSON.stringify(evidence, null, 2) + '\n');
|
|
console.log(JSON.stringify(evidence, null, 2));
|