Risk batches: one decision at a time, so a double click doesn't send it twice
(cherry picked from commit 88c1eb33be)
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
// 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,
|
||||
// request) and decides a batch in that domain, one decision at a time. 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 { of, Subject } from 'rxjs';
|
||||
import { vi } from 'vitest';
|
||||
import { AuthService } from '../../../auth/auth.service';
|
||||
import { RiskBatchesApi } from '../../api/risk-batches.api';
|
||||
@@ -45,4 +45,21 @@ describe('RiskBatchesPanel domains', () => {
|
||||
|
||||
expect(api['confirm']).toHaveBeenCalledExactlyOnceWith('cama', 5, 'revisado');
|
||||
});
|
||||
|
||||
// Fails if a double click sends the decision twice: the second one finds nothing to decide or collides with the first.
|
||||
it('sends one decision while another is on its way', () => {
|
||||
const answer = new Subject<{ lote_id: number; evaluaciones_cambiadas: number }>();
|
||||
api['confirm'].mockReturnValue(answer);
|
||||
const f = TestBed.createComponent(RiskBatchesPanel);
|
||||
f.detectChanges();
|
||||
const batch = f.componentInstance.batches()[0];
|
||||
f.componentInstance.reasonFor(batch).setValue('revisado');
|
||||
|
||||
f.componentInstance.confirm(batch);
|
||||
f.componentInstance.confirm(batch);
|
||||
f.componentInstance.void(batch);
|
||||
|
||||
expect(api['confirm']).toHaveBeenCalledTimes(1);
|
||||
expect(api['void']).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user