344dafd9fc
Keep preview visibility in the domain page and reset it on domain changes. Build the source controls from the folder schema, keep folder edits while hidden, and send only the discriminator for site training. Place the existing upload controls in the next card and use the server-declared file types. Keep shared ingestion endpoints used by Conectar and remove the EEG-page upload flow. Docker socket access was denied and the local environment lacks fastapi-users. Generate the changed OpenAPI route and schemas from the real models router with the production app settings, verify its other routes and schemas against the checked-in document, and run ng-openapi-gen directly from the cached dependencies.
255 lines
12 KiB
TypeScript
255 lines
12 KiB
TypeScript
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,
|
|
}) => {
|
|
const problems = watch(page);
|
|
const listed = page.waitForResponse(
|
|
(r) => r.url().includes('/tea/fhir/Measure') && !r.url().includes('MeasureReport'),
|
|
);
|
|
await page.goto('/indicadores/tea');
|
|
const measures = (await (await listed).json()).entry.length;
|
|
await expect(page.getByRole('tab', { name: 'Resumen' })).toBeVisible();
|
|
await expect(page.locator('app-tab-indicadores [data-measure]').first()).toBeVisible();
|
|
|
|
await page.getByRole('tab', { name: 'Trazabilidad' }).click();
|
|
await expect(page.getByText('Progresión del proceso diagnóstico')).toBeVisible();
|
|
await expect(page.locator('app-tab-trazabilidad app-plot').first()).toBeVisible();
|
|
|
|
await page.getByRole('tab', { name: 'Seguimiento' }).click();
|
|
const rows = page.locator('app-tab-seguimiento-tea table tbody tr');
|
|
await expect(rows.first().locator('td').first()).toHaveText(/^N-?\d{4}$/);
|
|
const name = await downloaded(
|
|
page,
|
|
page.getByRole('button', { name: 'Exportar a Excel' }),
|
|
'xlsx',
|
|
);
|
|
expect(name).toMatch(/^tea-seguimiento-/);
|
|
|
|
await page.getByRole('tab', { name: 'Análisis de riesgo' }).click();
|
|
const risk = page.locator('app-tab-riesgos-tea');
|
|
await expect(
|
|
risk.getByRole('heading', { name: 'EEG de los pacientes del periodo' }),
|
|
).toBeVisible();
|
|
await expect(risk.locator('table.worklist tbody tr').first().locator('td').first()).toHaveText(
|
|
/^N-?\d{4}$/,
|
|
);
|
|
await risk.getByRole('combobox', { name: 'Modelo de asociación' }).click();
|
|
await page.getByRole('option', { name: 'Con resultados' }).click();
|
|
await expect(risk.getByText('No hay registros para los filtros aplicados.')).toBeVisible();
|
|
|
|
await page.getByRole('tab', { name: 'Datos y definiciones' }).click();
|
|
await expect(page.locator('app-tab-definiciones details')).toHaveCount(measures);
|
|
expect(problems).toEqual([]);
|
|
});
|
|
|
|
test('tea patient: the record and the risk page load and export to PDF', async ({ page }) => {
|
|
const problems = watch(page);
|
|
await page.goto('/indicadores/tea');
|
|
await page.getByRole('tab', { name: 'Seguimiento' }).click();
|
|
const first = page.locator('app-tab-seguimiento-tea table tbody tr').first();
|
|
await expect(first.locator('td').first()).toHaveText(/^N-?\d{4}$/);
|
|
await first.getByRole('link').click();
|
|
|
|
await expect(page).toHaveURL(/\/indicadores\/tea\/pacientes\/[^/]+$/);
|
|
await expect(page.getByRole('heading', { level: 1 })).toBeVisible();
|
|
await expect(page.locator('app-tea-section').first()).toBeVisible();
|
|
const record = await downloaded(page, page.getByRole('button', { name: 'Exportar PDF' }), 'pdf');
|
|
expect(record).toMatch(/^tea-seguimiento-/);
|
|
|
|
await page.getByRole('link', { name: 'Regresar' }).click();
|
|
const focused = page.locator('app-tab-seguimiento-tea');
|
|
await expect(focused.getByRole('button', { name: 'Ver todos los pacientes' })).toBeVisible();
|
|
const focusedRows = focused.locator('table tbody tr');
|
|
await expect(focusedRows).toHaveCount(1);
|
|
await expect(focusedRows.first().locator('td').nth(4)).toHaveText(
|
|
/M-CHAT|Psicología|Neuropediatría|EEG/,
|
|
);
|
|
await expect(focusedRows.first().locator('td').nth(5)).toHaveText(
|
|
/Diagnóstico confirmado|En proceso|Sin TEA/,
|
|
);
|
|
await focusedRows.first().getByRole('link').click();
|
|
|
|
await page.getByRole('link', { name: 'Análisis de riesgo' }).click();
|
|
await expect(page.getByRole('heading', { name: 'Análisis de riesgo TEA' })).toBeVisible();
|
|
await expect(page.locator('app-tea-section').first()).toBeVisible();
|
|
expect(await downloaded(page, page.getByRole('button', { name: 'Exportar PDF' }), 'pdf')).toMatch(
|
|
/^tea-riesgos-/,
|
|
);
|
|
expect(problems).toEqual([]);
|
|
});
|
|
|
|
test('tea gobernanza: every section in sync mode, and the preview saved as PDF', async ({
|
|
page,
|
|
}) => {
|
|
const problems = watch(page);
|
|
await page.goto('/gobernanza/tea');
|
|
await expect(page.locator('app-gobernanza').getByRole('heading', { level: 2 })).toHaveText([
|
|
'Ejecución',
|
|
'Modelos',
|
|
'Entrenamiento',
|
|
'Subir archivos',
|
|
'Bundles',
|
|
'Estudios EEG',
|
|
]);
|
|
await expect(page.locator('app-eeg-preview')).toHaveCount(0);
|
|
await expect(page.getByText('Archivos de entrenamiento', { exact: true })).toHaveCount(0);
|
|
const uploads = page.getByRole('region', { name: 'Subir archivos' });
|
|
await expect(uploads.getByLabel('Conjunto')).toBeVisible();
|
|
await expect(uploads.getByRole('button', { name: 'Archivos', exact: true })).toBeVisible();
|
|
await expect(uploads.getByRole('button', { name: 'Subir archivos' })).toBeDisabled();
|
|
await page.getByRole('combobox', { name: 'Modo' }).click();
|
|
await page.getByRole('option', { name: 'Sync' }).click();
|
|
await expect(page.getByRole('status').filter({ hasText: 'Disponible' })).toBeVisible();
|
|
|
|
await page.getByRole('button', { name: 'Entrenar modelos' }).click();
|
|
const training = page.getByRole('heading', { name: 'Entrenamiento', level: 2 });
|
|
await expect(training).toBeVisible();
|
|
await expect(training).toBeFocused();
|
|
await expect(page.locator('app-governance-training formly-form')).toBeVisible();
|
|
|
|
const source = page.getByRole('combobox', { name: 'Origen' });
|
|
const folder = page.getByLabel('Carpeta', { exact: true });
|
|
const line = page.getByRole('combobox', { name: 'Frecuencia de la red eléctrica (Hz)' });
|
|
await expect(source).toHaveText('Niños del sitio sin el diagnóstico');
|
|
await expect(folder).toBeHidden();
|
|
await expect(line).toBeHidden();
|
|
await source.click();
|
|
await page.getByRole('option', { name: 'Carpeta de EDF con edades' }).click();
|
|
await expect(folder).toBeVisible();
|
|
await expect(line).toBeVisible();
|
|
await source.click();
|
|
await page.getByRole('option', { name: 'Niños del sitio sin el diagnóstico' }).click();
|
|
await expect(folder).toBeHidden();
|
|
await expect(line).toBeHidden();
|
|
|
|
const monitor = page.locator('app-governance-models app-run-monitor');
|
|
await page.getByRole('button', { name: 'Analizar EEG' }).click();
|
|
await expect(page.getByRole('heading', { name: 'Análisis de EEG' })).toBeVisible();
|
|
await expect(monitor.getByRole('status')).toHaveText('SUCCESS', { timeout: 10 * 60_000 });
|
|
await page.getByRole('button', { name: 'Calcular riesgos' }).click();
|
|
await expect(page.getByRole('heading', { name: 'Cálculo de riesgos' })).toBeVisible();
|
|
await expect(monitor.getByRole('status')).toHaveText('SUCCESS', { timeout: 10 * 60_000 });
|
|
await page.getByRole('button', { name: 'Promover candidatas' }).click();
|
|
await expect(page.getByText('No hay candidatas que se puedan promover.')).toBeVisible();
|
|
|
|
const studies = page.locator('app-eeg-studies');
|
|
await expect(studies.locator('input[type=file]')).toHaveCount(0);
|
|
await expect(studies.locator('table.eegs tbody tr').first()).toContainText(/Válido|No válido/);
|
|
await studies.locator('table.eegs tbody button:enabled').first().click();
|
|
await expect(studies.getByRole('heading', { name: /^EEG .* meses$/ })).toBeVisible();
|
|
await studies.getByRole('button', { name: 'Analizar', exact: true }).click();
|
|
await expect(studies.locator('app-run-monitor').first().getByRole('status')).toHaveText(
|
|
'SUCCESS',
|
|
{ timeout: 10 * 60_000 },
|
|
);
|
|
|
|
await page
|
|
.locator('app-governance-models')
|
|
.getByRole('button', {
|
|
name: 'Evaluar un solo estudio',
|
|
})
|
|
.click();
|
|
const preview = page.locator('app-eeg-preview');
|
|
await expect(preview.getByRole('heading', { name: 'Vista previa' })).toBeVisible();
|
|
await preview.getByLabel('EDF').setInputFiles(process.env['TEA_EDF']!);
|
|
await preview.getByLabel('ADOS-2 (PDF)').setInputFiles(process.env['TEA_ADOS2']!);
|
|
await preview.getByLabel('Fecha de nacimiento').fill(process.env['TEA_BIRTH']!);
|
|
await preview.getByRole('button', { name: 'Vista previa' }).click();
|
|
const dialog = page.getByRole('dialog', { name: 'Vista previa del estudio' });
|
|
await expect(dialog.getByText('Resultado de la vista previa')).toBeVisible({
|
|
timeout: 10 * 60_000,
|
|
});
|
|
await expect(dialog.locator('dt').first()).toHaveText(/^[AB]-\d+ \S/);
|
|
expect(
|
|
await downloaded(page, dialog.getByRole('button', { name: 'Guardar como PDF' }), 'pdf'),
|
|
).toMatch(/^tea-gobernanza-/);
|
|
await dialog.getByRole('button', { name: 'Cerrar' }).click();
|
|
|
|
const bundles = page.locator('app-governance-bundles');
|
|
await bundles.getByRole('combobox', { name: 'Versiones' }).click();
|
|
await page.getByRole('option', { name: 'Todas' }).click();
|
|
await bundles.getByRole('button', { name: 'Exportar bundle' }).click();
|
|
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([]);
|
|
});
|