mirror of
https://github.com/sartography/cr-connect-bpmn.git
synced 2025-02-22 05:08:32 +00:00
fixes tests around display order
This commit is contained in:
parent
4211c1254c
commit
8f5d87935c
@ -42,6 +42,7 @@ describe('LibraryListComponent', () => {
|
||||
libraries = [mockWorkflowSpec0, mockWorkflowSpec1];
|
||||
libraries[0].library = true;
|
||||
libraries[1].library = true;
|
||||
component.workflowSpec = mockWorkflowSpec0;
|
||||
fixture.detectChanges();
|
||||
const uReq = httpMock.expectOne('apiRoot/workflow-specification?libraries=true');
|
||||
expect(uReq.request.method).toEqual('GET');
|
||||
|
@ -55,9 +55,8 @@ const librarySpec0: WorkflowSpec = {
|
||||
id: 'one_thing',
|
||||
display_name: 'One thing',
|
||||
description: 'Do just one thing',
|
||||
category_id: 2,
|
||||
category_id: '2',
|
||||
library: true,
|
||||
category: mockWorkflowSpecCategory2,
|
||||
display_order: 2,
|
||||
};
|
||||
|
||||
@ -154,10 +153,14 @@ describe('WorkflowSpecListComponent', () => {
|
||||
id: '',
|
||||
display_name: '',
|
||||
description: '',
|
||||
category_id: 0,
|
||||
category_id: '0',
|
||||
display_order: 0,
|
||||
standalone: false,
|
||||
library: false
|
||||
library: false,
|
||||
libraries: [],
|
||||
is_master_spec: false,
|
||||
primary_file_name: '',
|
||||
primary_process_id: ''
|
||||
};
|
||||
|
||||
const _upsertWorkflowSpecificationSpy = spyOn((component as any), '_upsertWorkflowSpecification')
|
||||
@ -165,7 +168,6 @@ describe('WorkflowSpecListComponent', () => {
|
||||
const openDialogSpy = spyOn(component.dialog, 'open')
|
||||
.and.returnValue({afterClosed: () => of(mockSpecData)} as any);
|
||||
component.selectedSpec = mockWorkflowSpec1;
|
||||
component.selectedSpec.parents = [];
|
||||
component.selectedSpec.libraries = [];
|
||||
component.editWorkflowSpec('study');
|
||||
expect(openDialogSpy).toHaveBeenCalled();
|
||||
@ -177,7 +179,7 @@ describe('WorkflowSpecListComponent', () => {
|
||||
expect(_upsertWorkflowSpecificationSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should edit an existing workflow spec but add a new workflow spec', () => {
|
||||
it('should either edit a workflow spec, OR add a new workflow spec', () => {
|
||||
const _addWorkflowSpecSpy = spyOn((component as any), '_addWorkflowSpec').and.stub();
|
||||
const _updateWorkflowSpecSpy = spyOn((component as any), '_updateWorkflowSpec').and.stub();
|
||||
|
||||
@ -290,7 +292,7 @@ describe('WorkflowSpecListComponent', () => {
|
||||
expect(_upsertWorkflowSpecCategorySpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should edit an existing workflow spec category but add a new workflow spec category', () => {
|
||||
it('should edit an existing workflow spec category OR add a new workflow spec category', () => {
|
||||
const _addWorkflowSpecCategorySpy = spyOn((component as any), '_addWorkflowSpecCategory').and.stub();
|
||||
const _updateWorkflowSpecCategorySpy = spyOn((component as any), '_updateWorkflowSpecCategory').and.stub();
|
||||
|
||||
@ -312,13 +314,9 @@ describe('WorkflowSpecListComponent', () => {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
component.selectedCat = undefined;
|
||||
mockWorkflowSpecCategory1.id = null;
|
||||
(component as any)._upsertWorkflowSpecCategory(mockWorkflowSpecCategory1 as WorkflowSpecCategoryDialogData);
|
||||
expect(_addWorkflowSpecCategorySpy).toHaveBeenCalled();
|
||||
expect(_updateWorkflowSpecCategorySpy).not.toHaveBeenCalled();
|
||||
|
||||
_addWorkflowSpecCategorySpy.calls.reset();
|
||||
_updateWorkflowSpecCategorySpy.calls.reset();
|
||||
@ -423,7 +421,7 @@ describe('WorkflowSpecListComponent', () => {
|
||||
});
|
||||
|
||||
it('should update a single category display order', () => {
|
||||
mockWorkflowSpecCategory1.id = 5;
|
||||
mockWorkflowSpecCategory1.id = '5';
|
||||
|
||||
// Intermittently, Jasmine does not find the array prototype function, causing errors.
|
||||
// This defines the 'find' function in case it doesn't find it.
|
||||
|
@ -35,7 +35,7 @@ export interface WorkflowSpecCategoryGroup {
|
||||
id?: string;
|
||||
display_name: string;
|
||||
workflow_specs?: WorkflowSpec[];
|
||||
display_order: number;
|
||||
display_order?: number;
|
||||
admin: boolean,
|
||||
}
|
||||
|
||||
@ -191,15 +191,10 @@ export class WorkflowSpecListComponent implements OnInit {
|
||||
|
||||
|
||||
canDeleteWorkflowSpec(wfs){
|
||||
if ((wfs.parents.length > 0) && (wfs.library)){
|
||||
let message = '';
|
||||
for (let p of wfs.parents) {
|
||||
message += p.display_name + ', ';
|
||||
}
|
||||
message = message.replace(/,\s*$/, "");
|
||||
this.snackBar.open('The Library ' + '\'' + wfs.display_name + '\'' +
|
||||
' is still being referenced by these workflows: ' + message, 'Ok');
|
||||
return false;
|
||||
// TODO: move this to the backend
|
||||
// Find if library is still being referenced somewhere. If so, return a message about where
|
||||
if (wfs.library){
|
||||
// return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -336,7 +331,6 @@ export class WorkflowSpecListComponent implements OnInit {
|
||||
|
||||
if (isNew) {
|
||||
this._addWorkflowSpec(newSpec);
|
||||
this.selectSpec(newSpec);
|
||||
} else {
|
||||
this._updateWorkflowSpec(data.id, newSpec);
|
||||
}
|
||||
@ -354,9 +348,10 @@ export class WorkflowSpecListComponent implements OnInit {
|
||||
};
|
||||
this._updateWorkflowSpecCategory(data.id, newCat);
|
||||
} else {
|
||||
// TODO: prompt user for somethin about the id generation
|
||||
const newCat: WorkflowSpecCategory = {
|
||||
id: data.display_name,
|
||||
display_name: data.display_name,
|
||||
display_order: data.display_order,
|
||||
admin: data.admin,
|
||||
};
|
||||
this._addWorkflowSpecCategory(newCat);
|
||||
@ -377,6 +372,7 @@ export class WorkflowSpecListComponent implements OnInit {
|
||||
this._loadWorkflowLibraries(newSpec.id);
|
||||
this._loadWorkflowSpecs(newSpec.id);
|
||||
this._displayMessage('Saved new workflow spec.');
|
||||
this.selectSpec(newSpec);
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user