import { expect, test } from '@playwright/test'; test.beforeEach(async ({ page }) => { const form = { username: 'admin@isssteleon.mx', password: 'solo-para-pruebas' }; expect((await page.request.post('/api/auth/login', { form })).status()).toBe(204); }); test('indicadores cacu: its sections in order, each card read one mode at a time', async ({ page, }) => { await page.goto('/indicadores/cacu'); const tab = page.locator('app-tab-indicadores'); await expect(tab.getByRole('heading', { name: 'Indicadores clínicos' })).toBeVisible(); await expect(tab.locator('app-loading')).toHaveCount(0, { timeout: 5 * 60_000 }); const headings = await tab .locator('h2, app-readings h3') .evaluateAll((els) => els.map((e) => (e as HTMLElement).innerText.trim())); expect(headings.slice(headings.indexOf('Indicadores clínicos'))).toEqual([ 'Indicadores clínicos', 'Resultados de citología, VPH y biopsia', 'Distribución de resultados citológicos', 'Resultados de VPH por genotipo', 'Resultados de biopsia cervical', 'Tasa de confirmación histopatológica', 'Tasa de confirmación histopatológica de referencia a colposcopía', 'Indicadores de oportunidad', 'Tiempos de tamizaje', ]); // one selector reads both the cytology and the HPV card by group await tab.getByRole('radio', { name: 'Por detección inicial y anterior' }).first().click(); for (const card of ['Distribución de resultados citológicos', 'Resultados de VPH por genotipo']) await expect( tab .locator('app-readings', { has: page.getByRole('heading', { name: card }) }) .locator('section.group') .first(), ).toBeVisible(); const route = tab.locator('app-readings').last(); for (const mode of [ 'Por ventana de tiempo', 'Diagnóstico precolposcópico', 'Diagnóstico tras biopsia', 'Acumulado desde la toma', ]) { await route.getByRole('radio', { name: mode }).click(); await expect( route.getByRole('table', { name: mode }).or(route.getByText('Sin datos en el periodo.')), ).toBeVisible(); } await tab.getByRole('radio', { name: 'Biopsia', exact: true }).click(); await expect( tab.getByRole('heading', { name: 'Tasa de confirmación histopatológica de referencia a biopsia', }), ).toBeVisible(); }); test('indicadores cama: its sections in order, the route chained and the types by BI-RADS', async ({ page, }) => { await page.goto('/indicadores/cama'); const tab = page.locator('app-tab-indicadores'); await expect(tab.getByRole('heading', { name: 'Indicadores clínicos' })).toBeVisible(); await expect(tab.locator('app-loading')).toHaveCount(0, { timeout: 5 * 60_000 }); const headings = await tab .locator('h2, h3') .evaluateAll((els) => els.map((e) => (e as HTMLElement).innerText.trim())); expect(headings.slice(headings.indexOf('Indicadores de oportunidad'))).toEqual([ 'Indicadores de oportunidad', 'Pacientes evaluadas con BI-RADS 4, 5 o 6', 'Tiempo de toma de mastografía a interpretación radiológica', 'Tiempo de interpretación radiológica a diagnóstico', 'Tiempo de interpretación radiológica a resultado de biopsia', 'Tiempo de diagnóstico tras biopsia a tratamiento', 'Tiempo de tamizaje a diagnóstico', 'Tiempo de tamizaje a diagnóstico y tratamiento', 'Indicadores clínicos', expect.stringMatching(/^Porcentaje de mastografías con resultado BI-RADS 4, 5 ó 6 en /), expect.stringMatching(/^Porcentaje de pacientes con resultados BI-RADS 4, 5 ó 6 en /), 'Tipo histológico por categoría BI-RADS', 'Confirmación histopatológica', ]); const types = tab.locator('app-readings', { has: page.getByRole('heading', { name: 'Tipo histológico por categoría BI-RADS' }), }); await expect(types.getByRole('columnheader', { name: '% maligno' })).toBeVisible(); await tab.getByRole('radio', { name: 'Mastografías con biopsia' }).click(); await expect(tab.getByRole('table', { name: 'Con y sin biopsia' })).toBeVisible(); }); test('riesgos cacu: ages filter the whole list and a row opens its stages', async ({ page }) => { await page.goto('/indicadores/cacu'); await page.getByRole('tab', { name: 'Análisis de Riesgo' }).click(); const list = page.locator('table.worklist tbody tr'); await expect(list.first().locator('app-stages li')).toHaveCount(5); await list.first().getByRole('button', { name: 'Detalle' }).click(); await expect(page.locator('tr.stage-detail')).toContainText('Toma de muestra'); const answer = page.waitForResponse((r) => r.url().includes('birthdate=le')); await page.getByLabel('Edad mínima').fill('45'); expect((await answer).ok()).toBe(true); for (const age of await list.locator('td:nth-child(2)').allInnerTexts()) expect(parseInt(age)).toBeGreaterThanOrEqual(45); for (const [button, file] of [ ['Exportar Excel', 'seguimiento-cacu.xlsx'], ['Exportar PDF', 'seguimiento-cacu.pdf'], ]) { const saved = page.waitForEvent('download'); await page.getByRole('button', { name: button }).click(); expect((await saved).suggestedFilename()).toBe(file); } await list.first().locator('a').first().click(); await expect(page.locator('[data-section=etapas]')).toContainText('Reporte de biopsia'); const record = page.waitForEvent('download'); await page.getByRole('button', { name: 'Exportar PDF' }).click(); expect((await record).suggestedFilename()).toBe('expediente-cacu.pdf'); });