fix(tea): limitar consultas de trazabilidad

This commit is contained in:
Angel Capetillo Zavala
2026-11-22 23:36:03 -06:00
parent 52d00409a0
commit e0a3be26eb
9 changed files with 112 additions and 96 deletions
@@ -27,7 +27,7 @@ describe('UX-05B ciclo de vida con componentes Plotly y runtime simulado', () =>
{ provide: PLOTLY_LOADER, useValue: () => Promise.resolve(runtime) }] });
fixture = TestBed.createComponent(IndicadoresPage);
vi.spyOn(fixture.componentInstance as unknown as { evaluateVisibility(): void }, 'evaluateVisibility').mockImplementation(() => {}); http = TestBed.inject(HttpTestingController);
http.expectOne('/tea/indicadores').flush([{ id: 'i', titulo: 'I', contrato: 'C1', figuras: ['f', 'g'], tipos_periodo: ['semestre'] }, { id: 'j', titulo: 'J', contrato: 'C1', figuras: ['g'], tipos_periodo: ['semestre'] }]);
http.expectOne('/tea/indicadores').flush([{ id: 'M23_pacientes_evaluados', titulo: 'I', contrato: 'C1', figuras: ['f', 'g'], tipos_periodo: ['semestre'] }, { id: 'M24_confirmacion_diagnostico', titulo: 'J', contrato: 'C1', figuras: ['g'], tipos_periodo: ['semestre'] }]);
fixture.detectChanges();
for (const entry of fixture.debugElement.queryAll(By.directive(IndicadorCatalogCard))) (entry.componentInstance as IndicadorCatalogCard).setVisible(true);
fixture.detectChanges();
@@ -42,8 +42,8 @@ describe('UX-05B ciclo de vida con componentes Plotly y runtime simulado', () =>
respond(); await settle(); const charts = fixture.debugElement.queryAll(By.directive(PlotlyChart));
expect(charts).toHaveLength(2); expect(runtime.react).toHaveBeenCalledTimes(2);
const hosts = charts.map(c => c.componentInstance.host.nativeElement);
expect(hosts[0]).not.toBe(hosts[1]); expect(hosts[0].getAttribute('aria-label')).toBe('tea, i, f');
expect(hosts[1].getAttribute('aria-label')).toBe('tea, j, g');
expect(hosts[0]).not.toBe(hosts[1]); expect(hosts[0].getAttribute('aria-label')).toBe('tea, M23_pacientes_evaluados, f');
expect(hosts[1].getAttribute('aria-label')).toBe('tea, M24_confirmacion_diagnostico, g');
const card = fixture.debugElement.query(By.directive(IndicadorCatalogCard)).componentInstance as IndicadorCatalogCard;
fixture.componentInstance.catalog.set(fixture.componentInstance.catalog().slice(1)); fixture.detectChanges();
expect(runtime.purge).toHaveBeenCalledWith(hosts[0]);
@@ -59,7 +59,7 @@ describe('UX-05B ciclo de vida con componentes Plotly y runtime simulado', () =>
const card = fixture.debugElement.query(By.directive(IndicadorCatalogCard)).componentInstance as IndicadorCatalogCard;
card.selectFigure('g'); fixture.detectChanges();
expect(runtime.purge).toHaveBeenCalledWith(outgoing); expect(runtime.purge).not.toHaveBeenCalledWith(other);
http.expectOne(r => r.url.endsWith('/i/figuras/g')).flush({ data: [{ y: [3] }], layout: {} }); await settle();
http.expectOne(r => r.url.endsWith('/M23_pacientes_evaluados/figuras/g')).flush({ data: [{ y: [3] }], layout: {} }); await settle();
const current = fixture.debugElement.queryAll(By.directive(PlotlyChart));
expect(current[0].componentInstance.host.nativeElement).not.toBe(outgoing);
expect(current[1].componentInstance.host.nativeElement).toBe(other);