Updates sartography-workflow-lib. Updates file data and loads new file meta. Fixes broken tests.
This commit is contained in:
parent
4deb25eef7
commit
260d5af43d
|
@ -12171,9 +12171,9 @@
|
|||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
||||
},
|
||||
"sartography-workflow-lib": {
|
||||
"version": "0.0.73",
|
||||
"resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.73.tgz",
|
||||
"integrity": "sha512-GE+kB9018IWgUIBGv/5E4eoybnTmm8fz4kbES42LT6buAqNMtnvzVEt/XZKGAt78sM78Jc/CugrQFFxVFW/xxg=="
|
||||
"version": "0.0.74",
|
||||
"resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.74.tgz",
|
||||
"integrity": "sha512-v8Kz89ta85O1nO7ICtJnok0LbxwEofwcqG2eivmo78xR4qYGisUl68GUTYOHdctAQwNdNbyUW7DxkqpkaPb8ew=="
|
||||
},
|
||||
"sass": {
|
||||
"version": "1.23.3",
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
"ngx-file-drop": "^8.0.8",
|
||||
"ngx-markdown": "^9.0.0",
|
||||
"rxjs": "~6.5.4",
|
||||
"sartography-workflow-lib": "^0.0.73",
|
||||
"sartography-workflow-lib": "^0.0.74",
|
||||
"tslib": "^1.11.1",
|
||||
"uuid": "^7.0.2",
|
||||
"zone.js": "^0.10.3"
|
||||
|
|
|
@ -11,6 +11,7 @@ import {of} from 'rxjs';
|
|||
import {
|
||||
ApiService,
|
||||
FileMeta,
|
||||
FileType,
|
||||
MockEnvironment,
|
||||
mockFileMeta0,
|
||||
mockFileMetas,
|
||||
|
@ -20,6 +21,8 @@ import {DeleteFileDialogComponent} from '../_dialogs/delete-file-dialog/delete-f
|
|||
import {DeleteFileDialogData} from '../_interfaces/dialog-data';
|
||||
import {GetIconCodePipe} from '../_pipes/get-icon-code.pipe';
|
||||
import {FileListComponent} from './file-list.component';
|
||||
import createClone from 'rfdc';
|
||||
|
||||
|
||||
describe('FileListComponent', () => {
|
||||
let httpMock: HttpTestingController;
|
||||
|
@ -146,11 +149,58 @@ describe('FileListComponent', () => {
|
|||
expect(loadFileMetasSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should navigate to modeler to edit a file', () => {
|
||||
it('should navigate to modeler to edit a BPMN or DMN file', () => {
|
||||
const routerNavigateSpy = spyOn((component as any).router, 'navigate');
|
||||
component.workflowSpec = mockWorkflowSpec0;
|
||||
component.editFile(mockFileMeta0);
|
||||
expect(routerNavigateSpy).toHaveBeenCalledWith([`/modeler/${mockWorkflowSpec0.id}/${mockFileMeta0.id}`]);
|
||||
|
||||
routerNavigateSpy.calls.reset();
|
||||
const mockDmnMeta = createClone()(mockFileMeta0);
|
||||
mockDmnMeta.type = FileType.DMN;
|
||||
component.editFile(mockDmnMeta);
|
||||
expect(routerNavigateSpy).toHaveBeenCalledWith([`/modeler/${mockWorkflowSpec0.id}/${mockDmnMeta.id}`]);
|
||||
});
|
||||
|
||||
it('should open file metadata dialog for non-BPMN files', () => {
|
||||
const routerNavigateSpy = spyOn((component as any).router, 'navigate');
|
||||
const editFileMetaSpy = spyOn(component, 'editFileMeta');
|
||||
component.workflowSpec = mockWorkflowSpec0;
|
||||
const mockDocMeta = createClone()(mockFileMeta0);
|
||||
mockDocMeta.type = FileType.DOCX;
|
||||
component.editFile(mockDocMeta);
|
||||
expect(routerNavigateSpy).not.toHaveBeenCalled();
|
||||
expect(editFileMetaSpy).toHaveBeenCalledWith(mockDocMeta);
|
||||
|
||||
routerNavigateSpy.calls.reset();
|
||||
editFileMetaSpy.calls.reset();
|
||||
component.editFile(null);
|
||||
expect(routerNavigateSpy).not.toHaveBeenCalled();
|
||||
expect(editFileMetaSpy).toHaveBeenCalledWith(null);
|
||||
});
|
||||
|
||||
it('should change route and then open file metadata dialog', () => {
|
||||
const routerNavigateSpy = spyOn((component as any).router, 'navigate')
|
||||
.and.returnValue({finally: finallyCallback => finallyCallback()});
|
||||
const _openFileDialogSpy = spyOn((component as any), '_openFileDialog').and.stub();
|
||||
component.workflowSpec = mockWorkflowSpec0;
|
||||
const mockDocMeta = createClone()(mockFileMeta0);
|
||||
mockDocMeta.type = FileType.DOCX;
|
||||
component.editFileMeta(mockDocMeta);
|
||||
expect(routerNavigateSpy).toHaveBeenCalled();
|
||||
|
||||
const fakeBlob = new Blob(['I am a fake blob. A real blob says "blorp blorp blorp."']);
|
||||
const fReq = httpMock.expectOne(`apiRoot/file/${mockDocMeta.id}/data`);
|
||||
expect(fReq.request.method).toEqual('GET');
|
||||
fReq.flush(fakeBlob);
|
||||
expect(_openFileDialogSpy).toHaveBeenCalledWith(mockDocMeta, fakeBlob);
|
||||
|
||||
routerNavigateSpy.calls.reset();
|
||||
_openFileDialogSpy.calls.reset();
|
||||
|
||||
component.editFileMeta(null);
|
||||
expect(routerNavigateSpy).toHaveBeenCalled();
|
||||
expect(_openFileDialogSpy).toHaveBeenCalledWith();
|
||||
});
|
||||
|
||||
it('should flag a file as primary', () => {
|
||||
|
|
|
@ -283,7 +283,6 @@ describe('ModelerComponent', () => {
|
|||
});
|
||||
|
||||
it('should save file changes', () => {
|
||||
const updateFileMetaSpy = spyOn(component.api, 'updateFileMeta').and.returnValue(of(mockFileMeta0));
|
||||
const updateFileDataSpy = spyOn(component.api, 'updateFileData').and.returnValue(of(mockFileMeta0));
|
||||
const snackBarOpenSpy = spyOn(component.snackBar, 'open').and.stub();
|
||||
|
||||
|
@ -292,7 +291,6 @@ describe('ModelerComponent', () => {
|
|||
component.diagramComponent.writeValue(BPMN_DIAGRAM_EMPTY.replace(/REPLACE_ME/g, 'cream_colored_ponies'));
|
||||
component.saveFileChanges();
|
||||
|
||||
expect(updateFileMetaSpy).toHaveBeenCalledWith(mockFileMeta0);
|
||||
expect(updateFileDataSpy).toHaveBeenCalledWith(mockFileMeta0);
|
||||
expect(snackBarOpenSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
|
|
@ -295,10 +295,9 @@ export class ModelerComponent implements AfterViewInit {
|
|||
this.xml = this.draftXml;
|
||||
this.diagramFileMeta.file = new File([this.xml], this.diagramFileMeta.name, {type: 'text/xml'});
|
||||
|
||||
this.api.updateFileData(this.diagramFileMeta).subscribe(() => {
|
||||
this.api.updateFileMeta(this.diagramFileMeta).subscribe(() => {
|
||||
this.snackBar.open(`Saved changes to file metadata ${this.diagramFileMeta.name}.`, 'Ok', {duration: 5000});
|
||||
});
|
||||
this.api.updateFileData(this.diagramFileMeta).subscribe(newFileMeta => {
|
||||
this.diagramFileMeta = newFileMeta;
|
||||
this.snackBar.open(`Saved changes to file metadata ${this.diagramFileMeta.name}.`, 'Ok', {duration: 5000});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue