e1a8127c22
Horizontal bars of the days from the sample to each event of the route (cytology result, colposcopy, biopsy result and diagnosis), cumulative with the Q1 to Q3 interval or step by step with each step starting where the previous one ends. It reads the seven duration measures of the route and shows up in CaCu's page once the catalog publishes all of them; the measures only it draws get no card of their own.
58 lines
3.6 KiB
TypeScript
58 lines
3.6 KiB
TypeScript
// What this module covers: the screening route chart in CaCu's page: it appears only when the catalog publishes the seven
|
|
// measures it reads, and then those measures that nothing else draws lose their own cards. Catalogs are synthetic,
|
|
// 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 { By } from '@angular/platform-browser';
|
|
import { provideRouter } from '@angular/router';
|
|
import { IndicadorCatalogCard } from './indicador-catalog-card';
|
|
import { IndicadoresPage } from './indicadores-page';
|
|
import { IndicadoresMemory } from './indicadores-memory';
|
|
import { Dominio } from './indicadores.models';
|
|
import { ROUTE_IDS, ROUTE_ONLY_IDS } from './screening-route';
|
|
|
|
const item = (id: string, contrato = 'C3r') => ({ id, titulo: id, contrato, figuras: [], tipos_periodo: ['semestre', 'mes'] });
|
|
|
|
describe('Ruta del tamizaje: página de CaCu', () => {
|
|
let fixture: ReturnType<typeof TestBed.createComponent<IndicadoresPage>>, http: HttpTestingController;
|
|
beforeEach(() => {
|
|
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();
|
|
});
|
|
afterEach(() => { fixture.destroy(); http.match(() => true); http.verify(); vi.unstubAllGlobals(); });
|
|
function abrir(domain: Dominio, catalog: unknown[]) {
|
|
fixture.componentInstance.changeDominio(domain); fixture.detectChanges();
|
|
http.expectOne('/' + domain + '/indicadores').flush(catalog); fixture.detectChanges();
|
|
http.match(() => true);
|
|
}
|
|
const ruta = () => fixture.nativeElement.querySelector('app-indicador-screening-route');
|
|
const tarjetas = () => fixture.debugElement.queryAll(By.directive(IndicadorCatalogCard)).map(d => (d.componentInstance as IndicadorCatalogCard).indicador.id);
|
|
|
|
it('con las siete medidas publicadas aparece la gráfica y sus medidas exclusivas no tienen tarjeta', () => {
|
|
// Pins down: the chart replaces the cards of the five measures only it draws, while the cytology's and the diagnosis'
|
|
// keep theirs. Fails if the chart stops appearing, or a measure it draws also shows as a card.
|
|
abrir('cacu', [item('cacu_eu7', 'C2'), ...ROUTE_IDS.map(id => item(id))]);
|
|
expect(ruta()).not.toBeNull();
|
|
const ids = tarjetas();
|
|
for (const id of ROUTE_ONLY_IDS) expect(ids).not.toContain(id);
|
|
expect(ids).toContain('cacu_eu_tiempo_reporte');
|
|
expect(ids).toContain('cacu_eu7');
|
|
});
|
|
it('si el catálogo no publica alguna de las siete, no hay gráfica y las medidas conservan sus tarjetas', () => {
|
|
// Fails if the chart appears with a measure missing, or the cards of the others disappear anyway.
|
|
abrir('cacu', [item('cacu_eu7', 'C2'), ...ROUTE_IDS.filter(id => id !== 'cacu_dias_toma_biopsia').map(id => item(id))]);
|
|
expect(ruta()).toBeNull();
|
|
const ids = tarjetas();
|
|
for (const id of ROUTE_ONLY_IDS.filter(id => id !== 'cacu_dias_toma_biopsia')) expect(ids).toContain(id);
|
|
});
|
|
it('las otras áreas no la tienen', () => {
|
|
// Fails if the CaCu chart leaks into TEA or CaMa.
|
|
abrir('cama', [item('cama_eu38a'), ...ROUTE_IDS.map(id => item(id))]);
|
|
expect(ruta()).toBeNull();
|
|
});
|
|
});
|