T15/T16: one page case per page and tab: sign-in, Conectar, Revisión, CaCu, CaMa, TEA tabs, record, risk, Gobernanza
Shared helpers (admin sign-in fixture, watch, downloaded) live in e2e/support.ts. Conectar checks the EDF reader among the node kinds; CaCu and CaMa show their four tabs over a platform without their data; the training-inputs 404 of a domain without training files is the one allowed response.
This commit is contained in:
+80
-26
@@ -1,29 +1,5 @@
|
||||
import { statSync } from 'node:fs';
|
||||
import { expect, Locator, Page, test } from '@playwright/test';
|
||||
|
||||
function watch(page: Page): string[] {
|
||||
const problems: string[] = [];
|
||||
page.on('console', (m) => m.type() === 'error' && problems.push(`console: ${m.text()}`));
|
||||
page.on('response', (r) => r.status() >= 400 && problems.push(`${r.status()} ${r.url()}`));
|
||||
page.on('pageerror', (e) => problems.push(`page: ${e.message}`));
|
||||
return problems;
|
||||
}
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
const signed = await page.request.post('/api/auth/login', {
|
||||
form: { username: 'admin@isssteleon.mx', password: 'solo-para-pruebas' },
|
||||
});
|
||||
expect(signed.status()).toBe(204);
|
||||
});
|
||||
|
||||
async function downloaded(page: Page, button: Locator, kind: 'pdf' | 'xlsx'): Promise<string> {
|
||||
const [file] = await Promise.all([page.waitForEvent('download'), button.click()]);
|
||||
const name = file.suggestedFilename();
|
||||
expect(name).toMatch(new RegExp(`^tea-[a-z]+-\\d{4}-\\d{2}-\\d{2}\\.${kind}$`));
|
||||
expect(name).not.toMatch(/N-?\d{4}/);
|
||||
expect(statSync(await file.path()).size).toBeGreaterThan(0);
|
||||
return name;
|
||||
}
|
||||
import { expect } from '@playwright/test';
|
||||
import { downloaded, test, watch } from './support';
|
||||
|
||||
test('tea indicators: every tab loads, and the follow-up list exports to Excel', async ({
|
||||
page,
|
||||
@@ -169,3 +145,81 @@ test('tea gobernanza: every section in sync mode, and the preview saved as PDF',
|
||||
await expect(bundles.getByRole('alert')).toContainText('nothing to export');
|
||||
expect(problems.filter((p) => !p.includes('409'))).toEqual([]);
|
||||
});
|
||||
|
||||
test('conectar: the tea pipeline on the canvas, and a node form', async ({ page }) => {
|
||||
const problems = watch(page);
|
||||
await page.goto('/conectar');
|
||||
const pipelines = page.locator('aside.pipelines a');
|
||||
await expect(pipelines).toHaveCount(1);
|
||||
await expect(pipelines.first()).toContainText('tea');
|
||||
await pipelines.first().click();
|
||||
|
||||
const canvas = page.locator('.canvas');
|
||||
await expect(page.getByRole('button', { name: 'Leer EDF' })).toBeVisible();
|
||||
const extract = canvas.locator('.node-caption', { hasText: 'Extraer datos' });
|
||||
await expect(extract).toBeVisible();
|
||||
await extract.click();
|
||||
|
||||
const panel = page.locator('aside.panel');
|
||||
await expect(panel.getByRole('heading', { name: 'Extraer datos · ados2_results' })).toBeVisible();
|
||||
await expect(panel.locator('formly-form')).toBeVisible();
|
||||
expect(problems).toEqual([]);
|
||||
});
|
||||
|
||||
test('revision: the unrecognised-documents tab mirrors the pipeline', async ({ page }) => {
|
||||
const problems = watch(page);
|
||||
const answer = page.waitForResponse((r) => r.url().includes('/review/unrecognised'));
|
||||
await page.goto('/revision');
|
||||
await expect(page.getByRole('heading', { name: 'Revisión' })).toBeVisible();
|
||||
const count = ((await (await answer).json()) as unknown[]).length;
|
||||
const tab = page.getByRole('tab', { name: 'Documentos no reconocidos' });
|
||||
await expect(tab).toHaveText(`Documentos no reconocidos (${count})`);
|
||||
await tab.click();
|
||||
if (count === 0) {
|
||||
await expect(page.getByText('Sin documentos no reconocidos.')).toBeVisible();
|
||||
} else {
|
||||
await expect(page.locator('table.plain:not(.card) tbody tr')).toHaveCount(count);
|
||||
}
|
||||
expect(problems).toEqual([]);
|
||||
});
|
||||
|
||||
test('cacu and cama indicators: the four tabs over domains without data', async ({ page }) => {
|
||||
const problems = watch(page);
|
||||
expect(await (await page.request.get('/api/domains')).json()).toEqual(['cacu', 'cama', 'tea']);
|
||||
for (const [domain, title] of [
|
||||
['cacu', 'Cáncer cervicouterino'],
|
||||
['cama', 'Cáncer de mama'],
|
||||
]) {
|
||||
await page.goto(`/indicadores/${domain}`);
|
||||
await expect(page.getByRole('heading', { name: title, level: 1 })).toBeVisible();
|
||||
await expect(page.getByRole('tab')).toHaveText([
|
||||
'Indicadores',
|
||||
'Trazabilidad',
|
||||
'Análisis de riesgos',
|
||||
'Datos y definiciones',
|
||||
]);
|
||||
await expect(page.getByText('Sin datos en el periodo.').first()).toBeVisible();
|
||||
}
|
||||
expect(problems).toEqual([]);
|
||||
});
|
||||
|
||||
test('cacu gobernanza: the shared sections only, none of the TEA ones', async ({ page }) => {
|
||||
const problems = watch(page);
|
||||
await page.goto('/gobernanza/cacu');
|
||||
await expect(page.locator('app-gobernanza').getByRole('heading', { level: 2 })).toHaveText([
|
||||
'Ejecución',
|
||||
'Modelos',
|
||||
'Entrenamiento',
|
||||
'Bundles',
|
||||
]);
|
||||
await expect(page.locator('app-eeg-studies')).toHaveCount(0);
|
||||
await expect(page.locator('app-eeg-preview')).toHaveCount(0);
|
||||
const nav = page.getByRole('navigation', { name: 'Dominios' });
|
||||
await expect(nav.getByRole('link', { name: 'Cáncer de mama' })).toBeVisible();
|
||||
await expect(nav.getByRole('link', { name: 'Trastorno del espectro autista' })).toBeVisible();
|
||||
expect(
|
||||
problems.filter(
|
||||
(p) => !p.endsWith('/models/cacu/all/inputs') && !p.startsWith('console: Failed to load'),
|
||||
),
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user