3a26c63931
Keep the route, title, subtitle, domain navigation and composition in
gobernanza.{ts,html,scss}. Ejecución keeps mode and health in execution.ts.
Add models.{ts,html,scss} to own the actions, run monitor, status, versions,
reports, figures, clinical validation, and checks and lineage dialogs.
Render training.ts after Modelos with the existing source, configuration,
promotion checkbox, input sets and upload. Keep ZIP export and import in
bundles.ts. Keep scope, study list, EDF upload and run progress in
tea/studies.{ts,html}, and render tea/preview.ts separately for TEA with
its EDF and ADOS-2 selection, results and PDF export.
Use a page grid for section spacing and the global card style. Keep
table, action and dialog styles local to Modelos. Use Material fields
for editable values and Material buttons to open native file pickers,
retaining input labels and showing the selected filenames. Keep the
native suggestion lists for scheduler and input set names.
Default the training target to all on domain changes. Both Modelos
training actions focus the Entrenamiento heading and use the same
Formly submit path. Use the existing shared start flag and version
refresh via the Modelos component. Reset the training promotion
checkbox on domain changes and the upload selection with its input
listing. Ignore training submissions that finish in a different domain.
Move gobernanza.spec.ts to models.spec.ts alongside checkActions.
Keep bundles, execution, training, run-monitor, figures and preview PDF
logic specs. Update e2e/pages.spec.ts for Material selections and
the Modelos monitor, and check section order and training focus.
Prettier 3.10.1 and git diff --cached --check passed. The main checkout
has no local Prettier installation, so use the available lockfile
version directly from the requested working directory. Angular builds,
unit tests and Playwright are deferred to the VM per the spec.
151 lines
7.1 KiB
TypeScript
151 lines
7.1 KiB
TypeScript
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;
|
|
}
|
|
|
|
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 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();
|
|
await expect(page.locator('app-tab-riesgos app-tea-list')).toBeVisible();
|
|
await expect(page.getByText('Cargando pacientes…')).toHaveCount(0);
|
|
|
|
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 table tbody tr').first();
|
|
await expect(first.locator('td').first()).toHaveText(/^N-?\d{4}$/);
|
|
await first.getByRole('link', { name: 'Expediente' }).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: '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',
|
|
'Bundles',
|
|
'Estudios EEG',
|
|
'Vista previa',
|
|
]);
|
|
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 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('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 },
|
|
);
|
|
|
|
const preview = page.locator('app-eeg-preview');
|
|
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([]);
|
|
});
|