feat(ui): mejorar periodos KPI y presentacion del dashboard

This commit is contained in:
Angel Capetillo Zavala
2026-10-14 11:46:17 -06:00
parent 9fcc65d84f
commit 69afcc7fdb
26 changed files with 778 additions and 604 deletions
@@ -1,3 +1,4 @@
import { periodAvailabilityProvider } from './indicadores-periodos.testing';
import { Component } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { provideHttpClient } from '@angular/common/http';
@@ -21,7 +22,8 @@ class ChartStub { figure?: PlotlyFigure; }
describe('UX-04 navegación Angular', () => {
let http: HttpTestingController;
async function setup() {
TestBed.configureTestingModule({ providers: [provideRouter(routes), provideHttpClient(), provideHttpClientTesting()] });
vi.stubGlobal('IntersectionObserver', class { observe() {} unobserve() {} disconnect() {} });
TestBed.configureTestingModule({ providers: [provideRouter(routes), provideHttpClient(), provideHttpClientTesting(), periodAvailabilityProvider] });
TestBed.overrideComponent(IndicadorFigureCard, { remove: { imports: [PlotlyChart] }, add: { imports: [ChartStub] } });
http = TestBed.inject(HttpTestingController);
return RouterTestingHarness.create();
@@ -29,13 +31,15 @@ describe('UX-04 navegación Angular', () => {
function load(domain: 'tea' | 'cacu' | 'cama', harness: RouterTestingHarness) {
http.expectOne('/' + domain + '/indicadores').flush(syntheticCatalogs[domain]);
harness.detectChanges();
const page = harness.routeDebugElement!.componentInstance as IndicadoresPage;
vi.spyOn(page as unknown as { evaluateVisibility(): void }, 'evaluateVisibility').mockImplementation(() => {});
const card = harness.routeDebugElement!.query(By.directive(IndicadorCatalogCard)).componentInstance as IndicadorCatalogCard;
if (!card.expanded || card.awaitingFigures) { card.toggle(); harness.detectChanges(); }
if (!card.visible) { card.setVisible(true); harness.detectChanges(); }
const req = http.expectOne(r => r.url.includes('/figuras/'));
req.flush({ data: [{ y: [0, null] }], layout: {} });
return req;
}
afterEach(() => http.verify());
afterEach(() => { http.verify(); vi.unstubAllGlobals(); });
it.each(['tea', 'cacu', 'cama'] as const)('navegación %s mantiene tres enlaces, estado, decoración y foco independiente', async domain => {
const harness = await setup();
await harness.navigateByUrl('/indicadores/' + domain, IndicadoresPage);
@@ -97,7 +101,7 @@ describe('UX-04 navegación Angular', () => {
const restarted = await harness.navigateByUrl(url, IndicadoresPage);
const req = load('cacu', harness);
expect(TestBed.inject(Router).url).toBe('/indicadores/cacu');
expect((harness.routeDebugElement!.query(By.directive(IndicadorCatalogCard)).componentInstance as IndicadorCatalogCard).expanded).toBe(true);
expect((harness.routeDebugElement!.query(By.directive(IndicadorCatalogCard)).componentInstance as IndicadorCatalogCard).visible).toBe(true);
expect(restarted.tema).toBe('claro');
expect((harness.routeDebugElement!.componentInstance as IndicadoresPage).filters?.tipo).toBe('semestre');
expect((harness.routeDebugElement!.componentInstance as IndicadoresPage).filters?.editors.mes?.draft.mode).toBe('empty');