Updates API calls to match new endpoint params structure

This commit is contained in:
Aaron Louie 2020-02-03 22:21:59 -05:00
parent 6ee06f09a1
commit c1a0f2f79e
7 changed files with 18 additions and 13 deletions

6
package-lock.json generated
View File

@ -11635,9 +11635,9 @@
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"sartography-workflow-lib": {
"version": "0.0.25",
"resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.25.tgz",
"integrity": "sha512-km+08X+xt3vkL/QjXA/xSlHkq0z3T5cq4pqwDLgwJBrg/hhRCFMYIbuypmo4UFrhJ9TdFfouo/rRgHVCplld0Q==",
"version": "0.0.27",
"resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.27.tgz",
"integrity": "sha512-eopRRJjwTgKEwNcmCqIkAekwnzUrFglQzRHO4/fEwtN/yaLHYJv+b8O4/YcQtBkBp7hbYj+9MbmC8FU3o387yg==",
"requires": {
"tslib": "^1.9.0"
}

View File

@ -48,7 +48,7 @@
"file-saver": "^2.0.2",
"hammerjs": "^2.0.8",
"rxjs": "~6.5.4",
"sartography-workflow-lib": "^0.0.25",
"sartography-workflow-lib": "^0.0.27",
"tslib": "^1.10.0",
"uuid": "^3.4.0",
"zone.js": "~0.9.1"

View File

@ -13,6 +13,11 @@ describe('GetIconCodePipe', () => {
});
it('should get an icon code for each file type', () => {
Object.values(FileType).forEach(ft => expect(pipe.transform(ft)).toBeTruthy());
const types = [
FileType.BPMN,
FileType.DMN,
FileType.SVG
];
types.forEach(ft => expect(pipe.transform(ft)).toBeTruthy());
});
});

View File

@ -81,7 +81,7 @@ describe('FileListComponent', () => {
expect(fmsNoFiles.every(fm => !fm.file)).toEqual(true);
expect(justFiles.every(f => !!f.name)).toEqual(true);
const fmsReq = httpMock.expectOne(`apiRoot/file?spec_id=${mockWorkflowSpec0.id}`);
const fmsReq = httpMock.expectOne(`apiRoot/file?workflow_spec_id=${mockWorkflowSpec0.id}`);
expect(fmsReq.request.method).toEqual('GET');
fmsReq.flush(fmsNoFiles);
expect(component.fileMetas.length).toBeGreaterThan(0);

View File

@ -72,7 +72,7 @@ export class FileListComponent implements OnInit {
}
private _loadFileMetas() {
this.api.listBpmnFiles(this.workflowSpec.id).subscribe(fms => {
this.api.getFileMeta({workflow_spec_id: this.workflowSpec.id}).subscribe(fms => {
this.fileMetas = fms;
this._loadFileData();
});

View File

@ -112,7 +112,7 @@ describe('ModelerComponent', () => {
wfsReq.flush(mockWorkflowSpec0);
expect(component.workflowSpec).toEqual(mockWorkflowSpec0);
const req = httpMock.expectOne(`apiRoot/file?spec_id=${mockWorkflowSpec0.id}`);
const req = httpMock.expectOne(`apiRoot/file?workflow_spec_id=${mockWorkflowSpec0.id}`);
expect(req.request.method).toEqual('GET');
req.flush(mockFileMetas);
@ -362,7 +362,7 @@ describe('ModelerComponent', () => {
component.draftXml = newXml;
component._upsertFileMeta(data);
expect(component.xml).toEqual(newXml);
expect(addFileMetaSpy).toHaveBeenCalledWith(mockWorkflowSpec0.id, noDateOrVersion);
expect(addFileMetaSpy).toHaveBeenCalledWith({workflow_spec_id: mockWorkflowSpec0.id}, noDateOrVersion);
expect(loadFilesFromDbSpy).not.toHaveBeenCalled();
expect(routerNavigateSpy).toHaveBeenCalled();
expect(snackBarSpy).toHaveBeenCalled();
@ -371,7 +371,7 @@ describe('ModelerComponent', () => {
it('should load files from the database', () => {
const getWorkflowSpecSpy = spyOn(component.api, 'getWorkflowSpecification')
.and.returnValue(of(mockWorkflowSpec0));
const listBpmnFilesSpy = spyOn(component.api, 'listBpmnFiles')
const getFileMetaSpy = spyOn(component.api, 'getFileMeta')
.and.returnValue(of(mockFileMetas));
const getFileDataSpy = spyOn(component.api, 'getFileData')
.and.returnValue(of(mockFileMeta0));
@ -379,7 +379,7 @@ describe('ModelerComponent', () => {
expect(getWorkflowSpecSpy).toHaveBeenCalled();
expect(component.workflowSpec).toEqual(mockWorkflowSpec0);
expect(listBpmnFilesSpy).toHaveBeenCalledWith(mockWorkflowSpec0.id);
expect(getFileMetaSpy).toHaveBeenCalledWith({workflow_spec_id: mockWorkflowSpec0.id});
mockFileMetas.forEach(fm => {
expect(getFileDataSpy).toHaveBeenCalledWith(fm.id);

View File

@ -226,7 +226,7 @@ export class ModelerComponent implements AfterViewInit {
private loadFilesFromDb() {
this.api.getWorkflowSpecification(this.workflowSpecId).subscribe(wfs => {
this.workflowSpec = wfs;
this.api.listBpmnFiles(wfs.id).subscribe(files => {
this.api.getFileMeta({workflow_spec_id: wfs.id}).subscribe(files => {
this.bpmnFiles = [];
files.forEach(f => {
this.api.getFileData(f.id).subscribe(d => {
@ -271,7 +271,7 @@ export class ModelerComponent implements AfterViewInit {
});
} else {
// Add new file meta
this.api.addFileMeta(this.workflowSpec.id, this.diagramFileMeta).subscribe(fileMeta => {
this.api.addFileMeta({workflow_spec_id: this.workflowSpec.id}, this.diagramFileMeta).subscribe(fileMeta => {
this.router.navigate(['/modeler', this.workflowSpec.id, fileMeta.id]);
this.snackBar.open(`Saved new file ${fileMeta.name} to workflow spec ${this.workflowSpec.name}.`, 'Ok', {duration: 5000});
});