561a5dde36
dev already names the history tab «Trazabilidad» for the three domains, so its version of those files stays. CaCu's diagnosis-to-treatment time keeps one presentation, its card: it has no figure of its own next to the screening route chart.
97 lines
6.6 KiB
TypeScript
97 lines
6.6 KiB
TypeScript
// Covers how the Indicadores tab arranges CaCu's figures: the five times of «Tiempo de tamizaje a diagnóstico» under
|
|
// «Indicadores de oportunidad» (pending where the catalog publishes nothing) and the clinical figures. Fixtures: a CaCu catalog shaped like /cacu/indicadores.
|
|
import { TestBed } from '@angular/core/testing';
|
|
import { provideHttpClient } from '@angular/common/http';
|
|
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
|
|
import { provideRouter } from '@angular/router';
|
|
import { IndicadoresPage } from './indicadores-page';
|
|
import { IndicadoresMemory } from './indicadores-memory';
|
|
|
|
const item = (id: string, titulo: string, contrato: string, figuras: string[]) => ({ id, titulo, contrato, figuras, tipos_periodo: ['semestre', 'mes'] });
|
|
const CACU = [
|
|
item('cacu_eu13', 'Tasa de detección histopatológica', 'C1', []),
|
|
item('cacu_eu7', 'Distribución de resultados citológicos', 'C2', ['fig_c2_donas', 'fig_c2_barras']),
|
|
item('cacu_eu_tiempo_reporte', 'Días de la toma de la citología a su resultado', 'C3r', ['fig_c3r_caja']),
|
|
item('cacu_dias_toma_diagnostico', 'Tiempo de tamizaje a diagnóstico', 'C3r', ['fig_c3r_caja']),
|
|
item('cacu_confirmacion_citologia', 'Tasa de confirmación histopatológica', 'C2', ['fig_c2_donas']),
|
|
item('ind1', 'Pacientes con citología anómala', 'C1', []),
|
|
];
|
|
|
|
// The route measures besides the cytology and diagnosis ones in CACU; with all of them the screening route chart appears.
|
|
const RUTA = ['cacu_dias_resultado_colposcopia', 'cacu_dias_toma_colposcopia', 'cacu_dias_colposcopia_biopsia', 'cacu_dias_toma_biopsia', 'cacu_dias_biopsia_diagnostico']
|
|
.map(id => item(id, id, 'C3r', ['fig_c3r_caja']));
|
|
|
|
describe('Indicadores de CaCu: tiempos de oportunidad y figuras clínicas', () => {
|
|
let fixture: ReturnType<typeof TestBed.createComponent<IndicadoresPage>>, http: HttpTestingController;
|
|
const abrir = (catalogo: ReturnType<typeof item>[]) => {
|
|
vi.stubGlobal('IntersectionObserver', class { observe() {} unobserve() {} disconnect() {} });
|
|
TestBed.configureTestingModule({ imports: [IndicadoresPage], providers: [provideRouter([]), provideHttpClient(), provideHttpClientTesting()] });
|
|
for (const domain of ['tea', 'cacu', 'cama'] as const) TestBed.inject(IndicadoresMemory).finishInitialKpiPresentation(domain);
|
|
fixture = TestBed.createComponent(IndicadoresPage); http = TestBed.inject(HttpTestingController);
|
|
http.expectOne('/tea/indicadores').flush([]); fixture.detectChanges();
|
|
fixture.componentInstance.changeDominio('cacu'); fixture.detectChanges();
|
|
http.expectOne('/cacu/indicadores').flush(catalogo); fixture.detectChanges();
|
|
http.match(() => true); fixture.detectChanges();
|
|
};
|
|
// The KPI and period requests are not what these tests are about.
|
|
afterEach(() => { fixture.destroy(); http.match(() => true); http.verify(); vi.unstubAllGlobals(); });
|
|
const root = () => fixture.nativeElement as HTMLElement;
|
|
const titulos = (selector: string) => [...root().querySelectorAll(selector + ' > *')]
|
|
.map(e => e.tagName.toLowerCase().replace('app-indicador-', '') + ': ' + e.querySelector('h2')?.textContent?.trim());
|
|
|
|
it('las figuras disponibles conservan su orden sin reservas vacías', () => {
|
|
// Fails if a time figure changes place, if a missing indicator is drawn as a figure or if the published ones lose
|
|
// the names of the request.
|
|
abrir(CACU);
|
|
expect(root().querySelector('.subsection-title')?.textContent).toBe('Tiempo de tamizaje a diagnóstico');
|
|
expect(titulos('.kpi-section .catalog-grid')).toEqual([
|
|
'catalog-card: Tiempo de toma de muestra a resultado de citología',
|
|
'catalog-card: Tiempo de toma de muestra a diagnóstico']);
|
|
});
|
|
|
|
it('con la ruta del tamizaje no hay subsección «Tiempo de tamizaje a diagnóstico»: la gráfica dibuja los tiempos', () => {
|
|
// Fails if the times the route chart draws also get a figure or a «pendiente» slot of their own next to it.
|
|
abrir([...CACU, ...RUTA]);
|
|
expect(root().querySelector('.subsection-title')).toBeNull();
|
|
expect(titulos('.kpi-section .catalog-grid')).toEqual([]);
|
|
expect(root().querySelector('app-indicador-screening-route')).not.toBeNull();
|
|
expect(titulos('.graphic-section .catalog-grid')).toEqual([
|
|
'catalog-card: Distribución de resultados citológicos', 'catalog-card: Tasa de confirmación histopatológica']);
|
|
});
|
|
|
|
it('sin la gráfica de la ruta, colposcopía y biopsia publicadas son figuras con su nombre', () => {
|
|
// Fails if a published measure of the route stays a pending slot while the chart that would draw it is not there.
|
|
abrir([...CACU, ...RUTA.filter(medida => medida.id === 'cacu_dias_toma_colposcopia' || medida.id === 'cacu_dias_toma_biopsia')]);
|
|
expect(root().querySelector('app-indicador-screening-route')).toBeNull();
|
|
expect(titulos('.kpi-section .catalog-grid')).toEqual([
|
|
'catalog-card: Tiempo de toma de muestra a resultado de citología',
|
|
'catalog-card: Tiempo de toma de muestra a resultado de colposcopía',
|
|
'catalog-card: Tiempo de toma de muestra a resultado de biopsia',
|
|
'catalog-card: Tiempo de toma de muestra a diagnóstico']);
|
|
});
|
|
|
|
it('el resultado de laboratorio se llama «Tiempo desde la toma de muestra al resultado»', () => {
|
|
// Fails if the opportunity card goes back to «Días de toma a resultado».
|
|
abrir(CACU);
|
|
const titulosKpi = [...root().querySelectorAll('.kpi-section app-indicador-kpi-card h3')].map(h => h.textContent?.trim());
|
|
expect(titulosKpi).toContain('Tiempo desde la toma de muestra al resultado');
|
|
expect(titulosKpi).not.toContain('Días de toma a resultado');
|
|
});
|
|
|
|
it('los indicadores clínicos son los dos pedidos, sin tarjetas vacías ni figuras pendientes', () => {
|
|
// Fails if the time figures stay in the clinical section, if indicators with no figure get a card, or if a pending
|
|
// figure («Progresión por grupo de riesgo», withdrawn) comes back.
|
|
abrir(CACU);
|
|
expect(titulos('.graphic-section .catalog-grid')).toEqual([
|
|
'catalog-card: Distribución de resultados citológicos', 'catalog-card: Tasa de confirmación histopatológica']);
|
|
expect(root().querySelector('.graphic-section app-indicador-figura-pendiente')).toBeNull();
|
|
});
|
|
|
|
it('Datos y definiciones conserva todo el catálogo', () => {
|
|
// Fails if moving the time figures or hiding figure-less indicators removes them from the definitions tab.
|
|
abrir(CACU);
|
|
const definiciones = root().querySelector('#panel-datos')!.textContent!;
|
|
for (const titulo of ['Tasa de detección histopatológica', 'Pacientes con citología anómala', 'Tiempo de toma de muestra a diagnóstico']) expect(definiciones).toContain(titulo);
|
|
});
|
|
});
|