feat(ui): integrar grid y KPI preliminares UX-06E.D.1
This commit is contained in:
@@ -41,6 +41,51 @@ describe('UX-05B catálogo expandible', () => {
|
||||
function flushAll() { http.match(r => r.url.includes('/figuras/')).forEach(r => r.flush({ data: [{ y: [0, null] }], layout: {} })); fixture.detectChanges(); }
|
||||
function control(index = 0) { return fixture.debugElement.queryAll(By.directive(IndicadorPeriodFilters))[index].componentInstance as IndicadorPeriodFilters; }
|
||||
|
||||
it.each(['tea', 'cacu', 'cama'] as const)('D.1 muestra dos KPI pendientes propios de %s fuera del catálogo', domain => {
|
||||
if (domain !== 'tea') {
|
||||
const initial = http.expectOne('/tea/indicadores');
|
||||
page.changeDominio(domain); expect(initial.cancelled).toBe(true);
|
||||
}
|
||||
fixture.detectChanges();
|
||||
const section = fixture.nativeElement.querySelector('.kpi-section') as HTMLElement;
|
||||
expect(section.dataset['domain']).toBe(domain);
|
||||
expect(section.querySelector('h2')?.textContent).toBe('Indicadores destacados — Vista preliminar');
|
||||
expect(section.textContent).toContain('Muestra visual de ' + page.domainLabels[domain]);
|
||||
const kpis = section.querySelectorAll('app-indicador-kpi-card');
|
||||
expect(Array.from(kpis).map(kpi => kpi.querySelector('h3')?.textContent)).toEqual(['Indicador destacado 1', 'Indicador destacado 2']);
|
||||
expect(Array.from(kpis).map(kpi => kpi.querySelector('.kpi-state')?.textContent)).toEqual(['Pendiente de definición', 'Pendiente de definición']);
|
||||
expect(section.querySelector('.value, button, input, app-plotly-chart')).toBeNull();
|
||||
expect(section.textContent).not.toContain('publicados');
|
||||
load([], domain); expect(fixture.nativeElement.querySelectorAll('app-indicador-kpi-card')).toHaveLength(2);
|
||||
http.expectNone(() => true);
|
||||
});
|
||||
it('D.1 conserva KPI durante carga, error, reintento y catálogo vacío sin HTTP propio', () => {
|
||||
fixture.detectChanges();
|
||||
const kpis = Array.from(fixture.nativeElement.querySelectorAll('app-indicador-kpi-card'));
|
||||
expect(kpis).toHaveLength(2);
|
||||
http.expectOne('/tea/indicadores').flush('private', { status: 500, statusText: 'Error' }); fixture.detectChanges();
|
||||
expect(Array.from(fixture.nativeElement.querySelectorAll('app-indicador-kpi-card'))).toEqual(kpis);
|
||||
page.retryCatalog(); fixture.detectChanges();
|
||||
expect(Array.from(fixture.nativeElement.querySelectorAll('app-indicador-kpi-card'))).toEqual(kpis);
|
||||
load([]); expect(Array.from(fixture.nativeElement.querySelectorAll('app-indicador-kpi-card'))).toEqual(kpis);
|
||||
expect(fixture.nativeElement.querySelector('.catalog-count')).toBeNull(); http.expectNone(() => true);
|
||||
});
|
||||
it('D.1 separa secciones y conserva tarjetas, orden, identidades y figuras dentro del grid', () => {
|
||||
load(); const before = cards();
|
||||
const grid = fixture.nativeElement.querySelector('.catalog-grid') as HTMLElement;
|
||||
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(['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();
|
||||
expect(Array.from(grid.children).map(host => host.querySelectorAll('app-indicador-figure-panel').length)).toEqual([2, 1]);
|
||||
expect(panels().map(panel => panel.figuraId)).toEqual(['f1', 'f2', 'g']);
|
||||
expect(cards()).toEqual(before); expect(cards().every(card => card.expanded)).toBe(true);
|
||||
http.expectNone(() => true);
|
||||
});
|
||||
it('UX-06C: tarjeta contraída contiene solo identidad y flecha decorativa en un botón nativo', () => {
|
||||
load();
|
||||
const host = fixture.nativeElement.querySelector('app-indicador-catalog-card') as HTMLElement;
|
||||
|
||||
Reference in New Issue
Block a user