CaCu: show screening rounds and restore category palettes
This commit is contained in:
+162
-1
@@ -1,4 +1,6 @@
|
||||
import { expect, test } from '@playwright/test';
|
||||
import { expect, type Page, test } from '@playwright/test';
|
||||
import { layoutProblems } from './layout';
|
||||
import { type Simulation, simulateRounds } from './simulated-rounds';
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
const form = { username: 'admin@isssteleon.mx', password: 'solo-para-pruebas' };
|
||||
@@ -34,7 +36,41 @@ test('indicadores cacu: its sections in order, each card read one mode at a time
|
||||
route.getByRole('table', { name: mode }).or(route.getByText('Sin datos en el periodo.')),
|
||||
).toBeVisible();
|
||||
}
|
||||
// the screening round replaces the clinical scenario: the same tab, label and order on four cards
|
||||
const round = { name: 'Por detección inicial y subsecuente' };
|
||||
await expect(tab.getByRole('radio', { name: 'Por escenario clínico' })).toHaveCount(0);
|
||||
for (const card of [
|
||||
'Distribución de resultados citológicos',
|
||||
'Pacientes evaluadas por resultado de VPH',
|
||||
'Valor predictivo positivo de la colposcopía',
|
||||
]) {
|
||||
const readings = tab.locator('app-readings', {
|
||||
has: page.getByRole('heading', { name: card }),
|
||||
});
|
||||
await readings.getByRole('radio', round).click();
|
||||
// rows in the order of the contract, "no disponible", or no patients in the period
|
||||
await expect(
|
||||
readings
|
||||
.getByRole('table', round)
|
||||
.or(readings.locator('app-plot'))
|
||||
.or(readings.getByText(/No disponible|Sin datos en el periodo/)),
|
||||
).toBeVisible();
|
||||
if (await readings.getByRole('table', round).count()) {
|
||||
const labels = await readings.getByRole('rowheader').allInnerTexts();
|
||||
expect(labels.map((l) => l.trim().split(/\s{2,}|\n/)[0])).toEqual([
|
||||
'Detección inicial',
|
||||
'Detección subsecuente',
|
||||
'Sin dato',
|
||||
]);
|
||||
}
|
||||
}
|
||||
await tab.getByRole('radio', { name: 'Biopsia', exact: true }).click();
|
||||
await tab
|
||||
.locator('app-readings', {
|
||||
has: page.getByRole('heading', { name: 'Valor predictivo positivo de la biopsia' }),
|
||||
})
|
||||
.getByRole('radio', round)
|
||||
.click();
|
||||
await expect(
|
||||
tab.getByRole('heading', { name: 'Valor predictivo positivo de la biopsia' }),
|
||||
).toBeVisible();
|
||||
@@ -67,3 +103,128 @@ test('riesgos cacu: ages filter the whole list and a row opens its stages', asyn
|
||||
await page.getByRole('button', { name: 'Exportar PDF' }).click();
|
||||
expect((await record).suggestedFilename()).toBe('expediente-cacu.pdf');
|
||||
});
|
||||
|
||||
// ---- Screening rounds on SIMULATED answers (see simulated-rounds.ts): the groups the contract of
|
||||
// `rebuild` allows, tried without loading data. They show how the page draws them, not the backend.
|
||||
const ROUND = { name: 'Por detección inicial y subsecuente' };
|
||||
const TITLES = {
|
||||
cytology: 'Distribución de resultados citológicos',
|
||||
vph: 'Pacientes evaluadas por resultado de VPH',
|
||||
colposcopy: 'Valor predictivo positivo de la colposcopía',
|
||||
biopsy: 'Valor predictivo positivo de la biopsia',
|
||||
};
|
||||
const BAR = {
|
||||
initial: 'rgb(95, 127, 154)',
|
||||
subsequent: 'rgb(143, 167, 187)',
|
||||
no_data: 'rgb(201, 205, 210)',
|
||||
};
|
||||
|
||||
async function withRounds(page: Page, how: Simulation) {
|
||||
await simulateRounds(page, how);
|
||||
await page.goto('/indicadores/cacu');
|
||||
const tab = page.locator('app-tab-indicadores');
|
||||
await expect(tab.getByRole('heading', { name: 'Indicadores clínicos' })).toBeVisible({
|
||||
timeout: 3 * 60_000,
|
||||
});
|
||||
await expect(tab.locator('app-loading')).toHaveCount(0, { timeout: 5 * 60_000 });
|
||||
const card = (title: string) =>
|
||||
tab.locator('app-readings', { has: page.getByRole('heading', { name: title }) }).first();
|
||||
const open = async (key: keyof typeof TITLES) => {
|
||||
if (key === 'biopsy') await tab.getByRole('radio', { name: 'Biopsia', exact: true }).click();
|
||||
if (key === 'colposcopy')
|
||||
await tab.getByRole('radio', { name: 'Colposcopía', exact: true }).click();
|
||||
const readings = card(TITLES[key]);
|
||||
await readings.getByRole('radio', ROUND).click();
|
||||
return readings;
|
||||
};
|
||||
return { tab, open };
|
||||
}
|
||||
|
||||
for (const key of ['vph', 'colposcopy', 'biopsy'] as const) {
|
||||
test(`rondas (simulado) ${key}: three groups in order, each with its own colour`, async ({
|
||||
page,
|
||||
}) => {
|
||||
const { open } = await withRounds(page, 'as-is');
|
||||
const readings = await open(key);
|
||||
const rows = readings.getByRole('row').filter({ has: page.getByRole('rowheader') });
|
||||
await expect(rows).toHaveCount(3);
|
||||
const names = await readings.getByRole('rowheader').allInnerTexts();
|
||||
expect(names.map((n) => n.trim().split(/\s*\n\s*/)[0])).toEqual([
|
||||
'Detección inicial',
|
||||
'Detección subsecuente',
|
||||
'Sin dato',
|
||||
]);
|
||||
const colours = await readings
|
||||
.locator('tbody .bar')
|
||||
.evaluateAll((els) => els.map((e) => getComputedStyle(e).backgroundColor));
|
||||
expect(colours).toEqual([BAR.initial, BAR.subsequent, BAR.no_data]);
|
||||
});
|
||||
|
||||
test(`rondas (simulado) ${key}: an empty initial group is zero patients, not hidden`, async ({
|
||||
page,
|
||||
}) => {
|
||||
const { open } = await withRounds(page, 'no-initial');
|
||||
const readings = await open(key);
|
||||
const initial = readings.getByRole('row').filter({ hasText: 'Detección inicial' });
|
||||
await expect(initial).toContainText('Sin pacientes en el periodo');
|
||||
await expect(initial).toContainText('0/0');
|
||||
});
|
||||
|
||||
test(`rondas (simulado) ${key}: without the stratum the card says it is not available`, async ({
|
||||
page,
|
||||
}) => {
|
||||
const { open } = await withRounds(page, 'unpublished');
|
||||
const readings = await open(key);
|
||||
await expect(readings).toContainText('No disponible');
|
||||
await expect(readings.getByRole('table', ROUND)).toHaveCount(0);
|
||||
});
|
||||
}
|
||||
|
||||
test('rondas (simulado) cytology: the bars follow the round and the cytology colours', async ({
|
||||
page,
|
||||
}) => {
|
||||
const { open } = await withRounds(page, 'as-is');
|
||||
const readings = await open('cytology');
|
||||
const plot = readings.locator('.js-plotly-plot');
|
||||
await expect(plot).toBeVisible();
|
||||
const { y, colours } = await plot.evaluate((e: any) => ({
|
||||
y: e.data[0].y as string[],
|
||||
colours: Object.fromEntries(e.data.map((t: any) => [t.name, t.marker.color])),
|
||||
}));
|
||||
expect(y.map((s) => s.split('<br>')[0])).toEqual([
|
||||
'Detección inicial',
|
||||
'Detección subsecuente',
|
||||
'Sin dato',
|
||||
]);
|
||||
expect(colours).toMatchObject({
|
||||
Normal: '#408651',
|
||||
'ASC-US': '#2778B8',
|
||||
LIEBG: '#B19525',
|
||||
'ASC-H': '#7955B1',
|
||||
LIEAG: '#CE4778',
|
||||
'Carcinoma in situ': '#AA394D',
|
||||
});
|
||||
});
|
||||
|
||||
test('rondas (simulado): an initial group folded into "Sin dato" keeps its counts there', async ({
|
||||
page,
|
||||
}) => {
|
||||
const { open } = await withRounds(page, 'unclassified');
|
||||
const readings = await open('vph');
|
||||
const rows = readings.getByRole('row').filter({ has: page.getByRole('rowheader') });
|
||||
await expect(rows.filter({ hasText: 'Detección inicial' })).toContainText('0/0');
|
||||
await expect(rows.filter({ hasText: 'Sin dato' })).not.toContainText('0/0');
|
||||
await expect(readings).toContainText('una categoría en cero significa');
|
||||
});
|
||||
|
||||
for (const width of [1440, 480]) {
|
||||
test(`rondas (simulado) at ${width} px: the four cards open on their rounds lay out cleanly`, async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width, height: 1000 });
|
||||
const { open } = await withRounds(page, 'as-is');
|
||||
for (const key of ['cytology', 'vph', 'colposcopy', 'biopsy'] as const) await open(key);
|
||||
await page.waitForTimeout(1500);
|
||||
expect(await layoutProblems(page)).toEqual([]);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user