Skip to content

Commit

Permalink
MET-6239 Prevent double submit of runability check
Browse files Browse the repository at this point in the history
  • Loading branch information
andyjmaclean committed Nov 21, 2024
1 parent 5e5c8cc commit 9ecbbda
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,23 +185,32 @@ describe('DatasetInfoComponent', () => {
expect(component.fullInfoOpen).toBeFalsy();
});

it('should run the debias report', fakeAsync(() => {
it('should run the debias report unless busy', fakeAsync(() => {
expect(component.canRunDebias).toBeFalsy();
expect(component.canRunDebias).toBeFalsy();

fixture.detectChanges();

spyOn(component.cmpDebias, 'startPolling').and.callThrough();

component.cmpDebias.isBusy = true;
component.runOrShowDebiasReport(false);
expect(component.cmpDebias.startPolling).not.toHaveBeenCalled();

expect(component.canRunDebias).toBeUndefined();

component.cmpDebias.isBusy = false;
component.runOrShowDebiasReport(false);
expect(component.canRunDebias).toBeUndefined();

expect(component.cmpDebias.startPolling).toHaveBeenCalledTimes(1);
expect(component.cmpDebias.isBusy).toBeFalsy();

component.runOrShowDebiasReport(true);
expect(component.canRunDebias).not.toBeUndefined();
expect(component.canRunDebias).toBeFalsy();

expect(component.cmpDebias.startPolling).toHaveBeenCalledTimes(1);
discardPeriodicTasks();
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,18 @@ export class DatasetInfoComponent extends SubscriptionManager {
* @param { boolean } run - flags action
**/
runOrShowDebiasReport(run: boolean): void {
if (this.cmpDebias.isBusy) {
return;
}
this.cmpDebias.isBusy = true;
if (run) {
this.subs.push(
this.sandbox.runDebiasReport(this.datasetId).subscribe(() => {
this.canRunDebias = false;
this.cmpDebias.isBusy = false;
})
);
} else if (!this.cmpDebias.isBusy) {
} else {
const pollerId = this.cmpDebias.startPolling();
this.subs.push(
this.modalConfirms.open(this.modalIdPrefix + this.modalIdDebias).subscribe(() => {
Expand Down

0 comments on commit 9ecbbda

Please sign in to comment.