fix this last test - dont delete libraries referenced elsewhere

This commit is contained in:
alicia pritchett 2022-02-10 15:11:47 -05:00
parent 8f5d87935c
commit d40e2bc176
2 changed files with 12 additions and 10 deletions

View File

@ -495,10 +495,7 @@ describe('WorkflowSpecListComponent', () => {
it('should not delete a library if it is being used', () => {
const badWorkflowSpec = cloneDeep(mockWorkflowSpec0);
badWorkflowSpec.parents=[
{ id: 1234,
display_name: 'test parent',
}]
mockWorkflowSpec1.libraries = ['all_things']
badWorkflowSpec.library=true;
const mockConfirmDeleteData: DeleteWorkflowSpecDialogData = {
confirm: false,
@ -508,12 +505,10 @@ describe('WorkflowSpecListComponent', () => {
const _deleteWorkflowSpecSpy = spyOn((component as any), '_deleteWorkflowSpec').and.stub();
const openDialogSpy = spyOn(component.dialog, 'open')
.and.returnValue({afterClosed: () => of(mockConfirmDeleteData)} as any);
const snackBarSpy = spyOn((component as any).snackBar, 'open').and.stub();
mockConfirmDeleteData.confirm = true;
component.confirmDeleteWorkflowSpec(badWorkflowSpec);
expect(openDialogSpy).toHaveBeenCalled();
expect(_deleteWorkflowSpecSpy).not.toHaveBeenCalled();
expect(snackBarSpy).toHaveBeenCalled();
});

View File

@ -191,10 +191,15 @@ export class WorkflowSpecListComponent implements OnInit {
canDeleteWorkflowSpec(wfs){
// TODO: move this to the backend
// Find if library is still being referenced somewhere. If so, return a message about where
// TODO: put the popup back in for this
let references = []
if (wfs.library){
// return false;
this.workflowSpecs.forEach(spec => {
if (spec.libraries.indexOf(wfs.id) >= 0 ) {
references.push(wfs.id);
}
});
return false; // and later return and deal with references
}
return true;
}
@ -210,10 +215,12 @@ export class WorkflowSpecListComponent implements OnInit {
dialogRef.afterClosed().subscribe((data: DeleteWorkflowSpecDialogData) => {
if (data && data.confirm && data.workflowSpec && this.canDeleteWorkflowSpec(data.workflowSpec)) {
this._deleteWorkflowSpec(data.workflowSpec);
7 this._deleteWorkflowSpec(data.workflowSpec);
if (typeof this.masterStatusSpec !== 'undefined') {
this.selectSpec(this.masterStatusSpec);
}
} else {
// TODO: the library is being referenced elsewhere still
}
});
}