mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
[AAE-10317] - Fix APS unit tests warning "Test has no expectations" (#7850)
* [AAE-10317] - Fix process and task attachment list has no expectations * [AAE-10317] - More APS unit test fixes * Fix test excluded by mistake * Fix lint errors
This commit is contained in:
parent
3fdedae769
commit
b33b188807
@ -23,6 +23,7 @@ import { of, throwError } from 'rxjs';
|
||||
import { ProcessAttachmentListComponent } from './process-attachment-list.component';
|
||||
import { ProcessTestingModule } from '../testing/process.testing.module';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { mockEmittedProcessAttachments, mockProcessAttachments } from '../mock/process/process-attachments.mock';
|
||||
|
||||
describe('ProcessAttachmentListComponent', () => {
|
||||
|
||||
@ -30,7 +31,6 @@ describe('ProcessAttachmentListComponent', () => {
|
||||
let component: ProcessAttachmentListComponent;
|
||||
let fixture: ComponentFixture<ProcessAttachmentListComponent>;
|
||||
let getProcessRelatedContentSpy: jasmine.Spy;
|
||||
let mockAttachment: any;
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
@ -45,53 +45,7 @@ describe('ProcessAttachmentListComponent', () => {
|
||||
component = fixture.componentInstance;
|
||||
service = fixture.debugElement.injector.get(ProcessContentService);
|
||||
|
||||
mockAttachment = {
|
||||
size: 2,
|
||||
total: 2,
|
||||
start: 0,
|
||||
data: [{
|
||||
id: 4001,
|
||||
name: 'Invoice01.pdf',
|
||||
created: '2017-05-12T12:50:05.522+0000',
|
||||
createdBy: {
|
||||
id: 1,
|
||||
firstName: 'Apps',
|
||||
lastName: 'Administrator',
|
||||
email: 'admin@app.activiti.com',
|
||||
company: 'Alfresco.com',
|
||||
pictureId: 3003
|
||||
},
|
||||
relatedContent: true,
|
||||
contentAvailable: true,
|
||||
link: false,
|
||||
mimeType: 'application/pdf',
|
||||
simpleType: 'pdf',
|
||||
previewStatus: 'created',
|
||||
thumbnailStatus: 'created'
|
||||
},
|
||||
{
|
||||
id: 4002,
|
||||
name: 'Invoice02.pdf',
|
||||
created: '2017-05-12T12:50:05.522+0000',
|
||||
createdBy: {
|
||||
id: 1,
|
||||
firstName: 'Apps',
|
||||
lastName: 'Administrator',
|
||||
email: 'admin@app.activiti.com',
|
||||
company: 'Alfresco.com',
|
||||
pictureId: 3003
|
||||
},
|
||||
relatedContent: true,
|
||||
contentAvailable: true,
|
||||
link: false,
|
||||
mimeType: 'application/pdf',
|
||||
simpleType: 'pdf',
|
||||
previewStatus: 'created',
|
||||
thumbnailStatus: 'created'
|
||||
}]
|
||||
};
|
||||
|
||||
getProcessRelatedContentSpy = spyOn(service, 'getProcessRelatedContent').and.returnValue(of(mockAttachment));
|
||||
getProcessRelatedContentSpy = spyOn(service, 'getProcessRelatedContent').and.returnValue(of(mockProcessAttachments));
|
||||
spyOn(service, 'deleteRelatedContent').and.returnValue(of({ successCode: true }));
|
||||
|
||||
const blobObj = new Blob();
|
||||
@ -123,12 +77,10 @@ describe('ProcessAttachmentListComponent', () => {
|
||||
|
||||
it('should emit a success event when the attachments are loaded', () => {
|
||||
const change = new SimpleChange(null, '123', true);
|
||||
component.success.subscribe((attachments) => {
|
||||
expect(attachments[0].name).toEqual(mockAttachment.data[0].name);
|
||||
expect(attachments[0].id).toEqual(mockAttachment.data[0].id);
|
||||
});
|
||||
const spySuccessEmitter = spyOn(component.success, 'emit');
|
||||
component.ngOnChanges({ processInstanceId: change });
|
||||
|
||||
component.ngOnChanges({ taskId: change });
|
||||
expect(spySuccessEmitter).toHaveBeenCalledWith(mockEmittedProcessAttachments);
|
||||
});
|
||||
|
||||
it('should not attach when no processInstanceId is specified', () => {
|
||||
@ -234,7 +186,7 @@ describe('ProcessAttachmentListComponent', () => {
|
||||
});
|
||||
|
||||
it('should not show the empty list component when the attachments list is not empty for completed process', async () => {
|
||||
getProcessRelatedContentSpy.and.returnValue(of(mockAttachment));
|
||||
getProcessRelatedContentSpy.and.returnValue(of(mockProcessAttachments));
|
||||
const change = new SimpleChange(null, '123', true);
|
||||
component.ngOnChanges({ processInstanceId: change });
|
||||
component.disabled = true;
|
||||
@ -245,7 +197,7 @@ describe('ProcessAttachmentListComponent', () => {
|
||||
});
|
||||
|
||||
it('should call getProcessRelatedContent with opt isRelatedContent=true', () => {
|
||||
getProcessRelatedContentSpy.and.returnValue(of(mockAttachment));
|
||||
getProcessRelatedContentSpy.and.returnValue(of(mockProcessAttachments));
|
||||
const change = new SimpleChange(null, '123', true);
|
||||
const isRelatedContent = 'true';
|
||||
component.ngOnChanges({ processInstanceId: change });
|
||||
|
@ -23,6 +23,7 @@ import { TaskAttachmentListComponent } from './task-attachment-list.component';
|
||||
import { ProcessContentService, setupTestBed } from '@alfresco/adf-core';
|
||||
import { ProcessTestingModule } from '../testing/process.testing.module';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { mockEmittedTaskAttachments, mockTaskAttachments } from '../mock/task/task-attachments.mock';
|
||||
|
||||
describe('TaskAttachmentList', () => {
|
||||
|
||||
@ -30,7 +31,6 @@ describe('TaskAttachmentList', () => {
|
||||
let fixture: ComponentFixture<TaskAttachmentListComponent>;
|
||||
let service: ProcessContentService;
|
||||
let getTaskRelatedContentSpy: jasmine.Spy;
|
||||
let mockAttachment: any;
|
||||
let deleteContentSpy: jasmine.Spy;
|
||||
let getFileRawContentSpy: jasmine.Spy;
|
||||
let getContentPreviewSpy: jasmine.Spy;
|
||||
@ -51,43 +51,7 @@ describe('TaskAttachmentList', () => {
|
||||
|
||||
service = TestBed.inject(ProcessContentService);
|
||||
|
||||
mockAttachment = {
|
||||
size: 2,
|
||||
total: 2,
|
||||
start: 0,
|
||||
data: [
|
||||
{
|
||||
id: 8,
|
||||
name: 'fake.zip',
|
||||
created: 1494595697381,
|
||||
createdBy: { id: 2, firstName: 'user', lastName: 'user', email: 'user@user.com' },
|
||||
relatedContent: true,
|
||||
contentAvailable: true,
|
||||
link: false,
|
||||
mimeType: 'application/zip',
|
||||
simpleType: 'content',
|
||||
previewStatus: 'unsupported',
|
||||
thumbnailStatus: 'unsupported'
|
||||
},
|
||||
{
|
||||
id: 9,
|
||||
name: 'fake.jpg',
|
||||
created: 1494595655381,
|
||||
createdBy: { id: 2, firstName: 'user', lastName: 'user', email: 'user@user.com' },
|
||||
relatedContent: true,
|
||||
contentAvailable: true,
|
||||
link: false,
|
||||
mimeType: 'image/jpeg',
|
||||
simpleType: 'image',
|
||||
previewStatus: 'unsupported',
|
||||
thumbnailStatus: 'unsupported'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
getTaskRelatedContentSpy = spyOn(service, 'getTaskRelatedContent').and.returnValue(of(
|
||||
mockAttachment
|
||||
));
|
||||
getTaskRelatedContentSpy = spyOn(service, 'getTaskRelatedContent').and.returnValue(of(mockTaskAttachments));
|
||||
|
||||
deleteContentSpy = spyOn(service, 'deleteRelatedContent').and.returnValue(of({ successCode: true }));
|
||||
|
||||
@ -124,12 +88,10 @@ describe('TaskAttachmentList', () => {
|
||||
|
||||
it('should emit a success event when the attachments are loaded', () => {
|
||||
const change = new SimpleChange(null, '123', true);
|
||||
disposableSuccess = component.success.subscribe((attachments) => {
|
||||
expect(attachments[0].name).toEqual(mockAttachment.data[0].name);
|
||||
expect(attachments[0].id).toEqual(mockAttachment.data[0].id);
|
||||
});
|
||||
|
||||
const spySuccessEmitter = spyOn(component.success, 'emit');
|
||||
component.ngOnChanges({ taskId: change });
|
||||
|
||||
expect(spySuccessEmitter).toHaveBeenCalledWith(mockEmittedTaskAttachments);
|
||||
});
|
||||
|
||||
it('should not attach when no taskId is specified', () => {
|
||||
@ -146,13 +108,13 @@ describe('TaskAttachmentList', () => {
|
||||
});
|
||||
|
||||
it('emit document when a user wants to view the document', () => {
|
||||
component.emitDocumentContent(mockAttachment.data[1]);
|
||||
component.emitDocumentContent(mockTaskAttachments.data[1]);
|
||||
fixture.detectChanges();
|
||||
expect(getContentPreviewSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('download document when a user wants to view the document', () => {
|
||||
component.downloadContent(mockAttachment.data[1]);
|
||||
component.downloadContent(mockTaskAttachments.data[1]);
|
||||
fixture.detectChanges();
|
||||
expect(getFileRawContentSpy).toHaveBeenCalled();
|
||||
});
|
||||
@ -247,7 +209,7 @@ describe('TaskAttachmentList', () => {
|
||||
});
|
||||
|
||||
it('should not show the empty list component when the attachments list is not empty for completed task', async () => {
|
||||
getTaskRelatedContentSpy.and.returnValue(of(mockAttachment));
|
||||
getTaskRelatedContentSpy.and.returnValue(of(mockTaskAttachments));
|
||||
const change = new SimpleChange(null, '123', true);
|
||||
component.ngOnChanges({ taskId: change });
|
||||
component.disabled = true;
|
||||
|
@ -945,18 +945,18 @@ describe('FormComponent', () => {
|
||||
expect(formComponent.isOutcomeButtonEnabled(startProcessOutcome)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should raise [executeOutcome] event for formService', (done) => {
|
||||
formService.executeOutcome.subscribe(() => {
|
||||
done();
|
||||
});
|
||||
|
||||
it('should raise [executeOutcome] event for formService', () => {
|
||||
const executeOutcomeSpy = spyOn(formService.executeOutcome, 'next');
|
||||
const outcome = new FormOutcomeModel(new FormModel(), {
|
||||
id: FormComponent.CUSTOM_OUTCOME_ID,
|
||||
name: 'Custom'
|
||||
});
|
||||
const expectedEmittedOutcome = new FormOutcomeEvent(outcome);
|
||||
|
||||
formComponent.form = new FormModel();
|
||||
formComponent.onOutcomeClicked(outcome);
|
||||
|
||||
expect(executeOutcomeSpy).toHaveBeenCalledWith(expectedEmittedOutcome);
|
||||
});
|
||||
|
||||
it('should refresh form values when data is changed', () => {
|
||||
|
@ -149,14 +149,14 @@ export const startFormDropdownDefinitionMock = {
|
||||
id: 'mockTypeDropDown',
|
||||
name: 'mock DropDown',
|
||||
type: 'dropdown',
|
||||
value: 'Chooseone...',
|
||||
value: 'Choose one...',
|
||||
required: false,
|
||||
readOnly: false,
|
||||
overrideId: false,
|
||||
options: [
|
||||
{
|
||||
id: 'empty',
|
||||
name: 'Chooseone...'
|
||||
name: 'Choose one...'
|
||||
},
|
||||
{
|
||||
id: 'opt1',
|
||||
@ -471,7 +471,7 @@ export const startMockForm = {
|
||||
id: 'claimtype',
|
||||
name: 'ClaimType',
|
||||
type: 'dropdown',
|
||||
value: 'Chooseone...',
|
||||
value: 'Choose one...',
|
||||
required: false,
|
||||
readOnly: false,
|
||||
overrideId: false,
|
||||
@ -487,7 +487,7 @@ export const startMockForm = {
|
||||
options: [
|
||||
{
|
||||
id: 'empty',
|
||||
name: 'Chooseone...'
|
||||
name: 'Choose one...'
|
||||
},
|
||||
{
|
||||
id: 'cashless',
|
||||
|
@ -16,8 +16,8 @@
|
||||
*/
|
||||
|
||||
import { CUSTOM_ELEMENTS_SCHEMA, SimpleChange } from '@angular/core';
|
||||
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
|
||||
import { of, throwError } from 'rxjs';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { of } from 'rxjs';
|
||||
import {
|
||||
startFormDateWidgetMock, startFormDropdownDefinitionMock,
|
||||
startFormTextDefinitionMock, startMockForm, startMockFormWithTab,
|
||||
@ -114,12 +114,6 @@ describe('StartFormComponent', () => {
|
||||
expect(component.form.getFieldById('fake-multiple-upload').value).toBe(preselectedMultipleeNode['fake-multiple-upload']);
|
||||
});
|
||||
|
||||
it('should consume errors encountered when loading start form', () => {
|
||||
getStartFormSpy.and.returnValue(throwError({}));
|
||||
component.processDefinitionId = exampleId1;
|
||||
component.ngOnInit();
|
||||
});
|
||||
|
||||
it('should show outcome buttons by default', () => {
|
||||
getStartFormSpy.and.returnValue(of({
|
||||
id: '1',
|
||||
@ -164,116 +158,121 @@ describe('StartFormComponent', () => {
|
||||
|
||||
describe('Display widgets', () => {
|
||||
|
||||
it('should be able to display a textWidget from a process definition', () => {
|
||||
it('should be able to display a textWidget from a process definition', async () => {
|
||||
getStartFormSpy.and.returnValue(of(startFormTextDefinitionMock));
|
||||
component.processDefinitionId = exampleId1;
|
||||
component.showOutcomeButtons = true;
|
||||
component.ngOnChanges({ processDefinitionId: new SimpleChange(exampleId1, exampleId2, true) });
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
await fixture.whenStable();
|
||||
fixture.detectChanges();
|
||||
|
||||
const formFields = component.form.getFormFields();
|
||||
const labelField = formFields.find((field) => field.id === 'mocktext');
|
||||
const textWidget = fixture.debugElement.nativeElement.querySelector('text-widget');
|
||||
const textWidgetLabel = fixture.debugElement.nativeElement.querySelector('.adf-label');
|
||||
|
||||
expect(labelField.type).toBe('text');
|
||||
expect(textWidget).toBeDefined();
|
||||
expect(textWidget).toBeTruthy();
|
||||
expect(textWidgetLabel.innerText).toBe('mockText');
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to display a radioButtonWidget from a process definition', () => {
|
||||
it('should be able to display a radioButtonWidget from a process definition', async () => {
|
||||
getStartFormSpy.and.returnValue(of(startFormRadioButtonWidgetMock));
|
||||
component.processDefinitionId = exampleId1;
|
||||
component.showOutcomeButtons = true;
|
||||
component.ngOnChanges({ processDefinitionId: new SimpleChange(exampleId1, exampleId2, true) });
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const formFields = component.form.getFormFields();
|
||||
const labelField = formFields.find((field) => field.id === 'radio-but');
|
||||
const radioButtonWidget = fixture.debugElement.nativeElement.querySelector('radio-buttons-widget');
|
||||
const radioButtonWidgetLabel = fixture.debugElement.nativeElement.querySelector('.adf-input');
|
||||
const radioButtonWidgetLabel = fixture.debugElement.nativeElement.querySelector('.adf-radio-button-container .adf-label');
|
||||
|
||||
expect(labelField.type).toBe('radio-buttons');
|
||||
expect(radioButtonWidget).toBeDefined();
|
||||
expect(radioButtonWidgetLabel.innerText).toBe('radio-buttons');
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to display a amountWidget from a process definition', () => {
|
||||
it('should be able to display a amountWidget from a process definition', async () => {
|
||||
getStartFormSpy.and.returnValue(of(startFormAmountWidgetMock));
|
||||
component.processDefinitionId = exampleId1;
|
||||
component.showOutcomeButtons = true;
|
||||
component.ngOnChanges({ processDefinitionId: new SimpleChange(exampleId1, exampleId2, true) });
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const formFields = component.form.getFormFields();
|
||||
const labelField = formFields.find((field) => field.id === 'amount');
|
||||
const amountWidget = fixture.debugElement.nativeElement.querySelector('amount-widget');
|
||||
const amountWidgetLabel = fixture.debugElement.nativeElement.querySelector('.adf-input');
|
||||
|
||||
expect(labelField.type).toBe('amount');
|
||||
expect(amountWidget).toBeDefined();
|
||||
expect(amountWidgetLabel.innerText).toBe('amount');
|
||||
});
|
||||
expect(amountWidget).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should be able to display a numberWidget from a process definition', () => {
|
||||
it('should be able to display a numberWidget from a process definition', async () => {
|
||||
getStartFormSpy.and.returnValue(of(startFormNumberWidgetMock));
|
||||
component.processDefinitionId = exampleId1;
|
||||
component.showOutcomeButtons = true;
|
||||
component.ngOnChanges({ processDefinitionId: new SimpleChange(exampleId1, exampleId2, true) });
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const formFields = component.form.getFormFields();
|
||||
const labelField = formFields.find((field) => field.id === 'number');
|
||||
const numberWidget = fixture.debugElement.nativeElement.querySelector('number-widget');
|
||||
|
||||
expect(labelField.type).toBe('integer');
|
||||
expect(numberWidget).toBeDefined();
|
||||
});
|
||||
expect(numberWidget).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should be able to display a dropDown Widget from a process definition', () => {
|
||||
it('should be able to display a dropdown Widget for selecting a process definition', async () => {
|
||||
getStartFormSpy.and.returnValue(of(startFormDropdownDefinitionMock));
|
||||
component.processDefinitionId = exampleId1;
|
||||
component.showOutcomeButtons = true;
|
||||
component.ngOnChanges({ processDefinitionId: new SimpleChange(exampleId1, exampleId2, true) });
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const formFields = component.form.getFormFields();
|
||||
const labelField = formFields.find((field) => field.id === 'mockTypeDropDown');
|
||||
const dropDownWidget = fixture.debugElement.nativeElement.querySelector('dropdown-widget');
|
||||
const selectElement = fixture.debugElement.nativeElement.querySelector('.adf-dropdown-widget>mat-select .mat-select-trigger');
|
||||
const dropdownField = formFields.find((field) => field.id === 'mockTypeDropDown');
|
||||
const dropdownWidget = fixture.debugElement.nativeElement.querySelector('dropdown-widget');
|
||||
const dropdownLabel = fixture.debugElement.nativeElement.querySelector('.adf-dropdown-widget .adf-label');
|
||||
const selectElement = fixture.debugElement.nativeElement.querySelector('.adf-select .mat-select-trigger');
|
||||
selectElement.click();
|
||||
expect(selectElement).toBeDefined();
|
||||
expect(dropDownWidget).toBeDefined();
|
||||
expect(selectElement.innerText).toBe('Choose one...');
|
||||
expect(labelField.type).toBe('dropdown');
|
||||
expect(labelField.options[0].name).toBe('Chooseone...');
|
||||
expect(labelField.options[1].name).toBe('Option-1');
|
||||
expect(labelField.options[2].name).toBe('Option-2');
|
||||
});
|
||||
|
||||
expect(selectElement).toBeTruthy();
|
||||
expect(dropdownWidget).toBeTruthy();
|
||||
expect(dropdownLabel.innerText).toEqual('mock DropDown');
|
||||
expect(dropdownField.type).toBe('dropdown');
|
||||
expect(dropdownField.options[0].name).toBe('Choose one...');
|
||||
expect(dropdownField.options[1].name).toBe('Option-1');
|
||||
expect(dropdownField.options[2].name).toBe('Option-2');
|
||||
});
|
||||
|
||||
it('should be able to display a date Widget from a process definition', () => {
|
||||
it('should be able to display a date Widget from a process definition', async () => {
|
||||
getStartFormSpy.and.returnValue(of(startFormDateWidgetMock));
|
||||
component.processDefinitionId = exampleId1;
|
||||
component.showOutcomeButtons = true;
|
||||
component.ngOnChanges({ processDefinitionId: new SimpleChange(exampleId1, exampleId2, true) });
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const formFields = component.form.getFormFields();
|
||||
const labelField = formFields.find((field) => field.id === 'date');
|
||||
const dateWidget = fixture.debugElement.nativeElement.querySelector('dropdown-widget');
|
||||
const dateWidget = fixture.debugElement.nativeElement.querySelector('date-widget');
|
||||
const dateLabelElement = fixture.debugElement.nativeElement.querySelector('#data-widget .mat-form-field-infix> .adf-label');
|
||||
expect(dateWidget).toBeDefined();
|
||||
|
||||
expect(dateWidget).toBeTruthy();
|
||||
expect(labelField.type).toBe('date');
|
||||
expect(dateLabelElement.innerText).toBe('date (D-M-YYYY)');
|
||||
});
|
||||
});
|
||||
|
||||
it('should fetch and define form fields with proper type', () => {
|
||||
getStartFormSpy.and.returnValue(of(startMockForm));
|
||||
@ -290,22 +289,6 @@ describe('StartFormComponent', () => {
|
||||
expect(labelField1.type).toBe('dropdown');
|
||||
});
|
||||
|
||||
it('should show dropdown options', () => {
|
||||
getStartFormSpy.and.returnValue(of(startMockForm));
|
||||
component.processDefinitionId = exampleId1;
|
||||
component.showOutcomeButtons = true;
|
||||
component.ngOnChanges({ processDefinitionId: new SimpleChange(exampleId1, exampleId2, true) });
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const formFields = component.form.getFormFields();
|
||||
const labelField = formFields.find((field) => field.id === 'claimtype');
|
||||
expect(labelField.type).toBe('dropdown');
|
||||
expect(labelField.options[0].name).toBe('Chooseone...');
|
||||
expect(labelField.options[1].name).toBe('Cashless');
|
||||
expect(labelField.options[2].name).toBe('Reimbursement');
|
||||
});
|
||||
});
|
||||
|
||||
it('should display start form with fields ', async () => {
|
||||
getStartFormSpy.and.returnValue(of(startMockForm));
|
||||
component.processDefinitionId = exampleId1;
|
||||
@ -356,46 +339,49 @@ describe('StartFormComponent', () => {
|
||||
expect(translate.instant(selectLabelElement.innerText)).toBe('ClaimType');
|
||||
});
|
||||
|
||||
it('should define custom-tabs ', fakeAsync(() => {
|
||||
it('should define custom-tabs ', async () => {
|
||||
getStartFormSpy.and.returnValue(of(startMockFormWithTab));
|
||||
component.processDefinitionId = exampleId1;
|
||||
component.showOutcomeButtons = true;
|
||||
component.showRefreshButton = true;
|
||||
component.ngOnChanges({ processDefinitionId: new SimpleChange(exampleId1, exampleId2, true) });
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
await fixture.whenStable();
|
||||
|
||||
const formTabs = component.form.tabs;
|
||||
const tabField1 = formTabs.find((tab) => tab.id === 'form1');
|
||||
const tabField2 = formTabs.find((tab) => tab.id === 'form2');
|
||||
const tabsWidgetElement = fixture.debugElement.nativeElement.querySelector('tabs-widget');
|
||||
const tabsWidgetElement = fixture.debugElement.nativeElement.querySelector('.alfresco-tabs-widget');
|
||||
|
||||
expect(tabField1.name).toBe('Tab 1');
|
||||
expect(tabField2.name).toBe('Tab 2');
|
||||
expect(tabsWidgetElement).toBeDefined();
|
||||
expect(tabsWidgetElement).toBeTruthy();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should define title and [custom-action-buttons]', fakeAsync(() => {
|
||||
it('should define title and [custom-action-buttons]', async () => {
|
||||
getStartFormSpy.and.returnValue(of(startMockFormWithTab));
|
||||
component.processDefinitionId = exampleId1;
|
||||
component.showOutcomeButtons = true;
|
||||
component.showRefreshButton = true;
|
||||
component.showTitle = true;
|
||||
component.ngOnChanges({ processDefinitionId: new SimpleChange(exampleId1, exampleId2, true) });
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const titleIcon = fixture.debugElement.nativeElement.querySelector('mat-card-title>mat-icon');
|
||||
await fixture.whenStable();
|
||||
|
||||
const titleElement = fixture.debugElement.nativeElement.querySelector('mat-card-title>h2');
|
||||
const actionButtons = fixture.debugElement.nativeElement.querySelectorAll('.mat-button');
|
||||
expect(titleIcon).toBeDefined();
|
||||
expect(titleElement).toBeDefined();
|
||||
|
||||
expect(titleElement.innerText.trim()).toEqual('Mock Title');
|
||||
expect(actionButtons.length).toBe(4);
|
||||
expect(actionButtons[0].innerText).toBe('Save');
|
||||
expect(actionButtons[0].innerText.trim()).toBe('SAVE');
|
||||
expect(actionButtons[0].disabled).toBeFalsy();
|
||||
expect(actionButtons[1].innerText).toBe('Approve');
|
||||
expect(actionButtons[1].innerText.trim()).toBe('APPROVE');
|
||||
expect(actionButtons[1].disabled).toBeTruthy();
|
||||
expect(actionButtons[2].innerText).toBe('Complete');
|
||||
expect(actionButtons[2].innerText.trim()).toBe('COMPLETE');
|
||||
expect(actionButtons[2].disabled).toBeTruthy();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
describe('OutCome Actions', () => {
|
||||
|
@ -0,0 +1,81 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2019 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export const mockProcessAttachments = {
|
||||
size: 2,
|
||||
total: 2,
|
||||
start: 0,
|
||||
data: [
|
||||
{
|
||||
id: 4001,
|
||||
name: 'Invoice01.pdf',
|
||||
created: '2017-05-12T12:50:05.522+0000',
|
||||
createdBy: {
|
||||
id: 1,
|
||||
firstName: 'Apps',
|
||||
lastName: 'Administrator',
|
||||
email: 'admin@app.activiti.com',
|
||||
company: 'Alfresco.com',
|
||||
pictureId: 3003
|
||||
},
|
||||
relatedContent: true,
|
||||
contentAvailable: true,
|
||||
link: false,
|
||||
mimeType: 'application/pdf',
|
||||
simpleType: 'pdf',
|
||||
previewStatus: 'created',
|
||||
thumbnailStatus: 'created'
|
||||
},
|
||||
{
|
||||
id: 4002,
|
||||
name: 'Invoice02.pdf',
|
||||
created: '2017-05-12T12:50:05.522+0000',
|
||||
createdBy: {
|
||||
id: 1,
|
||||
firstName: 'Apps',
|
||||
lastName: 'Administrator',
|
||||
email: 'admin@app.activiti.com',
|
||||
company: 'Alfresco.com',
|
||||
pictureId: 3003
|
||||
},
|
||||
relatedContent: true,
|
||||
contentAvailable: true,
|
||||
link: false,
|
||||
mimeType: 'application/pdf',
|
||||
simpleType: 'pdf',
|
||||
previewStatus: 'created',
|
||||
thumbnailStatus: 'created'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
export const mockEmittedProcessAttachments = [
|
||||
{
|
||||
id: 4001,
|
||||
name: 'Invoice01.pdf',
|
||||
created: '2017-05-12T12:50:05.522+0000',
|
||||
createdBy: 'Apps Administrator',
|
||||
icon: './assets/images/ft_ic_pdf.svg'
|
||||
},
|
||||
{
|
||||
id: 4002,
|
||||
name: 'Invoice02.pdf',
|
||||
created: '2017-05-12T12:50:05.522+0000',
|
||||
createdBy: 'Apps Administrator',
|
||||
icon: './assets/images/ft_ic_pdf.svg'
|
||||
}
|
||||
];
|
@ -0,0 +1,67 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2019 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export const mockTaskAttachments = {
|
||||
size: 2,
|
||||
total: 2,
|
||||
start: 0,
|
||||
data: [
|
||||
{
|
||||
id: 8,
|
||||
name: 'fake.zip',
|
||||
created: 1494595697381,
|
||||
createdBy: { id: 2, firstName: 'user1', lastName: 'last1', email: 'user1@user.com' },
|
||||
relatedContent: true,
|
||||
contentAvailable: true,
|
||||
link: false,
|
||||
mimeType: 'application/zip',
|
||||
simpleType: 'content',
|
||||
previewStatus: 'unsupported',
|
||||
thumbnailStatus: 'unsupported'
|
||||
},
|
||||
{
|
||||
id: 9,
|
||||
name: 'fake.jpg',
|
||||
created: 1494595655381,
|
||||
createdBy: { id: 2, firstName: 'user2', lastName: 'last2', email: 'user2@user.com' },
|
||||
relatedContent: true,
|
||||
contentAvailable: true,
|
||||
link: false,
|
||||
mimeType: 'image/jpeg',
|
||||
simpleType: 'image',
|
||||
previewStatus: 'unsupported',
|
||||
thumbnailStatus: 'unsupported'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
export const mockEmittedTaskAttachments = [
|
||||
{
|
||||
id: 8,
|
||||
name: 'fake.zip',
|
||||
created: 1494595697381,
|
||||
createdBy: 'user1 last1',
|
||||
icon: './assets/images/ft_ic_archive.svg'
|
||||
},
|
||||
{
|
||||
id: 9,
|
||||
name: 'fake.jpg',
|
||||
created: 1494595655381,
|
||||
createdBy: 'user2 last2',
|
||||
icon: './assets/images/ft_ic_raster_image.svg'
|
||||
}
|
||||
];
|
@ -24,16 +24,16 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
const fakeUser: UserProcessModel = new UserProcessModel({
|
||||
id: '1',
|
||||
firstName: 'fake-name',
|
||||
lastName: 'fake-last',
|
||||
email: 'fake@mail.com'
|
||||
firstName: 'John',
|
||||
lastName: 'Doe',
|
||||
email: 'JohnDoe@fake.com'
|
||||
});
|
||||
|
||||
const fakeSecondUser: UserProcessModel = new UserProcessModel({
|
||||
id: '2',
|
||||
firstName: 'fake-involve-name',
|
||||
lastName: 'fake-involve-last',
|
||||
email: 'fake-involve@mail.com'
|
||||
firstName: 'Jane',
|
||||
lastName: 'Jackson',
|
||||
email: 'JaneJackson@fake.com'
|
||||
});
|
||||
|
||||
describe('PeopleSearchComponent', () => {
|
||||
@ -55,80 +55,40 @@ describe('PeopleSearchComponent', () => {
|
||||
fixture = TestBed.createComponent(PeopleSearchComponent);
|
||||
peopleSearchComponent = fixture.componentInstance;
|
||||
element = fixture.nativeElement;
|
||||
peopleSearchComponent.results = of([]);
|
||||
peopleSearchComponent.results = of(userArray);
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
function triggerSearch() {
|
||||
searchInput = element.querySelector('#userSearchText');
|
||||
searchInput.value = 'fake-search';
|
||||
searchInput.dispatchEvent(new Event('input'));
|
||||
}
|
||||
|
||||
it('should show input search text', () => {
|
||||
expect(element.querySelector('#userSearchText')).toBeDefined();
|
||||
expect(element.querySelector('#userSearchText')).not.toBeNull();
|
||||
expect(element.querySelector('#userSearchText')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should hide people-list container', () => {
|
||||
it('should display user search results', async () => {
|
||||
triggerSearch();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable()
|
||||
.then(() => {
|
||||
expect(element.querySelector('#search-people-list')).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
it('should show user which can be involved ', (done) => {
|
||||
peopleSearchComponent.results = of(userArray);
|
||||
peopleSearchComponent.ngOnInit();
|
||||
await fixture.whenStable();
|
||||
fixture.detectChanges();
|
||||
const datatableBodyElement = element.querySelector('adf-people-search-field .adf-datatable-body');
|
||||
const peopleResultElements = element.querySelectorAll('.adf-people-full-name');
|
||||
|
||||
searchInput = element.querySelector('#userSearchText');
|
||||
searchInput.value = 'fake-search';
|
||||
searchInput.dispatchEvent(new Event('input'));
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
const gatewayElement: any = element.querySelector('#search-people-list .adf-datatable-body');
|
||||
expect(gatewayElement).not.toBeNull();
|
||||
expect(gatewayElement.children.length).toBe(2);
|
||||
done();
|
||||
});
|
||||
expect(datatableBodyElement).not.toBeNull();
|
||||
expect(peopleResultElements.length).toBe(2);
|
||||
expect(peopleResultElements[0].textContent.trim()).toBe('John Doe');
|
||||
expect(peopleResultElements[1].textContent.trim()).toBe('Jane Jackson');
|
||||
});
|
||||
|
||||
it('should send an event when an user is clicked', (done) => {
|
||||
peopleSearchComponent.success.subscribe((user) => {
|
||||
expect(user).toBeDefined();
|
||||
expect(user.firstName).toBe('fake-name');
|
||||
done();
|
||||
});
|
||||
peopleSearchComponent.results = of(userArray);
|
||||
peopleSearchComponent.ngOnInit();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable()
|
||||
.then(() => {
|
||||
it('should emit a success event when a user is selected from the search results', () => {
|
||||
const successEventSpy = spyOn(peopleSearchComponent.success, 'emit');
|
||||
peopleSearchComponent.onRowClick(fakeUser);
|
||||
const addUserButton = element.querySelector<HTMLElement>('#add-people');
|
||||
addUserButton.click();
|
||||
});
|
||||
});
|
||||
|
||||
it('should remove clicked user', (done) => {
|
||||
peopleSearchComponent.results = of(userArray);
|
||||
peopleSearchComponent.ngOnInit();
|
||||
fixture.detectChanges();
|
||||
|
||||
searchInput = element.querySelector('#userSearchText');
|
||||
searchInput.value = 'fake-search';
|
||||
searchInput.dispatchEvent(new Event('input'));
|
||||
fixture.detectChanges();
|
||||
|
||||
peopleSearchComponent.onRowClick(fakeUser);
|
||||
const addUserButton = element.querySelector<HTMLElement>('#add-people');
|
||||
addUserButton.click();
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable()
|
||||
.then(() => {
|
||||
fixture.detectChanges();
|
||||
const gatewayElement: any = element.querySelector('#search-people-list .adf-datatable-body');
|
||||
expect(gatewayElement).not.toBeNull();
|
||||
expect(gatewayElement.children.length).toBe(1);
|
||||
done();
|
||||
});
|
||||
expect(successEventSpy).toHaveBeenCalledWith(fakeUser);
|
||||
});
|
||||
});
|
||||
|
@ -16,10 +16,11 @@
|
||||
*/
|
||||
|
||||
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
|
||||
import { LogService, setupTestBed, UserProcessModel } from '@alfresco/adf-core';
|
||||
import { LogService, PeopleProcessService, setupTestBed, UserProcessModel } from '@alfresco/adf-core';
|
||||
import { PeopleComponent } from './people.component';
|
||||
import { ProcessTestingModule } from '../../../testing/process.testing.module';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { throwError } from 'rxjs';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@ -44,6 +45,7 @@ describe('PeopleComponent', () => {
|
||||
let element: HTMLElement;
|
||||
const userArray = [fakeUser, fakeSecondUser];
|
||||
let logService: LogService;
|
||||
let peopleProcessService: PeopleProcessService;
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
@ -54,6 +56,7 @@ describe('PeopleComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
logService = TestBed.inject(LogService);
|
||||
peopleProcessService = TestBed.inject(PeopleProcessService);
|
||||
fixture = TestBed.createComponent(PeopleComponent);
|
||||
activitiPeopleComponent = fixture.componentInstance;
|
||||
element = fixture.nativeElement;
|
||||
@ -192,13 +195,13 @@ describe('PeopleComponent', () => {
|
||||
});
|
||||
|
||||
it('should log error message when search fails', async () => {
|
||||
await activitiPeopleComponent.peopleSearch$.subscribe(() => {
|
||||
expect(logService.error).toHaveBeenCalledWith('Could not load users');
|
||||
});
|
||||
const logServiceErrorSpy = spyOn(logService, 'error');
|
||||
const mockThrownError = { error: 'Could not load users'};
|
||||
|
||||
spyOn(peopleProcessService, 'getWorkflowUsers').and.returnValue(throwError(mockThrownError));
|
||||
activitiPeopleComponent.searchUser('fake-search');
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 403
|
||||
});
|
||||
|
||||
expect(logServiceErrorSpy).toHaveBeenCalledWith(mockThrownError);
|
||||
});
|
||||
|
||||
it('should not remove user if remove involved user fail', async () => {
|
||||
|
@ -38,7 +38,7 @@ import { deployedApps } from '../../mock/apps-list.mock';
|
||||
import { ProcessNamePipe } from '../../pipes/process-name.pipe';
|
||||
import { ProcessInstance } from '../models/process-instance.model';
|
||||
|
||||
describe('StartFormComponent', () => {
|
||||
describe('StartProcessComponent', () => {
|
||||
|
||||
let appConfig: AppConfigService;
|
||||
let activitiContentService: ActivitiContentService;
|
||||
@ -72,6 +72,12 @@ describe('StartFormComponent', () => {
|
||||
}
|
||||
};
|
||||
|
||||
function changeAppId(appId: number) {
|
||||
const change = new SimpleChange(null, appId, true);
|
||||
component.appId = appId;
|
||||
component.ngOnChanges({ appId: change });
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
appConfig = TestBed.inject(AppConfigService);
|
||||
activitiContentService = TestBed.inject(ActivitiContentService);
|
||||
@ -100,8 +106,7 @@ describe('StartFormComponent', () => {
|
||||
beforeEach(() => {
|
||||
fixture.detectChanges();
|
||||
component.name = 'My new process';
|
||||
const change = new SimpleChange(null, 123, true);
|
||||
component.ngOnChanges({ appId: change });
|
||||
changeAppId(123);
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
@ -162,8 +167,7 @@ describe('StartFormComponent', () => {
|
||||
beforeEach(() => {
|
||||
fixture.detectChanges();
|
||||
getDefinitionsSpy.and.returnValue(of(testProcessDefWithForm));
|
||||
const change = new SimpleChange(null, 123, true);
|
||||
component.ngOnChanges({ appId: change });
|
||||
changeAppId(123);
|
||||
});
|
||||
|
||||
it('should initialize start form', async () => {
|
||||
@ -305,43 +309,31 @@ describe('StartFormComponent', () => {
|
||||
beforeEach(() => {
|
||||
fixture.detectChanges();
|
||||
component.name = 'My new process';
|
||||
component.appId = 123;
|
||||
component.ngOnChanges({});
|
||||
changeAppId(123);
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call service to fetch process definitions with appId', () => {
|
||||
fixture.whenStable().then(() => {
|
||||
it('should call service to fetch process definitions with appId', async () => {
|
||||
await fixture.whenStable();
|
||||
expect(getDefinitionsSpy).toHaveBeenCalledWith(123);
|
||||
});
|
||||
});
|
||||
|
||||
it('should display the correct number of processes in the select list', () => {
|
||||
fixture.whenStable().then(() => {
|
||||
const selectElement = fixture.nativeElement.querySelector('mat-select');
|
||||
expect(selectElement.children.length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
it('should display the option def details', () => {
|
||||
component.processDefinitions = testMultipleProcessDefs;
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const selectElement = fixture.nativeElement.querySelector('mat-select > .mat-select-trigger');
|
||||
const optionElement = fixture.nativeElement.querySelectorAll('mat-option');
|
||||
it('should display the correct number of processes in the select list', async () => {
|
||||
const selectElement = fixture.nativeElement.querySelector('button#adf-select-process-dropdown');
|
||||
selectElement.click();
|
||||
expect(selectElement).not.toBeNull();
|
||||
expect(selectElement).toBeDefined();
|
||||
expect(optionElement).not.toBeNull();
|
||||
expect(optionElement).toBeDefined();
|
||||
});
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
const options: any = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
|
||||
expect(options.length).toBe(2);
|
||||
expect(options[0].nativeElement.innerText).toBe('My Process 1');
|
||||
expect(options[1].nativeElement.innerText).toBe('My Process 2');
|
||||
});
|
||||
|
||||
it('should show no process available message when no process definition is loaded', async () => {
|
||||
getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of([]));
|
||||
component.appId = 123;
|
||||
const change = new SimpleChange(null, 123, true);
|
||||
component.ngOnChanges({ appId: change });
|
||||
changeAppId(123);
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
@ -365,9 +357,7 @@ describe('StartFormComponent', () => {
|
||||
|
||||
it('should select automatically the processDefinition if the app contain only one', async () => {
|
||||
getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(testProcessDefinitions));
|
||||
component.appId = 123;
|
||||
const change = new SimpleChange(null, 123, true);
|
||||
component.ngOnChanges({ appId: change });
|
||||
changeAppId(123);
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
@ -377,9 +367,7 @@ describe('StartFormComponent', () => {
|
||||
|
||||
it('should not select automatically any processDefinition if the app contain multiple process and does not have any processDefinition as input', async () => {
|
||||
getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(testMultipleProcessDefs));
|
||||
component.appId = 123;
|
||||
const change = new SimpleChange(null, 123, true);
|
||||
component.ngOnChanges({ appId: change });
|
||||
changeAppId(123);
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
@ -438,26 +426,20 @@ describe('StartFormComponent', () => {
|
||||
|
||||
describe('input changes', () => {
|
||||
|
||||
const change = new SimpleChange(123, 456, true);
|
||||
|
||||
beforeEach(async () => {
|
||||
component.appId = 123;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should reload processes when appId input changed', async () => {
|
||||
component.appId = 456;
|
||||
component.ngOnChanges({ appId: change });
|
||||
|
||||
changeAppId(456);
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(getDefinitionsSpy).toHaveBeenCalledWith(456);
|
||||
});
|
||||
|
||||
it('should get current processDef', () => {
|
||||
component.appId = 456;
|
||||
component.ngOnChanges({ appId: change });
|
||||
changeAppId(456);
|
||||
fixture.detectChanges();
|
||||
expect(getDefinitionsSpy).toHaveBeenCalled();
|
||||
expect(component.processDefinitions).toBe(testMultipleProcessDefs);
|
||||
@ -469,8 +451,7 @@ describe('StartFormComponent', () => {
|
||||
beforeEach(() => {
|
||||
fixture.detectChanges();
|
||||
component.name = 'My new process';
|
||||
component.appId = 123;
|
||||
component.ngOnChanges({});
|
||||
changeAppId(123);
|
||||
});
|
||||
|
||||
it('should call service to start process if required fields provided', async () => {
|
||||
@ -533,25 +514,21 @@ describe('StartFormComponent', () => {
|
||||
expect(emitSpy).toHaveBeenCalledWith(newProcess);
|
||||
});
|
||||
|
||||
it('should emit start event when start select a process and add a name', (done) => {
|
||||
const disposableStart = component.start.subscribe(() => {
|
||||
disposableStart.unsubscribe();
|
||||
done();
|
||||
});
|
||||
|
||||
it('should emit start event when start select a process and add a name', () => {
|
||||
const startProcessEmitterSpy = spyOn(component.start, 'emit');
|
||||
component.processDefinitionSelectionChanged(testProcessDef);
|
||||
component.name = 'my:Process';
|
||||
component.startProcess();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(startProcessEmitterSpy).toHaveBeenCalledWith(newProcess);
|
||||
});
|
||||
|
||||
it('should emit processDefinitionSelection event when a process definition is selected', (done) => {
|
||||
component.processDefinitionSelection.subscribe((processDefinition) => {
|
||||
expect(processDefinition).toEqual(testProcessDef);
|
||||
done();
|
||||
});
|
||||
it('should emit processDefinitionSelection event when a process definition is selected', () => {
|
||||
const processDefinitionSelectionSpy = spyOn(component.processDefinitionSelection, 'emit');
|
||||
fixture.detectChanges();
|
||||
selectOptionByName(testProcessDef.name);
|
||||
|
||||
expect(processDefinitionSelectionSpy).toHaveBeenCalledWith(testProcessDef);
|
||||
});
|
||||
|
||||
it('should set the process name using the processName pipe when a process definition gets selected', () => {
|
||||
@ -560,9 +537,7 @@ describe('StartFormComponent', () => {
|
||||
const expectedProcessInstanceDetails = new ProcessInstance({ processDefinitionName: testProcessDef.name });
|
||||
getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(testMultipleProcessDefs));
|
||||
|
||||
component.appId = 123;
|
||||
const appIdChange = new SimpleChange(null, 123, true);
|
||||
component.ngOnChanges({ appId: appIdChange });
|
||||
changeAppId(123);
|
||||
fixture.detectChanges();
|
||||
|
||||
selectOptionByName(testProcessDef.name);
|
||||
@ -597,24 +572,10 @@ describe('StartFormComponent', () => {
|
||||
fixture.detectChanges();
|
||||
expect(startSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should able to start the process when the required fields are filled up', (done) => {
|
||||
component.name = 'my:process1';
|
||||
component.processDefinitionSelectionChanged(testProcessDef);
|
||||
|
||||
const disposableStart = component.start.subscribe(() => {
|
||||
disposableStart.unsubscribe();
|
||||
done();
|
||||
});
|
||||
|
||||
component.startProcess();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Select applications', () => {
|
||||
|
||||
const mockAppId = 3;
|
||||
|
||||
beforeEach(() => {
|
||||
fixture.detectChanges();
|
||||
component.name = 'My new process';
|
||||
@ -624,21 +585,20 @@ describe('StartFormComponent', () => {
|
||||
|
||||
it('Should be able to show application drop-down if showSelectApplicationDropdown set to true', () => {
|
||||
getDefinitionsSpy.and.returnValue(of(testMultipleProcessDefs));
|
||||
|
||||
const change = new SimpleChange(null, 3, true);
|
||||
component.ngOnChanges({ appId: change });
|
||||
changeAppId(3);
|
||||
fixture.detectChanges();
|
||||
|
||||
const appsSelector = fixture.nativeElement.querySelector('[data-automation-id="adf-start-process-apps-drop-down"]');
|
||||
const lableElement = fixture.nativeElement.querySelector('.adf-start-process-app-list .mat-form-field-label');
|
||||
const labelElement = fixture.nativeElement.querySelector('.adf-start-process-app-list .mat-form-field-label');
|
||||
|
||||
expect(appsSelector).not.toBeNull();
|
||||
expect(lableElement.innerText).toEqual('ADF_PROCESS_LIST.START_PROCESS.FORM.LABEL.SELECT_APPLICATION');
|
||||
expect(labelElement.innerText).toEqual('ADF_PROCESS_LIST.START_PROCESS.FORM.LABEL.SELECT_APPLICATION');
|
||||
|
||||
expect(getDeployedApplicationsSpy).toHaveBeenCalled();
|
||||
expect(component.applications.length).toBe(6);
|
||||
|
||||
expect(component.selectedApplication).toEqual(deployedApps[2]);
|
||||
expect(component.selectedApplication.id).toEqual(component.appId);
|
||||
expect(component.selectedApplication.id).toEqual(3);
|
||||
expect(component.selectedApplication.name).toEqual('App3');
|
||||
});
|
||||
|
||||
@ -651,20 +611,16 @@ describe('StartFormComponent', () => {
|
||||
|
||||
it('Should be able to list process-definition based on selected application', () => {
|
||||
getDefinitionsSpy.and.returnValue(of(testMultipleProcessDefs));
|
||||
|
||||
const change = new SimpleChange(null, 3, true);
|
||||
component.ngOnChanges({ appId: change });
|
||||
changeAppId(3);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.appId).toBe(component.selectedApplication.id);
|
||||
expect(component.selectedApplication).toEqual(deployedApps[2]);
|
||||
expect(component.selectedApplication.name).toEqual('App3');
|
||||
expect(getDefinitionsSpy).toHaveBeenCalledWith(mockAppId);
|
||||
expect(getDefinitionsSpy).toHaveBeenCalledWith(3);
|
||||
expect(component.processDefinitions.length).toEqual(2);
|
||||
expect(component.processDefinitions[0].name).toEqual('My Process 1');
|
||||
expect(component.processDefinitions[1].name).toEqual('My Process 2');
|
||||
|
||||
const changedAppId = 2;
|
||||
getDefinitionsSpy.and.returnValue(of([ { id: 'my:process 3', name: 'My Process 3', hasStartForm: true } ]));
|
||||
fixture.detectChanges();
|
||||
|
||||
@ -675,7 +631,7 @@ describe('StartFormComponent', () => {
|
||||
expect(component.selectedApplication).toEqual(deployedApps[1]);
|
||||
expect(component.selectedApplication.name).toEqual('App2');
|
||||
|
||||
expect(getDefinitionsSpy).toHaveBeenCalledWith(changedAppId);
|
||||
expect(getDefinitionsSpy).toHaveBeenCalledWith(2);
|
||||
expect(component.processDefinitions.length).toEqual(1);
|
||||
expect(component.processDefinitions[0].name).toEqual('My Process 3');
|
||||
});
|
||||
@ -683,10 +639,9 @@ describe('StartFormComponent', () => {
|
||||
it('Should be able to pre-select an application if the list has one application', () => {
|
||||
getDeployedApplicationsSpy.and.returnValues(of([deployedApps[0]]));
|
||||
getDefinitionsSpy.and.returnValue(of(testMultipleProcessDefs));
|
||||
|
||||
const change = new SimpleChange(null, 123, true);
|
||||
component.ngOnChanges({ appId: change });
|
||||
changeAppId(123);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(getDeployedApplicationsSpy).toHaveBeenCalled();
|
||||
expect(component.applications.length).toEqual(1);
|
||||
expect(component.selectedApplication.name).toEqual('App1');
|
||||
@ -695,10 +650,8 @@ describe('StartFormComponent', () => {
|
||||
it('[C333511] Should be able to preselect single app deployed with single process and start event Form', async () => {
|
||||
getDeployedApplicationsSpy.and.returnValues(of([deployedApps[0]]));
|
||||
getDefinitionsSpy.and.returnValues(of(testProcessDefWithForm));
|
||||
changeAppId(123);
|
||||
|
||||
const change = new SimpleChange(null, 123, true);
|
||||
component.appId = 123;
|
||||
component.ngOnChanges({ appId: change });
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
@ -728,10 +681,8 @@ describe('StartFormComponent', () => {
|
||||
it('[C333511] Should be able to preselect single app deployed with single process and no form', async () => {
|
||||
getDeployedApplicationsSpy.and.returnValues(of([deployedApps[0]]));
|
||||
getDefinitionsSpy.and.returnValues(of(testProcessDefinitions));
|
||||
changeAppId(123);
|
||||
|
||||
const change = new SimpleChange(null, 123, true);
|
||||
component.appId = 123;
|
||||
component.ngOnChanges({ appId: change });
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
@ -760,62 +711,55 @@ describe('StartFormComponent', () => {
|
||||
});
|
||||
|
||||
it('Should be able to pre-select an application from the apps based given appId', () => {
|
||||
component.appId = 2;
|
||||
const change = new SimpleChange(null, 2, true);
|
||||
component.ngOnChanges({ appId: change });
|
||||
changeAppId(2);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(getDeployedApplicationsSpy).toHaveBeenCalled();
|
||||
expect(component.applications.length).toEqual(6);
|
||||
expect(component.selectedApplication.id).toEqual(component.appId);
|
||||
expect(component.selectedApplication.id).toEqual(2);
|
||||
expect(component.selectedApplication.id).toEqual(2);
|
||||
expect(component.selectedApplication.name).toEqual('App2');
|
||||
});
|
||||
|
||||
it('Should be able to disable process name and definitions inputs if there is no application selected by default', () => {
|
||||
component.appId = 12345;
|
||||
const change = new SimpleChange(null, 12345, true);
|
||||
component.ngOnChanges({ appId: change });
|
||||
changeAppId(12345);
|
||||
fixture.detectChanges();
|
||||
expect(getDeployedApplicationsSpy).toHaveBeenCalled();
|
||||
expect(component.applications.length).toEqual(6);
|
||||
expect(component.selectedApplication).toBeUndefined();
|
||||
|
||||
const processDefinitionSelectInput = fixture.nativeElement.querySelector('#processDefinitionName');
|
||||
const processNameInput = fixture.nativeElement.querySelector('#processName');
|
||||
|
||||
expect(getDeployedApplicationsSpy).toHaveBeenCalled();
|
||||
expect(component.applications.length).toEqual(6);
|
||||
expect(component.selectedApplication).toBeUndefined();
|
||||
expect(processDefinitionSelectInput.disabled).toEqual(true);
|
||||
expect(processNameInput.disabled).toEqual(true);
|
||||
});
|
||||
|
||||
it('Should be able to enable process name and definitions inputs if the application selected by given appId', () => {
|
||||
component.appId = 2;
|
||||
const change = new SimpleChange(null, 2, true);
|
||||
component.ngOnChanges({ appId: change });
|
||||
changeAppId(2);
|
||||
fixture.detectChanges();
|
||||
expect(getDeployedApplicationsSpy).toHaveBeenCalled();
|
||||
expect(component.applications.length).toEqual(6);
|
||||
expect(component.selectedApplication.id).toEqual(component.appId);
|
||||
|
||||
const processDefinitionSelectInput = fixture.nativeElement.querySelector('#processDefinitionName');
|
||||
const processNameInput = fixture.nativeElement.querySelector('#processName');
|
||||
|
||||
expect(getDeployedApplicationsSpy).toHaveBeenCalled();
|
||||
expect(component.applications.length).toEqual(6);
|
||||
expect(component.selectedApplication.id).toEqual(2);
|
||||
expect(processDefinitionSelectInput.disabled).toEqual(false);
|
||||
expect(processNameInput.disabled).toEqual(false);
|
||||
});
|
||||
|
||||
it('Should be able to enable process name and definitions inputs when the application selected from the apps drop-down', () => {
|
||||
component.appId = 12345;
|
||||
const change = new SimpleChange(null, 12345, true);
|
||||
component.ngOnChanges({ appId: change });
|
||||
changeAppId(12345);
|
||||
fixture.detectChanges();
|
||||
expect(getDeployedApplicationsSpy).toHaveBeenCalled();
|
||||
expect(component.applications.length).toEqual(6);
|
||||
expect(component.selectedApplication).toBeUndefined();
|
||||
|
||||
const appsSelectElement = fixture.nativeElement.querySelector('[data-automation-id="adf-start-process-apps-drop-down"]');
|
||||
const processDefinitionSelectInput = fixture.nativeElement.querySelector('#processDefinitionName');
|
||||
const processNameInput = fixture.nativeElement.querySelector('#processName');
|
||||
|
||||
expect(getDeployedApplicationsSpy).toHaveBeenCalled();
|
||||
expect(component.applications.length).toEqual(6);
|
||||
expect(component.selectedApplication).toBeUndefined();
|
||||
expect(processDefinitionSelectInput.disabled).toEqual(true);
|
||||
expect(processNameInput.disabled).toEqual(true);
|
||||
|
||||
@ -833,18 +777,15 @@ describe('StartFormComponent', () => {
|
||||
|
||||
it('[C333521] Should be able to pre-select single deployed application with multiple processes', () => {
|
||||
const singleDeployedApp = deployedApps[0];
|
||||
const mockAppid = 1;
|
||||
getDeployedApplicationsSpy.and.returnValues(of([singleDeployedApp]));
|
||||
|
||||
const change = new SimpleChange(null, mockAppid, true);
|
||||
component.ngOnChanges({ appId: change });
|
||||
changeAppId(1);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(getDeployedApplicationsSpy).toHaveBeenCalled();
|
||||
expect(component.applications.length).toBe(1);
|
||||
expect(component.selectedApplication).toEqual(singleDeployedApp);
|
||||
|
||||
expect(getDefinitionsSpy).toHaveBeenCalledWith(mockAppid);
|
||||
expect(getDefinitionsSpy).toHaveBeenCalledWith(1);
|
||||
expect(component.processDefinitions.length).toEqual(2);
|
||||
|
||||
const processDefWithStartForm = testMultipleProcessDefs[1];
|
||||
@ -865,9 +806,7 @@ describe('StartFormComponent', () => {
|
||||
});
|
||||
|
||||
it('[C333522] Should be able to list multiple deployed apps with multiple process', async () => {
|
||||
|
||||
const change = new SimpleChange(null, 123, true);
|
||||
component.ngOnChanges({ appId: change });
|
||||
changeAppId(123);
|
||||
fixture.detectChanges();
|
||||
|
||||
const application1 = deployedApps[0];
|
||||
|
@ -182,12 +182,6 @@ describe('ProcessService', () => {
|
||||
expect(deleteProcessInstance).toHaveBeenCalledWith(processInstanceId);
|
||||
});
|
||||
|
||||
it('should run the success callback', (done) => {
|
||||
service.cancelProcess(processInstanceId).subscribe(() => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should pass on any error that is returned by the API', (done) => {
|
||||
deleteProcessInstance = deleteProcessInstance.and.returnValue(Promise.reject(mockError));
|
||||
service.cancelProcess(null).subscribe(
|
||||
|
@ -137,12 +137,12 @@ describe('TaskDetailsComponent', () => {
|
||||
component.onClaimAction('FAKE-TASK-CLAIM');
|
||||
});
|
||||
|
||||
it('should send a unclaim task event when a task is unclaimed', fakeAsync(() => {
|
||||
component.claimedTask.subscribe((taskId) => {
|
||||
expect(taskId).toBe('FAKE-TASK-UNCLAIM');
|
||||
});
|
||||
it('should send a unclaim task event when a task is unclaimed', async () => {
|
||||
const taskUnclaimedSpy = spyOn(component.unClaimedTask, 'emit');
|
||||
component.onUnclaimAction('FAKE-TASK-UNCLAIM');
|
||||
}));
|
||||
|
||||
expect(taskUnclaimedSpy).toHaveBeenCalledWith('FAKE-TASK-UNCLAIM');
|
||||
});
|
||||
|
||||
it('should set a placeholder message when taskId not initialised', () => {
|
||||
fixture.detectChanges();
|
||||
@ -163,25 +163,25 @@ describe('TaskDetailsComponent', () => {
|
||||
expect(fixture.debugElement.query(By.css('.adf-readonly-form'))).not.toBeNull();
|
||||
}));
|
||||
|
||||
it('should not display a form when the task does not have an associated form', fakeAsync(() => {
|
||||
it('should not display a form when the task does not have an associated form', async () => {
|
||||
component.taskId = '123';
|
||||
taskDetailsMock.formKey = undefined;
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(fixture.debugElement.query(By.css('adf-form'))).toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should display the claim message when the task is not assigned', fakeAsync(() => {
|
||||
it('should display the claim message when the task is not assigned', async () => {
|
||||
component.taskDetails = taskDetailsWithOutAssigneeMock;
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
await fixture.whenStable();
|
||||
const claimMessage = fixture.nativeElement.querySelector('#claim-message-id');
|
||||
expect(claimMessage).toBeDefined();
|
||||
|
||||
expect(claimMessage).toBeTruthy();
|
||||
expect(claimMessage.innerText).toBe('ADF_TASK_LIST.DETAILS.MESSAGES.CLAIM');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not display the claim message when the task is assigned', fakeAsync(() => {
|
||||
fixture.detectChanges();
|
||||
@ -430,12 +430,12 @@ describe('TaskDetailsComponent', () => {
|
||||
});
|
||||
|
||||
it('should log error message when search fails', async () => {
|
||||
spyOn(peopleProcessService, 'getWorkflowUsers').and.returnValue(throwError(''));
|
||||
const logServiceErrorSpy = spyOn(logService, 'error');
|
||||
|
||||
await component.peopleSearch.subscribe(() => {
|
||||
expect(logService.error).toHaveBeenCalledWith('Could not load users');
|
||||
});
|
||||
spyOn(peopleProcessService, 'getWorkflowUsers').and.returnValue(throwError('fake-error'));
|
||||
component.searchUser('fake-search');
|
||||
|
||||
expect(logServiceErrorSpy).toHaveBeenCalledWith('Could not load users');
|
||||
});
|
||||
|
||||
it('should assign task to user', () => {
|
||||
|
@ -431,7 +431,7 @@ describe('Activiti TaskList Service', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should unclaim a task', async() => {
|
||||
it('should unclaim a task', async () => {
|
||||
const taskId = '111';
|
||||
|
||||
await service.unclaimTask(taskId).subscribe((res) => {
|
||||
@ -445,7 +445,7 @@ describe('Activiti TaskList Service', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should update a task', async() => {
|
||||
it('should update a task', async () => {
|
||||
const taskId = '111';
|
||||
const updated: TaskUpdateRepresentation = {
|
||||
name: 'someName'
|
||||
|
Loading…
x
Reference in New Issue
Block a user