TEA: indicadores destacados (M23–M25), ocultar indicadores y renombrar a pacientes

This commit is contained in:
2026-10-15 22:23:39 +00:00
parent 11337679dc
commit 1fc23bd0bd
10 changed files with 87 additions and 44 deletions
@@ -41,12 +41,14 @@ describe('UX-06E.D.3.A catálogo permanentemente desplegado', () => {
function toggle(index = 0) { cards()[index].setVisible(true); fixture.detectChanges(); }
function request(figure: string) { return http.expectOne(r => r.url.endsWith('/figuras/' + figure)); }
function flushAll() { http.match(r => r.url.includes('/figuras/')).forEach(r => r.flush({ data: [{ y: [0, null] }], layout: {} })); fixture.detectChanges(); }
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 no deja sección, encabezado, tarjetas ni grid residual', () => {
it('KPI-DYNAMIC TEA muestra sus tres destacados sin consultar datos fuera del catálogo', () => {
load();
expect(fixture.nativeElement.querySelector('.kpi-section, #kpi-section-title, .kpi-grid, app-indicador-kpi-card')).toBeNull();
expect(fixture.nativeElement.textContent).not.toContain('Indicadores destacados');
expect(fixture.nativeElement.querySelector('#kpi-section-title').textContent).toBe('Indicadores destacados');
expect(Array.from(fixture.nativeElement.querySelectorAll('.kpi-grid app-indicador-kpi-card h3')).map(h => (h as HTMLElement).textContent))
.toEqual(['Pacientes evaluados', 'Confirmación de diagnóstico', 'Días de M-CHAT a diagnóstico']);
http.expectNone(r => r.url.endsWith('/datos'));
});
it('KPI-DYNAMIC distingue carga, error y catálogo vacío confirmado', () => {
@@ -61,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.querySelector('.kpi-section')).toBeNull();
expect(fixture.nativeElement.querySelectorAll('.kpi-section app-indicador-kpi-card')).toHaveLength(3);
http.expectNone(() => true);
});
it('D.1 separa secciones y conserva tarjetas, orden, identidades y figuras dentro del grid', () => {
@@ -71,7 +73,7 @@ describe('UX-06E.D.3.A catálogo permanentemente desplegado', () => {
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', 'graphic-section-title']);
expect(Array.from(sections).map(section => section.getAttribute('aria-labelledby'))).toEqual(['global-filters-title', 'kpi-section-title', 'graphic-section-title']);
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();
@@ -190,7 +192,7 @@ describe('UX-06E.D.3.A catálogo permanentemente desplegado', () => {
page.applyFilters(); fixture.detectChanges();
const appliedA = request('f1');
expect(appliedA.request.params.get('periodos')).toBe('2025-S1');
appliedA.flush({ data: [], layout: {} }); a.unit = 'S2'; a.add();
appliedA.flush({ data: [], layout: {} }); kpiMissing(); a.year = '2025'; a.unit = 'S2'; a.add();
page.changeTema('oscuro'); fixture.detectChanges();
const themedA = request('f1');
expect(themedA.request.params.get('periodos')).toBe('2025-S1');
@@ -216,7 +218,7 @@ describe('UX-06E.D.3.A catálogo permanentemente desplegado', () => {
});
it('salir y volver al viewport conserva borrador, aplicado y resultado sin HTTP redundante', () => {
load([item]); toggle(); flushAll(); const a = control(); a.changeMode('manual'); a.year = '2025'; a.unit = 'S1'; a.add();
page.applyFilters(); fixture.detectChanges(); flushAll(); a.unit = 'S2'; a.add();
page.applyFilters(); fixture.detectChanges(); flushAll(); kpiMissing(); a.year = '2025'; a.unit = 'S2'; a.add();
cards()[0].setVisible(false); fixture.detectChanges(); toggle();
expect(control()).toBe(a); expect(control().selectedPeriods).toEqual(['2025-S1', '2025-S2']);
http.expectNone(() => true);