integrating latest dashboard changes

This commit is contained in:
Roberto Treviño Cervantes
2026-10-26 01:42:32 -06:00
parent d9245fe9b7
commit 51517ddf61
85 changed files with 7754 additions and 320 deletions
@@ -44,11 +44,11 @@ describe('UX-06E.D.3.A catálogo permanentemente desplegado', () => {
function kpiMissing() { http.match(r => r.url.endsWith('/datos')).forEach(r => r.flush('missing', { status: 404, statusText: 'Not Found' })); fixture.detectChanges(); }
function control(index = 0) { return fixture.debugElement.queryAll(By.directive(IndicadorPeriodFilters))[index].componentInstance as IndicadorPeriodFilters; }
it('KPI-DYNAMIC TEA muestra sus tres destacados sin consultar datos fuera del catálogo', () => {
it('no presenta destacados retirados del catálogo ni consulta sus datos', () => {
load();
expect(fixture.nativeElement.querySelector('#kpi-section-title').textContent).toBe('Indicadores destacados');
expect(fixture.nativeElement.querySelector('#kpi-section-title')).toBeNull();
expect(Array.from(fixture.nativeElement.querySelectorAll('.kpi-grid app-indicador-kpi-card h3')).map(h => (h as HTMLElement).textContent))
.toEqual(['Total de pacientes evaluados', 'Porcentaje de confirmación diagnóstica', 'Tiempo de aplicación de M-CHAT (psicología) a diagnóstico positivo']);
.toEqual([]);
http.expectNone(r => r.url.endsWith('/datos'));
});
it('KPI-DYNAMIC distingue carga, error y catálogo vacío confirmado', () => {
@@ -63,7 +63,7 @@ describe('UX-06E.D.3.A catálogo permanentemente desplegado', () => {
page.retryCatalog(); fixture.detectChanges(); load([]);
expect(page.catalogLoading()).toBe(false); expect(page.catalogError()).toBe('');
expect(fixture.nativeElement.textContent).toContain('No hay indicadores disponibles');
expect(fixture.nativeElement.querySelectorAll('.kpi-section app-indicador-kpi-card')).toHaveLength(3);
expect(fixture.nativeElement.querySelectorAll('.kpi-section app-indicador-kpi-card')).toHaveLength(0);
http.expectNone(() => true);
});
it('D.1 separa secciones y conserva tarjetas, orden, identidades y figuras dentro del grid', () => {
@@ -72,8 +72,11 @@ describe('UX-06E.D.3.A catálogo permanentemente desplegado', () => {
expect(getComputedStyle(grid).display).toBe('grid');
expect(grid.children).toHaveLength(2);
expect(Array.from(grid.children).every(host => host.tagName === 'APP-INDICADOR-CATALOG-CARD')).toBe(true);
const sections = fixture.nativeElement.querySelectorAll('.dashboard > section') as NodeListOf<HTMLElement>;
expect(Array.from(sections).map(section => section.getAttribute('aria-labelledby'))).toEqual(['global-filters-title', 'kpi-section-title', 'graphic-section-title']);
const sections = fixture.nativeElement.querySelectorAll('#panel-resumen > section') as NodeListOf<HTMLElement>;
expect(Array.from(sections).map(section => section.getAttribute('aria-labelledby'))).toEqual(['global-filters-title', 'graphic-section-title']);
const summary = fixture.nativeElement.querySelector('app-indicadores-numeric-summary') as HTMLElement;
expect(sections[1].compareDocumentPosition(summary) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
expect(summary.textContent).toContain('Resumen de indicadores');
expect(fixture.nativeElement.querySelector('.catalog-count').textContent.trim()).toBe('2 indicadores publicados');
expect(getComputedStyle(fixture.nativeElement.querySelector('.catalog-count')).textAlign).toBe('right');
toggle(0); toggle(1); flushAll();
@@ -109,22 +112,20 @@ describe('UX-06E.D.3.A catálogo permanentemente desplegado', () => {
expect(fixture.nativeElement.querySelector('.pin-toggle').getAttribute('aria-label')).toContain(title);
http.expectNone(() => true);
});
it('UX-06B conserva una navegación con rutas y estado activo en los tres dominios', () => {
const domains = ['tea', 'cacu', 'cama'] as const;
for (const domain of domains) {
if (domain !== 'tea') page.changeDominio(domain);
load([], domain);
const navs = fixture.nativeElement.querySelectorAll('nav') as NodeListOf<HTMLElement>;
expect(navs).toHaveLength(1);
expect(navs[0].getAttribute('aria-label')).toBe('Dominios de indicadores');
const links = Array.from(navs[0].querySelectorAll('a'));
expect(links.map(link => link.textContent?.trim())).toEqual(['TEA', 'CaCu', 'CaMa']);
expect(links.map(link => link.getAttribute('href'))).toEqual(domains.map(d => '/indicadores/' + d));
expect(links.filter(link => link.getAttribute('aria-current') === 'page')).toHaveLength(1);
expect(links[domains.indexOf(domain)].getAttribute('aria-current')).toBe('page');
expect(cards()).toHaveLength(0);
http.expectNone(() => true);
}
it('UX-06B mantiene una sola navegación entre dominios, sin duplicar botones', () => {
// Our shell has no domain selector of its own (unlike upstream's App),
// so the page keeps exactly the one it always had -- not duplicated.
// (Needs a render pass first: unlike upstream's trivial "absent" check,
// confirming presence requires the template to have actually painted.)
fixture.detectChanges();
expect(fixture.nativeElement.querySelectorAll('nav.domain-nav')).toHaveLength(1);
expect(fixture.nativeElement.querySelectorAll('nav.domain-nav a')).toHaveLength(3);
expect(cards()).toHaveLength(0);
// Constructing the page legitimately initializes its domain catalog.
const catalogRequest = http.expectOne('/tea/indicadores');
expect(catalogRequest.request.method).toBe('GET');
catalogRequest.flush([]);
http.expectNone(() => true);
});
it('UX-06D retira el selector visual, inicia claro y conserva oscuro sin recargar catálogo', async () => {
@@ -199,7 +200,7 @@ describe('UX-06E.D.3.A catálogo permanentemente desplegado', () => {
expect(themedA.request.params.get('tema')).toBe('oscuro'); expect(a.selectedPeriods).toEqual(['2025-S1', '2025-S2']);
themedA.flush({ data: [], layout: {} });
});
it('UX-06D expandir metodología conserva panel, figura y borrador sin generar HTTP', () => {
it('UX-06D expandir metodología carga metadatos una vez y conserva panel, figura y borrador', () => {
load([{ ...item, contrato: 'C2', figuras: ['fig_c2_apiladas'] }]); toggle(); flushAll();
const panel = panels()[0], chart = fixture.debugElement.query(By.directive(ChartStub)).componentInstance;
const filters = control();
@@ -209,6 +210,10 @@ describe('UX-06E.D.3.A catálogo permanentemente desplegado', () => {
const button = fixture.nativeElement.querySelector('.methodology-toggle') as HTMLButtonElement;
for (let i = 0; i < 2; i++) {
button.click(); fixture.detectChanges();
if (i === 0) {
http.expectOne(r => r.url === '/tea/indicadores/i1/metadatos').flush({});
fixture.detectChanges();
}
expect(button.getAttribute('aria-expanded')).toBe(i === 0 ? 'true' : 'false');
expect(panels()[0]).toBe(panel); expect(panel.result()).toBe(result);
expect(fixture.debugElement.query(By.directive(ChartStub)).componentInstance).toBe(chart);
@@ -282,7 +287,7 @@ describe('UX-06E.D.3.A catálogo permanentemente desplegado', () => {
const c = control(); c.changeTipo('mes'); c.year = '2025'; c.unit = '01'; c.add(); http.expectNone(() => true);
page.applyFilters(); fixture.detectChanges(); const r = http.expectOne(r => r.url.includes('/figuras/'));
expect(r.request.params.get('periodos')).toBe('2025-01'); r.flush({ data: [{ y: [0, null] }], layout: {} }); fixture.detectChanges();
expect(fixture.nativeElement.textContent).toContain('no entregan intervalos Wilson efectivos');
expect(fixture.nativeElement.textContent).toContain('Cuando la figura publica intervalos Wilson al 95 %');
expect(fixture.nativeElement.textContent).toContain('suprimidos no representan tasas observadas de 0 %');
});
it('catálogo error, reintento y vacío no dejan paneles', () => {