mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-5422] remove deprecated "async()" from unit tests (#7109)
* remove angualar async from content services * upgrade more tests * upgrade core tests * upgrade tests * fix deprecated constant * fix tests * fix after rebase
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { Component } from '@angular/core';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { setupTestBed, AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import { of, throwError } from 'rxjs';
|
||||
|
||||
@@ -81,7 +81,7 @@ describe('AppListCloudComponent', () => {
|
||||
expect(component.isGrid()).toBe(true);
|
||||
});
|
||||
|
||||
it('Should fetch deployed apps', async(() => {
|
||||
it('Should fetch deployed apps', (done) => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
component.apps$.subscribe((response: any[]) => {
|
||||
@@ -95,10 +95,10 @@ describe('AppListCloudComponent', () => {
|
||||
expect(response[1].status).toEqual('Pending');
|
||||
expect(response[1].icon).toEqual('favorite_border');
|
||||
expect(response[1].theme).toEqual('theme-2');
|
||||
done();
|
||||
});
|
||||
});
|
||||
expect(getAppsSpy).toHaveBeenCalled();
|
||||
}));
|
||||
});
|
||||
|
||||
it('should display default adf-empty-content template when response empty', () => {
|
||||
getAppsSpy.and.returnValue(of([]));
|
||||
@@ -115,7 +115,7 @@ describe('AppListCloudComponent', () => {
|
||||
expect(getAppsSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should display default no permissions template when response returns exception', () => {
|
||||
it('should display default no permissions template when response returns exception', (done) => {
|
||||
getAppsSpy.and.returnValue(throwError({}));
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
@@ -128,6 +128,7 @@ describe('AppListCloudComponent', () => {
|
||||
expect(errorTitle.innerText).toBe('ADF_CLOUD_TASK_LIST.APPS.ERROR.TITLE');
|
||||
expect(errorSubtitle.innerText).toBe('ADF_CLOUD_TASK_LIST.APPS.ERROR.SUBTITLE');
|
||||
expect(getAppsSpy).toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -219,12 +220,12 @@ describe('AppListCloudComponent', () => {
|
||||
customFixture.destroy();
|
||||
});
|
||||
|
||||
it('should render the custom empty template', async(() => {
|
||||
it('should render the custom empty template', async () => {
|
||||
customFixture.detectChanges();
|
||||
customFixture.whenStable().then(() => {
|
||||
const title: any = customFixture.nativeElement.querySelector('#custom-id');
|
||||
expect(title.innerText).toBe('No Apps Found');
|
||||
});
|
||||
}));
|
||||
await customFixture.whenStable();
|
||||
|
||||
const title: any = customFixture.nativeElement.querySelector('#custom-id');
|
||||
expect(title.innerText).toBe('No Apps Found');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -1085,7 +1085,7 @@ describe('FormCloudWithCustomOutComesComponent', () => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
it('should be able to inject custom outcomes and click on custom outcomes', async(() => {
|
||||
it('should be able to inject custom outcomes and click on custom outcomes', async () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
const onCustomButtonOneSpy = spyOn(customComponent, 'onCustomButtonOneClick').and.callThrough();
|
||||
@@ -1096,11 +1096,12 @@ describe('FormCloudWithCustomOutComesComponent', () => {
|
||||
|
||||
buttonOneBtn.nativeElement.click();
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(onCustomButtonOneSpy).toHaveBeenCalled();
|
||||
expect(buttonOneBtn.nativeElement.innerText).toBe('CUSTOM-BUTTON-1');
|
||||
expect(buttonTwoBtn.nativeElement.innerText).toBe('CUSTOM-BUTTON-2');
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
describe('retrieve metadata on submit', () => {
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ContentCloudNodeSelectorService } from '../../../services/content-cloud-node-selector.service';
|
||||
import { ProcessCloudContentService } from '../../../services/process-cloud-content.service';
|
||||
@@ -114,7 +114,7 @@ describe('AttachFileCloudWidgetComponent', () => {
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
});
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
downloadService = TestBed.inject(DownloadService);
|
||||
fixture = TestBed.createComponent(AttachFileCloudWidgetComponent);
|
||||
widget = fixture.componentInstance;
|
||||
@@ -130,29 +130,28 @@ describe('AttachFileCloudWidgetComponent', () => {
|
||||
alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
||||
contentNodeSelectorPanelService = TestBed.inject(ContentNodeSelectorPanelService);
|
||||
openUploadFileDialogSpy = spyOn(contentCloudNodeSelectorService, 'openUploadFileDialog').and.returnValue(of([fakeMinimalNode]));
|
||||
}));
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
it('should show up as simple upload when is configured for only local files', async(() => {
|
||||
it('should show up as simple upload when is configured for only local files', async () => {
|
||||
createUploadWidgetField(new FormModel(), 'simple-upload-button', [], allSourceParams);
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
expect(element.querySelector('#simple-upload-button')).not.toBeNull();
|
||||
});
|
||||
}));
|
||||
expect(element.querySelector('#simple-upload-button')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should show up as content upload when is configured with content', async(() => {
|
||||
it('should show up as content upload when is configured with content', async () => {
|
||||
createUploadWidgetField(new FormModel(), 'attach-file-alfresco', [], contentSourceParam);
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(element.querySelector('.adf-attach-widget__menu-upload')).not.toBeNull();
|
||||
});
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
expect(element.querySelector('.adf-attach-widget__menu-upload')).not.toBeNull();
|
||||
});
|
||||
}));
|
||||
it('should be able to attach files coming from content selector', async () => {
|
||||
createUploadWidgetField(new FormModel(), 'attach-file-alfresco', [], contentSourceParam);
|
||||
fixture.detectChanges();
|
||||
@@ -183,14 +182,13 @@ describe('AttachFileCloudWidgetComponent', () => {
|
||||
expect(fileIcon).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should display file list when field has value', async(() => {
|
||||
it('should display file list when field has value', async () => {
|
||||
createUploadWidgetField(new FormModel(), 'attach-file-alfresco', [fakeLocalPngResponse], onlyLocalParams);
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
expect(element.querySelector('#file-1155-icon')).not.toBeNull();
|
||||
});
|
||||
}));
|
||||
expect(element.querySelector('#file-1155-icon')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should be able to set label property for Attach File widget', () => {
|
||||
createUploadWidgetField(new FormModel(), 'attach-file', [], onlyLocalParams, false, 'Label', true);
|
||||
@@ -469,56 +467,68 @@ describe('AttachFileCloudWidgetComponent', () => {
|
||||
expect(openUploadFileDialogSpy).toHaveBeenCalledWith('-my-', 'single', false, true);
|
||||
});
|
||||
|
||||
it('should display tooltip when tooltip is set', async(() => {
|
||||
it('should display tooltip when tooltip is set', async () => {
|
||||
createUploadWidgetField(new FormModel(), 'attach-file-attach', [], onlyLocalParams);
|
||||
|
||||
fixture.detectChanges();
|
||||
const attachElement: any = element.querySelector('#attach-file-attach');
|
||||
await fixture.whenStable();
|
||||
|
||||
const attachElement = element.querySelector('#attach-file-attach');
|
||||
const tooltip = attachElement.getAttribute('ng-reflect-message');
|
||||
|
||||
expect(tooltip).toEqual(widget.field.tooltip);
|
||||
}));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when is readonly', () => {
|
||||
|
||||
it('should show empty list message when there are no file', async(() => {
|
||||
it('should show empty list message when there are no file', async () => {
|
||||
createUploadWidgetField(new FormModel(), 'empty-test', [], onlyLocalParams, null, null, true);
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(element.querySelector('#adf-attach-empty-list-empty-test')).not.toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not show empty list message when there are files', async(() => {
|
||||
createUploadWidgetField(new FormModel(), 'fill-test', [fakeLocalPngResponse], onlyLocalParams, null, null, true);
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(element.querySelector('#adf-attach-empty-list-fill-test')).toBeNull();
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
it('should not show remove button when there are files attached', async(() => {
|
||||
expect(element.querySelector('#adf-attach-empty-list-empty-test')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should not show empty list message when there are files', async () => {
|
||||
createUploadWidgetField(new FormModel(), 'fill-test', [fakeLocalPngResponse], onlyLocalParams, null, null, true);
|
||||
|
||||
fixture.detectChanges();
|
||||
const menuButton: HTMLButtonElement = <HTMLButtonElement> (
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(element.querySelector('#adf-attach-empty-list-fill-test')).toBeNull();
|
||||
});
|
||||
|
||||
it('should not show remove button when there are files attached', async () => {
|
||||
createUploadWidgetField(new FormModel(), 'fill-test', [fakeLocalPngResponse], onlyLocalParams, null, null, true);
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const menuButton = <HTMLButtonElement> (
|
||||
fixture.debugElement.query(By.css('#file-1155-option-menu'))
|
||||
.nativeElement
|
||||
);
|
||||
menuButton.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(fixture.debugElement.query(By.css('#file-1155-remove'))).toBeNull();
|
||||
}));
|
||||
});
|
||||
|
||||
it('should not show any action when the attached file is a physical record', async(() => {
|
||||
it('should not show any action when the attached file is a physical record', async () => {
|
||||
createUploadWidgetField(new FormModel(), 'fill-test', [fakeLocalPhysicalRecordResponse], onlyLocalParams, null, null, true);
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const menuButton = fixture.debugElement.query(By.css('#file-1155-option-menu'));
|
||||
|
||||
expect(menuButton).toBeNull();
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
describe('when a file is uploaded', () => {
|
||||
@@ -532,9 +542,12 @@ describe('AttachFileCloudWidgetComponent', () => {
|
||||
});
|
||||
widget.field.id = 'attach-file-alfresco';
|
||||
widget.field.params = <FormFieldMetadata> menuTestSourceParam;
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
clickOnAttachFileWidget('attach-file-alfresco');
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
});
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { DateCloudWidgetComponent } from './date-cloud.widget';
|
||||
import { setupTestBed, FormFieldModel, FormModel } from '@alfresco/adf-core';
|
||||
import moment from 'moment-es6';
|
||||
@@ -36,11 +36,11 @@ describe('DateWidgetComponent', () => {
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(DateCloudWidgetComponent);
|
||||
widget = fixture.componentInstance;
|
||||
element = fixture.nativeElement;
|
||||
}));
|
||||
});
|
||||
|
||||
it('should setup min value for date picker', () => {
|
||||
const minValue = '1982-03-13';
|
||||
@@ -103,7 +103,7 @@ describe('DateWidgetComponent', () => {
|
||||
TestBed.resetTestingModule();
|
||||
});
|
||||
|
||||
it('should show visible date widget', async(() => {
|
||||
it('should show visible date widget', async () => {
|
||||
widget.field = new FormFieldModel(new FormModel(), {
|
||||
id: 'date-field-id',
|
||||
name: 'date-name',
|
||||
@@ -114,15 +114,14 @@ describe('DateWidgetComponent', () => {
|
||||
widget.field.isVisible = true;
|
||||
widget.ngOnInit();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(element.querySelector('#date-field-id')).toBeDefined();
|
||||
expect(element.querySelector('#date-field-id')).not.toBeNull();
|
||||
const dateElement: any = element.querySelector('#date-field-id');
|
||||
expect(dateElement.value).toContain('9-9-9999');
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
expect(element.querySelector('#date-field-id')).toBeDefined();
|
||||
expect(element.querySelector('#date-field-id')).not.toBeNull();
|
||||
const dateElement = element.querySelector<HTMLInputElement>('#date-field-id');
|
||||
expect(dateElement.value).toContain('9-9-9999');
|
||||
});
|
||||
|
||||
it('should show the correct format type', async(() => {
|
||||
it('should show the correct format type', async () => {
|
||||
widget.field = new FormFieldModel(new FormModel(), {
|
||||
id: 'date-field-id',
|
||||
name: 'date-name',
|
||||
@@ -134,16 +133,14 @@ describe('DateWidgetComponent', () => {
|
||||
widget.field.dateDisplayFormat = 'YYYY-DD-MM';
|
||||
widget.ngOnInit();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable()
|
||||
.then(() => {
|
||||
expect(element.querySelector('#date-field-id')).toBeDefined();
|
||||
expect(element.querySelector('#date-field-id')).not.toBeNull();
|
||||
const dateElement: any = element.querySelector('#date-field-id');
|
||||
expect(dateElement.value).toContain('9999-30-12');
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
expect(element.querySelector('#date-field-id')).toBeDefined();
|
||||
expect(element.querySelector('#date-field-id')).not.toBeNull();
|
||||
const dateElement = element.querySelector<HTMLInputElement>('#date-field-id');
|
||||
expect(dateElement.value).toContain('9999-30-12');
|
||||
});
|
||||
|
||||
it('should disable date button when is readonly', async(() => {
|
||||
it('should disable date button when is readonly', async () => {
|
||||
widget.field = new FormFieldModel(new FormModel(), {
|
||||
id: 'date-field-id',
|
||||
name: 'date-name',
|
||||
@@ -154,18 +151,20 @@ describe('DateWidgetComponent', () => {
|
||||
widget.field.isVisible = true;
|
||||
widget.field.readOnly = false;
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
let dateButton = <HTMLButtonElement> element.querySelector('button');
|
||||
let dateButton = element.querySelector<HTMLButtonElement>('button');
|
||||
expect(dateButton.disabled).toBeFalsy();
|
||||
|
||||
widget.field.readOnly = true;
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
dateButton = <HTMLButtonElement> element.querySelector('button');
|
||||
dateButton = element.querySelector<HTMLButtonElement> ('button');
|
||||
expect(dateButton.disabled).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
|
||||
it('should set isValid to false when the value is not a correct date value', async(() => {
|
||||
it('should set isValid to false when the value is not a correct date value', async () => {
|
||||
widget.field = new FormFieldModel(new FormModel(), {
|
||||
id: 'date-field-id',
|
||||
name: 'date-name',
|
||||
@@ -175,12 +174,14 @@ describe('DateWidgetComponent', () => {
|
||||
});
|
||||
widget.field.isVisible = true;
|
||||
widget.field.readOnly = false;
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(widget.field.isValid).toBeFalsy();
|
||||
}));
|
||||
});
|
||||
|
||||
it('should display tooltip when tooltip is set', async(() => {
|
||||
it('should display tooltip when tooltip is set', async () => {
|
||||
widget.field = new FormFieldModel(new FormModel(), {
|
||||
id: 'date-field-id',
|
||||
name: 'date-name',
|
||||
@@ -191,11 +192,13 @@ describe('DateWidgetComponent', () => {
|
||||
});
|
||||
|
||||
fixture.detectChanges();
|
||||
const dateElement: any = element.querySelector('#date-field-id');
|
||||
await fixture.whenStable();
|
||||
|
||||
const dateElement = element.querySelector('#date-field-id');
|
||||
const tooltip = dateElement.getAttribute('ng-reflect-message');
|
||||
|
||||
expect(tooltip).toEqual(widget.field.tooltip);
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
it('should display always the json value', () => {
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { of } from 'rxjs';
|
||||
import { DropdownCloudWidgetComponent } from './dropdown-cloud.widget';
|
||||
@@ -58,7 +58,7 @@ describe('DropdownCloudWidgetComponent', () => {
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(DropdownCloudWidgetComponent);
|
||||
widget = fixture.componentInstance;
|
||||
element = fixture.nativeElement;
|
||||
@@ -68,11 +68,11 @@ describe('DropdownCloudWidgetComponent', () => {
|
||||
formCloudService = TestBed.inject(FormCloudService);
|
||||
|
||||
widget.field = new FormFieldModel(new FormModel());
|
||||
}));
|
||||
});
|
||||
|
||||
afterEach(() => fixture.destroy());
|
||||
|
||||
it('should require field with restUrl', async(() => {
|
||||
it('should require field with restUrl', () => {
|
||||
spyOn(formService, 'getRestFieldValues').and.stub();
|
||||
|
||||
widget.field = null;
|
||||
@@ -82,13 +82,13 @@ describe('DropdownCloudWidgetComponent', () => {
|
||||
widget.field = new FormFieldModel(null, { restUrl: null });
|
||||
widget.ngOnInit();
|
||||
expect(formService.getRestFieldValues).not.toHaveBeenCalled();
|
||||
}));
|
||||
});
|
||||
|
||||
describe('when template is ready', () => {
|
||||
|
||||
describe('and dropdown is populated', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
spyOn(visibilityService, 'refreshVisibility').and.stub();
|
||||
spyOn(formService, 'getRestFieldValues').and.callFake(() => {
|
||||
return of(fakeOptionList);
|
||||
@@ -103,21 +103,21 @@ describe('DropdownCloudWidgetComponent', () => {
|
||||
widget.field.emptyOption = { id: 'empty', name: 'Choose one...' };
|
||||
widget.field.isVisible = true;
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
});
|
||||
|
||||
it('should select the default value when an option is chosen as default', async(() => {
|
||||
it('should select the default value when an option is chosen as default', async () => {
|
||||
widget.field.value = 'option_2';
|
||||
widget.ngOnInit();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable()
|
||||
.then(() => {
|
||||
const dropDownElement: any = element.querySelector('#dropdown-id');
|
||||
expect(dropDownElement.attributes['ng-reflect-model'].value).toBe('option_2');
|
||||
expect(dropDownElement.attributes['ng-reflect-model'].textContent).toBe('option_2');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should select the empty value when no default is chosen', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const dropDownElement: any = element.querySelector('#dropdown-id');
|
||||
expect(dropDownElement.attributes['ng-reflect-model'].value).toBe('option_2');
|
||||
expect(dropDownElement.attributes['ng-reflect-model'].textContent).toBe('option_2');
|
||||
});
|
||||
|
||||
it('should select the empty value when no default is chosen', async () => {
|
||||
widget.field.value = 'empty';
|
||||
widget.ngOnInit();
|
||||
fixture.detectChanges();
|
||||
@@ -125,26 +125,25 @@ describe('DropdownCloudWidgetComponent', () => {
|
||||
openSelect('#dropdown-id');
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
fixture.whenStable()
|
||||
.then(() => {
|
||||
const dropDownElement: any = element.querySelector('#dropdown-id');
|
||||
expect(dropDownElement.attributes['ng-reflect-model'].value).toBe('empty');
|
||||
});
|
||||
}));
|
||||
const dropDownElement = element.querySelector('#dropdown-id');
|
||||
expect(dropDownElement.attributes['ng-reflect-model'].value).toBe('empty');
|
||||
});
|
||||
|
||||
it('should display tooltip when tooltip is set', async(() => {
|
||||
it('should display tooltip when tooltip is set', async () => {
|
||||
widget.field.tooltip = 'dropdown widget';
|
||||
|
||||
widget.ngOnInit();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const dropDownElement: any = element.querySelector('#dropdown-id');
|
||||
const tooltip = dropDownElement.getAttribute('ng-reflect-message');
|
||||
|
||||
expect(tooltip).toEqual(widget.field.tooltip);
|
||||
});
|
||||
}));
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const dropDownElement: any = element.querySelector('#dropdown-id');
|
||||
const tooltip = dropDownElement.getAttribute('ng-reflect-message');
|
||||
|
||||
expect(tooltip).toEqual(widget.field.tooltip);
|
||||
});
|
||||
|
||||
it('should load data from restUrl and populate options', async () => {
|
||||
const jsonDataSpy = spyOn(formCloudService, 'getDropDownJsonData').and.returnValue(of(fakeOptionList));
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { of } from 'rxjs';
|
||||
import { ProcessServiceCloudTestingModule } from './../../testing/process-service-cloud.testing.module';
|
||||
@@ -74,24 +74,22 @@ describe('GroupCloudComponent', () => {
|
||||
spyOn(alfrescoApiService, 'getInstance').and.returnValue(mock);
|
||||
});
|
||||
|
||||
it('should populate placeholder when title is present', async(() => {
|
||||
it('should populate placeholder when title is present', async () => {
|
||||
component.title = 'TITLE_KEY';
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const matLabel: HTMLInputElement = <HTMLInputElement> element.querySelector('#adf-group-cloud-title-id');
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(matLabel.textContent).toEqual('TITLE_KEY');
|
||||
});
|
||||
}));
|
||||
const matLabel = element.querySelector<HTMLInputElement>('#adf-group-cloud-title-id');
|
||||
expect(matLabel.textContent).toEqual('TITLE_KEY');
|
||||
});
|
||||
|
||||
describe('Search group', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
fixture.detectChanges();
|
||||
findGroupsByNameSpy = spyOn(identityGroupService, 'findGroupsByName').and.returnValue(of(mockIdentityGroups));
|
||||
}));
|
||||
});
|
||||
|
||||
it('should list the groups as dropdown options if the search term has results', (done) => {
|
||||
const input = getElement<HTMLInputElement>('input');
|
||||
@@ -228,7 +226,7 @@ describe('GroupCloudComponent', () => {
|
||||
let checkGroupHasAnyClientAppRoleSpy: jasmine.Spy;
|
||||
let checkGroupHasClientAppSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
findGroupsByNameSpy = spyOn(identityGroupService, 'findGroupsByName').and.returnValue(of(mockIdentityGroups));
|
||||
checkGroupHasAnyClientAppRoleSpy = spyOn(identityGroupService, 'checkGroupHasAnyClientAppRole').and.returnValue(of(true));
|
||||
checkGroupHasClientAppSpy = spyOn(identityGroupService, 'checkGroupHasClientApp').and.returnValue(of(true));
|
||||
@@ -237,9 +235,9 @@ describe('GroupCloudComponent', () => {
|
||||
component.appName = 'mock-app-name';
|
||||
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
});
|
||||
|
||||
it('should fetch the client ID if appName specified', async (() => {
|
||||
it('should fetch the client ID if appName specified', async () => {
|
||||
const getClientIdByApplicationNameSpy = spyOn(identityGroupService, 'getClientIdByApplicationName').and.callThrough();
|
||||
component.appName = 'mock-app-name';
|
||||
|
||||
@@ -247,11 +245,10 @@ describe('GroupCloudComponent', () => {
|
||||
component.ngOnChanges({ 'appName': change });
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(getClientIdByApplicationNameSpy).toHaveBeenCalled();
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(getClientIdByApplicationNameSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should list groups who have access to the app when appName is specified', (done) => {
|
||||
const input = getElement<HTMLInputElement>('input');
|
||||
@@ -423,12 +420,12 @@ describe('GroupCloudComponent', () => {
|
||||
describe('When roles defined', () => {
|
||||
let checkGroupHasRoleSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
component.roles = ['mock-role-1', 'mock-role-2'];
|
||||
spyOn(identityGroupService, 'findGroupsByName').and.returnValue(of(mockIdentityGroups));
|
||||
checkGroupHasRoleSpy = spyOn(identityGroupService, 'checkGroupHasRole').and.returnValue(of(true));
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
});
|
||||
|
||||
it('should filter if groups has any specified role', (done) => {
|
||||
fixture.detectChanges();
|
||||
@@ -487,12 +484,12 @@ describe('GroupCloudComponent', () => {
|
||||
describe('Single Mode with pre-selected groups', () => {
|
||||
const changes = new SimpleChange(null, mockIdentityGroups, false);
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
component.mode = 'single';
|
||||
component.preSelectGroups = <any> mockIdentityGroups;
|
||||
component.ngOnChanges({ 'preSelectGroups': changes });
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
});
|
||||
|
||||
it('should show only one mat chip with the first preSelectedGroup', () => {
|
||||
const chips = fixture.debugElement.queryAll(By.css('mat-chip'));
|
||||
@@ -504,12 +501,12 @@ describe('GroupCloudComponent', () => {
|
||||
describe('Multiple Mode with pre-selected groups', () => {
|
||||
const change = new SimpleChange(null, mockIdentityGroups, false);
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
component.mode = 'multiple';
|
||||
component.preSelectGroups = <any> mockIdentityGroups;
|
||||
component.ngOnChanges({ 'preSelectGroups': change });
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
});
|
||||
|
||||
it('should render all preselected groups', () => {
|
||||
component.mode = 'multiple';
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { PeopleCloudComponent } from './people-cloud.component';
|
||||
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import {
|
||||
IdentityUserService,
|
||||
AlfrescoApiService,
|
||||
@@ -78,36 +78,33 @@ describe('PeopleCloudComponent', () => {
|
||||
spyOn(alfrescoApiService, 'getInstance').and.returnValue(mock);
|
||||
});
|
||||
|
||||
it('should populate placeholder when title is present', async(() => {
|
||||
it('should populate placeholder when title is present', async () => {
|
||||
component.title = 'TITLE_KEY';
|
||||
fixture.detectChanges();
|
||||
|
||||
const matLabel = getElement<HTMLInputElement>('#adf-people-cloud-title-id');
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(matLabel.textContent).toEqual('TITLE_KEY');
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
expect(matLabel.textContent).toEqual('TITLE_KEY');
|
||||
});
|
||||
|
||||
it('should not populate placeholder when title is not present', async(() => {
|
||||
it('should not populate placeholder when title is not present', async () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
const matLabel = getElement<HTMLInputElement>('#adf-people-cloud-title-id');
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(matLabel.textContent).toEqual('');
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(matLabel.textContent).toEqual('');
|
||||
});
|
||||
|
||||
describe('Search user', () => {
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
fixture.detectChanges();
|
||||
element = fixture.nativeElement;
|
||||
findUsersByNameSpy = spyOn(identityService, 'findUsersByName').and.returnValue(of(mockUsers));
|
||||
}));
|
||||
});
|
||||
|
||||
it('should list the users as dropdown options if the search term has results', (done) => {
|
||||
const input = getElement<HTMLInputElement>('input');
|
||||
@@ -337,7 +334,7 @@ describe('PeopleCloudComponent', () => {
|
||||
let checkUserHasAccessSpy: jasmine.Spy;
|
||||
let checkUserHasAnyClientAppRoleSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
findUsersByNameSpy = spyOn(identityService, 'findUsersByName').and.returnValue(of(mockUsers));
|
||||
checkUserHasAccessSpy = spyOn(identityService, 'checkUserHasClientApp').and.returnValue(of(true));
|
||||
checkUserHasAnyClientAppRoleSpy = spyOn(identityService, 'checkUserHasAnyClientAppRole').and.returnValue(of(true));
|
||||
@@ -346,9 +343,9 @@ describe('PeopleCloudComponent', () => {
|
||||
component.appName = 'mock-app-name';
|
||||
fixture.detectChanges();
|
||||
element = fixture.nativeElement;
|
||||
}));
|
||||
});
|
||||
|
||||
it('should fetch the client ID if appName specified', async (() => {
|
||||
it('should fetch the client ID if appName specified', async () => {
|
||||
const getClientIdByApplicationNameSpy = spyOn(identityService, 'getClientIdByApplicationName').and.callThrough();
|
||||
component.appName = 'mock-app-name';
|
||||
|
||||
@@ -356,11 +353,10 @@ describe('PeopleCloudComponent', () => {
|
||||
component.ngOnChanges({ 'appName': change });
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(getClientIdByApplicationNameSpy).toHaveBeenCalled();
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(getClientIdByApplicationNameSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should list users who have access to the app when appName is specified', (done) => {
|
||||
const input = getElement<HTMLInputElement>('input');
|
||||
@@ -529,13 +525,13 @@ describe('PeopleCloudComponent', () => {
|
||||
describe('When roles defined', () => {
|
||||
let checkUserHasRoleSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
component.roles = ['mock-role-1', 'mock-role-2'];
|
||||
spyOn(identityService, 'findUsersByName').and.returnValue(of(mockUsers));
|
||||
checkUserHasRoleSpy = spyOn(identityService, 'checkUserHasRole').and.returnValue(of(true));
|
||||
fixture.detectChanges();
|
||||
element = fixture.nativeElement;
|
||||
}));
|
||||
});
|
||||
|
||||
it('should filter users if users has any specified role', (done) => {
|
||||
fixture.detectChanges();
|
||||
@@ -594,14 +590,14 @@ describe('PeopleCloudComponent', () => {
|
||||
describe('Single Mode with Pre-selected users', () => {
|
||||
const changes = new SimpleChange(null, mockPreselectedUsers, false);
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
component.mode = 'single';
|
||||
component.preSelectUsers = <any> mockPreselectedUsers;
|
||||
component.ngOnChanges({ 'preSelectUsers': changes });
|
||||
|
||||
fixture.detectChanges();
|
||||
element = fixture.nativeElement;
|
||||
}));
|
||||
});
|
||||
|
||||
it('should show only one mat chip with the first preSelectedUser', (done) => {
|
||||
fixture.whenStable().then(() => {
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { SimpleChange } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
|
||||
@@ -126,78 +126,79 @@ describe('EditProcessFilterCloudComponent', () => {
|
||||
expect(count).toBe(1);
|
||||
});
|
||||
|
||||
it('should fetch process instance filter by id', async(() => {
|
||||
it('should fetch process instance filter by id', async () => {
|
||||
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
|
||||
component.ngOnChanges({ 'id': processFilterIdChange });
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(getProcessFilterByIdSpy).toHaveBeenCalled();
|
||||
expect(component.processFilter.name).toEqual('FakeRunningProcess');
|
||||
expect(component.processFilter.icon).toEqual('adjust');
|
||||
expect(component.processFilter.status).toEqual('RUNNING');
|
||||
expect(component.processFilter.order).toEqual('ASC');
|
||||
expect(component.processFilter.sort).toEqual('id');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should display filter name as title', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(getProcessFilterByIdSpy).toHaveBeenCalled();
|
||||
expect(component.processFilter.name).toEqual('FakeRunningProcess');
|
||||
expect(component.processFilter.icon).toEqual('adjust');
|
||||
expect(component.processFilter.status).toEqual('RUNNING');
|
||||
expect(component.processFilter.order).toEqual('ASC');
|
||||
expect(component.processFilter.sort).toEqual('id');
|
||||
});
|
||||
|
||||
it('should display filter name as title', async () => {
|
||||
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
|
||||
component.showProcessFilterName = true;
|
||||
component.ngOnChanges({ 'id': processFilterIdChange });
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const title = fixture.debugElement.nativeElement.querySelector('#adf-edit-process-filter-title-id');
|
||||
const subTitle = fixture.debugElement.nativeElement.querySelector('#adf-edit-process-filter-sub-title-id');
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
expect(title).toBeDefined();
|
||||
expect(subTitle).toBeDefined();
|
||||
expect(title.innerText).toEqual('FakeRunningProcess');
|
||||
expect(subTitle.innerText.trim()).toEqual('ADF_CLOUD_EDIT_PROCESS_FILTER.TITLE');
|
||||
});
|
||||
}));
|
||||
expect(title).toBeDefined();
|
||||
expect(subTitle).toBeDefined();
|
||||
expect(title.innerText).toEqual('FakeRunningProcess');
|
||||
expect(subTitle.innerText.trim()).toEqual('ADF_CLOUD_EDIT_PROCESS_FILTER.TITLE');
|
||||
});
|
||||
|
||||
it('should not display filter name as title if the flag is false', async(() => {
|
||||
it('should not display filter name as title if the flag is false', async () => {
|
||||
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
|
||||
component.showProcessFilterName = false;
|
||||
component.ngOnChanges({ 'id': processFilterIdChange });
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const title = fixture.debugElement.nativeElement.querySelector('#adf-edit-process-filter-title-id');
|
||||
expect(title).toBeNull();
|
||||
});
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
expect(title).toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not display mat-spinner if isloading set to false', async(() => {
|
||||
it('should not display mat-spinner if isloading set to false', async () => {
|
||||
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
|
||||
component.ngOnChanges({ 'id': processFilterIdChange });
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const title = fixture.debugElement.nativeElement.querySelector('#adf-edit-process-filter-title-id');
|
||||
const subTitle = fixture.debugElement.nativeElement.querySelector('#adf-edit-process-filter-sub-title-id');
|
||||
const matSpinnerElement = fixture.debugElement.nativeElement.querySelector('.adf-cloud-edit-process-filter-loading-margin');
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
expect(matSpinnerElement).toBeNull();
|
||||
expect(title).toBeDefined();
|
||||
expect(subTitle).toBeDefined();
|
||||
expect(title.innerText).toEqual('FakeRunningProcess');
|
||||
expect(subTitle.innerText.trim()).toEqual('ADF_CLOUD_EDIT_PROCESS_FILTER.TITLE');
|
||||
});
|
||||
}));
|
||||
expect(matSpinnerElement).toBeNull();
|
||||
expect(title).toBeDefined();
|
||||
expect(subTitle).toBeDefined();
|
||||
expect(title.innerText).toEqual('FakeRunningProcess');
|
||||
expect(subTitle.innerText.trim()).toEqual('ADF_CLOUD_EDIT_PROCESS_FILTER.TITLE');
|
||||
});
|
||||
|
||||
it('should display mat-spinner if isloading set to true', async(() => {
|
||||
it('should display mat-spinner if isloading set to true', async () => {
|
||||
component.isLoading = true;
|
||||
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
|
||||
component.ngOnChanges({ 'id': processFilterIdChange });
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const matSpinnerElement = fixture.debugElement.nativeElement.querySelector('.adf-cloud-edit-process-filter-loading-margin');
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
expect(matSpinnerElement).toBeDefined();
|
||||
});
|
||||
}));
|
||||
expect(matSpinnerElement).toBeDefined();
|
||||
});
|
||||
|
||||
describe('EditProcessFilter form', () => {
|
||||
|
||||
@@ -207,38 +208,36 @@ describe('EditProcessFilterCloudComponent', () => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should defined editProcessFilter form', () => {
|
||||
it('should create editProcessFilter form', async () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const stateController = component.editProcessFilterForm.get('status');
|
||||
const sortController = component.editProcessFilterForm.get('sort');
|
||||
const orderController = component.editProcessFilterForm.get('order');
|
||||
|
||||
expect(component.editProcessFilterForm).toBeDefined();
|
||||
expect(stateController).toBeDefined();
|
||||
expect(sortController).toBeDefined();
|
||||
expect(orderController).toBeDefined();
|
||||
|
||||
expect(stateController.value).toEqual('RUNNING');
|
||||
expect(sortController.value).toEqual('id');
|
||||
expect(orderController.value).toEqual('ASC');
|
||||
});
|
||||
|
||||
it('should create editProcessFilter form', async(() => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const stateController = component.editProcessFilterForm.get('status');
|
||||
const sortController = component.editProcessFilterForm.get('sort');
|
||||
const orderController = component.editProcessFilterForm.get('order');
|
||||
expect(component.editProcessFilterForm).toBeDefined();
|
||||
expect(stateController).toBeDefined();
|
||||
expect(sortController).toBeDefined();
|
||||
expect(orderController).toBeDefined();
|
||||
|
||||
expect(stateController.value).toEqual('RUNNING');
|
||||
expect(sortController.value).toEqual('id');
|
||||
expect(orderController.value).toEqual('ASC');
|
||||
});
|
||||
}));
|
||||
|
||||
describe('Save & Delete buttons', () => {
|
||||
it('should enable delete button for custom process filters', async(() => {
|
||||
it('should enable delete button for custom process filters', async () => {
|
||||
component.toggleFilterActions = true;
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-delete"]');
|
||||
expect(deleteButton.disabled).toEqual(false);
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-delete"]');
|
||||
expect(deleteButton.disabled).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('SaveAs Button', () => {
|
||||
@@ -303,26 +302,30 @@ describe('EditProcessFilterCloudComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should display current process filter details', async(() => {
|
||||
it('should display current process filter details', async () => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
fixture.detectChanges();
|
||||
const stateElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-process-property-status"]');
|
||||
const sortElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-process-property-sort"]');
|
||||
const orderElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-process-property-order"]');
|
||||
expect(stateElement).toBeDefined();
|
||||
expect(sortElement).toBeDefined();
|
||||
expect(orderElement).toBeDefined();
|
||||
expect(stateElement.innerText.trim()).toEqual('ADF_CLOUD_PROCESS_FILTERS.STATUS.RUNNING');
|
||||
expect(sortElement.innerText.trim()).toEqual('ADF_CLOUD_EDIT_PROCESS_FILTER.LABEL.ID');
|
||||
expect(orderElement.innerText.trim()).toEqual('ADF_CLOUD_PROCESS_FILTERS.DIRECTION.ASCENDING');
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
|
||||
it('should display state drop down', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const stateElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-process-property-status"]');
|
||||
const sortElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-process-property-sort"]');
|
||||
const orderElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-process-property-order"]');
|
||||
expect(stateElement).toBeDefined();
|
||||
expect(sortElement).toBeDefined();
|
||||
expect(orderElement).toBeDefined();
|
||||
expect(stateElement.innerText.trim()).toEqual('ADF_CLOUD_PROCESS_FILTERS.STATUS.RUNNING');
|
||||
expect(sortElement.innerText.trim()).toEqual('ADF_CLOUD_EDIT_PROCESS_FILTER.LABEL.ID');
|
||||
expect(orderElement.innerText.trim()).toEqual('ADF_CLOUD_PROCESS_FILTERS.DIRECTION.ASCENDING');
|
||||
});
|
||||
|
||||
it('should display state drop down', async () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
@@ -331,75 +334,92 @@ describe('EditProcessFilterCloudComponent', () => {
|
||||
stateElement.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const statusOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(statusOptions.length).toEqual(5);
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
it('should display sort drop down', async(() => {
|
||||
const statusOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(statusOptions.length).toEqual(5);
|
||||
});
|
||||
|
||||
it('should display sort drop down', async () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
const sortElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-process-property-sort"] .mat-select-trigger');
|
||||
sortElement.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const sortOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(sortOptions.length).toEqual(4);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should display order drop down', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const sortOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(sortOptions.length).toEqual(4);
|
||||
});
|
||||
|
||||
it('should display order drop down', async () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
const orderElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-process-property-order"] .mat-select-trigger');
|
||||
orderElement.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const orderOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(orderOptions.length).toEqual(2);
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
const orderOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(orderOptions.length).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
it('should have floating labels when values are present', async(() => {
|
||||
it('should have floating labels when values are present', async () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const inputLabelsNodes = document.querySelectorAll('mat-form-field');
|
||||
inputLabelsNodes.forEach(labelNode => {
|
||||
expect(labelNode.getAttribute('ng-reflect-float-label')).toBe('auto');
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
it('should be able to filter filterProperties when input is defined', async(() => {
|
||||
it('should be able to filter filterProperties when input is defined', async () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
component.filterProperties = ['appName', 'processName'];
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
|
||||
component.ngOnChanges({ 'id': processFilterIdChange });
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(component.processFilterProperties.length).toEqual(2);
|
||||
expect(component.processFilterProperties[0].key).toEqual('appName');
|
||||
expect(component.processFilterProperties[1].key).toEqual('processName');
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(component.processFilterProperties.length).toEqual(2);
|
||||
expect(component.processFilterProperties[0].key).toEqual('appName');
|
||||
expect(component.processFilterProperties[1].key).toEqual('processName');
|
||||
});
|
||||
|
||||
it('should get form attributes', async() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
component.filterProperties = ['appName', 'completedDateRange'];
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
|
||||
component.ngOnChanges({ 'id': processFilterIdChange });
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(component.editProcessFilterForm.get('_completedFrom')).toBeDefined();
|
||||
expect(component.editProcessFilterForm.get('_completedTo')).toBeDefined();
|
||||
expect(component.editProcessFilterForm.get('completedDateType')).toBeDefined();
|
||||
});
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(component.editProcessFilterForm.get('_completedFrom')).toBeDefined();
|
||||
expect(component.editProcessFilterForm.get('_completedTo')).toBeDefined();
|
||||
expect(component.editProcessFilterForm.get('completedDateType')).toBeDefined();
|
||||
});
|
||||
|
||||
it('should get form attributes for suspendedData', async() => {
|
||||
@@ -416,81 +436,98 @@ describe('EditProcessFilterCloudComponent', () => {
|
||||
getProcessFilterByIdSpy.and.returnValue(of(filter));
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
component.filterProperties = ['appName', 'suspendedDateRange'];
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
|
||||
component.ngOnChanges({ 'id': processFilterIdChange });
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(component.editProcessFilterForm.get('_suspendedFrom').value).toEqual(new Date(2021, 1, 1).toString());
|
||||
expect(component.editProcessFilterForm.get('_suspendedTo').value).toEqual(new Date(2021, 1, 2).toString());
|
||||
expect(component.editProcessFilterForm.get('suspendedDateType').value).toEqual(DateCloudFilterType.RANGE);
|
||||
});
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(component.editProcessFilterForm.get('_suspendedFrom').value).toEqual(new Date(2021, 1, 1).toString());
|
||||
expect(component.editProcessFilterForm.get('_suspendedTo').value).toEqual(new Date(2021, 1, 2).toString());
|
||||
expect(component.editProcessFilterForm.get('suspendedDateType').value).toEqual(DateCloudFilterType.RANGE);
|
||||
});
|
||||
|
||||
it('should able to build a editProcessFilter form with default properties if input is empty', async(() => {
|
||||
it('should able to build a editProcessFilter form with default properties if input is empty', async () => {
|
||||
fixture.detectChanges();
|
||||
component.filterProperties = [];
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
|
||||
component.ngOnChanges({ 'id': processFilterIdChange });
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const stateController = component.editProcessFilterForm.get('status');
|
||||
const sortController = component.editProcessFilterForm.get('sort');
|
||||
const orderController = component.editProcessFilterForm.get('order');
|
||||
const lastModifiedFromController = component.editProcessFilterForm.get('lastModifiedFrom');
|
||||
const lastModifiedToController = component.editProcessFilterForm.get('lastModifiedTo');
|
||||
fixture.detectChanges();
|
||||
expect(component.processFilterProperties).toBeDefined();
|
||||
expect(component.processFilterProperties.length).toEqual(5);
|
||||
expect(component.editProcessFilterForm).toBeDefined();
|
||||
expect(stateController).toBeDefined();
|
||||
expect(sortController).toBeDefined();
|
||||
expect(orderController).toBeDefined();
|
||||
expect(lastModifiedFromController).toBeDefined();
|
||||
expect(lastModifiedToController).toBeDefined();
|
||||
expect(stateController.value).toEqual('RUNNING');
|
||||
expect(sortController.value).toEqual('id');
|
||||
expect(orderController.value).toEqual('ASC');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should able to fetch running applications when appName property defined in the input', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const stateController = component.editProcessFilterForm.get('status');
|
||||
const sortController = component.editProcessFilterForm.get('sort');
|
||||
const orderController = component.editProcessFilterForm.get('order');
|
||||
const lastModifiedFromController = component.editProcessFilterForm.get('lastModifiedFrom');
|
||||
const lastModifiedToController = component.editProcessFilterForm.get('lastModifiedTo');
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(component.processFilterProperties).toBeDefined();
|
||||
expect(component.processFilterProperties.length).toEqual(5);
|
||||
expect(component.editProcessFilterForm).toBeDefined();
|
||||
expect(stateController).toBeDefined();
|
||||
expect(sortController).toBeDefined();
|
||||
expect(orderController).toBeDefined();
|
||||
expect(lastModifiedFromController).toBeDefined();
|
||||
expect(lastModifiedToController).toBeDefined();
|
||||
expect(stateController.value).toEqual('RUNNING');
|
||||
expect(sortController.value).toEqual('id');
|
||||
expect(orderController.value).toEqual('ASC');
|
||||
});
|
||||
|
||||
it('should able to fetch running applications when appName property defined in the input', async () => {
|
||||
component.filterProperties = ['appName', 'processName'];
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
|
||||
component.ngOnChanges({ 'id': processFilterIdChange });
|
||||
fixture.detectChanges();
|
||||
const appController = component.editProcessFilterForm.get('appName');
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(getRunningApplicationsSpy).toHaveBeenCalled();
|
||||
expect(appController).toBeDefined();
|
||||
expect(appController.value).toEqual('mock-app-name');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should fetch applications when appName and appVersion input is set', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const appController = component.editProcessFilterForm.get('appName');
|
||||
|
||||
expect(getRunningApplicationsSpy).toHaveBeenCalled();
|
||||
expect(appController).toBeDefined();
|
||||
expect(appController.value).toEqual('mock-app-name');
|
||||
});
|
||||
|
||||
it('should fetch applications when appName and appVersion input is set', async () => {
|
||||
component.filterProperties = ['appName', 'processName', 'appVersion'];
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
|
||||
component.ngOnChanges({ 'id': processFilterIdChange });
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const appController = component.editProcessFilterForm.get('appName');
|
||||
const appVersionController = component.editProcessFilterForm.get('appVersion');
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(getRunningApplicationsSpy).toHaveBeenCalled();
|
||||
expect(appController).toBeDefined();
|
||||
expect(appController.value).toEqual('mock-app-name');
|
||||
expect(appVersionController).toBeDefined();
|
||||
expect(appVersionController.value).toEqual(1);
|
||||
});
|
||||
}));
|
||||
|
||||
expect(getRunningApplicationsSpy).toHaveBeenCalled();
|
||||
expect(appController).toBeDefined();
|
||||
expect(appController.value).toEqual('mock-app-name');
|
||||
expect(appVersionController).toBeDefined();
|
||||
expect(appVersionController.value).toEqual(1);
|
||||
});
|
||||
|
||||
it('should fetch appVersionMultiple options when appVersionMultiple filter property is set', async () => {
|
||||
const mockAppVersion1: ApplicationVersionModel = {
|
||||
@@ -535,49 +572,60 @@ describe('EditProcessFilterCloudComponent', () => {
|
||||
expect(appVersionOptions[1].nativeElement.innerText).toEqual('2');
|
||||
});
|
||||
|
||||
it('should fetch process definitions when processDefinitionName filter property is set', async(() => {
|
||||
it('should fetch process definitions when processDefinitionName filter property is set', async () => {
|
||||
const processSpy = spyOn(processService, 'getProcessDefinitions').and.returnValue(of([new ProcessDefinitionCloud({ id: 'fake-id', name: 'fake-name' })]));
|
||||
fixture.detectChanges();
|
||||
component.filterProperties = ['processDefinitionName'];
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
|
||||
component.ngOnChanges({ 'id': processFilterIdChange });
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const controller = component.editProcessFilterForm.get('processDefinitionName');
|
||||
const processDefinitionNamesElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-process-property-processDefinitionName"]');
|
||||
processDefinitionNamesElement.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(processSpy).toHaveBeenCalled();
|
||||
expect(controller).toBeDefined();
|
||||
const processDefinitionNamesOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(processDefinitionNamesOptions[0].nativeElement.value).toBeUndefined();
|
||||
expect(processDefinitionNamesOptions[0].nativeElement.innerText).toEqual(component.allProcessDefinitionNamesOption.label);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should display default sort properties', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(processSpy).toHaveBeenCalled();
|
||||
expect(controller).toBeDefined();
|
||||
const processDefinitionNamesOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(processDefinitionNamesOptions[0].nativeElement.value).toBeUndefined();
|
||||
expect(processDefinitionNamesOptions[0].nativeElement.innerText).toEqual(component.allProcessDefinitionNamesOption.label);
|
||||
});
|
||||
|
||||
it('should display default sort properties', async () => {
|
||||
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
|
||||
component.ngOnChanges({ 'id': processFilterIdChange });
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const sortElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-process-property-sort"]');
|
||||
sortElement.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
const sortController = component.editProcessFilterForm.get('sort');
|
||||
const sortOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
fixture.detectChanges();
|
||||
expect(sortController).toBeDefined();
|
||||
expect(sortController.value).toEqual('id');
|
||||
expect(sortOptions.length).toEqual(4);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should display sort properties when sort properties are specified', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const sortController = component.editProcessFilterForm.get('sort');
|
||||
const sortOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(sortController).toBeDefined();
|
||||
expect(sortController.value).toEqual('id');
|
||||
expect(sortOptions.length).toEqual(4);
|
||||
});
|
||||
|
||||
it('should display sort properties when sort properties are specified', async () => {
|
||||
getProcessFilterByIdSpy.and.returnValue(of({
|
||||
id: 'filter-id',
|
||||
processName: 'process-name',
|
||||
@@ -586,26 +634,36 @@ describe('EditProcessFilterCloudComponent', () => {
|
||||
priority: '12'
|
||||
}));
|
||||
component.sortProperties = ['id', 'name', 'processDefinitionId'];
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
|
||||
component.ngOnChanges({ 'id': processFilterIdChange });
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const sortElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-process-property-sort"]');
|
||||
sortElement.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const sortController = component.editProcessFilterForm.get('sort');
|
||||
const sortOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(sortController).toBeDefined();
|
||||
expect(component.sortProperties).toBeDefined();
|
||||
expect(component.sortProperties.length).toBe(3);
|
||||
expect(sortController.value).toBe('my-custom-sort');
|
||||
expect(sortOptions.length).toEqual(3);
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
const sortController = component.editProcessFilterForm.get('sort');
|
||||
const sortOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(sortController).toBeDefined();
|
||||
expect(component.sortProperties).toBeDefined();
|
||||
expect(component.sortProperties.length).toBe(3);
|
||||
expect(sortController.value).toBe('my-custom-sort');
|
||||
expect(sortOptions.length).toEqual(3);
|
||||
});
|
||||
|
||||
it('should display the process name label for the name property', async () => {
|
||||
getProcessFilterByIdSpy.and.returnValue(of({
|
||||
@@ -618,14 +676,22 @@ describe('EditProcessFilterCloudComponent', () => {
|
||||
component.sortProperties = ['name'];
|
||||
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
|
||||
component.ngOnChanges({ 'id': processFilterIdChange });
|
||||
fixture.detectChanges();
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
fixture.detectChanges();
|
||||
const sortElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-process-property-sort"]');
|
||||
sortElement.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const sortElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-process-property-sort"]');
|
||||
sortElement.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const sortOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(sortOptions[0].nativeElement.textContent).toEqual('ADF_CLOUD_EDIT_PROCESS_FILTER.LABEL.PROCESS_NAME');
|
||||
});
|
||||
@@ -644,28 +710,37 @@ describe('EditProcessFilterCloudComponent', () => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
it('should emit save event and save the filter on click save button', async(() => {
|
||||
it('should emit save event and save the filter on click save button', async () => {
|
||||
component.toggleFilterActions = true;
|
||||
const saveFilterSpy = spyOn(service, 'updateFilter').and.returnValue(of([fakeFilter]));
|
||||
const saveSpy: jasmine.Spy = spyOn(component.action, 'emit');
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const stateElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-process-property-status"] .mat-select-trigger');
|
||||
stateElement.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-save"]');
|
||||
const stateOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
stateOptions[2].nativeElement.click();
|
||||
saveButton.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(saveFilterSpy).toHaveBeenCalled();
|
||||
expect(saveSpy).toHaveBeenCalled();
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(saveFilterSpy).toHaveBeenCalled();
|
||||
expect(saveSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should emit delete event and delete the filter on click of delete button', async () => {
|
||||
component.toggleFilterActions = true;
|
||||
@@ -689,6 +764,7 @@ describe('EditProcessFilterCloudComponent', () => {
|
||||
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-delete"]');
|
||||
deleteButton.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
@@ -696,86 +772,97 @@ describe('EditProcessFilterCloudComponent', () => {
|
||||
expect(deleteSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should emit saveAs event and add filter on click saveAs button', async(() => {
|
||||
it('should emit saveAs event and add filter on click saveAs button', async () => {
|
||||
component.toggleFilterActions = true;
|
||||
const saveAsFilterSpy = spyOn(service, 'addFilter').and.callThrough();
|
||||
const saveAsSpy: jasmine.Spy = spyOn(component.action, 'emit');
|
||||
const saveAsSpy = spyOn(component.action, 'emit');
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const stateElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-process-property-status"] .mat-select-trigger');
|
||||
stateElement.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-saveAs"]');
|
||||
const stateOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
stateOptions[2].nativeElement.click();
|
||||
fixture.detectChanges();
|
||||
saveButton.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(saveAsFilterSpy).toHaveBeenCalled();
|
||||
expect(saveAsSpy).toHaveBeenCalled();
|
||||
expect(dialog.open).toHaveBeenCalled();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should display default filter actions', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(saveAsFilterSpy).toHaveBeenCalled();
|
||||
expect(saveAsSpy).toHaveBeenCalled();
|
||||
expect(dialog.open).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should display default filter actions', async () => {
|
||||
component.toggleFilterActions = true;
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
const saveAsButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-saveAs"]');
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-save"]');
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-delete"]');
|
||||
expect(component.processFilterActions).toBeDefined();
|
||||
expect(component.processFilterActions.length).toEqual(3);
|
||||
expect(saveButton).toBeDefined();
|
||||
expect(saveAsButton).toBeDefined();
|
||||
expect(deleteButton).toBeDefined();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should filter actions when input actions are specified', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const saveAsButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-saveAs"]');
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-save"]');
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-delete"]');
|
||||
expect(component.processFilterActions).toBeDefined();
|
||||
expect(component.processFilterActions.length).toEqual(3);
|
||||
expect(saveButton).toBeDefined();
|
||||
expect(saveAsButton).toBeDefined();
|
||||
expect(deleteButton).toBeDefined();
|
||||
});
|
||||
|
||||
it('should filter actions when input actions are specified', async () => {
|
||||
component.actions = ['save'];
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
|
||||
component.ngOnChanges({ 'id': processFilterIdChange });
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(component.processFilterActions).toBeDefined();
|
||||
expect(component.actions.length).toEqual(1);
|
||||
expect(component.processFilterActions.length).toEqual(1);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should display default filter actions when input is empty', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(component.processFilterActions).toBeDefined();
|
||||
expect(component.actions.length).toEqual(1);
|
||||
expect(component.processFilterActions.length).toEqual(1);
|
||||
});
|
||||
|
||||
it('should display default filter actions when input is empty', async () => {
|
||||
component.toggleFilterActions = true;
|
||||
component.actions = [];
|
||||
component.id = 'mock-process-filter-id';
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const saveAsButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-saveAs"]');
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-save"]');
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-delete"]');
|
||||
expect(component.processFilterActions).toBeDefined();
|
||||
expect(component.processFilterActions.length).toEqual(3);
|
||||
expect(saveButton).toBeDefined();
|
||||
expect(saveAsButton).toBeDefined();
|
||||
expect(deleteButton).toBeDefined();
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
const saveAsButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-saveAs"]');
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-save"]');
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-delete"]');
|
||||
expect(component.processFilterActions).toBeDefined();
|
||||
expect(component.processFilterActions.length).toEqual(3);
|
||||
expect(saveButton).toBeDefined();
|
||||
expect(saveAsButton).toBeDefined();
|
||||
expect(deleteButton).toBeDefined();
|
||||
});
|
||||
|
||||
it('should set the correct lastModifiedTo date', (done) => {
|
||||
component.appName = 'fake';
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||
import { ProcessFilterDialogCloudComponent } from './process-filter-dialog-cloud.component';
|
||||
import { setupTestBed } from '@alfresco/adf-core';
|
||||
@@ -70,7 +70,7 @@ describe('ProcessFilterDialogCloudComponent', () => {
|
||||
expect(titleElement.textContent).toEqual(' ADF_CLOUD_EDIT_PROCESS_FILTER.DIALOG.TITLE ');
|
||||
});
|
||||
|
||||
it('should enable save button if form is valid', async(() => {
|
||||
it('should enable save button if form is valid', async () => {
|
||||
fixture.detectChanges();
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector(
|
||||
'#adf-save-button-id'
|
||||
@@ -80,48 +80,52 @@ describe('ProcessFilterDialogCloudComponent', () => {
|
||||
);
|
||||
inputElement.value = 'My custom Name';
|
||||
inputElement.dispatchEvent(new Event('input'));
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(saveButton).toBeDefined();
|
||||
expect(saveButton.disabled).toBeFalsy();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should disable save button if form is not valid', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(saveButton).toBeDefined();
|
||||
expect(saveButton.disabled).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should disable save button if form is not valid', async () => {
|
||||
fixture.detectChanges();
|
||||
const inputElement = fixture.debugElement.nativeElement.querySelector(
|
||||
'#adf-filter-name-id'
|
||||
);
|
||||
inputElement.value = '';
|
||||
inputElement.dispatchEvent(new Event('input'));
|
||||
fixture.whenStable().then(() => {
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector(
|
||||
'#adf-save-button-id'
|
||||
);
|
||||
fixture.detectChanges();
|
||||
expect(saveButton).toBeDefined();
|
||||
expect(saveButton.disabled).toBe(true);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should able to close dialog on click of save button if form is valid', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector(
|
||||
'#adf-save-button-id'
|
||||
);
|
||||
expect(saveButton).toBeDefined();
|
||||
expect(saveButton.disabled).toBe(true);
|
||||
});
|
||||
|
||||
it('should able to close dialog on click of save button if form is valid', async () => {
|
||||
fixture.detectChanges();
|
||||
const inputElement = fixture.debugElement.nativeElement.querySelector(
|
||||
'#adf-filter-name-id'
|
||||
);
|
||||
inputElement.value = 'My custom Name';
|
||||
inputElement.dispatchEvent(new Event('input'));
|
||||
fixture.whenStable().then(() => {
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector(
|
||||
'#adf-save-button-id'
|
||||
);
|
||||
fixture.detectChanges();
|
||||
saveButton.click();
|
||||
expect(saveButton).toBeDefined();
|
||||
expect(saveButton.disabled).toBeFalsy();
|
||||
expect(component.dialogRef.close).toHaveBeenCalled();
|
||||
});
|
||||
}));
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector(
|
||||
'#adf-save-button-id'
|
||||
);
|
||||
expect(saveButton).toBeDefined();
|
||||
expect(saveButton.disabled).toBeFalsy();
|
||||
|
||||
saveButton.click();
|
||||
expect(component.dialogRef.close).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should able close dialog on click of cancel button', () => {
|
||||
component.data = { data: { name: '' } };
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { setupTestBed, AppConfigService } from '@alfresco/adf-core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { of } from 'rxjs';
|
||||
@@ -62,161 +62,160 @@ describe('ProcessHeaderCloudComponent', () => {
|
||||
component.processInstanceId = 'sdfsdf-323';
|
||||
});
|
||||
|
||||
it('should render empty component if no process instance details are provided', async(() => {
|
||||
it('should render empty component if no process instance details are provided', async () => {
|
||||
component.appName = undefined;
|
||||
component.processInstanceId = undefined;
|
||||
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(component.properties).toBeUndefined();
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
it('should display process instance id', async(() => {
|
||||
expect(component.properties).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should display process instance id', async () => {
|
||||
component.ngOnChanges();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const formNameEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-id"]'));
|
||||
expect(formNameEl.nativeElement.value).toBe('00fcc4ab-4290-11e9-b133-0a586460016a');
|
||||
});
|
||||
}));
|
||||
const formNameEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-id"]'));
|
||||
expect(formNameEl.nativeElement.value).toBe('00fcc4ab-4290-11e9-b133-0a586460016a');
|
||||
});
|
||||
|
||||
it('should display name', async(() => {
|
||||
it('should display name', async () => {
|
||||
component.ngOnChanges();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const formNameEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-name"]'));
|
||||
expect(formNameEl.nativeElement.value).toBe('new name');
|
||||
});
|
||||
}));
|
||||
const formNameEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-name"]'));
|
||||
expect(formNameEl.nativeElement.value).toBe('new name');
|
||||
});
|
||||
|
||||
it('should display placeholder if no name is available', async(() => {
|
||||
it('should display placeholder if no name is available', async () => {
|
||||
processInstanceDetailsCloudMock.name = null;
|
||||
component.ngOnChanges();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const valueEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-name"]'));
|
||||
expect(valueEl.nativeElement.value).toBe('ADF_CLOUD_PROCESS_HEADER.PROPERTIES.NAME_DEFAULT');
|
||||
});
|
||||
const valueEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-name"]'));
|
||||
expect(valueEl.nativeElement.value).toBe('ADF_CLOUD_PROCESS_HEADER.PROPERTIES.NAME_DEFAULT');
|
||||
});
|
||||
|
||||
}));
|
||||
|
||||
it('should display status', async(() => {
|
||||
it('should display status', async () => {
|
||||
component.ngOnChanges();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const formNameEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-status"]'));
|
||||
expect(formNameEl.nativeElement.value).toBe('RUNNING');
|
||||
});
|
||||
}));
|
||||
const formNameEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-status"]'));
|
||||
expect(formNameEl.nativeElement.value).toBe('RUNNING');
|
||||
});
|
||||
|
||||
it('should display initiator', async(() => {
|
||||
it('should display initiator', async () => {
|
||||
component.ngOnChanges();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const formNameEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-initiator"]'));
|
||||
expect(formNameEl.nativeElement.value).toBe('devopsuser');
|
||||
});
|
||||
}));
|
||||
const formNameEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-initiator"]'));
|
||||
expect(formNameEl.nativeElement.value).toBe('devopsuser');
|
||||
});
|
||||
|
||||
it('should display start date', async(() => {
|
||||
it('should display start date', async () => {
|
||||
component.ngOnChanges();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-startDate"] .adf-property-value'));
|
||||
expect(valueEl.nativeElement.innerText.trim()).toBe('Mar 9, 2019');
|
||||
});
|
||||
}));
|
||||
const valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-startDate"] .adf-property-value'));
|
||||
expect(valueEl.nativeElement.innerText.trim()).toBe('Mar 9, 2019');
|
||||
});
|
||||
|
||||
it('should display lastModified date', async(() => {
|
||||
it('should display lastModified date', async () => {
|
||||
component.ngOnChanges();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-lastModified"] .adf-property-value'));
|
||||
expect(valueEl.nativeElement.innerText.trim()).toBe('Mar 9, 2019');
|
||||
});
|
||||
}));
|
||||
const valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-lastModified"] .adf-property-value'));
|
||||
expect(valueEl.nativeElement.innerText.trim()).toBe('Mar 9, 2019');
|
||||
});
|
||||
|
||||
it('should display parentId', async(() => {
|
||||
it('should display parentId', async () => {
|
||||
component.ngOnChanges();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const formNameEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-parentId"]'));
|
||||
expect(formNameEl.nativeElement.value).toBe('00fcc4ab-4290-11e9-b133-0a586460016b');
|
||||
});
|
||||
}));
|
||||
const formNameEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-parentId"]'));
|
||||
expect(formNameEl.nativeElement.value).toBe('00fcc4ab-4290-11e9-b133-0a586460016b');
|
||||
});
|
||||
|
||||
it('should display default value when parentId is not available', async(() => {
|
||||
it('should display default value when parentId is not available', async () => {
|
||||
processInstanceDetailsCloudMock.parentId = null;
|
||||
component.ngOnChanges();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const formNameEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-parentId"]'));
|
||||
expect(formNameEl.nativeElement.value).toBe('ADF_CLOUD_PROCESS_HEADER.PROPERTIES.NONE');
|
||||
});
|
||||
}));
|
||||
const formNameEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-parentId"]'));
|
||||
expect(formNameEl.nativeElement.value).toBe('ADF_CLOUD_PROCESS_HEADER.PROPERTIES.NONE');
|
||||
});
|
||||
|
||||
it('should display businessKey', async(() => {
|
||||
it('should display businessKey', async () => {
|
||||
component.ngOnChanges();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const formNameEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-businessKey"]'));
|
||||
expect(formNameEl.nativeElement.value).toBe('MyBusinessKey');
|
||||
});
|
||||
}));
|
||||
const formNameEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-businessKey"]'));
|
||||
expect(formNameEl.nativeElement.value).toBe('MyBusinessKey');
|
||||
});
|
||||
|
||||
it('should display default value when businessKey is not available', async(() => {
|
||||
it('should display default value when businessKey is not available', async () => {
|
||||
processInstanceDetailsCloudMock.businessKey = null;
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const formNameEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-businessKey"]'));
|
||||
expect(formNameEl.nativeElement.value).toBe('ADF_CLOUD_PROCESS_HEADER.PROPERTIES.NONE');
|
||||
});
|
||||
}));
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const formNameEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-businessKey"]'));
|
||||
expect(formNameEl.nativeElement.value).toBe('ADF_CLOUD_PROCESS_HEADER.PROPERTIES.NONE');
|
||||
});
|
||||
|
||||
describe('Config Filtering', () => {
|
||||
|
||||
it('should show only the properties from the configuration file', async(() => {
|
||||
it('should show only the properties from the configuration file', async () => {
|
||||
spyOn(appConfigService, 'get').and.returnValue(['name', 'status']);
|
||||
component.ngOnChanges();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const propertyList = fixture.debugElement.queryAll(By.css('.adf-property-list .adf-property'));
|
||||
expect(propertyList).toBeDefined();
|
||||
expect(propertyList).not.toBeNull();
|
||||
expect(propertyList.length).toBe(2);
|
||||
expect(propertyList[0].nativeElement.textContent).toContain('ADF_CLOUD_PROCESS_HEADER.PROPERTIES.NAME');
|
||||
expect(propertyList[1].nativeElement.textContent).toContain('ADF_CLOUD_PROCESS_HEADER.PROPERTIES.STATUS');
|
||||
});
|
||||
}));
|
||||
const propertyList = fixture.debugElement.queryAll(By.css('.adf-property-list .adf-property'));
|
||||
expect(propertyList).toBeDefined();
|
||||
expect(propertyList).not.toBeNull();
|
||||
expect(propertyList.length).toBe(2);
|
||||
expect(propertyList[0].nativeElement.textContent).toContain('ADF_CLOUD_PROCESS_HEADER.PROPERTIES.NAME');
|
||||
expect(propertyList[1].nativeElement.textContent).toContain('ADF_CLOUD_PROCESS_HEADER.PROPERTIES.STATUS');
|
||||
});
|
||||
|
||||
it('should show all the default properties if there is no configuration', async(() => {
|
||||
it('should show all the default properties if there is no configuration', async () => {
|
||||
spyOn(appConfigService, 'get').and.returnValue(null);
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const propertyList = fixture.debugElement.queryAll(By.css('.adf-property-list .adf-property'));
|
||||
expect(propertyList).toBeDefined();
|
||||
expect(propertyList).not.toBeNull();
|
||||
expect(propertyList.length).toBe(component.properties.length);
|
||||
expect(propertyList[0].nativeElement.textContent).toContain('ADF_CLOUD_PROCESS_HEADER.PROPERTIES.ID');
|
||||
expect(propertyList[1].nativeElement.textContent).toContain('ADF_CLOUD_PROCESS_HEADER.PROPERTIES.NAME');
|
||||
});
|
||||
}));
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const propertyList = fixture.debugElement.queryAll(By.css('.adf-property-list .adf-property'));
|
||||
expect(propertyList).toBeDefined();
|
||||
expect(propertyList).not.toBeNull();
|
||||
expect(propertyList.length).toBe(component.properties.length);
|
||||
expect(propertyList[0].nativeElement.textContent).toContain('ADF_CLOUD_PROCESS_HEADER.PROPERTIES.ID');
|
||||
expect(propertyList[1].nativeElement.textContent).toContain('ADF_CLOUD_PROCESS_HEADER.PROPERTIES.NAME');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { Component, SimpleChange, ViewChild } from '@angular/core';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import {
|
||||
AppConfigService,
|
||||
@@ -419,7 +419,7 @@ describe('ProcessListCloudComponent', () => {
|
||||
fixtureEmpty.destroy();
|
||||
});
|
||||
|
||||
it('should render the custom template', async((done) => {
|
||||
it('should render the custom template', fakeAsync((done) => {
|
||||
const emptyList = {list: {entries: []}};
|
||||
spyOn(processListCloudService, 'getProcessByRequest').and.returnValue(of(emptyList));
|
||||
component.success.subscribe(() => {
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { SimpleChange, DebugElement } from '@angular/core';
|
||||
import { async, ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
|
||||
import { setupTestBed } from '@alfresco/adf-core';
|
||||
import { of, throwError } from 'rxjs';
|
||||
import { StartProcessCloudService } from '../services/start-process-cloud.service';
|
||||
@@ -141,8 +141,7 @@ describe('StartProcessCloudComponent', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should create a process instance if the selection is valid', async(() => {
|
||||
|
||||
it('should create a process instance if the selection is valid', fakeAsync(() => {
|
||||
getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(fakeProcessDefinitions));
|
||||
component.name = 'My new process';
|
||||
component.processDefinitionName = 'process';
|
||||
@@ -178,29 +177,29 @@ describe('StartProcessCloudComponent', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should have start button disabled when no process is selected', async(() => {
|
||||
it('should have start button disabled when no process is selected', async () => {
|
||||
component.name = '';
|
||||
component.processDefinitionName = '';
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const startBtn = fixture.nativeElement.querySelector('#button-start');
|
||||
expect(startBtn.disabled).toBe(true);
|
||||
expect(component.isProcessFormValid()).toBe(false);
|
||||
});
|
||||
}));
|
||||
const startBtn = fixture.nativeElement.querySelector('#button-start');
|
||||
expect(startBtn.disabled).toBe(true);
|
||||
expect(component.isProcessFormValid()).toBe(false);
|
||||
});
|
||||
|
||||
it('should have start button disabled when name not filled out', async(() => {
|
||||
it('should have start button disabled when name not filled out', async () => {
|
||||
component.name = '';
|
||||
component.processDefinitionName = 'processwithoutform2';
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const startBtn = fixture.nativeElement.querySelector('#button-start');
|
||||
expect(startBtn.disabled).toBe(true);
|
||||
expect(component.isProcessFormValid()).toBe(false);
|
||||
});
|
||||
}));
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const startBtn = fixture.nativeElement.querySelector('#button-start');
|
||||
expect(startBtn.disabled).toBe(true);
|
||||
expect(component.isProcessFormValid()).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('start a process with start form', () => {
|
||||
@@ -445,40 +444,41 @@ describe('StartProcessCloudComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should indicate an error to the user if process defs cannot be loaded', async(() => {
|
||||
it('should indicate an error to the user if process defs cannot be loaded', async () => {
|
||||
getDefinitionsSpy = getDefinitionsSpy.and.returnValue(throwError({}));
|
||||
const change = new SimpleChange('myApp', 'myApp1', true);
|
||||
component.ngOnChanges({ appName: change });
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const errorEl = fixture.nativeElement.querySelector('#error-message');
|
||||
expect(errorEl.innerText.trim()).toBe('ADF_CLOUD_PROCESS_LIST.ADF_CLOUD_START_PROCESS.ERROR.LOAD_PROCESS_DEFS');
|
||||
});
|
||||
}));
|
||||
const errorEl = fixture.nativeElement.querySelector('#error-message');
|
||||
expect(errorEl.innerText.trim()).toBe('ADF_CLOUD_PROCESS_LIST.ADF_CLOUD_START_PROCESS.ERROR.LOAD_PROCESS_DEFS');
|
||||
});
|
||||
|
||||
it('should show no process available message when no process definition is loaded', async(() => {
|
||||
it('should show no process available message when no process definition is loaded', async () => {
|
||||
getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of([]));
|
||||
const change = new SimpleChange('myApp', 'myApp1', true);
|
||||
component.ngOnChanges({ appName: change });
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const noProcessElement = fixture.nativeElement.querySelector('#no-process-message');
|
||||
expect(noProcessElement).not.toBeNull('Expected no available process message to be present');
|
||||
expect(noProcessElement.innerText.trim()).toBe('ADF_CLOUD_PROCESS_LIST.ADF_CLOUD_START_PROCESS.NO_PROCESS_DEFINITIONS');
|
||||
});
|
||||
}));
|
||||
const noProcessElement = fixture.nativeElement.querySelector('#no-process-message');
|
||||
expect(noProcessElement).not.toBeNull('Expected no available process message to be present');
|
||||
expect(noProcessElement.innerText.trim()).toBe('ADF_CLOUD_PROCESS_LIST.ADF_CLOUD_START_PROCESS.NO_PROCESS_DEFINITIONS');
|
||||
});
|
||||
|
||||
it('should select automatically the processDefinition if the app contain only one', async(() => {
|
||||
it('should select automatically the processDefinition if the app contain only one', async () => {
|
||||
getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of([fakeProcessDefinitions[0]]));
|
||||
const change = new SimpleChange('myApp', 'myApp1', true);
|
||||
component.ngOnChanges({ appName: change });
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(component.processForm.controls['processDefinition'].value).toBe(JSON.parse(JSON.stringify(fakeProcessDefinitions[0])).name);
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(component.processForm.controls['processDefinition'].value).toBe(JSON.parse(JSON.stringify(fakeProcessDefinitions[0])).name);
|
||||
});
|
||||
|
||||
it('should select automatically the form when processDefinition is selected as default', fakeAsync(() => {
|
||||
getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of([fakeProcessDefinitions[0]]));
|
||||
@@ -501,17 +501,18 @@ describe('StartProcessCloudComponent', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not select automatically any processDefinition if the app contain multiple process and does not have any processDefinition as input', async(() => {
|
||||
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(fakeProcessDefinitions));
|
||||
component.appName = 'myApp';
|
||||
component.ngOnChanges({});
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(component.processPayloadCloud.name).toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should select the right process when the processKey begins with the name', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(component.processPayloadCloud.name).toBeNull();
|
||||
});
|
||||
|
||||
it('should select the right process when the processKey begins with the name', fakeAsync(() => {
|
||||
getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(fakeProcessDefinitions));
|
||||
component.name = 'My new process';
|
||||
component.processDefinitionName = 'process';
|
||||
@@ -525,45 +526,48 @@ describe('StartProcessCloudComponent', () => {
|
||||
|
||||
describe('dropdown', () => {
|
||||
|
||||
it('should hide the process dropdown button if showSelectProcessDropdown is false', async(() => {
|
||||
it('should hide the process dropdown button if showSelectProcessDropdown is false', async () => {
|
||||
fixture.detectChanges();
|
||||
getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(fakeProcessDefinitions));
|
||||
component.appName = 'myApp';
|
||||
component.showSelectProcessDropdown = false;
|
||||
component.ngOnChanges({});
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const selectElement = fixture.nativeElement.querySelector('button#adf-select-process-dropdown');
|
||||
expect(selectElement).toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should show the process dropdown button if showSelectProcessDropdown is false', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const selectElement = fixture.nativeElement.querySelector('button#adf-select-process-dropdown');
|
||||
expect(selectElement).toBeNull();
|
||||
});
|
||||
|
||||
it('should show the process dropdown button if showSelectProcessDropdown is false', async () => {
|
||||
fixture.detectChanges();
|
||||
getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(fakeProcessDefinitions));
|
||||
component.appName = 'myApp';
|
||||
component.processDefinitionName = 'NewProcess 2';
|
||||
component.showSelectProcessDropdown = true;
|
||||
component.ngOnChanges({});
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const selectElement = fixture.nativeElement.querySelector('button#adf-select-process-dropdown');
|
||||
expect(selectElement).not.toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should show the process dropdown button by default', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const selectElement = fixture.nativeElement.querySelector('button#adf-select-process-dropdown');
|
||||
expect(selectElement).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should show the process dropdown button by default', async () => {
|
||||
fixture.detectChanges();
|
||||
getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(fakeProcessDefinitions));
|
||||
component.appName = 'myApp';
|
||||
component.processDefinitionName = 'NewProcess 2';
|
||||
component.ngOnChanges({});
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const selectElement = fixture.nativeElement.querySelector('button#adf-select-process-dropdown');
|
||||
expect(selectElement).not.toBeNull();
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
const selectElement = fixture.nativeElement.querySelector('button#adf-select-process-dropdown');
|
||||
expect(selectElement).not.toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -571,53 +575,57 @@ describe('StartProcessCloudComponent', () => {
|
||||
|
||||
const change = new SimpleChange('myApp', 'myApp1', false);
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
component.appName = 'myApp';
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
getDefinitionsSpy.calls.reset();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
it('should have labels for process name and type', async(() => {
|
||||
it('should have labels for process name and type', async () => {
|
||||
component.appName = 'myApp';
|
||||
component.processDefinitionName = 'NewProcess 2';
|
||||
component.ngOnChanges({ appName: firstChange });
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const inputLabelsNodes = document.querySelectorAll('.adf-start-process .adf-process-input-container mat-label');
|
||||
expect(inputLabelsNodes.length).toBe(2);
|
||||
}));
|
||||
});
|
||||
|
||||
it('should have floating labels for process name and type', async(() => {
|
||||
it('should have floating labels for process name and type', async () => {
|
||||
component.appName = 'myApp';
|
||||
component.processDefinitionName = 'NewProcess 2';
|
||||
component.ngOnChanges({});
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const inputLabelsNodes = document.querySelectorAll('.adf-start-process .adf-process-input-container');
|
||||
inputLabelsNodes.forEach(labelNode => {
|
||||
expect(labelNode.getAttribute('ng-reflect-float-label')).toBe('always');
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
it('should reload processes when appName input changed', async(() => {
|
||||
it('should reload processes when appName input changed', async () => {
|
||||
component.ngOnChanges({ appName: firstChange });
|
||||
component.ngOnChanges({ appName: change });
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(getDefinitionsSpy).toHaveBeenCalledWith('myApp1');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should reload processes ONLY when appName input changed', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(getDefinitionsSpy).toHaveBeenCalledWith('myApp1');
|
||||
});
|
||||
|
||||
it('should reload processes ONLY when appName input changed', async () => {
|
||||
component.ngOnChanges({ appName: firstChange });
|
||||
fixture.detectChanges();
|
||||
|
||||
component.ngOnChanges({ maxNameLength: new SimpleChange(0, 2, false) });
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(getDefinitionsSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(getDefinitionsSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should get current processDef', () => {
|
||||
component.ngOnChanges({ appName: change });
|
||||
@@ -643,15 +651,16 @@ describe('StartProcessCloudComponent', () => {
|
||||
expect(component.filteredProcesses.length).toEqual(1);
|
||||
}));
|
||||
|
||||
it('should display the process definion field as empty if are more than one process definition in the list', async(() => {
|
||||
it('should display the process definion field as empty if are more than one process definition in the list', async () => {
|
||||
getDefinitionsSpy.and.returnValue(of(fakeProcessDefinitions));
|
||||
component.ngOnChanges({ appName: change });
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const processDefinitionInput = fixture.nativeElement.querySelector('#processDefinitionName');
|
||||
expect(processDefinitionInput.textContent).toEqual('');
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
const processDefinitionInput = fixture.nativeElement.querySelector('#processDefinitionName');
|
||||
expect(processDefinitionInput.textContent).toEqual('');
|
||||
});
|
||||
});
|
||||
|
||||
describe('start process', () => {
|
||||
@@ -663,23 +672,20 @@ describe('StartProcessCloudComponent', () => {
|
||||
component.ngOnChanges({});
|
||||
});
|
||||
|
||||
it('should call service to start process if required fields provided', async(() => {
|
||||
it('should call service to start process if required fields provided', () => {
|
||||
component.currentCreatedProcess = fakeProcessInstance;
|
||||
component.startProcess();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(startProcessSpy).toHaveBeenCalled();
|
||||
});
|
||||
}));
|
||||
expect(startProcessSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should call service to start process with the correct parameters', async(() => {
|
||||
it('should call service to start process with the correct parameters', () => {
|
||||
component.currentCreatedProcess = fakeProcessInstance;
|
||||
component.startProcess();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(startProcessSpy).toHaveBeenCalledWith(component.appName, fakeProcessInstance.id, component.processPayloadCloud);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should call service to start process with the variables setted', async(() => {
|
||||
expect(startProcessSpy).toHaveBeenCalledWith(component.appName, fakeProcessInstance.id, component.processPayloadCloud);
|
||||
});
|
||||
|
||||
it('should call service to start process with the variables setted', async () => {
|
||||
const inputProcessVariable: Map<string, object>[] = [];
|
||||
inputProcessVariable['name'] = { value: 'Josh' };
|
||||
|
||||
@@ -687,44 +693,42 @@ describe('StartProcessCloudComponent', () => {
|
||||
component.currentCreatedProcess = fakeProcessInstance;
|
||||
|
||||
component.startProcess();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(component.processPayloadCloud.variables).toBe(inputProcessVariable);
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
expect(component.processPayloadCloud.variables).toBe(inputProcessVariable);
|
||||
});
|
||||
|
||||
it('should output start event when process started successfully', async(() => {
|
||||
it('should output start event when process started successfully', () => {
|
||||
const emitSpy = spyOn(component.success, 'emit');
|
||||
component.currentCreatedProcess = fakeProcessInstance;
|
||||
component.startProcess();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(emitSpy).toHaveBeenCalledWith(fakeProcessInstance);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should throw error event when process cannot be started', async(() => {
|
||||
expect(emitSpy).toHaveBeenCalledWith(fakeProcessInstance);
|
||||
});
|
||||
|
||||
it('should throw error event when process cannot be started', async () => {
|
||||
const errorSpy = spyOn(component.error, 'emit');
|
||||
const error = { message: 'My error' };
|
||||
startProcessSpy = startProcessSpy.and.returnValue(throwError(error));
|
||||
component.currentCreatedProcess = fakeProcessInstance;
|
||||
component.startProcess();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(errorSpy).toHaveBeenCalledWith(error);
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
expect(errorSpy).toHaveBeenCalledWith(error);
|
||||
});
|
||||
|
||||
it('should indicate an error to the user if process cannot be started', async(() => {
|
||||
it('should indicate an error to the user if process cannot be started', async () => {
|
||||
getDefinitionsSpy.and.returnValue(of(fakeProcessDefinitions));
|
||||
const change = new SimpleChange('myApp', 'myApp1', true);
|
||||
component.currentCreatedProcess = fakeProcessInstance;
|
||||
component.ngOnChanges({ appName: change });
|
||||
startProcessSpy = startProcessSpy.and.returnValue(throwError({}));
|
||||
component.startProcess();
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const errorEl = fixture.nativeElement.querySelector('#error-message');
|
||||
expect(errorEl.innerText.trim()).toBe('ADF_CLOUD_PROCESS_LIST.ADF_CLOUD_START_PROCESS.ERROR.START');
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
const errorEl = fixture.nativeElement.querySelector('#error-message');
|
||||
expect(errorEl.innerText.trim()).toBe('ADF_CLOUD_PROCESS_LIST.ADF_CLOUD_START_PROCESS.ERROR.START');
|
||||
});
|
||||
|
||||
it('should emit start event when start select a process and add a name', (done) => {
|
||||
const disposableStart = component.success.subscribe(() => {
|
||||
@@ -761,17 +765,23 @@ describe('StartProcessCloudComponent', () => {
|
||||
expect(processInstanceName.valid).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should have start button disabled process name has a space as the first or last character.', async(() => {
|
||||
it('should have start button disabled process name has a space as the first or last character.', async () => {
|
||||
component.appName = 'myApp';
|
||||
component.processDefinitionName = ' Space in the beginning';
|
||||
component.ngOnChanges({ appName: firstChange });
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const startBtn = fixture.nativeElement.querySelector('#button-start');
|
||||
expect(startBtn.disabled).toBe(true);
|
||||
component.processDefinitionName = 'Space in the end ';
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(startBtn.disabled).toBe(true);
|
||||
}));
|
||||
});
|
||||
|
||||
it('should emit processDefinitionSelection event when a process definition is selected', (done) => {
|
||||
component.appName = 'myApp';
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { async, TestBed } from '@angular/core/testing';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { setupTestBed, IdentityUserService, TranslationService, AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import { TaskCloudService } from './task-cloud.service';
|
||||
import { taskCompleteCloudMock } from '../task-header/mocks/fake-complete-task.mock';
|
||||
@@ -34,6 +34,7 @@ describe('Task Cloud Service', () => {
|
||||
|
||||
function returnFakeTaskCompleteResults(): any {
|
||||
return {
|
||||
reply: () => {},
|
||||
oauth2Auth: {
|
||||
callCustomApi : () => {
|
||||
return Promise.resolve(taskCompleteCloudMock);
|
||||
@@ -47,6 +48,7 @@ describe('Task Cloud Service', () => {
|
||||
|
||||
function returnFakeTaskCompleteResultsError(): any {
|
||||
return {
|
||||
reply: () => {},
|
||||
oauth2Auth: {
|
||||
callCustomApi : () => {
|
||||
return Promise.reject(taskCompleteCloudMock);
|
||||
@@ -60,6 +62,7 @@ describe('Task Cloud Service', () => {
|
||||
|
||||
function returnFakeTaskDetailsResults(): any {
|
||||
return {
|
||||
reply: () => {},
|
||||
oauth2Auth: {
|
||||
callCustomApi : () => {
|
||||
return Promise.resolve(fakeTaskDetailsCloud);
|
||||
@@ -73,6 +76,7 @@ describe('Task Cloud Service', () => {
|
||||
|
||||
function returnFakeCandidateUsersResults(): any {
|
||||
return {
|
||||
reply: () => {},
|
||||
oauth2Auth: {
|
||||
callCustomApi : () => {
|
||||
return Promise.resolve(['mockuser1', 'mockuser2', 'mockuser3']);
|
||||
@@ -86,6 +90,7 @@ describe('Task Cloud Service', () => {
|
||||
|
||||
function returnFakeCandidateGroupResults(): any {
|
||||
return {
|
||||
reply: () => {},
|
||||
oauth2Auth: {
|
||||
callCustomApi : () => {
|
||||
return Promise.resolve(['mockgroup1', 'mockgroup2', 'mockgroup3']);
|
||||
@@ -104,15 +109,14 @@ describe('Task Cloud Service', () => {
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
alfrescoApiMock = TestBed.inject(AlfrescoApiService);
|
||||
identityUserService = TestBed.inject(IdentityUserService);
|
||||
translateService = TestBed.inject(TranslationService);
|
||||
service = TestBed.inject(TaskCloudService);
|
||||
spyOn(translateService, 'instant').and.callFake((key) => key ? `${key}_translated` : null);
|
||||
spyOn(identityUserService, 'getCurrentUserInfo').and.returnValue(cloudMockUser);
|
||||
|
||||
}));
|
||||
});
|
||||
|
||||
it('should complete a task', (done) => {
|
||||
const appName = 'simple-app';
|
||||
@@ -132,11 +136,13 @@ describe('Task Cloud Service', () => {
|
||||
const appName = 'simple-app';
|
||||
const taskId = '68d54a8f';
|
||||
|
||||
service.completeTask(appName, taskId).toPromise().then(() => {
|
||||
}, (error) => {
|
||||
expect(error).toBeDefined();
|
||||
done();
|
||||
});
|
||||
service.completeTask(appName, taskId).subscribe(
|
||||
() => {},
|
||||
(err) => {
|
||||
expect(err).toBeDefined();
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('should canCompleteTask', () => {
|
||||
@@ -159,7 +165,7 @@ describe('Task Cloud Service', () => {
|
||||
expect(isAssigneePropertyClickable).toEqual(true);
|
||||
});
|
||||
|
||||
it('should complete task with owner as null', async(() => {
|
||||
it('should complete task with owner as null', (done) => {
|
||||
const appName = 'simple-app';
|
||||
const taskId = '68d54a8f';
|
||||
const canCompleteTaskResult = service.canCompleteTask(emptyOwnerTaskDetailsCloudMock);
|
||||
@@ -171,8 +177,9 @@ describe('Task Cloud Service', () => {
|
||||
expect(res).not.toBeNull();
|
||||
expect(res.entry.appName).toBe('simple-app');
|
||||
expect(res.entry.id).toBe('68d54a8f');
|
||||
done();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
it('should return the task details when claiming a task', (done) => {
|
||||
const appName = 'taskp-app';
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { setupTestBed, IdentityUserService, AlfrescoApiService, IdentityUserModel } from '@alfresco/adf-core';
|
||||
import { StartTaskCloudComponent } from './start-task-cloud.component';
|
||||
import { of, throwError } from 'rxjs';
|
||||
@@ -58,7 +58,7 @@ describe('StartTaskCloudComponent', () => {
|
||||
schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
|
||||
});
|
||||
|
||||
beforeEach(async (() => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(StartTaskCloudComponent);
|
||||
component = fixture.componentInstance;
|
||||
element = fixture.nativeElement;
|
||||
@@ -72,53 +72,62 @@ describe('StartTaskCloudComponent', () => {
|
||||
spyOn(identityService, 'getCurrentUserInfo').and.returnValue(mockUser);
|
||||
spyOn(formDefinitionSelectorCloudService, 'getForms').and.returnValue(of([]));
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
});
|
||||
|
||||
describe('create task', () => {
|
||||
|
||||
it('should create new task when start button is clicked', async(() => {
|
||||
it('should create new task when start button is clicked', async () => {
|
||||
const successSpy = spyOn(component.success, 'emit');
|
||||
component.taskForm.controls['name'].setValue('fakeName');
|
||||
fixture.detectChanges();
|
||||
const createTaskButton = <HTMLElement> element.querySelector('#button-start');
|
||||
const createTaskButton = element.querySelector<HTMLElement>('#button-start');
|
||||
createTaskButton.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(createNewTaskSpy).toHaveBeenCalled();
|
||||
expect(successSpy).toHaveBeenCalled();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should send on success event when the task is started', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(createNewTaskSpy).toHaveBeenCalled();
|
||||
expect(successSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should send on success event when the task is started', async () => {
|
||||
const successSpy = spyOn(component.success, 'emit');
|
||||
component.taskForm.controls['name'].setValue('fakeName');
|
||||
component.assigneeName = 'fake-assignee';
|
||||
fixture.detectChanges();
|
||||
const createTaskButton = <HTMLElement> element.querySelector('#button-start');
|
||||
createTaskButton.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(successSpy).toHaveBeenCalledWith(taskDetailsMock);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should send on success event when only name is given', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const createTaskButton = element.querySelector<HTMLElement>('#button-start');
|
||||
createTaskButton.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(successSpy).toHaveBeenCalledWith(taskDetailsMock);
|
||||
});
|
||||
|
||||
it('should send on success event when only name is given', async () => {
|
||||
const successSpy = spyOn(component.success, 'emit');
|
||||
component.taskForm.controls['name'].setValue('fakeName');
|
||||
|
||||
fixture.detectChanges();
|
||||
const createTaskButton = <HTMLElement> element.querySelector('#button-start');
|
||||
await fixture.whenStable();
|
||||
|
||||
const createTaskButton = element.querySelector<HTMLElement>('#button-start');
|
||||
createTaskButton.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(successSpy).toHaveBeenCalled();
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(successSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not emit success event when data not present', () => {
|
||||
const successSpy = spyOn(component.success, 'emit');
|
||||
component.taskForm.controls['name'].setValue('');
|
||||
fixture.detectChanges();
|
||||
const createTaskButton = <HTMLElement> element.querySelector('#button-start');
|
||||
const createTaskButton = element.querySelector<HTMLElement>('#button-start');
|
||||
createTaskButton.click();
|
||||
expect(createNewTaskSpy).not.toHaveBeenCalled();
|
||||
expect(successSpy).not.toHaveBeenCalled();
|
||||
@@ -128,10 +137,10 @@ describe('StartTaskCloudComponent', () => {
|
||||
component.taskForm.controls['name'].setValue('fakeName');
|
||||
component.appName = 'fakeAppName';
|
||||
fixture.detectChanges();
|
||||
const assigneeInput = <HTMLElement> element.querySelector('input.adf-cloud-input');
|
||||
const assigneeInput = element.querySelector<HTMLElement>('input.adf-cloud-input');
|
||||
assigneeInput.nodeValue = 'a';
|
||||
fixture.detectChanges();
|
||||
const createTaskButton = <HTMLElement> element.querySelector('#button-start');
|
||||
const createTaskButton = element.querySelector<HTMLElement>('#button-start');
|
||||
createTaskButton.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
@@ -145,7 +154,7 @@ describe('StartTaskCloudComponent', () => {
|
||||
component.taskForm.controls['name'].setValue('fakeName');
|
||||
component.appName = 'fakeAppName';
|
||||
fixture.detectChanges();
|
||||
const createTaskButton = <HTMLElement> element.querySelector('#button-start');
|
||||
const createTaskButton = element.querySelector<HTMLElement>('#button-start');
|
||||
createTaskButton.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
@@ -200,10 +209,10 @@ describe('StartTaskCloudComponent', () => {
|
||||
createNewTaskSpy.and.returnValue(throwError({}));
|
||||
component.appName = 'fakeAppName';
|
||||
fixture.detectChanges();
|
||||
const assigneeInput = <HTMLElement> element.querySelector('input.adf-cloud-input');
|
||||
const assigneeInput = element.querySelector<HTMLElement>('input.adf-cloud-input');
|
||||
assigneeInput.nodeValue = 'a';
|
||||
fixture.detectChanges();
|
||||
const createTaskButton = <HTMLElement> element.querySelector('#button-start');
|
||||
const createTaskButton = element.querySelector<HTMLElement>('#button-start');
|
||||
createTaskButton.click();
|
||||
fixture.detectChanges();
|
||||
expect(errorSpy).toHaveBeenCalled();
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
|
||||
import { SimpleChange } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { setupTestBed } from '@alfresco/adf-core';
|
||||
@@ -94,7 +94,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should fetch process definitions when processDefinitionName filter property is set', async(() => {
|
||||
it('should fetch process definitions when processDefinitionName filter property is set', async () => {
|
||||
const processSpy = spyOn(taskService, 'getProcessDefinitions').and.returnValue(of([
|
||||
new ProcessDefinitionCloud({ id: 'fake-id', name: 'fake-name' })
|
||||
]));
|
||||
@@ -105,62 +105,66 @@ describe('EditServiceTaskFilterCloudComponent', () => {
|
||||
component.ngOnChanges({ 'id': taskFilterIdChange });
|
||||
fixture.detectChanges();
|
||||
const controller = component.editTaskFilterForm.get('processDefinitionName');
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(processSpy).toHaveBeenCalled();
|
||||
expect(controller).toBeDefined();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should display filter name as title', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(processSpy).toHaveBeenCalled();
|
||||
expect(controller).toBeDefined();
|
||||
});
|
||||
|
||||
it('should display filter name as title', async () => {
|
||||
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
|
||||
component.ngOnChanges({ 'id': taskFilterIdChange });
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const title = fixture.debugElement.nativeElement.querySelector('#adf-edit-task-filter-title-id');
|
||||
const subTitle = fixture.debugElement.nativeElement.querySelector('#adf-edit-task-filter-sub-title-id');
|
||||
expect(title.innerText).toEqual('FakeInvolvedTasks');
|
||||
expect(subTitle.innerText.trim()).toEqual('ADF_CLOUD_EDIT_TASK_FILTER.TITLE');
|
||||
}));
|
||||
});
|
||||
|
||||
it('should not display filter name if showFilterName is false', async(() => {
|
||||
it('should not display filter name if showFilterName is false', async () => {
|
||||
const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true);
|
||||
component.showTaskFilterName = false;
|
||||
component.ngOnChanges({ 'id': taskFilterIdChange });
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const title = fixture.debugElement.nativeElement.querySelector('#adf-edit-task-filter-title-id');
|
||||
expect(title).toBeNull();
|
||||
});
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
expect(title).toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not display mat-spinner if isloading set to false', async(() => {
|
||||
it('should not display mat-spinner if isloading set to false', async () => {
|
||||
const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true);
|
||||
component.ngOnChanges({ 'id': taskFilterIdChange });
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const title = fixture.debugElement.nativeElement.querySelector('#adf-edit-task-filter-title-id');
|
||||
const subTitle = fixture.debugElement.nativeElement.querySelector('#adf-edit-task-filter-sub-title-id');
|
||||
const matSpinnerElement = fixture.debugElement.nativeElement.querySelector('.adf-cloud-edit-task-filter-loading-margin');
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
expect(matSpinnerElement).toBeNull();
|
||||
expect(title.innerText).toEqual('FakeInvolvedTasks');
|
||||
expect(subTitle.innerText.trim()).toEqual('ADF_CLOUD_EDIT_TASK_FILTER.TITLE');
|
||||
});
|
||||
}));
|
||||
expect(matSpinnerElement).toBeNull();
|
||||
expect(title.innerText).toEqual('FakeInvolvedTasks');
|
||||
expect(subTitle.innerText.trim()).toEqual('ADF_CLOUD_EDIT_TASK_FILTER.TITLE');
|
||||
});
|
||||
|
||||
it('should display mat-spinner if isloading set to true', async(() => {
|
||||
it('should display mat-spinner if isloading set to true', async () => {
|
||||
component.isLoading = true;
|
||||
const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true);
|
||||
component.ngOnChanges({ 'id': taskFilterIdChange });
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const matSpinnerElement = fixture.debugElement.nativeElement.querySelector('.adf-cloud-edit-task-filter-loading-margin');
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
expect(matSpinnerElement).toBeDefined();
|
||||
});
|
||||
}));
|
||||
expect(matSpinnerElement).toBeDefined();
|
||||
});
|
||||
|
||||
describe('EditServiceTaskFilter form', () => {
|
||||
|
||||
@@ -170,29 +174,25 @@ describe('EditServiceTaskFilterCloudComponent', () => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should defined editTaskFilter form ', () => {
|
||||
it('should create editTaskFilter form with default user task properties', async () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const appNameController = component.editTaskFilterForm.get('appName');
|
||||
const statusController = component.editTaskFilterForm.get('status');
|
||||
const sortController = component.editTaskFilterForm.get('sort');
|
||||
const orderController = component.editTaskFilterForm.get('order');
|
||||
const activityNameController = component.editTaskFilterForm.get('activityName');
|
||||
expect(component.editTaskFilterForm).toBeDefined();
|
||||
expect(appNameController.value).toBe('mock-app-name');
|
||||
expect(statusController.value).toBe('COMPLETED');
|
||||
expect(sortController.value).toBe('id');
|
||||
expect(orderController.value).toBe('ASC');
|
||||
expect(activityNameController.value).toBe('fake-activity');
|
||||
});
|
||||
|
||||
it('should create editTaskFilter form with default user task properties', async(() => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const appNameController = component.editTaskFilterForm.get('appName');
|
||||
const statusController = component.editTaskFilterForm.get('status');
|
||||
const sortController = component.editTaskFilterForm.get('sort');
|
||||
const orderController = component.editTaskFilterForm.get('order');
|
||||
const activityNameController = component.editTaskFilterForm.get('activityName');
|
||||
expect(component.editTaskFilterForm).toBeDefined();
|
||||
expect(appNameController.value).toBe('mock-app-name');
|
||||
expect(statusController.value).toBe('COMPLETED');
|
||||
expect(sortController.value).toBe('id');
|
||||
expect(orderController.value).toBe('ASC');
|
||||
expect(activityNameController.value).toBe('fake-activity');
|
||||
});
|
||||
}));
|
||||
|
||||
describe('Save & Delete buttons', () => {
|
||||
it('should disable save and delete button for default task filters', async(() => {
|
||||
it('should disable save and delete button for default task filters', async () => {
|
||||
getTaskFilterSpy.and.returnValue(of({
|
||||
name: 'ADF_CLOUD_SERVICE_TASK_FILTERS.ALL_SERVICE_TASKS',
|
||||
id: 'filter-id',
|
||||
@@ -210,16 +210,17 @@ describe('EditServiceTaskFilterCloudComponent', () => {
|
||||
component.toggleFilterActions = true;
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-save"]');
|
||||
expect(saveButton.disabled).toBe(true);
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-delete"]');
|
||||
expect(deleteButton.disabled).toBe(true);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should enable delete button for custom task filters', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-save"]');
|
||||
expect(saveButton.disabled).toBe(true);
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-delete"]');
|
||||
expect(deleteButton.disabled).toBe(true);
|
||||
});
|
||||
|
||||
it('should enable delete button for custom task filters', async () => {
|
||||
const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true);
|
||||
component.ngOnChanges({ 'id': taskFilterIdChange });
|
||||
fixture.detectChanges();
|
||||
@@ -227,14 +228,15 @@ describe('EditServiceTaskFilterCloudComponent', () => {
|
||||
component.toggleFilterActions = true;
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-save"]');
|
||||
expect(saveButton.disabled).toBe(true);
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-delete"]');
|
||||
expect(deleteButton.disabled).toBe(false);
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-save"]');
|
||||
expect(saveButton.disabled).toBe(true);
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-delete"]');
|
||||
expect(deleteButton.disabled).toBe(false);
|
||||
});
|
||||
|
||||
it('should enable save button if the filter is changed for custom task filters', (done) => {
|
||||
const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true);
|
||||
@@ -263,20 +265,21 @@ describe('EditServiceTaskFilterCloudComponent', () => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should disable save button if the filter is not changed for custom filter', async(() => {
|
||||
it('should disable save button if the filter is not changed for custom filter', async () => {
|
||||
component.toggleFilterActions = true;
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-save"]');
|
||||
expect(saveButton.disabled).toBe(true);
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-save"]');
|
||||
expect(saveButton.disabled).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('SaveAs button', () => {
|
||||
it('should disable saveAs button if the process filter is not changed for default filter', async(() => {
|
||||
it('should disable saveAs button if the process filter is not changed for default filter', async () => {
|
||||
getTaskFilterSpy.and.returnValue(of({
|
||||
name: 'ADF_CLOUD_TASK_FILTERS.MY_TASKS',
|
||||
id: 'filter-id',
|
||||
@@ -294,23 +297,25 @@ describe('EditServiceTaskFilterCloudComponent', () => {
|
||||
component.toggleFilterActions = true;
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-saveAs"]');
|
||||
expect(saveButton.disabled).toEqual(true);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should disable saveAs button if the process filter is not changed for custom filter', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-saveAs"]');
|
||||
expect(saveButton.disabled).toEqual(true);
|
||||
});
|
||||
|
||||
it('should disable saveAs button if the process filter is not changed for custom filter', async () => {
|
||||
component.toggleFilterActions = true;
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-saveAs"]');
|
||||
expect(saveButton.disabled).toEqual(true);
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-saveAs"]');
|
||||
expect(saveButton.disabled).toEqual(true);
|
||||
});
|
||||
|
||||
it('should enable saveAs button if the filter values are changed for default filter', (done) => {
|
||||
getTaskFilterSpy.and.returnValue(of({
|
||||
@@ -375,31 +380,38 @@ describe('EditServiceTaskFilterCloudComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should display current task filter details', async(() => {
|
||||
it('should display current task filter details', async () => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
fixture.detectChanges();
|
||||
const stateElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-status"]');
|
||||
const assigneeElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-assignee"]');
|
||||
const sortElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-sort"]');
|
||||
const orderElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-order"]');
|
||||
expect(assigneeElement).toBeDefined();
|
||||
expect(stateElement.textContent.trim()).toBe('ADF_CLOUD_SERVICE_TASK_FILTERS.STATUS.COMPLETED');
|
||||
expect(sortElement.textContent.trim()).toBe('id');
|
||||
expect(orderElement.textContent.trim()).toBe('ADF_CLOUD_TASK_FILTERS.DIRECTION.ASCENDING');
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
it('should display all the statuses that are defined in the task filter', async(() => {
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const stateElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-status"]');
|
||||
const assigneeElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-assignee"]');
|
||||
const sortElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-sort"]');
|
||||
const orderElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-order"]');
|
||||
expect(assigneeElement).toBeDefined();
|
||||
expect(stateElement.textContent.trim()).toBe('ADF_CLOUD_SERVICE_TASK_FILTERS.STATUS.COMPLETED');
|
||||
expect(sortElement.textContent.trim()).toBe('id');
|
||||
expect(orderElement.textContent.trim()).toBe('ADF_CLOUD_TASK_FILTERS.DIRECTION.ASCENDING');
|
||||
});
|
||||
|
||||
it('should display all the statuses that are defined in the task filter', async () => {
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const stateElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-status"]');
|
||||
stateElement.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const statusOptions = fixture.debugElement.queryAll(By.css('[data-automation-id="adf-cloud-edit-task-property-options-status"]'));
|
||||
|
||||
@@ -408,82 +420,98 @@ describe('EditServiceTaskFilterCloudComponent', () => {
|
||||
expect(statusOptions[2].nativeElement.textContent.trim()).toBe('ADF_CLOUD_SERVICE_TASK_FILTERS.STATUS.COMPLETED');
|
||||
expect(statusOptions[3].nativeElement.textContent.trim()).toBe('ADF_CLOUD_SERVICE_TASK_FILTERS.STATUS.CANCELLED');
|
||||
expect(statusOptions[4].nativeElement.textContent.trim()).toBe('ADF_CLOUD_SERVICE_TASK_FILTERS.STATUS.ERROR');
|
||||
}));
|
||||
});
|
||||
|
||||
it('should display sort drop down', async(() => {
|
||||
it('should display sort drop down', async () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const sortElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-sort"]');
|
||||
sortElement.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const sortOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(sortOptions.length).toEqual(4);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should display order drop down', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const sortOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(sortOptions.length).toEqual(4);
|
||||
});
|
||||
|
||||
it('should display order drop down', async () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const orderElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-order"]');
|
||||
orderElement.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const orderOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(orderOptions.length).toEqual(2);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should have floating labels when values are present', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const orderOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(orderOptions.length).toEqual(2);
|
||||
});
|
||||
|
||||
it('should have floating labels when values are present', async () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const inputLabelsNodes = document.querySelectorAll('mat-form-field');
|
||||
inputLabelsNodes.forEach(labelNode => {
|
||||
expect(labelNode.getAttribute('ng-reflect-float-label')).toBe('auto');
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
it('should able to build a editTaskFilter form with default properties if input is empty', async(() => {
|
||||
it('should able to build a editTaskFilter form with default properties if input is empty', async () => {
|
||||
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
|
||||
component.ngOnChanges({ 'id': taskFilterIdChange });
|
||||
component.filterProperties = [];
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const stateController = component.editTaskFilterForm.get('status');
|
||||
const sortController = component.editTaskFilterForm.get('sort');
|
||||
const orderController = component.editTaskFilterForm.get('order');
|
||||
const activityNameController = component.editTaskFilterForm.get('activityName');
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(component.taskFilterProperties.length).toBe(5);
|
||||
expect(component.editTaskFilterForm).toBeDefined();
|
||||
expect(stateController.value).toBe('COMPLETED');
|
||||
expect(sortController.value).toBe('id');
|
||||
expect(orderController.value).toBe('ASC');
|
||||
expect(activityNameController.value).toBe('fake-activity');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should able to fetch running applications when appName property defined in the input', async(() => {
|
||||
expect(component.taskFilterProperties.length).toBe(5);
|
||||
expect(component.editTaskFilterForm).toBeDefined();
|
||||
expect(stateController.value).toBe('COMPLETED');
|
||||
expect(sortController.value).toBe('id');
|
||||
expect(orderController.value).toBe('ASC');
|
||||
expect(activityNameController.value).toBe('fake-activity');
|
||||
});
|
||||
|
||||
it('should able to fetch running applications when appName property defined in the input', async () => {
|
||||
component.filterProperties = ['appName', 'processInstanceId', 'priority'];
|
||||
fixture.detectChanges();
|
||||
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
|
||||
component.ngOnChanges({ 'id': taskFilterIdChange });
|
||||
const appController = component.editTaskFilterForm.get('appName');
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(getRunningApplicationsSpy).toHaveBeenCalled();
|
||||
expect(appController).toBeDefined();
|
||||
expect(appController.value).toBe('mock-app-name');
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(getRunningApplicationsSpy).toHaveBeenCalled();
|
||||
expect(appController).toBeDefined();
|
||||
expect(appController.value).toBe('mock-app-name');
|
||||
});
|
||||
});
|
||||
|
||||
describe('sort properties', () => {
|
||||
|
||||
it('should display default sort properties', async(() => {
|
||||
it('should display default sort properties', async () => {
|
||||
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
|
||||
component.ngOnChanges({ 'id': taskFilterIdChange });
|
||||
fixture.detectChanges();
|
||||
@@ -492,16 +520,17 @@ describe('EditServiceTaskFilterCloudComponent', () => {
|
||||
fixture.detectChanges();
|
||||
const sortElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-sort"]');
|
||||
sortElement.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const sortController = component.editTaskFilterForm.get('sort');
|
||||
const sortOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(sortController.value).toBe('id');
|
||||
expect(sortOptions.length).toEqual(4);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should display sort properties when sort properties are specified', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const sortController = component.editTaskFilterForm.get('sort');
|
||||
const sortOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(sortController.value).toBe('id');
|
||||
expect(sortOptions.length).toEqual(4);
|
||||
});
|
||||
|
||||
it('should display sort properties when sort properties are specified', async () => {
|
||||
component.sortProperties = ['id', 'name', 'processInstanceId'];
|
||||
getTaskFilterSpy.and.returnValue(of({
|
||||
sort: 'my-custom-sort',
|
||||
@@ -517,17 +546,18 @@ describe('EditServiceTaskFilterCloudComponent', () => {
|
||||
fixture.detectChanges();
|
||||
const sortElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-sort"]');
|
||||
sortElement.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const sortController = component.editTaskFilterForm.get('sort');
|
||||
const sortOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(component.sortProperties.length).toBe(3);
|
||||
expect(sortController.value).toBe('my-custom-sort');
|
||||
expect(sortOptions.length).toEqual(3);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should display default sort properties if input is empty', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const sortController = component.editTaskFilterForm.get('sort');
|
||||
const sortOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(component.sortProperties.length).toBe(3);
|
||||
expect(sortController.value).toBe('my-custom-sort');
|
||||
expect(sortOptions.length).toEqual(3);
|
||||
});
|
||||
|
||||
it('should display default sort properties if input is empty', async () => {
|
||||
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
|
||||
component.ngOnChanges({ 'id': taskFilterIdChange });
|
||||
fixture.detectChanges();
|
||||
@@ -538,39 +568,41 @@ describe('EditServiceTaskFilterCloudComponent', () => {
|
||||
fixture.detectChanges();
|
||||
const sortElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-sort"]');
|
||||
sortElement.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const sortController = component.editTaskFilterForm.get('sort');
|
||||
const sortOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(sortController.value).toBe('id');
|
||||
expect(sortOptions.length).toEqual(4);
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
const sortController = component.editTaskFilterForm.get('sort');
|
||||
const sortOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(sortController.value).toBe('id');
|
||||
expect(sortOptions.length).toEqual(4);
|
||||
});
|
||||
});
|
||||
|
||||
describe('filter actions', () => {
|
||||
|
||||
it('should display default filter actions', async(() => {
|
||||
it('should display default filter actions', async () => {
|
||||
component.toggleFilterActions = true;
|
||||
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
|
||||
component.ngOnChanges({ 'id': taskFilterIdChange });
|
||||
fixture.detectChanges();
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const saveAsButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-saveAs"]');
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-save"]');
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-delete"]');
|
||||
expect(component.taskFilterActions.map(action => action.actionType)).toEqual(['save', 'saveAs', 'delete']);
|
||||
expect(component.taskFilterActions.length).toBe(3);
|
||||
expect(saveButton.disabled).toBe(true);
|
||||
expect(saveAsButton.disabled).toBe(true);
|
||||
expect(deleteButton.disabled).toBe(false);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should display filter actions when input actions are specified', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const saveAsButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-saveAs"]');
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-save"]');
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-delete"]');
|
||||
expect(component.taskFilterActions.map(action => action.actionType)).toEqual(['save', 'saveAs', 'delete']);
|
||||
expect(component.taskFilterActions.length).toBe(3);
|
||||
expect(saveButton.disabled).toBe(true);
|
||||
expect(saveAsButton.disabled).toBe(true);
|
||||
expect(deleteButton.disabled).toBe(false);
|
||||
});
|
||||
|
||||
it('should display filter actions when input actions are specified', async () => {
|
||||
component.actions = ['save'];
|
||||
fixture.detectChanges();
|
||||
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
|
||||
@@ -580,18 +612,19 @@ describe('EditServiceTaskFilterCloudComponent', () => {
|
||||
fixture.detectChanges();
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-save"]');
|
||||
expect(component.taskFilterActions.map(action => action.actionType)).toEqual(['save']);
|
||||
expect(component.taskFilterActions.length).toBe(1);
|
||||
expect(saveButton.disabled).toBeTruthy();
|
||||
const saveAsButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-saveAs"]');
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-delete"]');
|
||||
expect(saveAsButton).toBeFalsy();
|
||||
expect(deleteButton).toBeFalsy();
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-save"]');
|
||||
expect(component.taskFilterActions.map(action => action.actionType)).toEqual(['save']);
|
||||
expect(component.taskFilterActions.length).toBe(1);
|
||||
expect(saveButton.disabled).toBeTruthy();
|
||||
const saveAsButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-saveAs"]');
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-delete"]');
|
||||
expect(saveAsButton).toBeFalsy();
|
||||
expect(deleteButton).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('edit filter actions', () => {
|
||||
@@ -603,7 +636,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
|
||||
spyOn(component.action, 'emit').and.callThrough();
|
||||
});
|
||||
|
||||
it('should emit save event and save the filter on click save button', async(() => {
|
||||
it('should emit save event and save the filter on click save button', fakeAsync(() => {
|
||||
component.toggleFilterActions = true;
|
||||
spyOn(service, 'updateFilter').and.returnValue(of(null));
|
||||
fixture.detectChanges();
|
||||
@@ -626,7 +659,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should emit delete event and delete the filter on click of delete button', async(() => {
|
||||
it('should emit delete event and delete the filter on click of delete button', fakeAsync(() => {
|
||||
component.toggleFilterActions = true;
|
||||
spyOn(service, 'deleteFilter').and.returnValue(of(null));
|
||||
fixture.detectChanges();
|
||||
@@ -646,7 +679,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should emit saveAs event and add filter on click saveAs button', async(() => {
|
||||
it('should emit saveAs event and add filter on click saveAs button', fakeAsync(() => {
|
||||
component.toggleFilterActions = true;
|
||||
spyOn(service, 'addFilter').and.returnValue(of(null));
|
||||
fixture.detectChanges();
|
||||
@@ -670,7 +703,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should call restore default filters service on deletion of last filter', async(() => {
|
||||
it('should call restore default filters service on deletion of last filter', fakeAsync(() => {
|
||||
component.toggleFilterActions = true;
|
||||
spyOn(service, 'deleteFilter').and.returnValue(of([]));
|
||||
const restoreDefaultFiltersSpy = spyOn(component, 'restoreDefaultTaskFilters').and.returnValue(of([]));
|
||||
@@ -692,7 +725,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not call restore default filters service on deletion of first filter', async(() => {
|
||||
it('should not call restore default filters service on deletion of first filter', fakeAsync(() => {
|
||||
component.toggleFilterActions = true;
|
||||
spyOn(service, 'deleteFilter').and.returnValue(of([{ name: 'mock-filter-name' }]));
|
||||
const restoreDefaultFiltersSpy = spyOn(component, 'restoreDefaultTaskFilters').and.returnValue(of([]));
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
|
||||
import { SimpleChange } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
|
||||
@@ -112,7 +112,7 @@ describe('EditTaskFilterCloudComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should fetch process definitions when processDefinitionName filter property is set', async(() => {
|
||||
it('should fetch process definitions when processDefinitionName filter property is set', async () => {
|
||||
const processSpy = spyOn(taskService, 'getProcessDefinitions').and.returnValue(of([new ProcessDefinitionCloud({ id: 'fake-id', name: 'fake-name' })]));
|
||||
fixture.detectChanges();
|
||||
component.filterProperties = ['processDefinitionName'];
|
||||
@@ -121,62 +121,66 @@ describe('EditTaskFilterCloudComponent', () => {
|
||||
component.ngOnChanges({ 'id': taskFilterIdChange });
|
||||
fixture.detectChanges();
|
||||
const controller = component.editTaskFilterForm.get('processDefinitionName');
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(processSpy).toHaveBeenCalled();
|
||||
expect(controller).toBeDefined();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should display filter name as title', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(processSpy).toHaveBeenCalled();
|
||||
expect(controller).toBeDefined();
|
||||
});
|
||||
|
||||
it('should display filter name as title', async () => {
|
||||
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
|
||||
component.ngOnChanges({ 'id': taskFilterIdChange });
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const title = fixture.debugElement.nativeElement.querySelector('#adf-edit-task-filter-title-id');
|
||||
const subTitle = fixture.debugElement.nativeElement.querySelector('#adf-edit-task-filter-sub-title-id');
|
||||
expect(title.innerText).toEqual('FakeInvolvedTasks');
|
||||
expect(subTitle.innerText.trim()).toEqual('ADF_CLOUD_EDIT_TASK_FILTER.TITLE');
|
||||
}));
|
||||
});
|
||||
|
||||
it('should not display filter name if showFilterName is false', async(() => {
|
||||
it('should not display filter name if showFilterName is false', async () => {
|
||||
const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true);
|
||||
component.showTaskFilterName = false;
|
||||
component.ngOnChanges({ 'id': taskFilterIdChange });
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const title = fixture.debugElement.nativeElement.querySelector('#adf-edit-task-filter-title-id');
|
||||
expect(title).toBeNull();
|
||||
});
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
expect(title).toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not display mat-spinner if isloading set to false', async(() => {
|
||||
it('should not display mat-spinner if isloading set to false', async () => {
|
||||
const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true);
|
||||
component.ngOnChanges({ 'id': taskFilterIdChange });
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const title = fixture.debugElement.nativeElement.querySelector('#adf-edit-task-filter-title-id');
|
||||
const subTitle = fixture.debugElement.nativeElement.querySelector('#adf-edit-task-filter-sub-title-id');
|
||||
const matSpinnerElement = fixture.debugElement.nativeElement.querySelector('.adf-cloud-edit-task-filter-loading-margin');
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
expect(matSpinnerElement).toBeNull();
|
||||
expect(title.innerText).toEqual('FakeInvolvedTasks');
|
||||
expect(subTitle.innerText.trim()).toEqual('ADF_CLOUD_EDIT_TASK_FILTER.TITLE');
|
||||
});
|
||||
}));
|
||||
expect(matSpinnerElement).toBeNull();
|
||||
expect(title.innerText).toEqual('FakeInvolvedTasks');
|
||||
expect(subTitle.innerText.trim()).toEqual('ADF_CLOUD_EDIT_TASK_FILTER.TITLE');
|
||||
});
|
||||
|
||||
it('should display mat-spinner if isloading set to true', async(() => {
|
||||
it('should display mat-spinner if isloading set to true', async () => {
|
||||
component.isLoading = true;
|
||||
const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true);
|
||||
component.ngOnChanges({ 'id': taskFilterIdChange });
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const matSpinnerElement = fixture.debugElement.nativeElement.querySelector('.adf-cloud-edit-task-filter-loading-margin');
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
expect(matSpinnerElement).toBeDefined();
|
||||
});
|
||||
}));
|
||||
expect(matSpinnerElement).toBeDefined();
|
||||
});
|
||||
|
||||
describe('EditTaskFilter form', () => {
|
||||
|
||||
@@ -186,28 +190,24 @@ describe('EditTaskFilterCloudComponent', () => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should defined editTaskFilter form ', () => {
|
||||
it('should create editTaskFilter form with default user task properties', async () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const stateController = component.editTaskFilterForm.get('status');
|
||||
const sortController = component.editTaskFilterForm.get('sort');
|
||||
const orderController = component.editTaskFilterForm.get('order');
|
||||
const assigneeController = component.editTaskFilterForm.get('assignee');
|
||||
expect(component.editTaskFilterForm).toBeDefined();
|
||||
expect(assigneeController).toBeDefined();
|
||||
expect(stateController.value).toBe('CREATED');
|
||||
expect(sortController.value).toBe('id');
|
||||
expect(orderController.value).toBe('ASC');
|
||||
expect(assigneeController.value).toBe('fake-involved');
|
||||
});
|
||||
|
||||
it('should create editTaskFilter form with default user task properties', async(() => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const stateController = component.editTaskFilterForm.get('status');
|
||||
const sortController = component.editTaskFilterForm.get('sort');
|
||||
const orderController = component.editTaskFilterForm.get('order');
|
||||
const assigneeController = component.editTaskFilterForm.get('assignee');
|
||||
expect(component.editTaskFilterForm).toBeDefined();
|
||||
expect(assigneeController).toBeDefined();
|
||||
expect(stateController.value).toBe('CREATED');
|
||||
expect(sortController.value).toBe('id');
|
||||
expect(orderController.value).toBe('ASC');
|
||||
expect(assigneeController.value).toBe('fake-involved');
|
||||
});
|
||||
}));
|
||||
|
||||
describe('Save & Delete buttons', () => {
|
||||
it('should disable save and delete button for default task filters', async(() => {
|
||||
it('should disable save and delete button for default task filters', async () => {
|
||||
getTaskFilterSpy.and.returnValue(of({
|
||||
name: 'ADF_CLOUD_TASK_FILTERS.MY_TASKS',
|
||||
id: 'filter-id',
|
||||
@@ -225,16 +225,17 @@ describe('EditTaskFilterCloudComponent', () => {
|
||||
component.toggleFilterActions = true;
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-save"]');
|
||||
expect(saveButton.disabled).toBe(true);
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-delete"]');
|
||||
expect(deleteButton.disabled).toBe(true);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should enable delete button for custom task filters', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-save"]');
|
||||
expect(saveButton.disabled).toBe(true);
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-delete"]');
|
||||
expect(deleteButton.disabled).toBe(true);
|
||||
});
|
||||
|
||||
it('should enable delete button for custom task filters', async () => {
|
||||
const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true);
|
||||
component.ngOnChanges({ 'id': taskFilterIdChange });
|
||||
fixture.detectChanges();
|
||||
@@ -242,14 +243,15 @@ describe('EditTaskFilterCloudComponent', () => {
|
||||
component.toggleFilterActions = true;
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-save"]');
|
||||
expect(saveButton.disabled).toBe(true);
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-delete"]');
|
||||
expect(deleteButton.disabled).toBe(false);
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-save"]');
|
||||
expect(saveButton.disabled).toBe(true);
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-delete"]');
|
||||
expect(deleteButton.disabled).toBe(false);
|
||||
});
|
||||
|
||||
it('should enable save button if the filter is changed for custom task filters', (done) => {
|
||||
const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true);
|
||||
@@ -278,20 +280,21 @@ describe('EditTaskFilterCloudComponent', () => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should disable save button if the filter is not changed for custom filter', async(() => {
|
||||
it('should disable save button if the filter is not changed for custom filter', async () => {
|
||||
component.toggleFilterActions = true;
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-save"]');
|
||||
expect(saveButton.disabled).toBe(true);
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-save"]');
|
||||
expect(saveButton.disabled).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('SaveAs button', () => {
|
||||
it('should disable saveAs button if the process filter is not changed for default filter', async(() => {
|
||||
it('should disable saveAs button if the process filter is not changed for default filter', async () => {
|
||||
getTaskFilterSpy.and.returnValue(of({
|
||||
name: 'ADF_CLOUD_TASK_FILTERS.MY_TASKS',
|
||||
id: 'filter-id',
|
||||
@@ -309,23 +312,25 @@ describe('EditTaskFilterCloudComponent', () => {
|
||||
component.toggleFilterActions = true;
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-saveAs"]');
|
||||
expect(saveButton.disabled).toEqual(true);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should disable saveAs button if the process filter is not changed for custom filter', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-saveAs"]');
|
||||
expect(saveButton.disabled).toEqual(true);
|
||||
});
|
||||
|
||||
it('should disable saveAs button if the process filter is not changed for custom filter', async () => {
|
||||
component.toggleFilterActions = true;
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-saveAs"]');
|
||||
expect(saveButton.disabled).toEqual(true);
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-saveAs"]');
|
||||
expect(saveButton.disabled).toEqual(true);
|
||||
});
|
||||
|
||||
it('should enable saveAs button if the filter values are changed for default filter', (done) => {
|
||||
getTaskFilterSpy.and.returnValue(of({
|
||||
@@ -390,24 +395,27 @@ describe('EditTaskFilterCloudComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should display current task filter details', async(() => {
|
||||
it('should display current task filter details', async () => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
fixture.detectChanges();
|
||||
const stateElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-status"]');
|
||||
const assigneeElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-assignee"]');
|
||||
const sortElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-sort"]');
|
||||
const orderElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-order"]');
|
||||
expect(assigneeElement).toBeDefined();
|
||||
expect(stateElement.textContent.trim()).toBe('ADF_CLOUD_TASK_FILTERS.STATUS.CREATED');
|
||||
expect(sortElement.textContent.trim()).toBe('id');
|
||||
expect(orderElement.textContent.trim()).toBe('ADF_CLOUD_TASK_FILTERS.DIRECTION.ASCENDING');
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
it('should display all the statuses that are defined in the task filter', async(() => {
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const stateElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-status"]');
|
||||
const assigneeElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-assignee"]');
|
||||
const sortElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-sort"]');
|
||||
const orderElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-order"]');
|
||||
expect(assigneeElement).toBeDefined();
|
||||
expect(stateElement.textContent.trim()).toBe('ADF_CLOUD_TASK_FILTERS.STATUS.CREATED');
|
||||
expect(sortElement.textContent.trim()).toBe('id');
|
||||
expect(orderElement.textContent.trim()).toBe('ADF_CLOUD_TASK_FILTERS.DIRECTION.ASCENDING');
|
||||
});
|
||||
|
||||
it('should display all the statuses that are defined in the task filter', () => {
|
||||
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
@@ -425,37 +433,39 @@ describe('EditTaskFilterCloudComponent', () => {
|
||||
expect(statusOptions[3].nativeElement.textContent.trim()).toBe('ADF_CLOUD_TASK_FILTERS.STATUS.SUSPENDED');
|
||||
expect(statusOptions[4].nativeElement.textContent.trim()).toBe('ADF_CLOUD_TASK_FILTERS.STATUS.CANCELLED');
|
||||
expect(statusOptions[5].nativeElement.textContent.trim()).toBe('ADF_CLOUD_TASK_FILTERS.STATUS.COMPLETED');
|
||||
}));
|
||||
});
|
||||
|
||||
it('should display sort drop down', async(() => {
|
||||
it('should display sort drop down', async () => {
|
||||
fixture.detectChanges();
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
fixture.detectChanges();
|
||||
const sortElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-sort"]');
|
||||
sortElement.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const sortOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(sortOptions.length).toEqual(4);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should display order drop down', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const sortOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(sortOptions.length).toEqual(4);
|
||||
});
|
||||
|
||||
it('should display order drop down', async () => {
|
||||
fixture.detectChanges();
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
fixture.detectChanges();
|
||||
const orderElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-order"]');
|
||||
orderElement.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const orderOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(orderOptions.length).toEqual(2);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should able to build a editTaskFilter form with default properties if input is empty', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const orderOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(orderOptions.length).toEqual(2);
|
||||
});
|
||||
|
||||
it('should able to build a editTaskFilter form with default properties if input is empty', async () => {
|
||||
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
|
||||
component.ngOnChanges({ 'id': taskFilterIdChange });
|
||||
component.filterProperties = [];
|
||||
@@ -463,57 +473,60 @@ describe('EditTaskFilterCloudComponent', () => {
|
||||
const stateController = component.editTaskFilterForm.get('status');
|
||||
const sortController = component.editTaskFilterForm.get('sort');
|
||||
const orderController = component.editTaskFilterForm.get('order');
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(component.taskFilterProperties.length).toBe(4);
|
||||
expect(component.editTaskFilterForm).toBeDefined();
|
||||
expect(stateController.value).toBe('CREATED');
|
||||
expect(sortController.value).toBe('id');
|
||||
expect(orderController.value).toBe('ASC');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should able to fetch running applications when appName property defined in the input', async(() => {
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(component.taskFilterProperties.length).toBe(4);
|
||||
expect(component.editTaskFilterForm).toBeDefined();
|
||||
expect(stateController.value).toBe('CREATED');
|
||||
expect(sortController.value).toBe('id');
|
||||
expect(orderController.value).toBe('ASC');
|
||||
});
|
||||
|
||||
it('should able to fetch running applications when appName property defined in the input', async () => {
|
||||
component.filterProperties = ['appName', 'processInstanceId', 'priority'];
|
||||
fixture.detectChanges();
|
||||
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
|
||||
component.ngOnChanges({ 'id': taskFilterIdChange });
|
||||
const appController = component.editTaskFilterForm.get('appName');
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(getRunningApplicationsSpy).toHaveBeenCalled();
|
||||
expect(appController).toBeDefined();
|
||||
expect(appController.value).toBe('mock-app-name');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should fetch data in completedBy filter', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(getRunningApplicationsSpy).toHaveBeenCalled();
|
||||
expect(appController).toBeDefined();
|
||||
expect(appController.value).toBe('mock-app-name');
|
||||
});
|
||||
|
||||
it('should fetch data in completedBy filter', async () => {
|
||||
component.filterProperties = ['appName', 'processInstanceId', 'priority', 'completedBy'];
|
||||
fixture.detectChanges();
|
||||
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
|
||||
component.ngOnChanges({ 'id': taskFilterIdChange });
|
||||
const appController = component.editTaskFilterForm.get('completedBy');
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(appController).toBeDefined();
|
||||
expect(JSON.stringify(appController.value)).toBe(JSON.stringify({
|
||||
id: 'mock-id',
|
||||
username: 'testCompletedByUser'
|
||||
}));
|
||||
});
|
||||
}));
|
||||
|
||||
it('should show completedBy filter', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(appController).toBeDefined();
|
||||
expect(JSON.stringify(appController.value)).toBe(JSON.stringify({
|
||||
id: 'mock-id',
|
||||
username: 'testCompletedByUser'
|
||||
}));
|
||||
});
|
||||
|
||||
it('should show completedBy filter', async () => {
|
||||
component.filterProperties = ['appName', 'processInstanceId', 'priority', 'completedBy'];
|
||||
fixture.detectChanges();
|
||||
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
|
||||
component.ngOnChanges({ 'id': taskFilterIdChange });
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const peopleCloudComponent = fixture.debugElement.nativeElement.querySelector('adf-cloud-people');
|
||||
expect(peopleCloudComponent).toBeTruthy();
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
const peopleCloudComponent = fixture.debugElement.nativeElement.querySelector('adf-cloud-people');
|
||||
expect(peopleCloudComponent).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should update form on completed by user is updated', (done) => {
|
||||
component.appName = 'fake';
|
||||
@@ -789,7 +802,7 @@ describe('EditTaskFilterCloudComponent', () => {
|
||||
|
||||
describe('sort properties', () => {
|
||||
|
||||
it('should display default sort properties', async(() => {
|
||||
it('should display default sort properties', async () => {
|
||||
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
|
||||
component.ngOnChanges({ 'id': taskFilterIdChange });
|
||||
fixture.detectChanges();
|
||||
@@ -798,16 +811,17 @@ describe('EditTaskFilterCloudComponent', () => {
|
||||
fixture.detectChanges();
|
||||
const sortElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-sort"]');
|
||||
sortElement.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const sortController = component.editTaskFilterForm.get('sort');
|
||||
const sortOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(sortController.value).toBe('id');
|
||||
expect(sortOptions.length).toEqual(4);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should display sort properties when sort properties are specified', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const sortController = component.editTaskFilterForm.get('sort');
|
||||
const sortOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(sortController.value).toBe('id');
|
||||
expect(sortOptions.length).toEqual(4);
|
||||
});
|
||||
|
||||
it('should display sort properties when sort properties are specified', async () => {
|
||||
component.sortProperties = ['id', 'name', 'processInstanceId'];
|
||||
getTaskFilterSpy.and.returnValue(of({
|
||||
sort: 'my-custom-sort',
|
||||
@@ -823,17 +837,18 @@ describe('EditTaskFilterCloudComponent', () => {
|
||||
fixture.detectChanges();
|
||||
const sortElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-sort"]');
|
||||
sortElement.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const sortController = component.editTaskFilterForm.get('sort');
|
||||
const sortOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(component.sortProperties.length).toBe(3);
|
||||
expect(sortController.value).toBe('my-custom-sort');
|
||||
expect(sortOptions.length).toEqual(3);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should display default sort properties if input is empty', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const sortController = component.editTaskFilterForm.get('sort');
|
||||
const sortOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(component.sortProperties.length).toBe(3);
|
||||
expect(sortController.value).toBe('my-custom-sort');
|
||||
expect(sortOptions.length).toEqual(3);
|
||||
});
|
||||
|
||||
it('should display default sort properties if input is empty', async () => {
|
||||
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
|
||||
component.ngOnChanges({ 'id': taskFilterIdChange });
|
||||
fixture.detectChanges();
|
||||
@@ -844,39 +859,41 @@ describe('EditTaskFilterCloudComponent', () => {
|
||||
fixture.detectChanges();
|
||||
const sortElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-sort"]');
|
||||
sortElement.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const sortController = component.editTaskFilterForm.get('sort');
|
||||
const sortOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(sortController.value).toBe('id');
|
||||
expect(sortOptions.length).toEqual(4);
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
const sortController = component.editTaskFilterForm.get('sort');
|
||||
const sortOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
expect(sortController.value).toBe('id');
|
||||
expect(sortOptions.length).toEqual(4);
|
||||
});
|
||||
});
|
||||
|
||||
describe('filter actions', () => {
|
||||
|
||||
it('should display default filter actions', async(() => {
|
||||
it('should display default filter actions', async () => {
|
||||
component.toggleFilterActions = true;
|
||||
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
|
||||
component.ngOnChanges({ 'id': taskFilterIdChange });
|
||||
fixture.detectChanges();
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const saveAsButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-saveAs"]');
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-save"]');
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-delete"]');
|
||||
expect(component.taskFilterActions.map(action => action.actionType)).toEqual(['save', 'saveAs', 'delete']);
|
||||
expect(component.taskFilterActions.length).toBe(3);
|
||||
expect(saveButton.disabled).toBe(true);
|
||||
expect(saveAsButton.disabled).toBe(true);
|
||||
expect(deleteButton.disabled).toBe(false);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should display filter actions when input actions are specified', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const saveAsButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-saveAs"]');
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-save"]');
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-delete"]');
|
||||
expect(component.taskFilterActions.map(action => action.actionType)).toEqual(['save', 'saveAs', 'delete']);
|
||||
expect(component.taskFilterActions.length).toBe(3);
|
||||
expect(saveButton.disabled).toBe(true);
|
||||
expect(saveAsButton.disabled).toBe(true);
|
||||
expect(deleteButton.disabled).toBe(false);
|
||||
});
|
||||
|
||||
it('should display filter actions when input actions are specified', async () => {
|
||||
component.actions = ['save'];
|
||||
fixture.detectChanges();
|
||||
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
|
||||
@@ -886,18 +903,19 @@ describe('EditTaskFilterCloudComponent', () => {
|
||||
fixture.detectChanges();
|
||||
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||
expansionPanel.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-save"]');
|
||||
expect(component.taskFilterActions.map(action => action.actionType)).toEqual(['save']);
|
||||
expect(component.taskFilterActions.length).toBe(1);
|
||||
expect(saveButton.disabled).toBeTruthy();
|
||||
const saveAsButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-saveAs"]');
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-delete"]');
|
||||
expect(saveAsButton).toBeFalsy();
|
||||
expect(deleteButton).toBeFalsy();
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-save"]');
|
||||
expect(component.taskFilterActions.map(action => action.actionType)).toEqual(['save']);
|
||||
expect(component.taskFilterActions.length).toBe(1);
|
||||
expect(saveButton.disabled).toBeTruthy();
|
||||
const saveAsButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-saveAs"]');
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-delete"]');
|
||||
expect(saveAsButton).toBeFalsy();
|
||||
expect(deleteButton).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should set the correct lastModifiedTo date', (done) => {
|
||||
component.appName = 'fake';
|
||||
@@ -934,7 +952,7 @@ describe('EditTaskFilterCloudComponent', () => {
|
||||
spyOn(component.action, 'emit').and.callThrough();
|
||||
});
|
||||
|
||||
it('should emit save event and save the filter on click save button', async(() => {
|
||||
it('should emit save event and save the filter on click save button', fakeAsync(() => {
|
||||
component.toggleFilterActions = true;
|
||||
spyOn(service, 'updateFilter').and.returnValue(of(null));
|
||||
fixture.detectChanges();
|
||||
@@ -946,10 +964,10 @@ describe('EditTaskFilterCloudComponent', () => {
|
||||
fixture.detectChanges();
|
||||
const sortOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
sortOptions[3].nativeElement.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-save"]');
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-save"]');
|
||||
expect(saveButton.disabled).toBe(false);
|
||||
saveButton.click();
|
||||
expect(service.updateFilter).toHaveBeenCalled();
|
||||
@@ -957,7 +975,7 @@ describe('EditTaskFilterCloudComponent', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should emit delete event and delete the filter on click of delete button', async(() => {
|
||||
it('should emit delete event and delete the filter on click of delete button', async () => {
|
||||
component.toggleFilterActions = true;
|
||||
spyOn(service, 'deleteFilter').and.returnValue(of(null));
|
||||
fixture.detectChanges();
|
||||
@@ -966,18 +984,18 @@ describe('EditTaskFilterCloudComponent', () => {
|
||||
fixture.detectChanges();
|
||||
const stateElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-sort"] .mat-select-trigger');
|
||||
stateElement.click();
|
||||
fixture.detectChanges();
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-delete"]');
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(deleteButton.disabled).toBe(false);
|
||||
deleteButton.click();
|
||||
expect(service.deleteFilter).toHaveBeenCalled();
|
||||
expect(component.action.emit).toHaveBeenCalled();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should emit saveAs event and add filter on click saveAs button', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-delete"]');
|
||||
expect(deleteButton.disabled).toBe(false);
|
||||
deleteButton.click();
|
||||
expect(service.deleteFilter).toHaveBeenCalled();
|
||||
expect(component.action.emit).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should emit saveAs event and add filter on click saveAs button', fakeAsync(() => {
|
||||
component.toggleFilterActions = true;
|
||||
spyOn(service, 'addFilter').and.returnValue(of(null));
|
||||
fixture.detectChanges();
|
||||
@@ -989,10 +1007,10 @@ describe('EditTaskFilterCloudComponent', () => {
|
||||
fixture.detectChanges();
|
||||
const sortOptions = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
sortOptions[2].nativeElement.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
const saveAsButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-saveAs"]');
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
const saveAsButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-saveAs"]');
|
||||
expect(saveAsButton.disabled).toBe(false);
|
||||
saveAsButton.click();
|
||||
expect(service.addFilter).toHaveBeenCalled();
|
||||
@@ -1001,7 +1019,7 @@ describe('EditTaskFilterCloudComponent', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should call restore default filters service on deletion of last filter', async(() => {
|
||||
it('should call restore default filters service on deletion of last filter', async () => {
|
||||
component.toggleFilterActions = true;
|
||||
spyOn(service, 'deleteFilter').and.returnValue(of([]));
|
||||
const restoreDefaultFiltersSpy = spyOn(component, 'restoreDefaultTaskFilters').and.returnValue(of([]));
|
||||
@@ -1011,19 +1029,19 @@ describe('EditTaskFilterCloudComponent', () => {
|
||||
fixture.detectChanges();
|
||||
const stateElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-sort"] .mat-select-trigger');
|
||||
stateElement.click();
|
||||
fixture.detectChanges();
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-delete"]');
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(deleteButton.disabled).toBe(false);
|
||||
deleteButton.click();
|
||||
expect(service.deleteFilter).toHaveBeenCalled();
|
||||
expect(component.action.emit).toHaveBeenCalled();
|
||||
expect(restoreDefaultFiltersSpy).toHaveBeenCalled();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not call restore default filters service on deletion of first filter', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-delete"]');
|
||||
expect(deleteButton.disabled).toBe(false);
|
||||
deleteButton.click();
|
||||
expect(service.deleteFilter).toHaveBeenCalled();
|
||||
expect(component.action.emit).toHaveBeenCalled();
|
||||
expect(restoreDefaultFiltersSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not call restore default filters service on deletion of first filter', async () => {
|
||||
component.toggleFilterActions = true;
|
||||
spyOn(service, 'deleteFilter').and.returnValue(of([new TaskFilterCloudModel({ name: 'mock-filter-name' })]));
|
||||
const restoreDefaultFiltersSpy = spyOn(component, 'restoreDefaultTaskFilters').and.returnValue(of([]));
|
||||
@@ -1033,16 +1051,16 @@ describe('EditTaskFilterCloudComponent', () => {
|
||||
fixture.detectChanges();
|
||||
const stateElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-sort"] .mat-select-trigger');
|
||||
stateElement.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const deleteButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-filter-action-delete"]');
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(deleteButton.disabled).toBe(false);
|
||||
deleteButton.click();
|
||||
expect(service.deleteFilter).toHaveBeenCalled();
|
||||
expect(component.action.emit).toHaveBeenCalled();
|
||||
expect(restoreDefaultFiltersSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
}));
|
||||
expect(deleteButton.disabled).toBe(false);
|
||||
deleteButton.click();
|
||||
expect(service.deleteFilter).toHaveBeenCalled();
|
||||
expect(component.action.emit).toHaveBeenCalled();
|
||||
expect(restoreDefaultFiltersSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||
import { TaskFilterDialogCloudComponent } from './task-filter-dialog-cloud.component';
|
||||
import { TaskFiltersCloudModule } from '../../task-filters-cloud.module';
|
||||
@@ -67,46 +67,49 @@ describe('TaskFilterDialogCloudComponent', () => {
|
||||
expect(titleElement.textContent).toEqual(' ADF_CLOUD_EDIT_TASK_FILTER.DIALOG.TITLE ');
|
||||
});
|
||||
|
||||
it('should enable save button if form is valid', async(() => {
|
||||
it('should enable save button if form is valid', async () => {
|
||||
fixture.detectChanges();
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('#adf-save-button-id');
|
||||
const inputElement = fixture.debugElement.nativeElement.querySelector('#adf-filter-name-id');
|
||||
inputElement.value = 'My custom Name';
|
||||
inputElement.dispatchEvent(new Event('input'));
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(saveButton).toBeDefined();
|
||||
expect(saveButton.disabled).toBeFalsy();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should disable save button if form is not valid', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(saveButton).toBeDefined();
|
||||
expect(saveButton.disabled).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should disable save button if form is not valid', async () => {
|
||||
fixture.detectChanges();
|
||||
const inputElement = fixture.debugElement.nativeElement.querySelector('#adf-filter-name-id');
|
||||
inputElement.value = '';
|
||||
inputElement.dispatchEvent(new Event('input'));
|
||||
fixture.whenStable().then(() => {
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('#adf-save-button-id');
|
||||
fixture.detectChanges();
|
||||
expect(saveButton).toBeDefined();
|
||||
expect(saveButton.disabled).toBe(true);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should able to close dialog on click of save button if form is valid', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('#adf-save-button-id');
|
||||
expect(saveButton).toBeDefined();
|
||||
expect(saveButton.disabled).toBe(true);
|
||||
});
|
||||
|
||||
it('should able to close dialog on click of save button if form is valid', async () => {
|
||||
fixture.detectChanges();
|
||||
const inputElement = fixture.debugElement.nativeElement.querySelector('#adf-filter-name-id');
|
||||
inputElement.value = 'My custom Name';
|
||||
inputElement.dispatchEvent(new Event('input'));
|
||||
fixture.whenStable().then(() => {
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('#adf-save-button-id');
|
||||
fixture.detectChanges();
|
||||
saveButton.click();
|
||||
expect(saveButton).toBeDefined();
|
||||
expect(saveButton.disabled).toBeFalsy();
|
||||
expect(component.dialogRef.close).toHaveBeenCalled();
|
||||
});
|
||||
}));
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const saveButton = fixture.debugElement.nativeElement.querySelector('#adf-save-button-id');
|
||||
saveButton.click();
|
||||
expect(saveButton).toBeDefined();
|
||||
expect(saveButton.disabled).toBeFalsy();
|
||||
expect(component.dialogRef.close).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should able close dialog on click of cancel button', () => {
|
||||
component.data = { data: { name: '' } };
|
||||
|
@@ -18,7 +18,7 @@
|
||||
import { DebugElement, SimpleChange } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { of } from 'rxjs';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { IdentityUserService, setupTestBed } from '@alfresco/adf-core';
|
||||
import { ProcessServiceCloudTestingModule } from '../../../testing/process-service-cloud.testing.module';
|
||||
import { TaskFormCloudComponent } from './task-form-cloud.component';
|
||||
@@ -75,183 +75,193 @@ describe('TaskFormCloudComponent', () => {
|
||||
|
||||
describe('Complete button', () => {
|
||||
|
||||
it('should show complete button when status is ASSIGNED', async(() => {
|
||||
it('should show complete button when status is ASSIGNED', async () => {
|
||||
component.appName = 'app1';
|
||||
component.taskId = 'task1';
|
||||
|
||||
component.loadTask();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const completeBtn = debugElement.query(By.css('[adf-cloud-complete-task]'));
|
||||
expect(completeBtn.nativeElement).toBeDefined();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not show complete button when status is ASSIGNED but assigned to a different person', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const completeBtn = debugElement.query(By.css('[adf-cloud-complete-task]'));
|
||||
expect(completeBtn.nativeElement).toBeDefined();
|
||||
});
|
||||
|
||||
it('should not show complete button when status is ASSIGNED but assigned to a different person', async () => {
|
||||
component.appName = 'app1';
|
||||
component.taskId = 'task1';
|
||||
|
||||
getCurrentUserSpy.and.returnValue({});
|
||||
|
||||
component.loadTask();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const completeBtn = debugElement.query(By.css('[adf-cloud-complete-task]'));
|
||||
expect(completeBtn).toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not show complete button when showCompleteButton=false', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const completeBtn = debugElement.query(By.css('[adf-cloud-complete-task]'));
|
||||
expect(completeBtn).toBeNull();
|
||||
});
|
||||
|
||||
it('should not show complete button when showCompleteButton=false', async () => {
|
||||
component.appName = 'app1';
|
||||
component.taskId = 'task1';
|
||||
component.showCompleteButton = false;
|
||||
|
||||
component.loadTask();
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const completeBtn = debugElement.query(By.css('[adf-cloud-complete-task]'));
|
||||
expect(completeBtn).toBeNull();
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
const completeBtn = debugElement.query(By.css('[adf-cloud-complete-task]'));
|
||||
expect(completeBtn).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Claim/Unclaim buttons', () => {
|
||||
|
||||
it('should not show release button for standalone task', async(() => {
|
||||
it('should not show release button for standalone task', async () => {
|
||||
component.taskId = 'task1';
|
||||
component.loadTask();
|
||||
fixture.detectChanges();
|
||||
getTaskSpy.and.returnValue(of(taskDetails));
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const unclaimBtn = debugElement.query(By.css('[adf-cloud-unclaim-task]'));
|
||||
expect(unclaimBtn).toBeNull();
|
||||
});
|
||||
}));
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
it('should show release button when task has candidate users and is assigned to one of these users', async(() => {
|
||||
const unclaimBtn = debugElement.query(By.css('[adf-cloud-unclaim-task]'));
|
||||
expect(unclaimBtn).toBeNull();
|
||||
});
|
||||
|
||||
it('should show release button when task has candidate users and is assigned to one of these users', async () => {
|
||||
spyOn(component, 'hasCandidateUsers').and.returnValue(true);
|
||||
|
||||
component.appName = 'app1';
|
||||
component.taskId = 'task1';
|
||||
|
||||
component.loadTask();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const unclaimBtn = debugElement.query(By.css('[adf-cloud-unclaim-task]'));
|
||||
expect(unclaimBtn).not.toBeNull();
|
||||
});
|
||||
}));
|
||||
const unclaimBtn = debugElement.query(By.css('[adf-cloud-unclaim-task]'));
|
||||
expect(unclaimBtn).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should not show unclaim button when status is ASSIGNED but assigned to different person', async(() => {
|
||||
it('should not show unclaim button when status is ASSIGNED but assigned to different person', async () => {
|
||||
component.appName = 'app1';
|
||||
component.taskId = 'task1';
|
||||
|
||||
getCurrentUserSpy.and.returnValue({});
|
||||
|
||||
component.loadTask();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const unclaimBtn = debugElement.query(By.css('[adf-cloud-unclaim-task]'));
|
||||
expect(unclaimBtn).toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not show unclaim button when status is not ASSIGNED', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const unclaimBtn = debugElement.query(By.css('[adf-cloud-unclaim-task]'));
|
||||
expect(unclaimBtn).toBeNull();
|
||||
});
|
||||
|
||||
it('should not show unclaim button when status is not ASSIGNED', async () => {
|
||||
component.appName = 'app1';
|
||||
component.taskId = 'task1';
|
||||
taskDetails.status = undefined;
|
||||
getTaskSpy.and.returnValue(of(taskDetails));
|
||||
|
||||
component.loadTask();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const unclaimBtn = debugElement.query(By.css('[adf-cloud-unclaim-task]'));
|
||||
expect(unclaimBtn).toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should show claim button when status is CREATED', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const unclaimBtn = debugElement.query(By.css('[adf-cloud-unclaim-task]'));
|
||||
expect(unclaimBtn).toBeNull();
|
||||
});
|
||||
|
||||
it('should show claim button when status is CREATED', async () => {
|
||||
component.appName = 'app1';
|
||||
component.taskId = 'task1';
|
||||
taskDetails.status = 'CREATED';
|
||||
getTaskSpy.and.returnValue(of(taskDetails));
|
||||
|
||||
component.loadTask();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const claimBtn = debugElement.query(By.css('[adf-cloud-claim-task]'));
|
||||
expect(claimBtn.nativeElement).toBeDefined();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not show claim button when status is not CREATED', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const claimBtn = debugElement.query(By.css('[adf-cloud-claim-task]'));
|
||||
expect(claimBtn.nativeElement).toBeDefined();
|
||||
});
|
||||
|
||||
it('should not show claim button when status is not CREATED', async () => {
|
||||
component.appName = 'app1';
|
||||
component.taskId = 'task1';
|
||||
taskDetails.status = undefined;
|
||||
getTaskSpy.and.returnValue(of(taskDetails));
|
||||
|
||||
component.loadTask();
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const claimBtn = debugElement.query(By.css('[adf-cloud-claim-task]'));
|
||||
expect(claimBtn).toBeNull();
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
const claimBtn = debugElement.query(By.css('[adf-cloud-claim-task]'));
|
||||
expect(claimBtn).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Cancel button', () => {
|
||||
|
||||
it('should show cancel button by default', async(() => {
|
||||
it('should show cancel button by default', async () => {
|
||||
component.appName = 'app1';
|
||||
component.taskId = 'task1';
|
||||
|
||||
component.loadTask();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const cancelBtn = debugElement.query(By.css('#adf-cloud-cancel-task'));
|
||||
expect(cancelBtn.nativeElement).toBeDefined();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not show cancel button when showCancelButton=false', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const cancelBtn = debugElement.query(By.css('#adf-cloud-cancel-task'));
|
||||
expect(cancelBtn.nativeElement).toBeDefined();
|
||||
});
|
||||
|
||||
it('should not show cancel button when showCancelButton=false', async () => {
|
||||
component.appName = 'app1';
|
||||
component.taskId = 'task1';
|
||||
component.showCancelButton = false;
|
||||
|
||||
component.loadTask();
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const cancelBtn = debugElement.query(By.css('#adf-cloud-cancel-task'));
|
||||
expect(cancelBtn).toBeNull();
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
const cancelBtn = debugElement.query(By.css('#adf-cloud-cancel-task'));
|
||||
expect(cancelBtn).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Inputs', () => {
|
||||
|
||||
it('should not show complete/claim/unclaim buttons when readOnly=true', async(() => {
|
||||
it('should not show complete/claim/unclaim buttons when readOnly=true', async () => {
|
||||
component.appName = 'app1';
|
||||
component.taskId = 'task1';
|
||||
component.readOnly = true;
|
||||
|
||||
component.loadTask();
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const completeBtn = debugElement.query(By.css('[adf-cloud-complete-task]'));
|
||||
expect(completeBtn).toBeNull();
|
||||
await fixture.whenStable();
|
||||
|
||||
const claimBtn = debugElement.query(By.css('[adf-cloud-claim-task]'));
|
||||
expect(claimBtn).toBeNull();
|
||||
const completeBtn = debugElement.query(By.css('[adf-cloud-complete-task]'));
|
||||
expect(completeBtn).toBeNull();
|
||||
|
||||
const unclaimBtn = debugElement.query(By.css('[adf-cloud-unclaim-task]'));
|
||||
expect(unclaimBtn).toBeNull();
|
||||
const claimBtn = debugElement.query(By.css('[adf-cloud-claim-task]'));
|
||||
expect(claimBtn).toBeNull();
|
||||
|
||||
const cancelBtn = debugElement.query(By.css('#adf-cloud-cancel-task'));
|
||||
expect(cancelBtn.nativeElement).toBeDefined();
|
||||
});
|
||||
}));
|
||||
const unclaimBtn = debugElement.query(By.css('[adf-cloud-unclaim-task]'));
|
||||
expect(unclaimBtn).toBeNull();
|
||||
|
||||
const cancelBtn = debugElement.query(By.css('#adf-cloud-cancel-task'));
|
||||
expect(cancelBtn.nativeElement).toBeDefined();
|
||||
});
|
||||
|
||||
it('should load data when appName changes', () => {
|
||||
component.taskId = 'task1';
|
||||
|
@@ -18,7 +18,7 @@
|
||||
import { TaskHeaderCloudComponent } from './task-header-cloud.component';
|
||||
import { of, throwError } from 'rxjs';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed, fakeAsync } from '@angular/core/testing';
|
||||
import { setupTestBed, AppConfigService, AlfrescoApiService, CardViewArrayItem } from '@alfresco/adf-core';
|
||||
import { ProcessServiceCloudTestingModule } from '../../../testing/process-service-cloud.testing.module';
|
||||
import { TaskCloudService } from '../../services/task-cloud.service';
|
||||
@@ -186,23 +186,21 @@ describe('TaskHeaderCloudComponent', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
it('should roll back task description on error', async(async () => {
|
||||
it('should roll back task description on error', fakeAsync(() => {
|
||||
spyOn(taskCloudService, 'updateTask').and.returnValue(throwError('fake'));
|
||||
fixture.detectChanges();
|
||||
|
||||
await fixture.whenStable();
|
||||
fixture.detectChanges();
|
||||
let description = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-description"]'));
|
||||
expect(description.nativeElement.value.trim()).toEqual('This is the description');
|
||||
const inputEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-description"]'));
|
||||
inputEl.nativeElement.value = 'updated description';
|
||||
inputEl.nativeElement.dispatchEvent(new Event('input'));
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
fixture.detectChanges();
|
||||
description = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-description"]'));
|
||||
expect(description.nativeElement.value.trim()).toEqual('This is the description');
|
||||
expect(taskCloudService.updateTask).toHaveBeenCalled();
|
||||
fixture.whenStable().then(() => {
|
||||
description = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-description"]'));
|
||||
expect(description.nativeElement.value.trim()).toEqual('This is the description');
|
||||
expect(taskCloudService.updateTask).toHaveBeenCalled();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should show spinner before loading task details', () => {
|
||||
@@ -523,22 +521,23 @@ describe('TaskHeaderCloudComponent', () => {
|
||||
|
||||
describe('Task errors', () => {
|
||||
|
||||
it('should emit an error when task can not be found', async(() => {
|
||||
it('should emit an error when task can not be found', (done) => {
|
||||
getTaskByIdSpy.and.returnValue(throwError('Task not found'));
|
||||
|
||||
component.error.subscribe((error) => {
|
||||
expect(error).toEqual('Task not found');
|
||||
done();
|
||||
});
|
||||
|
||||
component.appName = 'appName';
|
||||
component.taskId = 'taskId';
|
||||
component.ngOnChanges();
|
||||
}));
|
||||
|
||||
it('should emit an error when app name and/or task id are not provided', async(() => {
|
||||
});
|
||||
|
||||
it('should emit an error when app name and/or task id are not provided', (done) => {
|
||||
component.error.subscribe((error) => {
|
||||
expect(error).toEqual('App Name and Task Id are mandatory');
|
||||
done();
|
||||
});
|
||||
|
||||
component.appName = '';
|
||||
@@ -551,7 +550,7 @@ describe('TaskHeaderCloudComponent', () => {
|
||||
component.appName = '';
|
||||
component.taskId = 'taskId';
|
||||
component.ngOnChanges();
|
||||
}));
|
||||
});
|
||||
|
||||
it('should call the loadTaskDetailsById when both app name and task id are provided', () => {
|
||||
spyOn(component, 'loadTaskDetailsById');
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { Component, SimpleChange, ViewChild } from '@angular/core';
|
||||
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed, fakeAsync } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { AppConfigService, setupTestBed, DataRowEvent, ObjectDataRow, EcmUserModel } from '@alfresco/adf-core';
|
||||
import { ServiceTaskListCloudComponent } from './service-task-list-cloud.component';
|
||||
@@ -362,7 +362,7 @@ describe('ServiceTaskListCloudComponent', () => {
|
||||
let fixtureCustom: ComponentFixture<CustomTaskListComponent>;
|
||||
let componentCustom: CustomTaskListComponent;
|
||||
let customCopyComponent: CustomCopyContentTaskListComponent;
|
||||
let element: any;
|
||||
let element: HTMLElement;
|
||||
let copyFixture: ComponentFixture<CustomCopyContentTaskListComponent>;
|
||||
|
||||
setupTestBed({
|
||||
@@ -399,12 +399,12 @@ describe('ServiceTaskListCloudComponent', () => {
|
||||
expect(componentCustom.taskList.columns.length).toEqual(2);
|
||||
});
|
||||
|
||||
it('it should show copy tooltip when key is present in data-colunn', async(() => {
|
||||
it('it should show copy tooltip when key is present in data-colunn', fakeAsync(() => {
|
||||
copyFixture.detectChanges();
|
||||
const appName = new SimpleChange(null, 'FAKE-APP-NAME', true);
|
||||
copyFixture.whenStable().then(() => {
|
||||
copyFixture.detectChanges();
|
||||
const spanHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('span[title="04fdf69f-4ddd-48ab-9563-da776c9b163c"]');
|
||||
const spanHTMLElement = <HTMLInputElement> element.querySelector('span[title="04fdf69f-4ddd-48ab-9563-da776c9b163c"]');
|
||||
spanHTMLElement.dispatchEvent(new Event('mouseenter'));
|
||||
copyFixture.detectChanges();
|
||||
expect(copyFixture.debugElement.nativeElement.querySelector('.adf-copy-tooltip')).not.toBeNull();
|
||||
@@ -434,7 +434,7 @@ describe('ServiceTaskListCloudComponent', () => {
|
||||
|
||||
describe('Copy cell content directive from app.config specifications', () => {
|
||||
|
||||
let element: any;
|
||||
let element: HTMLElement;
|
||||
let taskSpy: jasmine.Spy;
|
||||
|
||||
setupTestBed({
|
||||
@@ -478,14 +478,14 @@ describe('ServiceTaskListCloudComponent', () => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
it('shoud show tooltip if config copyContent flag is true', async(() => {
|
||||
it('shoud show tooltip if config copyContent flag is true', fakeAsync(() => {
|
||||
taskSpy.and.returnValue(of(fakeServiceTask));
|
||||
const appName = new SimpleChange(null, 'FAKE-APP-NAME', true);
|
||||
|
||||
component.success.subscribe(() => {
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
const spanHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('span[title="04fdf69f-4ddd-48ab-9563-da776c9b163c"]');
|
||||
const spanHTMLElement = element.querySelector<HTMLInputElement>('span[title="04fdf69f-4ddd-48ab-9563-da776c9b163c"]');
|
||||
spanHTMLElement.dispatchEvent(new Event('mouseenter'));
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement.querySelector('.adf-copy-tooltip')).not.toBeNull();
|
||||
@@ -498,13 +498,13 @@ describe('ServiceTaskListCloudComponent', () => {
|
||||
component.ngAfterContentInit();
|
||||
}));
|
||||
|
||||
it('shoud not show tooltip if config copyContent flag is true', async(() => {
|
||||
it('shoud not show tooltip if config copyContent flag is true', fakeAsync(() => {
|
||||
taskSpy.and.returnValue(of(fakeServiceTask));
|
||||
const appName = new SimpleChange(null, 'FAKE-APP-NAME', true);
|
||||
component.success.subscribe(() => {
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
const spanHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('span[title="serviceTaskName"]');
|
||||
const spanHTMLElement = element.querySelector<HTMLInputElement>('span[title="serviceTaskName"]');
|
||||
spanHTMLElement.dispatchEvent(new Event('mouseenter'));
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement.querySelector('.adf-copy-tooltip')).toBeNull();
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { Component, SimpleChange, ViewChild } from '@angular/core';
|
||||
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed, fakeAsync } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { AppConfigService, setupTestBed, DataRowEvent, ObjectDataRow, EcmUserModel } from '@alfresco/adf-core';
|
||||
import { TaskListCloudService } from '../services/task-list-cloud.service';
|
||||
@@ -420,7 +420,7 @@ describe('TaskListCloudComponent', () => {
|
||||
expect(componentCustom.taskList.columns.length).toEqual(3);
|
||||
});
|
||||
|
||||
it('it should show copy tooltip when key is present in data-colunn', async(() => {
|
||||
it('it should show copy tooltip when key is present in data-colunn', fakeAsync(() => {
|
||||
copyFixture.detectChanges();
|
||||
const appName = new SimpleChange(null, 'FAKE-APP-NAME', true);
|
||||
copyFixture.whenStable().then(() => {
|
||||
@@ -535,7 +535,7 @@ describe('TaskListCloudComponent', () => {
|
||||
|
||||
// TODO: highly unstable test
|
||||
// tslint:disable-next-line:ban
|
||||
xit('should show tooltip if config copyContent flag is true', async(() => {
|
||||
xit('should show tooltip if config copyContent flag is true', fakeAsync(() => {
|
||||
taskSpy.and.returnValue(of(fakeGlobalTask));
|
||||
const appName = new SimpleChange(null, 'FAKE-APP-NAME', true);
|
||||
|
||||
|
Reference in New Issue
Block a user