preliminary release
This commit is contained in:
@@ -10,7 +10,7 @@ import { IndicadorCatalogCard } from './indicador-catalog-card';
|
||||
import { IndicadorFigureCard } from './indicador-figure-card';
|
||||
import { IndicadorPeriodFilters } from './indicador-period-filters';
|
||||
import { PlotlyChart } from '../../shared/plotly/plotly-chart';
|
||||
import { KPI_BY_DOMAIN } from './indicadores-kpi';
|
||||
import { CACU_RESULTADO_KPI, KPI_BY_DOMAIN } from './indicadores-kpi';
|
||||
import { pending } from './indicadores-memory';
|
||||
import { Indicador } from './indicadores.models';
|
||||
|
||||
@@ -22,7 +22,8 @@ describe.each(['tea', 'cacu', 'cama'] as const)('P0 autoridad temporal compartid
|
||||
const definitions = KPI_BY_DOMAIN[domain];
|
||||
const otherDomain = domain === 'cacu' ? 'cama' : 'cacu';
|
||||
const items = [...definitions.map(d => ({ id: d.id, titulo: d.title, contrato: d.contrato, tipos_periodo: ['semestre'], figuras: ['f', 'g'] })),
|
||||
{ id: 'other', titulo: 'Otra figura', contrato: 'C1', tipos_periodo: ['semestre'], figuras: ['f'] }];
|
||||
// Two figures, so every domain keeps an ordinary card whose representation can change.
|
||||
{ id: 'other', titulo: 'Otra figura', contrato: 'C1', tipos_periodo: ['semestre'], figuras: ['f', 'g'] }];
|
||||
beforeEach(() => {
|
||||
vi.stubGlobal('IntersectionObserver', class { observe() {} unobserve() {} disconnect() {} });
|
||||
TestBed.configureTestingModule({ imports: [IndicadoresPage], providers: [provideRouter([]), provideHttpClient(), provideHttpClientTesting()] });
|
||||
@@ -45,11 +46,22 @@ describe.each(['tea', 'cacu', 'cama'] as const)('P0 autoridad temporal compartid
|
||||
valor: 50, numerador: 5, denominador: 10, mediana: 2, q1: 1, q3: 3, unidad: 'dias' }] };
|
||||
}
|
||||
function request(period: string) { return http.expectOne(r => r.url.endsWith(`/${definitions[0].id}/datos`) && r.params.get('periodos') === period); }
|
||||
function panels() { return fixture.debugElement.queryAll(By.directive(IndicadorKpiPanel)).map(e => e.componentInstance as IndicadorKpiPanel); }
|
||||
// Regression assertions below target the original KPI contracts. The added lab
|
||||
// consumer has complete contract/transport coverage in indicadores-kpi-resultado.spec.ts.
|
||||
// Satisfy its independent request with an explicit empty response, never diagnosis data.
|
||||
function originalRequests() {
|
||||
const requests = http.match(r => r.url.endsWith('/datos'));
|
||||
for (const r of requests.filter(r => r.request.url.endsWith('/' + CACU_RESULTADO_KPI.id + '/datos'))) {
|
||||
const period = r.request.params.get('periodos')!;
|
||||
r.flush({ id: CACU_RESULTADO_KPI.id, contrato: 'C3r', tipo_periodo: period.includes('-S') ? 'semestre' : 'mes', periodos: [], filas: [] });
|
||||
}
|
||||
return requests.filter(r => !r.request.url.endsWith('/' + CACU_RESULTADO_KPI.id + '/datos'));
|
||||
}
|
||||
function panels() { return fixture.debugElement.queryAll(By.directive(IndicadorKpiPanel)).map(e => e.componentInstance as IndicadorKpiPanel).filter(panel => panel.definition.id !== CACU_RESULTADO_KPI.id); }
|
||||
function cards() { return fixture.debugElement.queryAll(By.directive(IndicadorCatalogCard)).map(e => e.componentInstance as IndicadorCatalogCard); }
|
||||
function editor() { return fixture.debugElement.query(By.directive(IndicadorPeriodFilters)).componentInstance as IndicadorPeriodFilters; }
|
||||
function flushPanels(period: string, expected = definitions.length - 1) {
|
||||
const requests = http.match(r => r.url.endsWith('/datos'));
|
||||
const requests = originalRequests();
|
||||
expect(requests).toHaveLength(expected);
|
||||
requests.forEach(r => { expect(r.request.params.get('periodos')).toBe(period);
|
||||
const index = definitions.findIndex(d => r.request.url.endsWith(`/${d.id}/datos`)); r.flush(data(index, period)); });
|
||||
@@ -108,13 +120,19 @@ describe.each(['tea', 'cacu', 'cama'] as const)('P0 autoridad temporal compartid
|
||||
it('todas las figuras reciben el periodo compartido y mantienen carga diferida', () => {
|
||||
choose(); http.expectNone(r => r.url.includes('/figuras/'));
|
||||
cards().forEach(card => { expect(card.applied).toBe(page.filters!.applied); card.setVisible(true); });
|
||||
// EU7 now owns a coordinated C2 view. This temporal fixture publishes only
|
||||
// placeholder f/g figures, so that card must stop as incompatible, without GET.
|
||||
fixture.detectChanges(); flushFigures(periods[1], cards().filter(card => !card.isEu7).length); http.expectNone(() => true);
|
||||
// EU7 and the CaCu paired times own coordinated views. This temporal fixture publishes
|
||||
// only placeholder f/g figures, so EU7 stops as incompatible without GET; the paired times
|
||||
// ask /datos for the same shared period, including the partner hidden from the catalog.
|
||||
fixture.detectChanges(); flushFigures(periods[1], cards().filter(card => !card.isEu7 && !card.tiempos).length);
|
||||
const tiempos = http.match(r => r.url.endsWith('/datos'));
|
||||
// P0-C.1 cached the same lab payload; the paired figure reuses it.
|
||||
expect(tiempos.some(r => r.request.url === '/cacu/indicadores/cacu_eu_tiempo_reporte/datos')).toBe(false);
|
||||
for (const r of tiempos) { expect(r.request.params.get('periodos')).toBe(periods[1]); r.flush('', { status: 404, statusText: 'Missing' }); }
|
||||
http.expectNone(() => true);
|
||||
});
|
||||
it('KPI secundarios sin datos no retroceden a otro periodo', () => {
|
||||
request(periods[0]).flush(data(0, periods[0])); fixture.detectChanges();
|
||||
const requests = http.match(r => r.url.endsWith('/datos')); expect(requests).toHaveLength(definitions.length - 1);
|
||||
const requests = originalRequests(); expect(requests).toHaveLength(definitions.length - 1);
|
||||
requests.forEach(r => { expect(r.request.params.get('periodos')).toBe(periods[0]); r.flush('', { status: 404, statusText: 'Missing' }); });
|
||||
fixture.detectChanges(); expect(panels().slice(1).every(p => p.result().state === 'Sin datos del periodo')).toBe(true); http.expectNone(() => true);
|
||||
});
|
||||
@@ -128,7 +146,7 @@ describe.each(['tea', 'cacu', 'cama'] as const)('P0 autoridad temporal compartid
|
||||
it('tema, ancho y representación no reinician el periodo ni la búsqueda', () => {
|
||||
choose(); const applied = page.filters!.applied;
|
||||
page.changeTema('oscuro'); window.dispatchEvent(new Event('resize')); fixture.detectChanges(); http.expectNone(() => true);
|
||||
const card = cards().find(card => !card.isEu7)!;
|
||||
const card = cards().find(card => !card.isEu7 && !card.tiempos)!;
|
||||
card.setVisible(true); fixture.detectChanges(); flushFigures(periods[1], 1);
|
||||
card.selectFigure('g'); fixture.detectChanges(); flushFigures(periods[1], 1);
|
||||
expect(card.selectedFigure).toBe('g'); http.expectNone(() => true);
|
||||
@@ -185,7 +203,7 @@ describe.each(['tea', 'cacu', 'cama'] as const)('P0 autoridad temporal compartid
|
||||
expect(page.kpiIndicator(definitions[0].id)).toBeUndefined();
|
||||
expect(panels()).toHaveLength(0); expect(cards()).toHaveLength(0); http.expectNone(r => r.url.endsWith('/datos'));
|
||||
editor().select([periods[0]]); page.applyFilters(); fixture.detectChanges();
|
||||
http.match(r => r.url.endsWith('/datos')).forEach(r => {
|
||||
originalRequests().forEach(r => {
|
||||
const index = definitions.findIndex(d => r.request.url.endsWith('/' + d.id + '/datos'));
|
||||
expect(index).toBeGreaterThan(0); r.flush(data(index, periods[0]));
|
||||
}); fixture.detectChanges();
|
||||
@@ -209,7 +227,7 @@ describe.each(['tea', 'cacu', 'cama'] as const)('P0 autoridad temporal compartid
|
||||
value.filas[0].grupo = definitions[index].contrato === 'C1' && target !== 'tea' ? 'total' : 'TOTAL'; return value;
|
||||
};
|
||||
http.expectOne(r => r.url.endsWith('/' + definitions[0].id + '/datos')).flush(payload(0)); fixture.detectChanges();
|
||||
http.match(r => r.url.endsWith('/datos')).forEach(r => {
|
||||
originalRequests().forEach(r => {
|
||||
const index = definitions.findIndex(d => r.request.url.endsWith('/' + d.id + '/datos')); r.flush(payload(index));
|
||||
}); fixture.detectChanges();
|
||||
expect(page.filters!.applied.selection).toEqual({ mode: 'explicit', periodos: [period] });
|
||||
|
||||
Reference in New Issue
Block a user