CaCu Indicadores as the old page: its cards and words, the route, cytology and biopsy donuts, results by clinical scenario, confirmation rates; the page test compares with the capture; the guard injects before it waits
This commit is contained in:
+44
-3
@@ -1,3 +1,4 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { expect, Page, test } from '@playwright/test';
|
||||
|
||||
/** Every page loads from the API with no failed request and no console error. */
|
||||
@@ -12,7 +13,7 @@ function watch(page: Page): string[] {
|
||||
// The pages show only to someone signed in (the API itself answers everyone).
|
||||
test.beforeEach(async ({ page }) => {
|
||||
const signed = await page.request.post('/api/auth/login', {
|
||||
form: { username: 'admin@isssteleon.test', password: 'solo-para-pruebas' },
|
||||
form: { username: 'admin@isssteleon.mx', password: 'solo-para-pruebas' },
|
||||
});
|
||||
expect(signed.status()).toBe(204);
|
||||
});
|
||||
@@ -22,7 +23,7 @@ test('login: the pages wait for a sign-in, and a wrong password says so', async
|
||||
await page.goto('/conectar');
|
||||
await expect(page).toHaveURL(/\/login\?next=%2Fconectar/);
|
||||
await expect(page.getByRole('heading', { name: 'Inicio de sesión' })).toBeVisible();
|
||||
await page.getByRole('textbox', { name: 'Usuario' }).fill('admin@isssteleon.test');
|
||||
await page.getByRole('textbox', { name: 'Usuario' }).fill('admin@isssteleon.mx');
|
||||
await page.getByRole('textbox', { name: 'Contraseña' }).fill('otra');
|
||||
await page.getByRole('button', { name: 'Ingresar' }).click();
|
||||
await expect(page.getByText('Usuario o contraseña incorrectos.')).toBeVisible();
|
||||
@@ -80,7 +81,7 @@ test("indicators: the KPIs are the API's MeasureReports, every tab and the patie
|
||||
|
||||
await page.goto('/indicadores/cama');
|
||||
await expect(page.getByRole('tab', { name: 'Indicadores' })).toBeVisible();
|
||||
await page.getByRole('tab', { name: 'Seguimiento' }).click();
|
||||
await page.getByRole('tab', { name: 'Análisis de riesgos' }).click();
|
||||
await page.locator('mat-form-field', { hasText: 'Ventana' }).click();
|
||||
await page.getByRole('option', { name: '12 meses' }).click();
|
||||
const camaRows = page.locator('table.worklist tbody tr');
|
||||
@@ -178,3 +179,43 @@ test('conectar: someone who knows nothing of databases connects the SQL Server w
|
||||
await expect(page.getByText('Versión 1 guardada.')).toBeVisible();
|
||||
expect(problems).toEqual([]);
|
||||
});
|
||||
|
||||
/** The old app's Indicadores tab as captured (tools/capture_pages.py): its headings from the
|
||||
* opportunity section on, in order, and the kind of each plot (its traces' types). */
|
||||
function captured(domain: string) {
|
||||
const path = `../tests/fixtures/reference/${domain}/ui/pages.json`;
|
||||
const items = JSON.parse(readFileSync(path, 'utf8')).tabs['Indicadores'] as any[];
|
||||
const from = items.findIndex((i) => i.text === 'Indicadores de oportunidad');
|
||||
return items.slice(from).filter((i) => ['h2', 'h3', 'plot'].includes(i.kind));
|
||||
}
|
||||
const period = (text: string) => text.replace(/, \d{4}-(S[12]|\d{2})$/, ', <periodo>');
|
||||
const kindOf = (types: string[]) => [...new Set(types)].sort().join('+');
|
||||
|
||||
for (const domain of ['cacu']) {
|
||||
test(`indicadores ${domain}: the old page's headings, in order, and the same kinds of plots`, async ({
|
||||
page,
|
||||
}) => {
|
||||
const old = captured(domain);
|
||||
await page.goto(`/indicadores/${domain}`);
|
||||
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()));
|
||||
const from = headings.indexOf('Indicadores de oportunidad');
|
||||
expect(headings.slice(from).map(period)).toEqual(
|
||||
old.filter((i) => i.kind !== 'plot').map((i) => period(i.text)),
|
||||
);
|
||||
// Each figure drawn is one of the old kinds (a figure with no data in the period is named).
|
||||
const drawn = await tab
|
||||
.locator('.js-plotly-plot')
|
||||
.evaluateAll((els) =>
|
||||
els.map((e: any) => (e.data ?? []).map((t: any) => t.type ?? 'scatter')),
|
||||
);
|
||||
const kinds = new Set(
|
||||
old.filter((i) => i.kind === 'plot').map((i) => kindOf(i.traces.map((t: any) => t.type))),
|
||||
);
|
||||
for (const types of drawn) expect(kinds).toContain(kindOf(types));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user