preliminary release
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
import { provideHttpClient } from '@angular/common/http';
|
||||
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { ReportesPage } from './reportes-page';
|
||||
|
||||
describe('ReportesPage', () => {
|
||||
let http: HttpTestingController;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ReportesPage],
|
||||
providers: [provideHttpClient(), provideHttpClientTesting()],
|
||||
});
|
||||
http = TestBed.inject(HttpTestingController);
|
||||
});
|
||||
|
||||
afterEach(() => http.verify());
|
||||
|
||||
it('shows the indicator status and the aggregate attempts', () => {
|
||||
const fixture = TestBed.createComponent(ReportesPage);
|
||||
fixture.detectChanges();
|
||||
http.expectOne('/reportes/indicadores').flush({
|
||||
cacu: { estado: 'ok', pendiente: false, fin: '2026-10-29T10:00:00+00:00', duracion_s: 12 },
|
||||
cama: { estado: 'error', pendiente: false, error: { tipo: 'OperationalError', mensaje: 'x' } },
|
||||
tea: { estado: 'sin_correr', pendiente: true },
|
||||
});
|
||||
http.expectOne((r) => r.url === '/reportes/importaciones').flush({
|
||||
resumen: { intentos: {}, ultimo: null },
|
||||
intentos: [{
|
||||
id: 'a', fecha: '2026-10-29T10:00:00+00:00', operacion: 'carga', dominio: 'cacu', resultado: 'completada',
|
||||
duracion_s: 1, totales: { leidas: 10, validas: 8, insertadas: 8, rechazadas_en_validacion: 2 },
|
||||
fuentes: [{
|
||||
destino: 'cacu.Paciente', origen: { tipo: 'csv' },
|
||||
mapeo: { requeridos_sin_mapear: [], campos_sin_mapear: [], columnas_origen: [] },
|
||||
filas: {}, campos: { pac_sexo: { con_valor: 10, vacios: 0, errores: { out_of_catalog: 2 } } },
|
||||
}],
|
||||
}],
|
||||
});
|
||||
fixture.detectChanges();
|
||||
const text: string = fixture.nativeElement.textContent;
|
||||
expect(text).toContain('Actualizado');
|
||||
expect(text).toContain('Error en el cálculo');
|
||||
expect(text).toContain('En espera de cálculo');
|
||||
expect(text).toContain('cacu.Paciente');
|
||||
|
||||
(fixture.nativeElement.querySelector('.intentos button') as HTMLButtonElement).click();
|
||||
fixture.detectChanges();
|
||||
expect(fixture.nativeElement.querySelector('.campos').textContent).toContain('out_of_catalog: 2');
|
||||
});
|
||||
|
||||
it('asks for a recomputation', () => {
|
||||
const fixture = TestBed.createComponent(ReportesPage);
|
||||
fixture.componentInstance.recalcular('tea');
|
||||
http.expectOne('/reportes/indicadores/tea/recalcular').flush({ pendiente: true });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user