Fixes some unit tests

This commit is contained in:
Aaron Louie 2020-01-28 16:59:39 -05:00
parent 5d53350adc
commit 599ff28f8e
3 changed files with 40 additions and 43 deletions

View File

@ -1,9 +1,9 @@
<mat-toolbar [ngClass]="{'expanded': expandToolbar}">
<mat-toolbar-row *ngIf="workflowSpec">
<button mat-button [routerLink]="['/']">
<a mat-button [routerLink]="['/']">
<mat-icon>arrow_back</mat-icon>
Back
</button>
</a>
{{workflowSpec.display_name}}
({{workflowSpec.name}})
</mat-toolbar-row>
@ -33,7 +33,7 @@
Open previously saved...
</button>
<mat-menu #dbMenu="matMenu">
<button
<a
mat-menu-item
*ngFor="let bf of bpmnFiles"
[routerLink]="['/modeler', workflowSpec.id, bf.id]"
@ -42,7 +42,7 @@
matTooltipPosition="right"
>
{{getFileMetaDisplayString(bf)}}
</button>
</a>
</mat-menu>
<button mat-menu-item (click)="openMethod = 'file'; expandToolbar = true">

View File

@ -14,6 +14,7 @@ import {MatTooltipModule} from '@angular/material/tooltip';
import {BrowserDynamicTestingModule} from '@angular/platform-browser-dynamic/testing';
import {BrowserAnimationsModule, NoopAnimationsModule} from '@angular/platform-browser/animations';
import {ActivatedRoute, convertToParamMap} from '@angular/router';
import {RouterTestingModule} from '@angular/router/testing';
import {Observable, of} from 'rxjs';
import {
ApiService,
@ -27,7 +28,7 @@ import {
} from 'sartography-workflow-lib';
import {BPMN_DIAGRAM, BPMN_DIAGRAM_WITH_WARNINGS} from '../../testing/mocks/diagram.mocks';
import {BpmnWarning} from '../_interfaces/bpmn-warning';
import {DialogData} from '../_interfaces/dialog-data';
import {FileMetaDialogData} from '../_interfaces/dialog-data';
import {GetIconCodePipe} from '../_pipes/get-icon-code.pipe';
import {DiagramComponent} from '../diagram/diagram.component';
import {FileMetaDialogComponent} from '../file-meta-dialog/file-meta-dialog.component';
@ -61,6 +62,7 @@ describe('ModelerComponent', () => {
MatTooltipModule,
NoopAnimationsModule,
ReactiveFormsModule,
RouterTestingModule,
],
providers: [
ApiService,
@ -74,6 +76,9 @@ describe('ModelerComponent', () => {
},
{provide: MAT_DIALOG_DATA, useValue: []},
{provide: ActivatedRoute, useValue: {
queryParams: of(convertToParamMap({
action: ''
})),
paramMap: of(convertToParamMap({
workflowSpecId: mockWorkflowSpec0.id,
fileMetaId: `${mockFileMeta0.id}`
@ -88,13 +93,12 @@ describe('ModelerComponent', () => {
component.diagramComponent = TestBed.createComponent(DiagramComponent).componentInstance;
fixture.detectChanges();
const wfsReq = httpMock.expectOne('apiRoot/workflow-specification');
const wfsReq = httpMock.expectOne(`apiRoot/workflow-specification/${mockWorkflowSpec0.id}`);
expect(wfsReq.request.method).toEqual('GET');
wfsReq.flush(mockWorkflowSpecs);
expect(component.workflowSpecs.length).toBeGreaterThan(0);
wfsReq.flush(mockWorkflowSpec0);
expect(component.workflowSpec).toEqual(mockWorkflowSpec0);
mockWorkflowSpecs.forEach(wfs => {
const req = httpMock.expectOne(`apiRoot/file?spec_id=${wfs.id}`);
const req = httpMock.expectOne(`apiRoot/file?spec_id=${mockWorkflowSpec0.id}`);
expect(req.request.method).toEqual('GET');
req.flush(mockFileMetas);
@ -103,8 +107,6 @@ describe('ModelerComponent', () => {
expect(fmReq.request.method).toEqual('GET');
fmReq.flush(mockFileMetas[i].file);
});
});
}));
afterEach(() => {
@ -268,7 +270,7 @@ describe('ModelerComponent', () => {
});
it('should open file metadata dialog', () => {
const data: DialogData = {
const data: FileMetaDialogData = {
fileName: 'after',
fileType: FileType.BPMN,
};
@ -283,7 +285,7 @@ describe('ModelerComponent', () => {
it('should update file metadata for existing file', () => {
const newXml = '<xml>New Value</xml>';
const data: DialogData = {
const data: FileMetaDialogData = {
fileName: mockFileMeta0.name,
fileType: FileType.BPMN,
};
@ -315,7 +317,7 @@ describe('ModelerComponent', () => {
it('should create new file metadata for new file', () => {
const newXml = '<xml>New Value</xml>';
const data: DialogData = {
const data: FileMetaDialogData = {
fileName: mockFileMeta0.name,
fileType: FileType.BPMN,
};

View File

@ -235,12 +235,9 @@ export class ModelerComponent implements AfterViewInit {
}
private loadFilesFromDb() {
this.api.getWorkflowSpecList().subscribe(wfs => {
this.workflowSpecs = wfs;
this.workflowSpecs.forEach(w => {
if (w.id === this.workflowSpecId) {
this.workflowSpec = w;
this.api.listBpmnFiles(w.id).subscribe(files => {
this.api.getWorkflowSpecification(this.workflowSpecId).subscribe(wfs => {
this.workflowSpec = wfs;
this.api.listBpmnFiles(wfs.id).subscribe(files => {
this.bpmnFiles = [];
files.forEach(f => {
this.api.getFileData(f.id).subscribe(d => {
@ -258,8 +255,6 @@ export class ModelerComponent implements AfterViewInit {
});
});
});
}
});
});
}