feat(ui): incorporar selector de figuras KPI y fijacion de indicadores
This commit is contained in:
@@ -24,9 +24,9 @@ describe('UX-05B ciclo de vida con componentes Plotly y runtime simulado', () =>
|
||||
TestBed.configureTestingModule({ imports: [IndicadoresPage], providers: [provideRouter([]), provideHttpClient(), provideHttpClientTesting(),
|
||||
{ provide: PLOTLY_LOADER, useValue: () => Promise.resolve(runtime) }] });
|
||||
fixture = TestBed.createComponent(IndicadoresPage); http = TestBed.inject(HttpTestingController);
|
||||
http.expectOne('/tea/indicadores').flush([{ id: 'i', titulo: 'I', contrato: 'C1', figuras: ['f', 'g'], tipos_periodo: ['semestre'] }]);
|
||||
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'] }]);
|
||||
fixture.detectChanges();
|
||||
(fixture.debugElement.query(By.directive(IndicadorCatalogCard)).componentInstance as IndicadorCatalogCard).toggle();
|
||||
for (const entry of fixture.debugElement.queryAll(By.directive(IndicadorCatalogCard))) (entry.componentInstance as IndicadorCatalogCard).toggle();
|
||||
fixture.detectChanges();
|
||||
});
|
||||
afterEach(() => { fixture.destroy(); http.verify(); vi.unstubAllGlobals(); });
|
||||
@@ -40,12 +40,27 @@ describe('UX-05B ciclo de vida con componentes Plotly y runtime simulado', () =>
|
||||
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 · i · g');
|
||||
expect(hosts[1].getAttribute('aria-label')).toBe('tea · j · g');
|
||||
const card = fixture.debugElement.query(By.directive(IndicadorCatalogCard)).componentInstance as IndicadorCatalogCard;
|
||||
card.toggle(); fixture.detectChanges();
|
||||
for (const host of hosts) expect(runtime.purge).toHaveBeenCalledWith(host);
|
||||
for (const disconnect of disconnects) expect(disconnect).toHaveBeenCalledTimes(1);
|
||||
expect(fixture.debugElement.queryAll(By.directive(PlotlyChart))).toHaveLength(0);
|
||||
expect(runtime.purge).toHaveBeenCalledWith(hosts[0]);
|
||||
expect(runtime.purge).not.toHaveBeenCalledWith(hosts[1]);
|
||||
expect(disconnects[0]).toHaveBeenCalledTimes(1); expect(disconnects[1]).not.toHaveBeenCalled();
|
||||
expect(fixture.debugElement.queryAll(By.directive(PlotlyChart))).toHaveLength(1);
|
||||
});
|
||||
it('cambiar representación purga el host saliente y conserva el host del otro indicador', async () => {
|
||||
respond(); await settle();
|
||||
const charts = fixture.debugElement.queryAll(By.directive(PlotlyChart));
|
||||
const outgoing = charts[0].componentInstance.host.nativeElement;
|
||||
const other = charts[1].componentInstance.host.nativeElement;
|
||||
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();
|
||||
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);
|
||||
expect(runtime.react.mock.calls.filter(c => c[0] === other)).toHaveLength(1);
|
||||
});
|
||||
it('un error de renderizado y su reintento no afectan la otra instancia', async () => {
|
||||
runtime.react.mockRejectedValueOnce(new Error('render'));
|
||||
@@ -76,7 +91,7 @@ describe('UX-05B ciclo de vida con componentes Plotly y runtime simulado', () =>
|
||||
expect(fixture.debugElement.queryAll(By.directive(PlotlyChart)).map(c => c.componentInstance.host.nativeElement)).toEqual(hosts);
|
||||
// Published capability change is evaluated by each existing consumer.
|
||||
const current = page.catalog()[0];
|
||||
page.catalog.set([{ ...current, tipos_periodo: ['mes'] }]); fixture.detectChanges(); await settle();
|
||||
page.catalog.set(page.catalog().map(item => ({ ...item, tipos_periodo: ['mes'] }))); fixture.detectChanges(); await settle();
|
||||
for (const host of hosts) expect(host.closest('[hidden]')).toBeTruthy();
|
||||
expect(fixture.nativeElement.querySelectorAll('.incompatible')).toHaveLength(2);
|
||||
expect(runtime.purge).not.toHaveBeenCalled(); http.expectNone(() => true);
|
||||
|
||||
Reference in New Issue
Block a user