mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[AAE-2107] Move e2e to Unit test (#5535)
* [AAE-2107] Move e2e to Unit test * * fixed namings * * more unit test added * * minor changes
This commit is contained in:
+119
-97
@@ -23,17 +23,26 @@ import { CardViewDateItemModel } from '../../models/card-view-dateitem.model';
|
||||
import { CardViewUpdateService } from '../../services/card-view-update.service';
|
||||
import { CardViewDateItemComponent } from './card-view-dateitem.component';
|
||||
import { CoreTestingModule } from '../../../testing/core.testing.module';
|
||||
import { AppConfigService } from '@alfresco/adf-core';
|
||||
|
||||
describe('CardViewDateItemComponent', () => {
|
||||
|
||||
let fixture: ComponentFixture<CardViewDateItemComponent>;
|
||||
let component: CardViewDateItemComponent;
|
||||
let appConfigService: AppConfigService;
|
||||
|
||||
setupTestBed({
|
||||
imports: [CoreTestingModule]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
appConfigService = TestBed.get(AppConfigService);
|
||||
appConfigService.config.dateValues = {
|
||||
defaultDateFormat: 'shortDate',
|
||||
defaultDateTimeFormat: 'M/d/yy, h:mm a',
|
||||
defaultLocale: 'uk'
|
||||
};
|
||||
|
||||
fixture = TestBed.createComponent(CardViewDateItemComponent);
|
||||
component = fixture.componentInstance;
|
||||
component.property = new CardViewDateItemModel({
|
||||
@@ -46,8 +55,10 @@ describe('CardViewDateItemComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
afterEach(() => fixture.destroy());
|
||||
|
||||
it('should pick date format from appConfigService', () => {
|
||||
expect(component.dateFormat).toEqual('shortDate');
|
||||
});
|
||||
|
||||
it('should render the label and value', () => {
|
||||
@@ -153,6 +164,7 @@ describe('CardViewDateItemComponent', () => {
|
||||
component.property.editable = true;
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.isEditable()).toBe(false);
|
||||
const datePicker = fixture.debugElement.query(By.css(`[data-automation-id="datepicker-${component.property.key}"]`));
|
||||
const datePickerToggle = fixture.debugElement.query(By.css(`[data-automation-id="datepickertoggle-${component.property.key}"]`));
|
||||
expect(datePicker).toBeNull('Datepicker should NOT be in DOM');
|
||||
@@ -206,101 +218,111 @@ describe('CardViewDateItemComponent', () => {
|
||||
);
|
||||
}));
|
||||
|
||||
it('should render the clear icon in case of displayClearAction:true', () => {
|
||||
component.editable = true;
|
||||
component.property.editable = true;
|
||||
component.property.value = 'Jul 10 2017';
|
||||
fixture.detectChanges();
|
||||
|
||||
const datePickerClearToggle = fixture.debugElement.query(By.css(`[data-automation-id="datepicker-date-clear-${component.property.key}"]`));
|
||||
expect(datePickerClearToggle).not.toBeNull('Clean Icon should be in DOM');
|
||||
});
|
||||
|
||||
it('should not render the clear icon in case of property value empty', () => {
|
||||
component.editable = true;
|
||||
component.property.editable = true;
|
||||
component.property.value = null;
|
||||
fixture.detectChanges();
|
||||
|
||||
const datePickerClearToggle = fixture.debugElement.query(By.css(`[data-automation-id="datepicker-date-clear--${component.property.key}"]`));
|
||||
expect(datePickerClearToggle).toBeNull('Clean Icon should not be in DOM');
|
||||
});
|
||||
|
||||
it('should not render the clear icon in case of displayClearAction:false', () => {
|
||||
component.editable = true;
|
||||
component.property.editable = true;
|
||||
component.displayClearAction = false;
|
||||
component.property.value = 'Jul 10 2017';
|
||||
fixture.detectChanges();
|
||||
|
||||
const datePickerClearToggle = fixture.debugElement.query(By.css(`[data-automation-id="datepicker-date-clear--${component.property.key}"]`));
|
||||
expect(datePickerClearToggle).toBeNull('Clean Icon should not be in DOM');
|
||||
});
|
||||
|
||||
it('should remove the property value after a successful clear attempt', async(() => {
|
||||
component.editable = true;
|
||||
component.property.editable = true;
|
||||
component.property.value = 'Jul 10 2017';
|
||||
fixture.detectChanges();
|
||||
|
||||
component.onDateClear();
|
||||
|
||||
fixture.whenStable().then(
|
||||
() => {
|
||||
expect(component.property.value).toBeNull();
|
||||
}
|
||||
);
|
||||
}));
|
||||
|
||||
it('should remove the property default value after a successful clear attempt', async(() => {
|
||||
component.editable = true;
|
||||
component.property.editable = true;
|
||||
component.property.default = 'Jul 10 2017';
|
||||
fixture.detectChanges();
|
||||
|
||||
component.onDateClear();
|
||||
|
||||
fixture.whenStable().then(
|
||||
() => {
|
||||
expect(component.property.default).toBeNull();
|
||||
}
|
||||
);
|
||||
}));
|
||||
|
||||
it('should remove actual and default value after a successful clear attempt', async(() => {
|
||||
component.editable = true;
|
||||
component.property.editable = true;
|
||||
component.property.default = 'Jul 10 2017';
|
||||
component.property.value = 'Jul 10 2017';
|
||||
fixture.detectChanges();
|
||||
|
||||
component.onDateClear();
|
||||
|
||||
fixture.whenStable().then(
|
||||
() => {
|
||||
expect(component.property.value).toBeNull();
|
||||
expect(component.property.default).toBeNull();
|
||||
}
|
||||
);
|
||||
}));
|
||||
|
||||
it('should be possible update a date/date-time', async(() => {
|
||||
component.editable = true;
|
||||
component.property.editable = true;
|
||||
component.property.default = 'Jul 10 2017';
|
||||
component.property.key = 'fake-key';
|
||||
component.property.value = 'Jul 10 2017';
|
||||
const expectedDate = moment('Jul 10 2018', 'MMM DD YY');
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
describe('clear icon', () => {
|
||||
it('should render the clear icon in case of displayClearAction:true', () => {
|
||||
component.editable = true;
|
||||
component.property.editable = true;
|
||||
component.property.value = 'Jul 10 2017';
|
||||
fixture.detectChanges();
|
||||
const element = fixture.debugElement.nativeElement.querySelector('span[data-automation-id="card-date-value-fake-key"]');
|
||||
expect(element).toBeDefined();
|
||||
expect(element.innerText).toEqual('Jul 10, 2017');
|
||||
component.onDateChanged({ value: expectedDate });
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => expect(component.property.value).toEqual(expectedDate.toDate()));
|
||||
|
||||
const datePickerClearToggle = fixture.debugElement.query(By.css(`[data-automation-id="datepicker-date-clear-${component.property.key}"]`));
|
||||
expect(datePickerClearToggle).not.toBeNull('Clean Icon should be in DOM');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not render the clear icon in case of property value empty', () => {
|
||||
component.editable = true;
|
||||
component.property.editable = true;
|
||||
component.property.value = null;
|
||||
fixture.detectChanges();
|
||||
|
||||
const datePickerClearToggle = fixture.debugElement.query(By.css(`[data-automation-id="datepicker-date-clear--${component.property.key}"]`));
|
||||
expect(datePickerClearToggle).toBeNull('Clean Icon should not be in DOM');
|
||||
});
|
||||
|
||||
it('should not render the clear icon in case of displayClearAction:false', () => {
|
||||
component.editable = true;
|
||||
component.property.editable = true;
|
||||
component.displayClearAction = false;
|
||||
component.property.value = 'Jul 10 2017';
|
||||
fixture.detectChanges();
|
||||
|
||||
const datePickerClearToggle = fixture.debugElement.query(By.css(`[data-automation-id="datepicker-date-clear--${component.property.key}"]`));
|
||||
expect(datePickerClearToggle).toBeNull('Clean Icon should not be in DOM');
|
||||
});
|
||||
|
||||
it('should remove the property value after a successful clear attempt', async(() => {
|
||||
component.editable = true;
|
||||
component.property.editable = true;
|
||||
component.property.value = 'Jul 10 2017';
|
||||
fixture.detectChanges();
|
||||
|
||||
component.onDateClear();
|
||||
|
||||
fixture.whenStable().then(
|
||||
() => {
|
||||
expect(component.property.value).toBeNull();
|
||||
}
|
||||
);
|
||||
}));
|
||||
|
||||
it('should remove the property default value after a successful clear attempt', async(() => {
|
||||
component.editable = true;
|
||||
component.property.editable = true;
|
||||
component.property.default = 'Jul 10 2017';
|
||||
fixture.detectChanges();
|
||||
|
||||
component.onDateClear();
|
||||
|
||||
fixture.whenStable().then(
|
||||
() => {
|
||||
expect(component.property.default).toBeNull();
|
||||
}
|
||||
);
|
||||
}));
|
||||
|
||||
it('should remove actual and default value after a successful clear attempt', async(() => {
|
||||
component.editable = true;
|
||||
component.property.editable = true;
|
||||
component.property.default = 'Jul 10 2017';
|
||||
component.property.value = 'Jul 10 2017';
|
||||
fixture.detectChanges();
|
||||
const cardViewUpdateService = TestBed.get(CardViewUpdateService);
|
||||
|
||||
const disposableUpdate = cardViewUpdateService.itemUpdated$.subscribe(
|
||||
(updateNotification) => {
|
||||
expect(updateNotification.target).toBe(component.property);
|
||||
expect(updateNotification.changed).toEqual({ dateKey: null });
|
||||
disposableUpdate.unsubscribe();
|
||||
}
|
||||
);
|
||||
|
||||
component.onDateClear();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
expect(component.property.value).toBeNull();
|
||||
expect(component.property.default).toBeNull();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
it('should be possible update a date-time', async () => {
|
||||
component.editable = true;
|
||||
component.property.editable = true;
|
||||
component.property.default = 'Jul 10 2017 00:01:00';
|
||||
component.property.key = 'fake-key';
|
||||
component.dateFormat = 'M/d/yy, h:mm a';
|
||||
component.property.value = 'Jul 10 2017 00:01:00';
|
||||
const expectedDate = moment('Jul 10 2018', 'MMM DD YY h:m:s');
|
||||
fixture.detectChanges();
|
||||
|
||||
await fixture.whenStable();
|
||||
fixture.detectChanges();
|
||||
const element = fixture.debugElement.nativeElement.querySelector('span[data-automation-id="card-date-value-fake-key"]');
|
||||
expect(element).toBeDefined();
|
||||
expect(element.innerText).toEqual('Jul 10, 2017');
|
||||
component.onDateChanged({ value: expectedDate });
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(component.property.value).toEqual(expectedDate.toDate());
|
||||
});
|
||||
});
|
||||
|
||||
+3
-2
@@ -66,12 +66,14 @@ describe('CardViewKeyValuePairsItemComponent', () => {
|
||||
component.property = new CardViewKeyValuePairsItemModel({
|
||||
label: 'Key Value Pairs',
|
||||
value: mockData,
|
||||
key: 'key-value-pairs'
|
||||
key: 'key-value-pairs',
|
||||
editable: false
|
||||
});
|
||||
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.isEditable()).toBe(false);
|
||||
const table = fixture.debugElement.query(By.css('.adf-card-view__key-value-pairs__read-only'));
|
||||
const form = fixture.debugElement.query(By.css('.adf-card-view__key-value-pairs'));
|
||||
|
||||
@@ -96,7 +98,6 @@ describe('CardViewKeyValuePairsItemComponent', () => {
|
||||
const valueInput = fixture.debugElement.query(By.css(`[data-automation-id="card-${component.property.key}-value-input-0"]`));
|
||||
expect(nameInput).not.toBeNull();
|
||||
expect(valueInput).not.toBeNull();
|
||||
|
||||
});
|
||||
|
||||
it('should remove an item from list on REMOVE button click', () => {
|
||||
|
||||
+47
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { OverlayContainer } from '@angular/cdk/overlay';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { CardViewSelectItemModel } from '../../models/card-view-selectitem.model';
|
||||
import { CardViewSelectItemComponent } from './card-view-selectitem.component';
|
||||
@@ -27,6 +28,7 @@ describe('CardViewSelectItemComponent', () => {
|
||||
|
||||
let fixture: ComponentFixture<CardViewSelectItemComponent>;
|
||||
let component: CardViewSelectItemComponent;
|
||||
let overlayContainer: OverlayContainer;
|
||||
const mockData = [{ key: 'one', label: 'One' }, { key: 'two', label: 'Two' }, { key: 'three', label: 'Three' }];
|
||||
const mockDefaultProps = {
|
||||
label: 'Select box label',
|
||||
@@ -43,6 +45,7 @@ describe('CardViewSelectItemComponent', () => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(CardViewSelectItemComponent);
|
||||
component = fixture.componentInstance;
|
||||
overlayContainer = TestBed.get(OverlayContainer);
|
||||
component.property = new CardViewSelectItemModel(mockDefaultProps);
|
||||
});
|
||||
|
||||
@@ -75,6 +78,50 @@ describe('CardViewSelectItemComponent', () => {
|
||||
expect(selectBox).toBeNull();
|
||||
});
|
||||
|
||||
it('should be possible edit selectBox item', () => {
|
||||
component.property = new CardViewSelectItemModel({
|
||||
...mockDefaultProps,
|
||||
editable: true
|
||||
});
|
||||
component.editable = true;
|
||||
component.displayNoneOption = true;
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.value).toEqual('two');
|
||||
expect(component.isEditable()).toBe(true);
|
||||
const selectBox = fixture.debugElement.query(By.css('.mat-select-trigger'));
|
||||
selectBox.triggerEventHandler('click', {});
|
||||
|
||||
fixture.detectChanges();
|
||||
const optionsElement = Array.from(overlayContainer.getContainerElement().querySelectorAll('mat-option'));
|
||||
expect(optionsElement.length).toEqual(4);
|
||||
optionsElement[1].dispatchEvent(new Event('click'));
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.value).toEqual('one');
|
||||
});
|
||||
|
||||
it('should be able to enable None option', () => {
|
||||
component.property = new CardViewSelectItemModel({
|
||||
...mockDefaultProps,
|
||||
editable: true
|
||||
});
|
||||
component.editable = true;
|
||||
component.displayNoneOption = true;
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.isEditable()).toBe(true);
|
||||
const selectBox = fixture.debugElement.query(By.css('.mat-select-trigger'));
|
||||
selectBox.triggerEventHandler('click', {});
|
||||
|
||||
fixture.detectChanges();
|
||||
const noneElement: HTMLElement = overlayContainer.getContainerElement().querySelector('mat-option');
|
||||
expect(noneElement).toBeDefined();
|
||||
expect(noneElement.innerText).toEqual('CORE.CARDVIEW.NONE');
|
||||
});
|
||||
|
||||
it('should render select box if editable property is TRUE', () => {
|
||||
component.ngOnChanges();
|
||||
component.editable = true;
|
||||
|
||||
+425
-124
@@ -22,11 +22,13 @@ import { CardViewUpdateService } from '../../services/card-view-update.service';
|
||||
import { CardViewTextItemComponent } from './card-view-textitem.component';
|
||||
import { setupTestBed } from '../../../testing/setup-test-bed';
|
||||
import { CoreTestingModule } from '../../../testing/core.testing.module';
|
||||
import { CardViewItemFloatValidator, CardViewItemIntValidator } from '@alfresco/adf-core';
|
||||
|
||||
describe('CardViewTextItemComponent', () => {
|
||||
|
||||
let fixture: ComponentFixture<CardViewTextItemComponent>;
|
||||
let component: CardViewTextItemComponent;
|
||||
const mouseEvent = new MouseEvent('click');
|
||||
|
||||
setupTestBed({
|
||||
imports: [CoreTestingModule]
|
||||
@@ -109,128 +111,6 @@ describe('CardViewTextItemComponent', () => {
|
||||
expect(value.nativeElement.innerText.trim()).toBe('FAKE-DEFAULT-KEY');
|
||||
});
|
||||
|
||||
it('should render the default as value if the value is empty, clickable is false and displayEmpty is true', () => {
|
||||
component.property = new CardViewTextItemModel({
|
||||
label: 'Text label',
|
||||
value: '',
|
||||
key: 'textkey',
|
||||
default: 'FAKE-DEFAULT-KEY',
|
||||
clickable: false
|
||||
});
|
||||
component.displayEmpty = true;
|
||||
fixture.detectChanges();
|
||||
|
||||
const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${component.property.key}"]`));
|
||||
expect(value).not.toBeNull();
|
||||
expect(value.nativeElement.innerText.trim()).toBe('FAKE-DEFAULT-KEY');
|
||||
});
|
||||
|
||||
it('should render the default as value if the value is empty and clickable true', () => {
|
||||
component.property = new CardViewTextItemModel({
|
||||
label: 'Text label',
|
||||
value: '',
|
||||
key: 'textkey',
|
||||
default: 'FAKE-DEFAULT-KEY',
|
||||
clickable: true
|
||||
});
|
||||
fixture.detectChanges();
|
||||
|
||||
const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${component.property.key}"]`));
|
||||
expect(value).not.toBeNull();
|
||||
expect(value.nativeElement.innerText.trim()).toBe('FAKE-DEFAULT-KEY');
|
||||
});
|
||||
|
||||
it('should not render the edit icon in case of clickable true but edit false', () => {
|
||||
component.property = new CardViewTextItemModel({
|
||||
label: 'Text label',
|
||||
value: '',
|
||||
key: 'textkey',
|
||||
default: 'FAKE-DEFAULT-KEY',
|
||||
clickable: true
|
||||
});
|
||||
fixture.detectChanges();
|
||||
|
||||
const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-edit-icon-${component.property.icon}"]`));
|
||||
expect(value).toBeNull();
|
||||
});
|
||||
|
||||
it('should not render the clickable icon in case editable set to false', () => {
|
||||
component.property = new CardViewTextItemModel({
|
||||
label: 'Text label',
|
||||
value: '',
|
||||
key: 'textkey',
|
||||
default: 'FAKE-DEFAULT-KEY',
|
||||
clickable: true,
|
||||
icon: 'create'
|
||||
});
|
||||
component.editable = false;
|
||||
fixture.detectChanges();
|
||||
|
||||
const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-clickable-icon-textkey"]`));
|
||||
expect(value).toBeNull('icon should NOT be shown');
|
||||
});
|
||||
|
||||
it('should render the defined clickable icon in case of clickable true and editable input set to true', () => {
|
||||
component.property = new CardViewTextItemModel({
|
||||
label: 'Text label',
|
||||
value: '',
|
||||
key: 'textkey',
|
||||
default: 'FAKE-DEFAULT-KEY',
|
||||
clickable: true,
|
||||
icon: 'FAKE_ICON'
|
||||
});
|
||||
component.editable = true;
|
||||
fixture.detectChanges();
|
||||
|
||||
const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-clickable-icon-textkey"]`));
|
||||
expect(value).not.toBeNull();
|
||||
expect(value.nativeElement.innerText).toBe('FAKE_ICON');
|
||||
});
|
||||
|
||||
it('should not render clickable icon in case of clickable true and icon undefined', () => {
|
||||
component.property = new CardViewTextItemModel({
|
||||
label: 'Text label',
|
||||
value: '',
|
||||
key: 'textkey',
|
||||
default: 'FAKE-DEFAULT-KEY',
|
||||
clickable: true
|
||||
});
|
||||
component.editable = true;
|
||||
fixture.detectChanges();
|
||||
|
||||
const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-clickable-icon-textkey"]`));
|
||||
expect(value).toBeNull('icon should NOT be shown');
|
||||
});
|
||||
|
||||
it('should not render the edit icon in case of clickable true and icon undefined', () => {
|
||||
component.property = new CardViewTextItemModel({
|
||||
label: 'Text label',
|
||||
value: '',
|
||||
key: 'textkey',
|
||||
default: 'FAKE-DEFAULT-KEY',
|
||||
clickable: true
|
||||
});
|
||||
fixture.detectChanges();
|
||||
|
||||
const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-edit-icon-${component.property.icon}"]`));
|
||||
expect(value).toBeNull('Edit icon should NOT be shown');
|
||||
});
|
||||
|
||||
it('should not render the edit icon in case of clickable false and icon defined', () => {
|
||||
component.property = new CardViewTextItemModel({
|
||||
label: 'Text label',
|
||||
value: '',
|
||||
key: 'textkey',
|
||||
default: 'FAKE-DEFAULT-KEY',
|
||||
clickable: false,
|
||||
icon: 'FAKE-ICON'
|
||||
});
|
||||
fixture.detectChanges();
|
||||
|
||||
const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-edit-icon-${component.property.icon}"]`));
|
||||
expect(value).toBeNull('Edit icon should NOT be shown');
|
||||
});
|
||||
|
||||
it('should render value when editable:true', () => {
|
||||
component.editable = true;
|
||||
component.property.editable = true;
|
||||
@@ -268,6 +148,142 @@ describe('CardViewTextItemComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('clickable', () => {
|
||||
beforeEach(() => {
|
||||
component.property = new CardViewTextItemModel({
|
||||
label: 'Text label',
|
||||
value: '',
|
||||
key: 'textkey',
|
||||
default: 'FAKE-DEFAULT-KEY'
|
||||
});
|
||||
});
|
||||
|
||||
it('should render the default as value if the value is empty, clickable is false and displayEmpty is true', () => {
|
||||
component.property.clickable = false;
|
||||
component.displayEmpty = true;
|
||||
fixture.detectChanges();
|
||||
|
||||
const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${component.property.key}"]`));
|
||||
expect(value).not.toBeNull();
|
||||
expect(value.nativeElement.innerText.trim()).toBe('FAKE-DEFAULT-KEY');
|
||||
});
|
||||
|
||||
it('should render the default as value if the value is empty and clickable true', () => {
|
||||
component.property.clickable = true;
|
||||
fixture.detectChanges();
|
||||
|
||||
const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${component.property.key}"]`));
|
||||
expect(value).not.toBeNull();
|
||||
expect(value.nativeElement.innerText.trim()).toBe('FAKE-DEFAULT-KEY');
|
||||
});
|
||||
|
||||
it('should not render the edit icon in case of clickable true but edit false', () => {
|
||||
component.property.clickable = true;
|
||||
fixture.detectChanges();
|
||||
|
||||
const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-edit-icon-${component.property.icon}"]`));
|
||||
expect(value).toBeNull();
|
||||
});
|
||||
|
||||
it('should not render the clickable icon in case editable set to false', () => {
|
||||
component.property.clickable = true;
|
||||
component.property.icon = 'create';
|
||||
component.editable = false;
|
||||
fixture.detectChanges();
|
||||
|
||||
const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-clickable-icon-textkey"]`));
|
||||
expect(value).toBeNull('icon should NOT be shown');
|
||||
});
|
||||
|
||||
it('should render the defined clickable icon in case of clickable true and editable input set to true', () => {
|
||||
component.property.clickable = true;
|
||||
component.property.icon = 'FAKE_ICON';
|
||||
component.editable = true;
|
||||
fixture.detectChanges();
|
||||
|
||||
const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-clickable-icon-textkey"]`));
|
||||
expect(value).not.toBeNull();
|
||||
expect(value.nativeElement.innerText).toBe('FAKE_ICON');
|
||||
});
|
||||
|
||||
it('should not render clickable icon in case of clickable true and icon undefined', () => {
|
||||
component.property.clickable = true;
|
||||
component.editable = true;
|
||||
fixture.detectChanges();
|
||||
|
||||
const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-clickable-icon-textkey"]`));
|
||||
expect(value).toBeNull('icon should NOT be shown');
|
||||
});
|
||||
|
||||
it('should not render the edit icon in case of clickable false and icon defined', () => {
|
||||
component.property.clickable = false;
|
||||
component.property.icon = 'FAKE_ICON';
|
||||
fixture.detectChanges();
|
||||
|
||||
const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-edit-icon-${component.property.icon}"]`));
|
||||
expect(value).toBeNull('Edit icon should NOT be shown');
|
||||
});
|
||||
|
||||
it('should call back function when clickable property enabled', () => {
|
||||
const callBackSpy = jasmine.createSpy('callBack');
|
||||
component.property.clickable = true;
|
||||
component.property.icon = 'FAKE_ICON';
|
||||
component.property.clickCallBack = callBackSpy;
|
||||
component.editable = true;
|
||||
fixture.detectChanges();
|
||||
|
||||
const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-clickable-icon-textkey"]`));
|
||||
expect(value.nativeElement.innerText).toBe('FAKE_ICON');
|
||||
value.nativeElement.click();
|
||||
expect(callBackSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should click event to the event stream when clickable property enabled', () => {
|
||||
const cardViewUpdateService = TestBed.get(CardViewUpdateService);
|
||||
spyOn(cardViewUpdateService, 'clicked').and.stub();
|
||||
|
||||
component.property.clickable = true;
|
||||
component.property.icon = 'FAKE_ICON';
|
||||
component.editable = false;
|
||||
fixture.detectChanges();
|
||||
|
||||
const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-toggle-${component.property.key}"]`));
|
||||
value.nativeElement.click();
|
||||
expect(cardViewUpdateService.clicked).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should update input the value on click of save', () => {
|
||||
component.property.clickable = true;
|
||||
|
||||
component.property.editable = true;
|
||||
component.editable = true;
|
||||
component.editedValue = 'updated-value';
|
||||
component.property.isValid = () => true;
|
||||
const expectedText = 'changed text';
|
||||
spyOn(component, 'update').and.callThrough();
|
||||
const cardViewUpdateService = TestBed.get(CardViewUpdateService);
|
||||
fixture.detectChanges();
|
||||
|
||||
const disposableUpdate = cardViewUpdateService.itemUpdated$.subscribe((updateNotification) => {
|
||||
expect(updateNotification.target).toBe(component.property);
|
||||
expect(updateNotification.changed).toEqual({ textkey: expectedText });
|
||||
disposableUpdate.unsubscribe();
|
||||
});
|
||||
|
||||
updateTextField(component.property.key, expectedText);
|
||||
|
||||
const saveButton = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-update-${component.property.key}"]`));
|
||||
saveButton.nativeElement.click();
|
||||
|
||||
expect(component.update).toHaveBeenCalled();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(getFieldValue(component.property.key)).toEqual(expectedText);
|
||||
expect(component.property.value).toBe(expectedText);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Update', () => {
|
||||
const event = new MouseEvent('click');
|
||||
|
||||
@@ -416,7 +432,7 @@ describe('CardViewTextItemComponent', () => {
|
||||
editInput.nativeElement.dispatchEvent(enterKeyboardEvent);
|
||||
fixture.detectChanges();
|
||||
|
||||
const textItemReadOnly = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-textkey"]`));
|
||||
const textItemReadOnly = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${component.property.key}"]`));
|
||||
expect(textItemReadOnly.nativeElement.textContent).toEqual(expectedText);
|
||||
expect(component.property.value).toBe(expectedText);
|
||||
}));
|
||||
@@ -439,9 +455,294 @@ describe('CardViewTextItemComponent', () => {
|
||||
editInput.nativeElement.dispatchEvent(enterKeyboardEvent);
|
||||
fixture.detectChanges();
|
||||
|
||||
const textItemReadOnly = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-textkey"]`));
|
||||
const textItemReadOnly = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${component.property.key}"]`));
|
||||
expect(textItemReadOnly.nativeElement.textContent).toEqual('Lorem ipsum');
|
||||
expect(component.property.value).toBe('Lorem ipsum');
|
||||
}));
|
||||
|
||||
it('should reset the value onclick of clear button', () => {
|
||||
component.inEdit = false;
|
||||
component.property.isValid = () => true;
|
||||
spyOn(component, 'reset').and.callThrough();
|
||||
fixture.detectChanges();
|
||||
|
||||
updateTextField(component.property.key, 'changed text');
|
||||
|
||||
const clearButton = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-reset-${component.property.key}"]`));
|
||||
clearButton.nativeElement.click();
|
||||
expect(component.reset).toHaveBeenCalled();
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(getFieldValue(component.property.key)).toEqual('Lorem ipsum');
|
||||
expect(component.property.value).toBe('Lorem ipsum');
|
||||
});
|
||||
|
||||
it('should update multiline input the value on click of save', () => {
|
||||
component.inEdit = false;
|
||||
component.property.isValid = () => true;
|
||||
component.property.multiline = true;
|
||||
const expectedText = 'changed text';
|
||||
spyOn(component, 'update').and.callThrough();
|
||||
const cardViewUpdateService = TestBed.get(CardViewUpdateService);
|
||||
fixture.detectChanges();
|
||||
|
||||
const disposableUpdate = cardViewUpdateService.itemUpdated$.subscribe((updateNotification) => {
|
||||
expect(updateNotification.target).toBe(component.property);
|
||||
expect(updateNotification.changed).toEqual({ textkey: expectedText });
|
||||
disposableUpdate.unsubscribe();
|
||||
});
|
||||
|
||||
updateTextArea(component.property.key, expectedText);
|
||||
|
||||
const saveButton = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-update-${component.property.key}"]`));
|
||||
saveButton.nativeElement.click();
|
||||
|
||||
expect(component.update).toHaveBeenCalled();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(getFieldValue(component.property.key)).toEqual(expectedText);
|
||||
expect(component.property.value).toBe(expectedText);
|
||||
});
|
||||
});
|
||||
|
||||
describe('number', () => {
|
||||
let cardViewUpdateService: CardViewUpdateService;
|
||||
|
||||
beforeEach(() => {
|
||||
component.property.editable = true;
|
||||
component.editable = true;
|
||||
component.inEdit = false;
|
||||
component.property.value = 10;
|
||||
component.property.validators.push(new CardViewItemIntValidator());
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
cardViewUpdateService = TestBed.get(CardViewUpdateService);
|
||||
});
|
||||
|
||||
it('should show validation error when string passed', () => {
|
||||
spyOn(component, 'update').and.callThrough();
|
||||
|
||||
updateTextField(component.property.key, 'update number');
|
||||
|
||||
const saveButton = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-update-${component.property.key}"]`));
|
||||
saveButton.nativeElement.click();
|
||||
fixture.detectChanges();
|
||||
expect(component.update).toHaveBeenCalled();
|
||||
|
||||
const error = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-error-${component.property.key}"] li`));
|
||||
expect(error.nativeElement.innerText).toEqual('CORE.CARDVIEW.VALIDATORS.INT_VALIDATION_ERROR');
|
||||
expect(component.property.value).toBe(10);
|
||||
});
|
||||
|
||||
it('should show validation error for empty string', () => {
|
||||
spyOn(component, 'update').and.callThrough();
|
||||
|
||||
updateTextField(component.property.key, ' ');
|
||||
|
||||
const saveButton = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-update-${component.property.key}"]`));
|
||||
saveButton.nativeElement.click();
|
||||
expect(component.update).toHaveBeenCalled();
|
||||
|
||||
fixture.detectChanges();
|
||||
const error = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-error-${component.property.key}"] li`));
|
||||
expect(error.nativeElement.innerText).toEqual('CORE.CARDVIEW.VALIDATORS.INT_VALIDATION_ERROR');
|
||||
|
||||
expect(component.property.value).toBe(10);
|
||||
});
|
||||
|
||||
it('should show validation error for float number', () => {
|
||||
spyOn(component, 'update').and.callThrough();
|
||||
|
||||
updateTextField(component.property.key, 0.024);
|
||||
|
||||
const saveButton = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-update-${component.property.key}"]`));
|
||||
saveButton.nativeElement.click();
|
||||
expect(component.update).toHaveBeenCalled();
|
||||
|
||||
fixture.detectChanges();
|
||||
const error = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-error-${component.property.key}"] li`));
|
||||
expect(error.nativeElement.innerText).toEqual('CORE.CARDVIEW.VALIDATORS.INT_VALIDATION_ERROR');
|
||||
|
||||
expect(component.property.value).toBe(10);
|
||||
});
|
||||
|
||||
it('should show validation error for exceed the number limit (2147483648)', () => {
|
||||
spyOn(component, 'update').and.callThrough();
|
||||
|
||||
updateTextField(component.property.key, 2147483648);
|
||||
|
||||
const saveButton = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-update-${component.property.key}"]`));
|
||||
saveButton.nativeElement.click();
|
||||
expect(component.update).toHaveBeenCalled();
|
||||
|
||||
fixture.detectChanges();
|
||||
const error = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-error-${component.property.key}"] li`));
|
||||
expect(error.nativeElement.innerText).toEqual('CORE.CARDVIEW.VALIDATORS.INT_VALIDATION_ERROR');
|
||||
|
||||
expect(component.property.value).toBe(10);
|
||||
});
|
||||
|
||||
it('should not show validation error for below the number limit (2147483647)', () => {
|
||||
spyOn(component, 'update').and.callThrough();
|
||||
|
||||
updateTextField(component.property.key, 2147483647);
|
||||
|
||||
const saveButton = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-update-${component.property.key}"]`));
|
||||
saveButton.nativeElement.click();
|
||||
expect(component.update).toHaveBeenCalled();
|
||||
|
||||
fixture.detectChanges();
|
||||
const error = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-error-${component.property.key}"] li`));
|
||||
expect(error).toBeFalsy();
|
||||
|
||||
expect(component.property.value).toBe('2147483647');
|
||||
});
|
||||
|
||||
it('should reset the value onclick of clear button', () => {
|
||||
spyOn(component, 'reset').and.callThrough();
|
||||
fixture.detectChanges();
|
||||
|
||||
updateTextField(component.property.key, 20);
|
||||
|
||||
const clearButton = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-reset-${component.property.key}"]`));
|
||||
clearButton.nativeElement.click();
|
||||
expect(component.reset).toHaveBeenCalled();
|
||||
|
||||
fixture.detectChanges();
|
||||
const error = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-error-${component.property.key}"] li`));
|
||||
expect(error).toBeFalsy();
|
||||
|
||||
expect(getFieldValue(component.property.key)).toEqual('10');
|
||||
expect(component.property.value).toBe(10);
|
||||
});
|
||||
|
||||
it('should update input the value on click of save', () => {
|
||||
component.property.multiline = true;
|
||||
const expectedNumber = 2020;
|
||||
spyOn(component, 'update').and.callThrough();
|
||||
fixture.detectChanges();
|
||||
expect(component.property.value).not.toEqual(expectedNumber);
|
||||
|
||||
const disposableUpdate = cardViewUpdateService.itemUpdated$.subscribe((updateNotification) => {
|
||||
expect(updateNotification.target).toBe(component.property);
|
||||
expect(updateNotification.changed).toEqual({ textkey: expectedNumber.toString() });
|
||||
disposableUpdate.unsubscribe();
|
||||
});
|
||||
|
||||
updateTextArea(component.property.key, expectedNumber);
|
||||
|
||||
const saveButton = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-update-${component.property.key}"]`));
|
||||
saveButton.nativeElement.click();
|
||||
expect(component.update).toHaveBeenCalled();
|
||||
|
||||
fixture.detectChanges();
|
||||
const error = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-error-${component.property.key}"] li`));
|
||||
expect(error).toBeFalsy();
|
||||
|
||||
expect(getFieldValue(component.property.key)).toEqual(expectedNumber.toString());
|
||||
expect(component.property.value).toBe(expectedNumber.toString());
|
||||
});
|
||||
});
|
||||
|
||||
describe('float', () => {
|
||||
let cardViewUpdateService: CardViewUpdateService;
|
||||
const floatValue = 77.33;
|
||||
|
||||
beforeEach(() => {
|
||||
component.property.editable = true;
|
||||
component.editable = true;
|
||||
component.inEdit = false;
|
||||
component.property.value = floatValue;
|
||||
component.property.validators.push(new CardViewItemFloatValidator());
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
cardViewUpdateService = TestBed.get(CardViewUpdateService);
|
||||
});
|
||||
|
||||
it('should show validation error when string passed', () => {
|
||||
spyOn(component, 'update').and.callThrough();
|
||||
|
||||
updateTextField(component.property.key, ' ');
|
||||
|
||||
const saveButton = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-update-${component.property.key}"]`));
|
||||
saveButton.nativeElement.click();
|
||||
expect(component.update).toHaveBeenCalled();
|
||||
|
||||
fixture.detectChanges();
|
||||
const error = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-error-${component.property.key}"] li`));
|
||||
expect(error.nativeElement.innerText).toEqual('CORE.CARDVIEW.VALIDATORS.FLOAT_VALIDATION_ERROR');
|
||||
|
||||
expect(component.property.value).toBe(floatValue);
|
||||
});
|
||||
|
||||
it('should show validation error for empty string', () => {
|
||||
spyOn(component, 'update').and.callThrough();
|
||||
|
||||
updateTextField(component.property.key, ' ');
|
||||
|
||||
const saveButton = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-update-${component.property.key}"]`));
|
||||
saveButton.nativeElement.click();
|
||||
expect(component.update).toHaveBeenCalled();
|
||||
|
||||
fixture.detectChanges();
|
||||
const error = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-error-${component.property.key}"] li`));
|
||||
expect(error.nativeElement.innerText).toEqual('CORE.CARDVIEW.VALIDATORS.FLOAT_VALIDATION_ERROR');
|
||||
|
||||
expect(component.property.value).toBe(floatValue);
|
||||
});
|
||||
|
||||
it('should update input the value on click of save', () => {
|
||||
component.property.multiline = true;
|
||||
const expectedFloat = 88.44;
|
||||
spyOn(component, 'update').and.callThrough();
|
||||
fixture.detectChanges();
|
||||
|
||||
const disposableUpdate = cardViewUpdateService.itemUpdated$.subscribe((updateNotification) => {
|
||||
expect(updateNotification.target).toBe(component.property);
|
||||
expect(updateNotification.changed).toEqual({ textkey: expectedFloat.toString() });
|
||||
disposableUpdate.unsubscribe();
|
||||
});
|
||||
|
||||
updateTextArea(component.property.key, expectedFloat);
|
||||
|
||||
const saveButton = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-update-${component.property.key}"]`));
|
||||
saveButton.nativeElement.click();
|
||||
expect(component.update).toHaveBeenCalled();
|
||||
|
||||
fixture.detectChanges();
|
||||
const error = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-error-${component.property.key}"] li`));
|
||||
expect(error).toBeFalsy();
|
||||
|
||||
expect(getFieldValue(component.property.key)).toEqual(expectedFloat.toString());
|
||||
expect(component.property.value).toBe(expectedFloat.toString());
|
||||
});
|
||||
});
|
||||
|
||||
function updateTextField(key, value) {
|
||||
const editIcon = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-toggle-${key}"]`));
|
||||
editIcon.nativeElement.dispatchEvent(new MouseEvent('click'));
|
||||
fixture.detectChanges();
|
||||
|
||||
const editInput = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-editinput-${key}"]`));
|
||||
editInput.nativeElement.value = value;
|
||||
editInput.nativeElement.dispatchEvent(new Event('input'));
|
||||
fixture.detectChanges();
|
||||
}
|
||||
|
||||
function updateTextArea(key, value) {
|
||||
const editIcon = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-toggle-${key}"]`));
|
||||
editIcon.nativeElement.dispatchEvent(mouseEvent);
|
||||
fixture.detectChanges();
|
||||
|
||||
const editInput = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-edittextarea-${key}"]`));
|
||||
editInput.nativeElement.value = value;
|
||||
editInput.nativeElement.dispatchEvent(new Event('input'));
|
||||
fixture.detectChanges();
|
||||
}
|
||||
|
||||
function getFieldValue(key): string {
|
||||
const textItemReadOnly = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${key}"]`));
|
||||
return textItemReadOnly.nativeElement.textContent;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -890,6 +890,25 @@ describe('DataTable', () => {
|
||||
expect(dataTable.isSelectAllChecked).toBe(true);
|
||||
});
|
||||
|
||||
it('should allow select row when multi-select enabled', () => {
|
||||
const data = new ObjectDataTableAdapter([{}, {}], []);
|
||||
const rows = data.getRows();
|
||||
|
||||
dataTable.multiselect = true;
|
||||
dataTable.ngOnChanges({ 'data': new SimpleChange('123', data, true) });
|
||||
|
||||
expect(rows[0].isSelected).toBe(false);
|
||||
expect(rows[1].isSelected).toBe(false);
|
||||
|
||||
dataTable.onCheckboxChange(rows[1], <MatCheckboxChange> { checked: true });
|
||||
expect(rows[0].isSelected).toBe(false);
|
||||
expect(rows[1].isSelected).toBe(true);
|
||||
|
||||
dataTable.onCheckboxChange(rows[0], <MatCheckboxChange> { checked: true });
|
||||
expect(rows[0].isSelected).toBe(true);
|
||||
expect(rows[1].isSelected).toBe(true);
|
||||
});
|
||||
|
||||
it('should require multiselect option to toggle row state', () => {
|
||||
const data = new ObjectDataTableAdapter([{}, {}, {}], []);
|
||||
const rows = data.getRows();
|
||||
|
||||
+61
-10
@@ -15,12 +15,19 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { Component, SimpleChange, ViewChild } from '@angular/core';
|
||||
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { AppConfigService, setupTestBed, CoreModule, DataTableModule, DataRowEvent, ObjectDataRow } from '@alfresco/adf-core';
|
||||
import {
|
||||
AppConfigService,
|
||||
CoreModule,
|
||||
DataRowEvent,
|
||||
DataTableModule,
|
||||
ObjectDataRow,
|
||||
setupTestBed
|
||||
} from '@alfresco/adf-core';
|
||||
import { ProcessListCloudService } from '../services/process-list-cloud.service';
|
||||
import { ProcessListCloudComponent } from './process-list-cloud.component';
|
||||
import { fakeProcessCloudList, fakeCustomSchema } from '../mock/process-list-service.mock';
|
||||
import { fakeCustomSchema, fakeProcessCloudList, processListSchemaMock } from '../mock/process-list-service.mock';
|
||||
import { of } from 'rxjs';
|
||||
import { ProcessListCloudTestingModule } from '../testing/process-list.testing.module';
|
||||
import { ProcessListCloudModule } from '../process-list-cloud.module';
|
||||
@@ -65,7 +72,8 @@ describe('ProcessListCloudComponent', () => {
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
ProcessListCloudTestingModule, ProcessListCloudModule
|
||||
ProcessListCloudTestingModule,
|
||||
ProcessListCloudModule
|
||||
],
|
||||
providers: [ProcessListCloudService]
|
||||
});
|
||||
@@ -97,14 +105,57 @@ describe('ProcessListCloudComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
afterEach(() => fixture.destroy());
|
||||
|
||||
it('should use the default schemaColumn', () => {
|
||||
appConfig.config = Object.assign(appConfig.config, { 'adf-cloud-process-list': processListSchemaMock });
|
||||
component.ngAfterContentInit();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.columns).toBeDefined();
|
||||
expect(component.columns.length).toEqual(10);
|
||||
});
|
||||
|
||||
it('should use the default schemaColumn as default', () => {
|
||||
component.ngAfterContentInit();
|
||||
expect(component.columns).toBeDefined();
|
||||
expect(component.columns.length).toEqual(2);
|
||||
it('should display empty content when process list is empty', () => {
|
||||
const emptyList = {list: {entries: []}};
|
||||
spyOn(processListCloudService, 'getProcessByRequest').and.returnValue(of(emptyList));
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(component.isLoading).toBe(true);
|
||||
let loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
|
||||
expect(loadingContent.nativeElement).toBeDefined();
|
||||
|
||||
const appName = new SimpleChange(null, 'FAKE-APP-NAME', true);
|
||||
component.ngOnChanges({ appName });
|
||||
fixture.detectChanges();
|
||||
|
||||
loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
|
||||
expect(loadingContent).toBeFalsy();
|
||||
|
||||
const emptyContent = fixture.debugElement.query(By.css('.adf-empty-content'));
|
||||
expect(emptyContent.nativeElement).toBeDefined();
|
||||
});
|
||||
|
||||
it('should load spinner and show the content', () => {
|
||||
spyOn(processListCloudService, 'getProcessByRequest').and.returnValue(of(fakeProcessCloudList));
|
||||
const appName = new SimpleChange(null, 'FAKE-APP-NAME', true);
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(component.isLoading).toBe(true);
|
||||
let loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
|
||||
expect(loadingContent.nativeElement).toBeDefined();
|
||||
|
||||
component.ngOnChanges({ appName });
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.isLoading).toBe(false);
|
||||
loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
|
||||
expect(loadingContent).toBeFalsy();
|
||||
|
||||
const emptyContent = fixture.debugElement.query(By.css('.adf-empty-content'));
|
||||
expect(emptyContent).toBeFalsy();
|
||||
|
||||
expect(component.rows.length).toEqual(3);
|
||||
});
|
||||
|
||||
it('should use the custom schemaColumn from app.config.json', () => {
|
||||
|
||||
+68
@@ -97,3 +97,71 @@ export let fakeCustomSchema =
|
||||
'sortable': true
|
||||
})
|
||||
];
|
||||
|
||||
export const processListSchemaMock = {
|
||||
'presets': {
|
||||
'default': [
|
||||
{
|
||||
'key': 'entry.id',
|
||||
'type': 'text',
|
||||
'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.ID',
|
||||
'sortable': true
|
||||
},
|
||||
{
|
||||
'key': 'entry.name',
|
||||
'type': 'text',
|
||||
'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.NAME',
|
||||
'sortable': true
|
||||
},
|
||||
{
|
||||
'key': 'entry.status',
|
||||
'type': 'text',
|
||||
'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.STATUS',
|
||||
'sortable': true
|
||||
},
|
||||
{
|
||||
'key': 'entry.startDate',
|
||||
'type': 'date',
|
||||
'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.START_DATE',
|
||||
'sortable': true,
|
||||
'format': 'timeAgo'
|
||||
},
|
||||
{
|
||||
'key': 'entry.appName',
|
||||
'type': 'text',
|
||||
'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.APP_NAME',
|
||||
'sortable': true
|
||||
},
|
||||
{
|
||||
'key': 'entry.businessKey',
|
||||
'type': 'text',
|
||||
'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.BUSINESS_KEY',
|
||||
'sortable': true
|
||||
},
|
||||
{
|
||||
'key': 'entry.initiator',
|
||||
'type': 'text',
|
||||
'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.INITIATOR',
|
||||
'sortable': true
|
||||
},
|
||||
{
|
||||
'key': 'entry.lastModified',
|
||||
'type': 'date',
|
||||
'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.LAST_MODIFIED',
|
||||
'sortable': true
|
||||
},
|
||||
{
|
||||
'key': 'entry.processDefinitionId',
|
||||
'type': 'text',
|
||||
'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.PROCESS_DEF_ID',
|
||||
'sortable': true
|
||||
},
|
||||
{
|
||||
'key': 'entry.processDefinitionKey',
|
||||
'type': 'text',
|
||||
'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.PROCESS_DEF_KEY',
|
||||
'sortable': true
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
+3
-2
@@ -166,10 +166,11 @@ describe('StartTaskCloudComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should select logged in user as assignee by default', () => {
|
||||
it('should show logged in user as assignee by default', () => {
|
||||
fixture.detectChanges();
|
||||
const assignee = fixture.nativeElement.querySelector('[data-automation-id="adf-people-cloud-search-input"]');
|
||||
const assignee = fixture.nativeElement.querySelector('[data-automation-id="adf-people-cloud-chip-currentUser"]');
|
||||
expect(assignee).toBeDefined();
|
||||
expect(assignee.innerText).toContain('Test User');
|
||||
});
|
||||
|
||||
it('should show start task button', () => {
|
||||
|
||||
+2
-2
@@ -58,11 +58,11 @@ describe('EditTaskFilterCloudComponent', () => {
|
||||
service = TestBed.get(TaskFilterCloudService);
|
||||
appsService = TestBed.get(AppsProcessCloudService);
|
||||
dialog = TestBed.get(MatDialog);
|
||||
spyOn(dialog, 'open').and.returnValue({ afterClosed() { return of({
|
||||
spyOn(dialog, 'open').and.returnValue({ afterClosed: of({
|
||||
action: TaskFilterDialogCloudComponent.ACTION_SAVE,
|
||||
icon: 'icon',
|
||||
name: 'fake-name'
|
||||
}); }});
|
||||
}) });
|
||||
getTaskFilterSpy = spyOn(service, 'getTaskFilterById').and.returnValue(of(fakeFilter));
|
||||
getRunningApplicationsSpy = spyOn(appsService, 'getDeployedApplicationsByStatus').and.returnValue(of(fakeApplicationInstance));
|
||||
fixture.detectChanges();
|
||||
|
||||
+15
@@ -67,6 +67,21 @@ describe('TaskFiltersCloudComponent', () => {
|
||||
taskFilterService = TestBed.get(TaskFilterCloudService);
|
||||
});
|
||||
|
||||
it('should the first element active', async(() => {
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(fakeGlobalFilterObservable);
|
||||
const change = new SimpleChange(undefined, 'my-app-1', true);
|
||||
component.ngOnChanges({'appName': change});
|
||||
fixture.detectChanges();
|
||||
component.showIcons = true;
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
const activeElement = fixture.debugElement.nativeElement.querySelector('.adf-active span');
|
||||
expect(activeElement).toBeDefined();
|
||||
expect(activeElement.innerText).toEqual(fakeGlobalFilter[0].name);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should attach specific icon for each filter if hasIcon is true', async(() => {
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(fakeGlobalFilterObservable);
|
||||
const change = new SimpleChange(undefined, 'my-app-1', true);
|
||||
|
||||
+42
@@ -124,6 +124,48 @@ describe('TaskListCloudComponent', () => {
|
||||
expect(component.columns.length).toEqual(3);
|
||||
});
|
||||
|
||||
it('should display empty content when process list is empty', () => {
|
||||
const emptyList = {list: {entries: []}};
|
||||
spyOn(taskListCloudService, 'getTaskByRequest').and.returnValue(of(emptyList));
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(component.isLoading).toBe(true);
|
||||
let loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
|
||||
expect(loadingContent.nativeElement).toBeDefined();
|
||||
|
||||
const appName = new SimpleChange(null, 'FAKE-APP-NAME', true);
|
||||
component.ngOnChanges({ appName });
|
||||
fixture.detectChanges();
|
||||
|
||||
loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
|
||||
expect(loadingContent).toBeFalsy();
|
||||
|
||||
const emptyContent = fixture.debugElement.query(By.css('.adf-empty-content'));
|
||||
expect(emptyContent.nativeElement).toBeDefined();
|
||||
});
|
||||
|
||||
it('should load spinner and show the content', () => {
|
||||
spyOn(taskListCloudService, 'getTaskByRequest').and.returnValue(of(fakeGlobalTask));
|
||||
const appName = new SimpleChange(null, 'FAKE-APP-NAME', true);
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(component.isLoading).toBe(true);
|
||||
let loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
|
||||
expect(loadingContent.nativeElement).toBeDefined();
|
||||
|
||||
component.ngOnChanges({ appName });
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.isLoading).toBe(false);
|
||||
loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
|
||||
expect(loadingContent).toBeFalsy();
|
||||
|
||||
const emptyContent = fixture.debugElement.query(By.css('.adf-empty-content'));
|
||||
expect(emptyContent).toBeFalsy();
|
||||
|
||||
expect(component.rows.length).toEqual(1);
|
||||
});
|
||||
|
||||
it('should use the custom schemaColumn from app.config.json', () => {
|
||||
component.presetColumn = 'fakeCustomSchema';
|
||||
component.ngAfterContentInit();
|
||||
|
||||
Reference in New Issue
Block a user