[no-issue] speed up test CS part 2 (#3009)

* remove tag and rating service the testbed

* remove unused import in modules

* pdf viewer async

* viewer test fixed

* remove testbed share datatable

* remove unused dependencies

* add missing parameter

* remove testbed from folder actions service

* TaskHeaderComponent async

* remove testbed from document actions and list

* remove unused import

* use done for nested test

* fast finish false
This commit is contained in:
Eugenio Romano
2018-02-28 17:15:52 +00:00
committed by GitHub
parent b359579078
commit 45426fd246
52 changed files with 410 additions and 561 deletions
@@ -18,10 +18,9 @@
import { DebugElement, Component } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { AppsProcessService, CoreModule } from '@alfresco/adf-core';
import { AppsProcessService } from '@alfresco/adf-core';
import { Observable } from 'rxjs/Observable';
import { MaterialModule } from '../material.module';
import { defaultApp, deployedApps, nonDeployedApps } from '../mock/apps-list.mock';
import { AppsListComponent } from './apps-list.component';
import { TranslateModule } from '@ngx-translate/core';
@@ -37,8 +36,6 @@ describe('AppsListComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
CoreModule,
MaterialModule,
TranslateModule
],
declarations: [
@@ -273,9 +270,6 @@ describe('Custom CustomEmptyAppListTemplateComponent', () => {
declarations: [
AppsListComponent,
CustomEmptyAppListTemplateComponent
],
imports: [
MaterialModule
]
}).compileComponents();
}));
@@ -20,7 +20,6 @@ import { async, TestBed } from '@angular/core/testing';
import { ComponentFixture } from '@angular/core/testing';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
import { MaterialModule } from '../material.module';
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
import { MatDialog } from '@angular/material';
import { OverlayContainer } from '@angular/cdk/overlay';
@@ -70,7 +69,6 @@ describe('Select app dialog', () => {
TestBed.configureTestingModule({
imports: [
MaterialModule,
FormsModule,
ReactiveFormsModule,
BrowserDynamicTestingModule
@@ -17,7 +17,6 @@
import { SimpleChange } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { MaterialModule } from '../material.module';
import { ProcessContentService } from '@alfresco/adf-core';
import { TranslationService } from '@alfresco/adf-core';
import { CreateProcessAttachmentComponent } from './create-process-attachment.component';
@@ -51,7 +50,6 @@ describe('Activiti Process Create Attachment', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
MaterialModule
],
declarations: [
CreateProcessAttachmentComponent
@@ -17,7 +17,6 @@
import { SimpleChange } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { MaterialModule } from '../material.module';
import { Observable } from 'rxjs/Observable';
import { ProcessContentService } from '@alfresco/adf-core';
@@ -33,7 +32,6 @@ describe('Activiti Task Create Attachment', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
MaterialModule
],
declarations: [
AttachmentComponent
@@ -18,7 +18,6 @@
import { NgZone, SimpleChange, Component } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { MatProgressSpinnerModule } from '@angular/material';
import { MaterialModule } from '../material.module';
import { By } from '@angular/platform-browser';
import { TranslateService } from '@ngx-translate/core';
import { ProcessContentService } from '@alfresco/adf-core';
@@ -325,7 +324,6 @@ describe('Custom CustomEmptyTemplateComponent', () => {
CustomEmptyTemplateComponent
],
imports: [
MaterialModule
]
}).compileComponents();
}));
@@ -18,7 +18,6 @@
import { SimpleChange, Component } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { MaterialModule } from '../material.module';
import { Observable } from 'rxjs/Observable';
import { TaskAttachmentListComponent } from './task-attachment-list.component';
import { ProcessContentService } from '@alfresco/adf-core';
@@ -35,9 +34,6 @@ describe('TaskAttachmentList', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
MaterialModule
],
declarations: [
TaskAttachmentListComponent
],
@@ -327,9 +323,6 @@ describe('Custom CustomEmptyTemplateComponent', () => {
declarations: [
TaskAttachmentListComponent,
CustomEmptyTemplateComponent
],
imports: [
MaterialModule
]
}).compileComponents();
}));
@@ -33,7 +33,6 @@ import {
ContentService
} from '@alfresco/adf-core';
import { ContentNodeDialogService, DocumentListService } from '@alfresco/adf-content-services';
import { MaterialModule } from '../material.module';
import { Observable } from 'rxjs/Observable';
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
@@ -105,7 +104,6 @@ describe('AttachFileWidgetComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [MaterialModule],
declarations: [AttachFileWidgetComponent],
providers: [
FormService,
@@ -29,7 +29,6 @@ import {
NodesApiService
} from '@alfresco/adf-core';
import { ContentNodeDialogService, DocumentListService } from '@alfresco/adf-content-services';
import { MaterialModule } from '../material.module';
import { Observable } from 'rxjs/Observable';
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
@@ -59,7 +58,6 @@ describe('AttachFolderWidgetComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [MaterialModule],
declarations: [AttachFolderWidgetComponent],
providers: [
FormService,
@@ -17,7 +17,6 @@
import { DebugElement, NO_ERRORS_SCHEMA, SimpleChange } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { MaterialModule } from '../../material.module';
import { By } from '@angular/platform-browser';
import { Observable } from 'rxjs/Observable';
@@ -39,7 +38,6 @@ describe('ProcessInstanceDetailsComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
MaterialModule,
FormModule,
TaskListModule
],
@@ -17,7 +17,6 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AppConfigService, CardViewUpdateService } from '@alfresco/adf-core';
import { MaterialModule } from '../../material.module';
import { ProcessInstance } from '../models/process-instance.model';
import { exampleProcess } from '../../mock';
@@ -32,9 +31,6 @@ describe('ProcessInstanceHeaderComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
MaterialModule
],
declarations: [
ProcessInstanceHeaderComponent
],
@@ -20,7 +20,6 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { TaskDetailsModel } from '../models/task-details.model';
import { TaskListService } from '../services/tasklist.service';
import { ChecklistComponent } from './checklist.component';
import { MaterialModule } from '../../material.module';
import { TranslateModule } from '@ngx-translate/core';
declare let jasmine: any;
@@ -40,7 +39,6 @@ describe('ChecklistComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
MaterialModule,
TranslateModule
],
declarations: [
@@ -16,7 +16,6 @@
*/
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { MaterialModule } from '../../material.module';
import { TranslationService, TranslationMock } from '@alfresco/adf-core';
import { PeopleSelectorComponent, PeopleSearchFieldComponent, PeopleListComponent } from '../../people';
import { Observable } from 'rxjs/Observable';
@@ -47,9 +46,6 @@ describe('StartTaskComponent', () => {
let testUser = {id: 1001, firstName: 'fakeName', email: 'fake@app.activiti.com'};
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
MaterialModule
],
declarations: [
StartTaskComponent,
PeopleSearchFieldComponent,
@@ -22,7 +22,6 @@ import { Observable } from 'rxjs/Observable';
import { FilterParamsModel, FilterRepresentationModel } from '../models/filter.model';
import { TaskListService } from '../services/tasklist.service';
import { TaskFilterService } from '../services/task-filter.service';
import { MaterialModule } from '../../material.module';
import { TaskFiltersComponent } from './task-filters.component';
describe('TaskFiltersComponent', () => {
@@ -65,9 +64,6 @@ describe('TaskFiltersComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
MaterialModule
],
declarations: [
TaskFiltersComponent
],
@@ -19,7 +19,6 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { CardViewUpdateService, AppConfigService } from '@alfresco/adf-core';
import { BpmUserService } from '@alfresco/adf-core';
import { MaterialModule } from '../../material.module';
import { Observable } from 'rxjs/Observable';
import {
completedTaskDetailsMock,
@@ -27,7 +26,8 @@ import {
claimableTaskDetailsMock,
claimedTaskDetailsMock,
claimedByGroupMemberMock,
taskDetailsWithOutCandidateGroup } from '../../mock';
taskDetailsWithOutCandidateGroup
} from '../../mock';
import { TaskDetailsModel } from '../models/task-details.model';
import { TaskListService } from './../services/tasklist.service';
@@ -57,9 +57,6 @@ describe('TaskHeaderComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
MaterialModule
],
declarations: [
TaskHeaderComponent
],
@@ -82,236 +79,303 @@ describe('TaskHeaderComponent', () => {
appConfigService = TestBed.get(AppConfigService);
});
it('should render empty component if no task details provided', () => {
it('should render empty component if no task details provided', async(() => {
component.taskDetails = undefined;
fixture.detectChanges();
expect(fixture.debugElement.children.length).toBe(0);
});
}));
it('should display assignee', () => {
component.ngOnChanges({});
it('should display assignee', async(() => {
component.refreshData();
fixture.detectChanges();
let formNameEl = fixture.debugElement.query(By.css('[data-automation-id="header-assignee"] .adf-property-value'));
expect(formNameEl.nativeElement.innerText).toBe('Wilbur Adams');
});
it('should display placeholder if no assignee', () => {
fixture.whenStable().then(() => {
let formNameEl = fixture.debugElement.query(By.css('[data-automation-id="header-assignee"] .adf-property-value'));
expect(formNameEl.nativeElement.innerText).toBe('Wilbur Adams');
});
}));
it('should display placeholder if no assignee', async(() => {
component.taskDetails.assignee = null;
component.ngOnChanges({});
component.refreshData();
fixture.detectChanges();
let valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-assignee"] .adf-property-value'));
expect(valueEl.nativeElement.innerText).toBe('ADF_TASK_LIST.PROPERTIES.ASSIGNEE_DEFAULT');
});
it('should display created-by', () => {
component.ngOnChanges({});
fixture.whenStable().then(() => {
let valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-assignee"] .adf-property-value'));
expect(valueEl.nativeElement.innerText).toBe('ADF_TASK_LIST.PROPERTIES.ASSIGNEE_DEFAULT');
});
}));
it('should display created-by', async(() => {
component.refreshData();
fixture.detectChanges();
let formNameEl = fixture.debugElement.query(By.css('[data-automation-id="header-created-by"] .adf-property-value'));
expect(formNameEl.nativeElement.innerText).toBe('Wilbur Adams');
});
it('should display priority', () => {
fixture.whenStable().then(() => {
let formNameEl = fixture.debugElement.query(By.css('[data-automation-id="header-created-by"] .adf-property-value'));
expect(formNameEl.nativeElement.innerText).toBe('Wilbur Adams');
});
}));
it('should display priority', async(() => {
component.taskDetails.priority = 27;
component.ngOnChanges({});
component.refreshData();
fixture.detectChanges();
let formNameEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-priority"]'));
expect(formNameEl.nativeElement.innerText).toBe('27');
});
it('should set editable to false if the task has already completed', () => {
fixture.whenStable().then(() => {
let formNameEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-priority"]'));
expect(formNameEl.nativeElement.innerText).toBe('27');
});
}));
it('should set editable to false if the task has already completed', async(() => {
component.taskDetails.endDate = new Date('05/05/2002');
component.ngOnChanges({});
component.refreshData();
fixture.detectChanges();
let datePicker = fixture.debugElement.query(By.css(`[data-automation-id="datepicker-dueDate"]`));
expect(datePicker).toBeNull('Datepicker should NOT be in DOM');
});
fixture.whenStable().then(() => {
let datePicker = fixture.debugElement.query(By.css(`[data-automation-id="datepicker-dueDate"]`));
expect(datePicker).toBeNull('Datepicker should NOT be in DOM');
});
}));
it('should set editable to true if the task has not completed yet', () => {
it('should set editable to true if the task has not completed yet', async(() => {
component.taskDetails.endDate = undefined;
component.ngOnChanges({});
component.refreshData();
fixture.detectChanges();
let datePicker = fixture.debugElement.query(By.css(`[data-automation-id="datepicker-dueDate"]`));
expect(datePicker).not.toBeNull('Datepicker should be in DOM');
});
fixture.whenStable().then(() => {
let datePicker = fixture.debugElement.query(By.css(`[data-automation-id="datepicker-dueDate"]`));
expect(datePicker).not.toBeNull('Datepicker should be in DOM');
});
}));
describe('Claiming', () => {
it('should display the claim button if no assignee', () => {
it('should display the claim button if no assignee', async(() => {
component.taskDetails = new TaskDetailsModel(claimableTaskDetailsMock);
component.ngOnChanges({});
component.refreshData();
fixture.detectChanges();
let claimButton = fixture.debugElement.query(By.css('[data-automation-id="header-claim-button"]'));
expect(claimButton.nativeElement.innerText).toBe('ADF_TASK_LIST.DETAILS.BUTTON.CLAIM');
});
fixture.whenStable().then(() => {
let claimButton = fixture.debugElement.query(By.css('[data-automation-id="header-claim-button"]'));
expect(claimButton.nativeElement.innerText).toBe('ADF_TASK_LIST.DETAILS.BUTTON.CLAIM');
});
}));
it('should display the claim button if the task is claimable', () => {
it('should display the claim button if the task is claimable', async(() => {
component.taskDetails = new TaskDetailsModel(claimableTaskDetailsMock);
component.ngOnChanges({});
component.refreshData();
fixture.detectChanges();
let claimButton = fixture.debugElement.query(By.css('[data-automation-id="header-claim-button"]'));
expect(component.isTaskClaimable()).toBeTruthy();
expect(claimButton.nativeElement.innerText).toBe('ADF_TASK_LIST.DETAILS.BUTTON.CLAIM');
});
it('should not display the claim/requeue button if the task is not claimable ', () => {
fixture.whenStable().then(() => {
let claimButton = fixture.debugElement.query(By.css('[data-automation-id="header-claim-button"]'));
expect(component.isTaskClaimable()).toBeTruthy();
expect(claimButton.nativeElement.innerText).toBe('ADF_TASK_LIST.DETAILS.BUTTON.CLAIM');
});
}));
it('should not display the claim/requeue button if the task is not claimable ', async(() => {
component.taskDetails = new TaskDetailsModel(taskDetailsWithOutCandidateGroup);
component.ngOnChanges({});
component.refreshData();
fixture.detectChanges();
let claimButton = fixture.debugElement.query(By.css('[data-automation-id="header-claim-button"]'));
fixture.whenStable().then(() => {
let claimButton = fixture.debugElement.query(By.css('[data-automation-id="header-claim-button"]'));
let unclaimButton = fixture.debugElement.query(By.css('[data-automation-id="header-unclaim-button"]'));
expect(component.isTaskClaimable()).toBeFalsy();
expect(component.isTaskClaimedByCandidateMember()).toBeFalsy();
expect(unclaimButton).toBeNull();
expect(claimButton).toBeNull();
});
}));
});
it('should display the requeue button if task is claimed by the current logged-in user', async(() => {
component.taskDetails = new TaskDetailsModel(claimedTaskDetailsMock);
component.refreshData();
fixture.detectChanges();
fixture.whenStable().then(() => {
let unclaimButton = fixture.debugElement.query(By.css('[data-automation-id="header-unclaim-button"]'));
expect(component.isTaskClaimedByCandidateMember()).toBeTruthy();
expect(unclaimButton.nativeElement.innerText).toBe('ADF_TASK_LIST.DETAILS.BUTTON.UNCLAIM');
});
}));
it('should not display the requeue button to logged in user if task is claimed by other candidate member', async(() => {
component.taskDetails = new TaskDetailsModel(claimedByGroupMemberMock);
component.refreshData();
fixture.detectChanges();
fixture.whenStable().then(() => {
let unclaimButton = fixture.debugElement.query(By.css('[data-automation-id="header-unclaim-button"]'));
expect(component.isTaskClaimable()).toBeFalsy();
expect(component.isTaskClaimedByCandidateMember()).toBeFalsy();
expect(unclaimButton).toBeNull();
expect(claimButton).toBeNull();
});
});
}));
it('should display the requeue button if task is claimed by the current logged-in user', () => {
component.taskDetails = new TaskDetailsModel(claimedTaskDetailsMock);
component.ngOnChanges({});
fixture.detectChanges();
let unclaimButton = fixture.debugElement.query(By.css('[data-automation-id="header-unclaim-button"]'));
expect(component.isTaskClaimedByCandidateMember()).toBeTruthy();
expect(unclaimButton.nativeElement.innerText).toBe('ADF_TASK_LIST.DETAILS.BUTTON.UNCLAIM');
});
it('should not display the requeue button to logged in user if task is claimed by other candidate member', () => {
component.taskDetails = new TaskDetailsModel(claimedByGroupMemberMock);
component.ngOnChanges({});
fixture.detectChanges();
let unclaimButton = fixture.debugElement.query(By.css('[data-automation-id="header-unclaim-button"]'));
expect(component.isTaskClaimedByCandidateMember()).toBeFalsy();
expect(unclaimButton).toBeNull();
});
it('should display the claime button if the task is claimable by candidates members', () => {
it('should display the claime button if the task is claimable by candidates members', async(() => {
component.taskDetails = new TaskDetailsModel(claimableTaskDetailsMock);
component.ngOnChanges({});
component.refreshData();
fixture.detectChanges();
let claimButton = fixture.debugElement.query(By.css('[data-automation-id="header-claim-button"]'));
expect(component.isTaskClaimable()).toBeTruthy();
expect(component.isTaskClaimedByCandidateMember()).toBeFalsy();
expect(claimButton.nativeElement.innerText).toBe('ADF_TASK_LIST.DETAILS.BUTTON.CLAIM');
});
it('should not display the requeue button if the task is completed', () => {
fixture.whenStable().then(() => {
let claimButton = fixture.debugElement.query(By.css('[data-automation-id="header-claim-button"]'));
expect(component.isTaskClaimable()).toBeTruthy();
expect(component.isTaskClaimedByCandidateMember()).toBeFalsy();
expect(claimButton.nativeElement.innerText).toBe('ADF_TASK_LIST.DETAILS.BUTTON.CLAIM');
});
}));
it('should not display the requeue button if the task is completed', async(() => {
component.taskDetails = new TaskDetailsModel(completedTaskDetailsMock);
component.ngOnChanges({});
component.refreshData();
fixture.detectChanges();
let claimButton = fixture.debugElement.query(By.css('[data-automation-id="header-claim-button"]'));
let unclaimButton = fixture.debugElement.query(By.css('[data-automation-id="header-unclaim-button"]'));
expect(claimButton).toBeNull();
expect(unclaimButton).toBeNull();
});
it('should call the service\'s unclaim method on unclaiming', () => {
fixture.whenStable().then(() => {
let claimButton = fixture.debugElement.query(By.css('[data-automation-id="header-claim-button"]'));
let unclaimButton = fixture.debugElement.query(By.css('[data-automation-id="header-unclaim-button"]'));
expect(claimButton).toBeNull();
expect(unclaimButton).toBeNull();
});
}));
it('should call the service\'s unclaim method on unclaiming', async(() => {
spyOn(service, 'unclaimTask');
component.taskDetails = new TaskDetailsModel(claimedTaskDetailsMock);
component.ngOnChanges({});
component.refreshData();
fixture.detectChanges();
let unclaimButton = fixture.debugElement.query(By.css('[data-automation-id="header-unclaim-button"]'));
unclaimButton.triggerEventHandler('click', {});
fixture.whenStable().then(() => {
let unclaimButton = fixture.debugElement.query(By.css('[data-automation-id="header-unclaim-button"]'));
unclaimButton.triggerEventHandler('click', {});
expect(service.unclaimTask).toHaveBeenCalledWith('91');
});
expect(service.unclaimTask).toHaveBeenCalledWith('91');
});
}));
it('should trigger the unclaim event on successfull unclaiming', () => {
it('should trigger the unclaim event on successfull unclaiming', async(() => {
let unclaimed: boolean = false;
spyOn(service, 'unclaimTask').and.returnValue(Observable.of(true));
component.taskDetails = new TaskDetailsModel(claimedTaskDetailsMock);
component.ngOnChanges({});
component.refreshData();
fixture.detectChanges();
component.unclaim.subscribe(() => { unclaimed = true; });
let unclaimButton = fixture.debugElement.query(By.css('[data-automation-id="header-unclaim-button"]'));
unclaimButton.triggerEventHandler('click', {});
fixture.whenStable().then(() => {
component.unclaim.subscribe(() => {
unclaimed = true;
});
expect(unclaimed).toBeTruthy();
});
let unclaimButton = fixture.debugElement.query(By.css('[data-automation-id="header-unclaim-button"]'));
unclaimButton.triggerEventHandler('click', {});
it('should display due date', () => {
expect(unclaimed).toBeTruthy();
});
}));
it('should display due date', async(() => {
component.taskDetails.dueDate = new Date('2016-11-03');
component.ngOnChanges({});
component.refreshData();
fixture.detectChanges();
let valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-dueDate"] .adf-property-value'));
expect(valueEl.nativeElement.innerText.trim()).toBe('Nov 03 2016');
});
it('should display placeholder if no due date', () => {
fixture.whenStable().then(() => {
let valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-dueDate"] .adf-property-value'));
expect(valueEl.nativeElement.innerText.trim()).toBe('Nov 03 2016');
});
}));
it('should display placeholder if no due date', async(() => {
component.taskDetails.dueDate = null;
component.ngOnChanges({});
component.refreshData();
fixture.detectChanges();
let valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-dueDate"] .adf-property-value'));
expect(valueEl.nativeElement.innerText.trim()).toBe('ADF_TASK_LIST.PROPERTIES.DUE_DATE_DEFAULT');
});
it('should display form name', () => {
fixture.whenStable().then(() => {
let valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-dueDate"] .adf-property-value'));
expect(valueEl.nativeElement.innerText.trim()).toBe('ADF_TASK_LIST.PROPERTIES.DUE_DATE_DEFAULT');
});
}));
it('should display form name', async(() => {
component.formName = 'test form';
component.ngOnChanges({});
component.refreshData();
fixture.detectChanges();
let valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-formName"] .adf-property-value'));
expect(valueEl.nativeElement.innerText).toBe('test form');
});
it('should display the default parent value if is undefined', () => {
fixture.whenStable().then(() => {
let valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-formName"] .adf-property-value'));
expect(valueEl.nativeElement.innerText).toBe('test form');
});
}));
it('should display the default parent value if is undefined', async(() => {
component.taskDetails.processInstanceId = null;
component.ngOnChanges({});
component.refreshData();
fixture.detectChanges();
let valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-parentName"] .adf-property-value'));
expect(valueEl.nativeElement.innerText.trim()).toEqual('ADF_TASK_LIST.PROPERTIES.PARENT_NAME_DEFAULT');
});
it('should display the Parent name value', () => {
fixture.whenStable().then(() => {
let valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-parentName"] .adf-property-value'));
expect(valueEl.nativeElement.innerText.trim()).toEqual('ADF_TASK_LIST.PROPERTIES.PARENT_NAME_DEFAULT');
});
}));
it('should display the Parent name value', async(() => {
component.taskDetails.processInstanceId = '1';
component.taskDetails.processDefinitionName = 'Parent Name';
component.ngOnChanges({});
component.refreshData();
fixture.detectChanges();
let valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-parentName"] .adf-property-value'));
expect(valueEl.nativeElement.innerText.trim()).toEqual('Parent Name');
});
it('should not display form name if no form name provided', () => {
component.ngOnChanges({});
fixture.whenStable().then(() => {
let valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-parentName"] .adf-property-value'));
expect(valueEl.nativeElement.innerText.trim()).toEqual('Parent Name');
});
}));
it('should not display form name if no form name provided', async(() => {
component.refreshData();
fixture.detectChanges();
let valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-formName"] .adf-property-value'));
expect(valueEl.nativeElement.innerText).toBe('ADF_TASK_LIST.PROPERTIES.FORM_NAME_DEFAULT');
});
fixture.whenStable().then(() => {
let valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-formName"] .adf-property-value'));
expect(valueEl.nativeElement.innerText).toBe('ADF_TASK_LIST.PROPERTIES.FORM_NAME_DEFAULT');
});
}));
describe('Config Filtering', () => {
it('should show only the properties from the configuration file', () => {
it('should show only the properties from the configuration file', async(() => {
spyOn(appConfigService, 'get').and.returnValue(['assignee', 'status']);
component.taskDetails.processInstanceId = '1';
component.taskDetails.processDefinitionName = 'Parent Name';
component.ngOnChanges({});
component.refreshData();
fixture.detectChanges();
let 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_TASK_LIST.PROPERTIES.ASSIGNEE');
expect(propertyList[1].nativeElement.textContent).toContain('ADF_TASK_LIST.PROPERTIES.STATUS');
});
it('should show all the default properties if there is no configuration', () => {
fixture.whenStable().then(() => {
expect(propertyList).toBeDefined();
expect(propertyList).not.toBeNull();
expect(propertyList.length).toBe(2);
expect(propertyList[0].nativeElement.textContent).toContain('ADF_TASK_LIST.PROPERTIES.ASSIGNEE');
expect(propertyList[1].nativeElement.textContent).toContain('ADF_TASK_LIST.PROPERTIES.STATUS');
});
}));
it('should show all the default properties if there is no configuration', async(() => {
spyOn(appConfigService, 'get').and.returnValue(null);
component.taskDetails.processInstanceId = '1';
component.taskDetails.processDefinitionName = 'Parent Name';
component.ngOnChanges({});
component.refreshData();
fixture.detectChanges();
let 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_TASK_LIST.PROPERTIES.ASSIGNEE');
expect(propertyList[1].nativeElement.textContent).toContain('ADF_TASK_LIST.PROPERTIES.STATUS');
});
fixture.whenStable().then(() => {
let 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_TASK_LIST.PROPERTIES.ASSIGNEE');
expect(propertyList[1].nativeElement.textContent).toContain('ADF_TASK_LIST.PROPERTIES.STATUS');
});
}));
});
});
@@ -17,7 +17,6 @@
import { Component, SimpleChange, ViewChild } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { MaterialModule } from '../../material.module';
import { AppConfigService } from '@alfresco/adf-core';
import { DataRowEvent, ObjectDataRow, ObjectDataTableAdapter } from '@alfresco/adf-core';
import { TaskListService } from '../services/tasklist.service';
@@ -128,9 +127,7 @@ describe('TaskListComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
MaterialModule
],
declarations: [
TaskListComponent
],