One shell with the current look: indicators, follow-up list and patient view from FHIR; /conectar canvas; /revision; Playwright page tests
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
import { expect, Page, test } from '@playwright/test';
|
||||
|
||||
/** Every page loads from the API with no failed request and no console error. */
|
||||
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("indicators: the KPIs are the API's MeasureReports, every tab and the patient view load", async ({
|
||||
page,
|
||||
}) => {
|
||||
const problems = watch(page);
|
||||
const report = page.waitForResponse(
|
||||
(r) =>
|
||||
r.url().includes('MeasureReport') &&
|
||||
r.url().includes('measure=cacu-eu7') &&
|
||||
!r.url().includes('%2C'),
|
||||
);
|
||||
await page.goto('/indicadores/cacu');
|
||||
const eu7 = await (await report).json();
|
||||
const count = eu7.entry[0].resource.group[0].population.find(
|
||||
(p: any) => p.code.coding[0].code === 'initial-population',
|
||||
).count;
|
||||
await expect(page.locator('[data-measure="CACU_EU7"] .kpi-value')).toHaveText(String(count));
|
||||
await expect(page.locator('app-tab-indicadores app-plot').first()).toBeVisible();
|
||||
|
||||
await page.getByRole('tab', { name: 'Trazabilidad' }).click();
|
||||
await expect(page.locator('app-tab-trazabilidad mat-card')).toHaveCount(14);
|
||||
|
||||
await page.getByRole('tab', { name: 'Datos y definiciones' }).click();
|
||||
await expect(page.locator('app-tab-definiciones tbody tr')).toHaveCount(14);
|
||||
|
||||
const list = page.waitForResponse((r) => r.url().includes('/fhir/Patient?'));
|
||||
await page.getByRole('tab', { name: 'Análisis de riesgos' }).click();
|
||||
const bundle = await (await list).json();
|
||||
const first = bundle.entry.find((e: any) => e.search.mode === 'match').resource.id;
|
||||
const rows = page.locator('table.worklist tbody tr');
|
||||
await expect(rows).toHaveCount(Math.min(20, bundle.total));
|
||||
await expect(rows.first().locator('a.id')).toHaveText(first.slice(0, 10));
|
||||
await page.getByRole('button', { name: 'Siguiente' }).click();
|
||||
await expect(page.getByText(`21–`)).toBeVisible();
|
||||
|
||||
await page.getByRole('button', { name: 'Anterior' }).click();
|
||||
await rows.first().locator('a.id').click();
|
||||
await expect(page.getByText('Historial médico')).toBeVisible();
|
||||
await expect(page.getByText('Pruebas y resultados')).toBeVisible();
|
||||
await expect(
|
||||
page.locator('app-paciente table').nth(1).locator('tbody tr').first(),
|
||||
).not.toContainText('Sin estudios');
|
||||
|
||||
await page.goto('/indicadores/cama');
|
||||
await expect(page.getByText('todavía no tiene indicadores')).toBeVisible();
|
||||
expect(problems).toEqual([]);
|
||||
});
|
||||
|
||||
test('conectar: open the hospital pipeline, preview a source, run it to success', async ({
|
||||
page,
|
||||
}) => {
|
||||
const problems = watch(page);
|
||||
await page.goto('/conectar');
|
||||
await page.getByText('cacu', { exact: true }).click();
|
||||
await expect(page.locator('vflow')).toBeVisible();
|
||||
await page.getByText('Fuente · Patients').click();
|
||||
await expect(page.locator('formly-form')).toBeVisible();
|
||||
await page.getByRole('button', { name: 'Vista previa' }).click();
|
||||
await expect(page.locator('.preview tr[mat-row]').first()).toBeVisible();
|
||||
await page.getByRole('button', { name: 'Ejecutar' }).click();
|
||||
await expect(page.getByText('SUCCESS')).toBeVisible({ timeout: 10 * 60_000 });
|
||||
expect(problems).toEqual([]);
|
||||
});
|
||||
|
||||
test('revision: what the messy site holds, and a decision through the page', async ({ page }) => {
|
||||
const problems = watch(page);
|
||||
await page.goto('/revision');
|
||||
await page.getByRole('tab', { name: 'Personas' }).click();
|
||||
await page.locator('mat-form-field', { hasText: 'Canalización' }).click();
|
||||
await page.getByRole('option', { name: 'site', exact: true }).click();
|
||||
await expect(page.getByText(/Posibles pacientes duplicadas \([1-9]/)).toBeVisible();
|
||||
await page.getByRole('button', { name: 'Distintas' }).first().click();
|
||||
await expect(page.getByText('Decisión registrada.')).toBeVisible();
|
||||
expect(problems).toEqual([]);
|
||||
});
|
||||
Reference in New Issue
Block a user