Governance: spec for the risk batches panel's domains
This commit is contained in:
@@ -0,0 +1,48 @@
|
|||||||
|
// Covers the risk batches panel's domain choice: it lists the pending batches of the domain shown (CaCu first, CaMa on
|
||||||
|
// request) and decides a batch in that domain. Fixtures: a stub of `RiskBatchesApi` that records the domain of each call,
|
||||||
|
// and an account that reaches every domain.
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
import { of } from 'rxjs';
|
||||||
|
import { vi } from 'vitest';
|
||||||
|
import { AuthService } from '../../../auth/auth.service';
|
||||||
|
import { RiskBatchesApi } from '../../api/risk-batches.api';
|
||||||
|
import { RiskBatchesPanel } from './risk-batches-panel';
|
||||||
|
|
||||||
|
describe('RiskBatchesPanel domains', () => {
|
||||||
|
let api: Record<string, ReturnType<typeof vi.fn>>;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
api = {
|
||||||
|
listPending: vi.fn(() => of([{ lote_id: 5, modelo: 'cama-survival v1', evaluado_en: '2026-01-01T00:00:00Z', n_evaluaciones: 1500, motivo: null }])),
|
||||||
|
confirm: vi.fn(() => of({ lote_id: 5, evaluaciones_cambiadas: 1500 })),
|
||||||
|
void: vi.fn(() => of({ lote_id: 5, evaluaciones_cambiadas: 1500 })),
|
||||||
|
};
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
providers: [{ provide: RiskBatchesApi, useValue: api }, { provide: AuthService, useValue: { puedeVer: () => true } }],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fails if the panel stops asking CaCu first, or never asks CaMa's batches when it is chosen.
|
||||||
|
it('lists CaCu first and the chosen domain after', () => {
|
||||||
|
const f = TestBed.createComponent(RiskBatchesPanel);
|
||||||
|
f.detectChanges();
|
||||||
|
expect(api['listPending']).toHaveBeenLastCalledWith('cacu');
|
||||||
|
|
||||||
|
f.componentInstance.setDomain('cama');
|
||||||
|
|
||||||
|
expect(api['listPending']).toHaveBeenLastCalledWith('cama');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fails if a decision goes to the wrong domain's batches, which would confirm another model's evaluations.
|
||||||
|
it('confirms a batch in the domain being shown', () => {
|
||||||
|
const f = TestBed.createComponent(RiskBatchesPanel);
|
||||||
|
f.detectChanges();
|
||||||
|
f.componentInstance.setDomain('cama');
|
||||||
|
const batch = f.componentInstance.batches()[0];
|
||||||
|
f.componentInstance.reasonFor(batch).setValue('revisado');
|
||||||
|
|
||||||
|
f.componentInstance.confirm(batch);
|
||||||
|
|
||||||
|
expect(api['confirm']).toHaveBeenCalledExactlyOnceWith('cama', 5, 'revisado');
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user