Pre-Angular 9 upgrade fixes (#5712)

* remove deprecated angular/http

* upgrade adf libs

* fix production builds

* ivy-compatible translate module usage

* improved module usage

* upgrade content services module

* fix process services tests

* upgrade process cloud tests

* lint fixes

* update core max size

* fix insights test module

* remove insights lazy loading workaround

* fix insights module exports

* * Fixed skipped form-cloud unit test and removed duplicated tests

* cleanup the use of services

Co-authored-by: sivakumar414ram <siva.kumar@muraai.com>
This commit is contained in:
Denys Vuika
2020-05-20 16:51:51 +01:00
committed by GitHub
parent 4cb3a876d9
commit 654be10dd2
185 changed files with 622 additions and 1156 deletions

View File

@@ -19,7 +19,7 @@
</div>
<ng-template #noApps>
<div class="adf-app-list-empty">
<ng-content select="adf-custom-empty-content" *ngIf="hasEmptyCustomContentTemplate; else defaultEmptyTemplate"
<ng-content select="adf-custom-empty-content-template" *ngIf="hasEmptyCustomContentTemplate; else defaultEmptyTemplate"
class="adf-custom-empty-template">
</ng-content>

View File

@@ -15,16 +15,15 @@
* limitations under the License.
*/
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { Component } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { setupTestBed, CoreModule, AlfrescoApiServiceMock, AlfrescoApiService } from '@alfresco/adf-core';
import { setupTestBed, AlfrescoApiService } from '@alfresco/adf-core';
import { of, throwError } from 'rxjs';
import { fakeApplicationInstance } from '../mock/app-model.mock';
import { AppListCloudComponent } from './app-list-cloud.component';
import { AppsProcessCloudService } from '../services/apps-process-cloud.service';
import { ProcessServiceCloudTestingModule } from '../../testing/process-service-cloud.testing.module';
import { AppListCloudModule } from '../app-list-cloud.module';
describe('AppListCloudComponent', () => {
@@ -40,11 +39,22 @@ describe('AppListCloudComponent', () => {
}
};
@Component({
template: `
<adf-cloud-app-list>
<adf-custom-empty-content-template>
<mat-icon>apps</mat-icon>
<p id="custom-id">No Apps Found</p>
</adf-custom-empty-content-template>
</adf-cloud-app-list>
`
})
class CustomEmptyAppListCloudTemplateComponent {
}
setupTestBed({
imports: [CoreModule.forRoot(), ProcessServiceCloudTestingModule, AppListCloudModule],
providers: [
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }
]
imports: [ProcessServiceCloudTestingModule],
declarations: [CustomEmptyAppListCloudTemplateComponent]
});
beforeEach(() => {
@@ -188,43 +198,25 @@ describe('AppListCloudComponent', () => {
onAppClick.click();
expect(component.appClick.emit).toHaveBeenCalledWith(fakeApplicationInstance[0]);
});
});
@Component({
template: `
<adf-cloud-app-list>
<adf-custom-empty-content>
<mat-icon>apps</mat-icon>
<p id="custom-id">No Apps Found</p>
</adf-custom-empty-content>
</adf-cloud-app-list>
`
})
class CustomEmptyAppListCloudTemplateComponent {
}
describe('Custom CustomEmptyAppListCloudTemplateComponent', () => {
let customFixture: ComponentFixture<CustomEmptyAppListCloudTemplateComponent>;
describe('Custom CustomEmptyAppListCloudTemplateComponent', () => {
let fixture: ComponentFixture<CustomEmptyAppListCloudTemplateComponent>;
setupTestBed({
imports: [ProcessServiceCloudTestingModule],
declarations: [CustomEmptyAppListCloudTemplateComponent],
schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
});
beforeEach(() => {
fixture = TestBed.createComponent(CustomEmptyAppListCloudTemplateComponent);
});
afterEach(() => {
fixture.destroy();
});
it('should render the custom empty template', async(() => {
fixture.detectChanges();
fixture.whenStable().then(() => {
const title: any = fixture.nativeElement.querySelector('#custom-id');
expect(title.innerText).toBe('No Apps Found');
beforeEach(() => {
getAppsSpy.and.returnValue(of([]));
customFixture = TestBed.createComponent(CustomEmptyAppListCloudTemplateComponent);
});
}));
afterEach(() => {
customFixture.destroy();
});
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');
});
}));
});
});

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { Component, CUSTOM_ELEMENTS_SCHEMA, DebugElement, SimpleChange, NgModule, Injector, ComponentFactoryResolver } from '@angular/core';
import { Component, DebugElement, SimpleChange, NgModule, Injector, ComponentFactoryResolver, ViewChild } from '@angular/core';
import { By } from '@angular/platform-browser';
import { async, ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { Observable, of, throwError } from 'rxjs';
@@ -43,7 +43,7 @@ import {
} from '../mocks/cloud-form.mock';
import { FormCloudRepresentation } from '../models/form-cloud-representation.model';
import { FormCloudModule } from '../form-cloud.module';
import { TranslateService } from '@ngx-translate/core';
import { TranslateService, TranslateModule } from '@ngx-translate/core';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { CloudFormRenderingService } from './cloud-form-rendering.service';
@@ -84,6 +84,7 @@ describe('FormCloudComponent', () => {
setupTestBed({
imports: [
NoopAnimationsModule,
TranslateModule.forRoot(),
CoreModule.forRoot(),
FormCloudModule,
CustomUploadModule
@@ -1015,10 +1016,10 @@ describe('FormCloudComponent', () => {
template: `
<adf-cloud-form #adfCloudForm>
<adf-cloud-form-custom-outcomes>
<button mat-button id="adf-custom-outcome-1" (click)="onButtonClick()">
<button mat-button id="adf-custom-outcome-1" (click)="onCustomButtonOneClick()">
CUSTOM-BUTTON-1
</button>
<button mat-button id="adf-custom-outcome-2" (click)="onButtonClick()">
<button mat-button id="adf-custom-outcome-2" (click)="onCustomButtonTwoClick()">
CUSTOM-BUTTON-2
</button>
</adf-cloud-form-custom-outcomes>
@@ -1027,25 +1028,39 @@ describe('FormCloudComponent', () => {
class FormCloudWithCustomOutComesComponent {
onButtonClick() { }
@ViewChild('adfCloudForm')
adfCloudForm: FormCloudComponent;
onCustomButtonOneClick() { }
onCustomButtonTwoClick() { }
}
describe('FormCloudWithCustomOutComesComponent', () => {
let fixture: ComponentFixture<FormCloudWithCustomOutComesComponent>;
let component: FormCloudWithCustomOutComesComponent;
let customComponent: FormCloudWithCustomOutComesComponent;
let debugElement: DebugElement;
setupTestBed({
imports: [ProcessServiceCloudTestingModule],
declarations: [FormCloudWithCustomOutComesComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
declarations: [FormCloudWithCustomOutComesComponent]
});
beforeEach(() => {
fixture = TestBed.createComponent(FormCloudWithCustomOutComesComponent);
component = fixture.componentInstance;
customComponent = fixture.componentInstance;
debugElement = fixture.debugElement;
const formRepresentation = {
fields: [
{ id: 'container1' }
],
outcomes: [
{ id: 'outcome-1', name: 'outcome 1' }
]
};
const form = new FormModel(formRepresentation);
customComponent.adfCloudForm.form = form;
fixture.detectChanges();
});
@@ -1054,11 +1069,15 @@ describe('FormCloudWithCustomOutComesComponent', () => {
});
it('should be able to inject custom outcomes and click on custom outcomes', () => {
fixture.detectChanges();
const cancelSpy = spyOn(component, 'onButtonClick').and.callThrough();
const cancelBtn = debugElement.query(By.css('#adf-custom-outcome-1'));
cancelBtn.nativeElement.click();
expect(cancelSpy).toHaveBeenCalled();
expect(cancelBtn.nativeElement.innerText).toBe('CUSTOM-BUTTON-1');
const onCustomButtonOneSpy = spyOn(customComponent, 'onCustomButtonOneClick').and.callThrough();
const buttonOneBtn = debugElement.query(By.css('#adf-custom-outcome-1'));
const buttonTwoBtn = debugElement.query(By.css('#adf-custom-outcome-2'));
expect(buttonOneBtn).not.toBeNull();
expect(buttonTwoBtn).not.toBeNull();
buttonOneBtn.nativeElement.click();
expect(onCustomButtonOneSpy).toHaveBeenCalled();
expect(buttonOneBtn.nativeElement.innerText).toBe('CUSTOM-BUTTON-1');
expect(buttonTwoBtn.nativeElement.innerText).toBe('CUSTOM-BUTTON-2');
});
});

View File

@@ -16,10 +16,10 @@
*/
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { DateCloudWidgetComponent } from './date-cloud.widget';
import { setupTestBed, FormFieldModel, FormModel, CoreModule } from '@alfresco/adf-core';
import { setupTestBed, FormFieldModel, FormModel } from '@alfresco/adf-core';
import moment from 'moment-es6';
import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module';
describe('DateWidgetComponent', () => {
@@ -29,10 +29,8 @@ describe('DateWidgetComponent', () => {
setupTestBed({
imports: [
NoopAnimationsModule,
CoreModule.forRoot()
],
declarations: [DateCloudWidgetComponent]
ProcessServiceCloudTestingModule
]
});
beforeEach(async(() => {

View File

@@ -18,10 +18,10 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { of } from 'rxjs';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { DropdownCloudWidgetComponent } from './dropdown-cloud.widget';
import { FormService, WidgetVisibilityService, FormFieldOption, setupTestBed, FormFieldModel, FormModel, CoreModule } from '@alfresco/adf-core';
import { FormService, WidgetVisibilityService, FormFieldOption, setupTestBed, FormFieldModel, FormModel } from '@alfresco/adf-core';
import { FormCloudService } from '../../../services/form-cloud.service';
import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module';
describe('DropdownCloudWidgetComponent', () => {
@@ -45,10 +45,8 @@ describe('DropdownCloudWidgetComponent', () => {
setupTestBed({
imports: [
NoopAnimationsModule,
CoreModule.forRoot()
],
declarations: [DropdownCloudWidgetComponent]
ProcessServiceCloudTestingModule
]
});
beforeEach(async(() => {

View File

@@ -16,10 +16,10 @@
*/
import { TestBed } from '@angular/core/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { FormCloudService } from './form-cloud.service';
import { AlfrescoApiService, CoreModule, setupTestBed } from '@alfresco/adf-core';
import { AlfrescoApiService, setupTestBed } from '@alfresco/adf-core';
import { of } from 'rxjs';
import { ProcessServiceCloudTestingModule } from '../../testing/process-service-cloud.testing.module';
declare let jasmine: any;
@@ -40,8 +40,7 @@ describe('Form Cloud service', () => {
setupTestBed({
imports: [
NoopAnimationsModule,
CoreModule.forRoot()
ProcessServiceCloudTestingModule
]
});

View File

@@ -16,9 +16,9 @@
*/
import { TestBed } from '@angular/core/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { AlfrescoApiService, CoreModule, setupTestBed } from '@alfresco/adf-core';
import { AlfrescoApiService, setupTestBed } from '@alfresco/adf-core';
import { FormDefinitionSelectorCloudService } from './form-definition-selector-cloud.service';
import { ProcessServiceCloudTestingModule } from '../../testing/process-service-cloud.testing.module';
declare let jasmine: any;
@@ -61,8 +61,7 @@ describe('Form Definition Selector Cloud Service', () => {
setupTestBed({
imports: [
NoopAnimationsModule,
CoreModule.forRoot()
ProcessServiceCloudTestingModule
]
});

View File

@@ -17,9 +17,10 @@
import { Component, ViewChild } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CoreModule, IdentityUserService, setupTestBed } from '@alfresco/adf-core';
import { IdentityUserService, setupTestBed } from '@alfresco/adf-core';
import { CancelProcessDirective } from './cancel-process.directive';
import { processDetailsMockRunning, processDetailsMockCompleted } from '../mock/process-details.mock';
import { ProcessServiceCloudTestingModule } from '../../testing/process-service-cloud.testing.module';
describe('CancelProcessDirective', () => {
@@ -39,11 +40,10 @@ describe('CancelProcessDirective', () => {
setupTestBed({
imports: [
CoreModule.forRoot()
ProcessServiceCloudTestingModule
],
declarations: [
TestComponent,
CancelProcessDirective
TestComponent
]
});

View File

@@ -25,12 +25,12 @@ import { ProcessDirectiveModule } from './directives/process-directive.module';
@NgModule({
imports: [
CoreModule,
ProcessFiltersCloudModule,
ProcessListCloudModule,
StartProcessCloudModule,
ProcessHeaderCloudModule,
ProcessDirectiveModule,
CoreModule
ProcessDirectiveModule
],
exports: [
ProcessFiltersCloudModule,

View File

@@ -16,7 +16,7 @@
*/
import { async, TestBed } from '@angular/core/testing';
import { setupTestBed, CoreModule, IdentityUserService } from '@alfresco/adf-core';
import { setupTestBed, IdentityUserService } from '@alfresco/adf-core';
import { of } from 'rxjs';
import { ProcessFilterCloudService } from './process-filter-cloud.service';
import {
@@ -28,6 +28,7 @@ import {
} from '../mock/process-filters.cloud.mock';
import { PROCESS_FILTERS_SERVICE_TOKEN } from '../../../services/cloud-token.service';
import { LocalPreferenceCloudService } from '../../../services/local-preference-cloud.service';
import { ProcessServiceCloudTestingModule } from '../../../testing/process-service-cloud.testing.module';
describe('ProcessFilterCloudService', () => {
let service: ProcessFilterCloudService;
@@ -41,7 +42,7 @@ describe('ProcessFilterCloudService', () => {
setupTestBed({
imports: [
CoreModule.forRoot()
ProcessServiceCloudTestingModule
],
providers: [
{ provide: PROCESS_FILTERS_SERVICE_TOKEN, useClass: LocalPreferenceCloudService }

View File

@@ -19,9 +19,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import {
AppConfigService,
CoreModule,
DataRowEvent,
DataTableModule,
ObjectDataRow,
setupTestBed
} from '@alfresco/adf-core';
@@ -29,8 +27,7 @@ import { ProcessListCloudService } from '../services/process-list-cloud.service'
import { ProcessListCloudComponent } from './process-list-cloud.component';
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';
import { ProcessServiceCloudTestingModule } from '../../../testing/process-service-cloud.testing.module';
@Component({
template: `
@@ -72,10 +69,8 @@ describe('ProcessListCloudComponent', () => {
setupTestBed({
imports: [
ProcessListCloudTestingModule,
ProcessListCloudModule
],
providers: [ProcessListCloudService]
ProcessServiceCloudTestingModule
]
});
beforeEach(() => {
@@ -260,9 +255,8 @@ describe('ProcessListCloudComponent', () => {
let componentCustom: CustomTaskListComponent;
setupTestBed({
imports: [CoreModule.forRoot()],
declarations: [ProcessListCloudComponent, CustomTaskListComponent],
providers: [ProcessListCloudService]
imports: [ProcessServiceCloudTestingModule],
declarations: [CustomTaskListComponent]
});
beforeEach(() => {
@@ -289,7 +283,7 @@ describe('ProcessListCloudComponent', () => {
let fixtureEmpty: ComponentFixture<EmptyTemplateComponent>;
setupTestBed({
imports: [ProcessListCloudModule, ProcessListCloudTestingModule, DataTableModule],
imports: [ProcessServiceCloudTestingModule],
declarations: [EmptyTemplateComponent]
});

View File

@@ -1,30 +0,0 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ProcessListCloudModule } from './process-list-cloud.module';
describe('ProcessListCloudModule', () => {
let processListCloudModule: ProcessListCloudModule;
beforeEach(() => {
processListCloudModule = new ProcessListCloudModule();
});
it('should create an instance', () => {
expect(processListCloudModule).toBeTruthy();
});
});

View File

@@ -1,45 +0,0 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NgModule } from '@angular/core';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { HttpClientModule } from '@angular/common/http';
import { ProcessListCloudModule } from '../process-list-cloud.module';
import {
AlfrescoApiService,
AlfrescoApiServiceMock,
AppConfigService,
AppConfigServiceMock,
TranslationService,
TranslationMock,
ContextMenuModule,
CoreModule
} from '@alfresco/adf-core';
@NgModule({
imports: [
HttpClientModule,
NoopAnimationsModule,
ProcessListCloudModule,
CoreModule.forRoot(),
ContextMenuModule
],
providers: [
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
{ provide: AppConfigService, useClass: AppConfigServiceMock },
{ provide: TranslationService, useClass: TranslationMock }
]
})
export class ProcessListCloudTestingModule { }

View File

@@ -17,21 +17,11 @@
import { SimpleChange, DebugElement } from '@angular/core';
import { async, ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
import {
setupTestBed,
StorageService,
LogService,
TranslationService,
TranslationMock,
FormService
} from '@alfresco/adf-core';
import { setupTestBed } from '@alfresco/adf-core';
import { of, throwError } from 'rxjs';
import { StartProcessCloudService } from '../services/start-process-cloud.service';
import { FormCloudService } from '../../../form/services/form-cloud.service';
import { StartProcessCloudComponent } from './start-process-cloud.component';
import { HttpClientModule } from '@angular/common/http';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { TranslateModule, TranslateStore } from '@ngx-translate/core';
import {
MatCardModule,
MatOptionModule,
@@ -44,7 +34,6 @@ import {
MatCommonModule
} from '@angular/material';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { FormCloudModule } from '../../../form/form-cloud.module';
import {
fakeProcessDefinitions, fakeStartForm, fakeStartFormNotValid,
@@ -53,6 +42,7 @@ import {
} from '../mock/start-process.component.mock';
import { By } from '@angular/platform-browser';
import { ProcessPayloadCloud } from '../models/process-payload-cloud.model';
import { ProcessServiceCloudTestingModule } from '../../../testing/process-service-cloud.testing.module';
describe('StartProcessCloudComponent', () => {
@@ -86,8 +76,7 @@ describe('StartProcessCloudComponent', () => {
setupTestBed({
imports: [
HttpClientModule,
NoopAnimationsModule,
ProcessServiceCloudTestingModule,
FormsModule,
MatCommonModule,
ReactiveFormsModule,
@@ -98,17 +87,7 @@ describe('StartProcessCloudComponent', () => {
MatButtonModule,
MatFormFieldModule,
MatInputModule,
MatRippleModule,
FormCloudModule,
TranslateModule.forChild()
],
declarations: [StartProcessCloudComponent],
providers: [
{ provide: TranslationService, useClass: TranslationMock },
FormService,
TranslateStore,
StorageService,
LogService
MatRippleModule
]
});

View File

@@ -18,8 +18,9 @@
import { TestBed, async } from '@angular/core/testing';
import { UserPreferenceCloudService } from './user-preference-cloud.service';
import { setupTestBed, CoreModule, AlfrescoApiServiceMock, AlfrescoApiService } from '@alfresco/adf-core';
import { setupTestBed, AlfrescoApiServiceMock, AlfrescoApiService } from '@alfresco/adf-core';
import { mockPreferences, getMockPreference, createMockPreference, updateMockPreference } from '../mock/user-preference.mock';
import { ProcessServiceCloudTestingModule } from '../testing/process-service-cloud.testing.module';
describe('PreferenceService', () => {
let service: UserPreferenceCloudService;
@@ -49,10 +50,7 @@ describe('PreferenceService', () => {
setupTestBed({
imports: [
CoreModule.forRoot()
],
providers: [
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }
ProcessServiceCloudTestingModule
]
});

View File

@@ -16,12 +16,12 @@
*/
import { Component, ContentChildren, ViewChild } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { setupTestBed, CoreModule } from '@alfresco/adf-core';
import { setupTestBed } from '@alfresco/adf-core';
import { TaskCloudService } from '../services/task-cloud.service';
import { RouterTestingModule } from '@angular/router/testing';
import { of } from 'rxjs';
import { ClaimTaskDirective } from './claim-task.directive';
import { taskClaimCloudMock } from '../task-header/mocks/fake-claim-task.mock';
import { ProcessServiceCloudTestingModule } from '../../testing/process-service-cloud.testing.module';
describe('ClaimTaskDirective', () => {
@@ -43,12 +43,10 @@ describe('ClaimTaskDirective', () => {
setupTestBed({
imports: [
CoreModule.forRoot(),
RouterTestingModule
ProcessServiceCloudTestingModule
],
declarations: [
TestComponent,
ClaimTaskDirective
TestComponent
]
});
@@ -124,15 +122,13 @@ describe('Claim Task Directive validation errors', () => {
setupTestBed({
imports: [
CoreModule.forRoot(),
RouterTestingModule
ProcessServiceCloudTestingModule
],
declarations: [
ClaimTestMissingTaskIdDirectiveComponent,
ClaimTestInvalidAppNameUndefineddDirectiveComponent,
ClaimTestInvalidAppNameNulldDirectiveComponent,
ClaimTestMissingInputDirectiveComponent,
ClaimTaskDirective
ClaimTestMissingInputDirectiveComponent
]
});

View File

@@ -17,11 +17,11 @@
import { Component, ViewChild, ContentChildren } from '@angular/core';
import { CompleteTaskDirective } from './complete-task.directive';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CoreModule, setupTestBed } from '@alfresco/adf-core';
import { RouterTestingModule } from '@angular/router/testing';
import { setupTestBed } from '@alfresco/adf-core';
import { of } from 'rxjs';
import { taskCompleteCloudMock } from '../task-header/mocks/fake-complete-task.mock';
import { TaskCloudService } from '../services/task-cloud.service';
import { ProcessServiceCloudTestingModule } from '../../testing/process-service-cloud.testing.module';
describe('CompleteTaskDirective', () => {
@@ -47,12 +47,10 @@ describe('CompleteTaskDirective', () => {
setupTestBed({
imports: [
CoreModule.forRoot(),
RouterTestingModule
ProcessServiceCloudTestingModule
],
declarations: [
TestComponent,
CompleteTaskDirective
TestComponent
]
});
@@ -144,15 +142,13 @@ describe('Complete Task Directive validation errors', () => {
setupTestBed({
imports: [
CoreModule.forRoot(),
RouterTestingModule
ProcessServiceCloudTestingModule
],
declarations: [
TestMissingTaskIdDirectiveComponent,
TestInvalidAppNameUndefineddDirectiveComponent,
TestInvalidAppNameNulldDirectiveComponent,
TestMissingInputDirectiveComponent,
CompleteTaskDirective
TestMissingInputDirectiveComponent
]
});

View File

@@ -16,12 +16,12 @@
*/
import { Component, ContentChildren, ViewChild } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { setupTestBed, CoreModule } from '@alfresco/adf-core';
import { setupTestBed } from '@alfresco/adf-core';
import { TaskCloudService } from '../services/task-cloud.service';
import { RouterTestingModule } from '@angular/router/testing';
import { of } from 'rxjs';
import { UnClaimTaskDirective } from './unclaim-task.directive';
import { taskClaimCloudMock } from '../task-header/mocks/fake-claim-task.mock';
import { ProcessServiceCloudTestingModule } from '../../testing/process-service-cloud.testing.module';
describe('UnClaimTaskDirective', () => {
@@ -43,14 +43,11 @@ describe('UnClaimTaskDirective', () => {
setupTestBed({
imports: [
CoreModule.forRoot(),
RouterTestingModule
ProcessServiceCloudTestingModule
],
declarations: [
TestComponent,
UnClaimTaskDirective
],
providers: [ TaskCloudService ]
TestComponent
]
});
beforeEach(() => {
@@ -125,15 +122,13 @@ describe('UnClaim Task Directive validation errors', () => {
setupTestBed({
imports: [
CoreModule.forRoot(),
RouterTestingModule
ProcessServiceCloudTestingModule
],
declarations: [
ClaimTestMissingTaskIdDirectiveComponent,
ClaimTestInvalidAppNameUndefineddDirectiveComponent,
ClaimTestInvalidAppNameNulldDirectiveComponent,
ClaimTestMissingInputDirectiveComponent,
UnClaimTaskDirective
ClaimTestMissingInputDirectiveComponent
]
});

View File

@@ -16,12 +16,13 @@
*/
import { async, TestBed } from '@angular/core/testing';
import { setupTestBed, IdentityUserService, StorageService, AlfrescoApiServiceMock, LogService, AppConfigService, CoreModule } from '@alfresco/adf-core';
import { setupTestBed, IdentityUserService, StorageService, AlfrescoApiServiceMock, LogService, AppConfigService } from '@alfresco/adf-core';
import { TaskCloudService } from './task-cloud.service';
import { taskCompleteCloudMock } from '../task-header/mocks/fake-complete-task.mock';
import { assignedTaskDetailsCloudMock, createdTaskDetailsCloudMock, emptyOwnerTaskDetailsCloudMock } from '../task-header/mocks/task-details-cloud.mock';
import { fakeTaskDetailsCloud } from '../task-header/mocks/fake-task-details-response.mock';
import { cloudMockUser } from '../start-task/mock/user-cloud.mock';
import { ProcessServiceCloudTestingModule } from '../../testing/process-service-cloud.testing.module';
describe('Task Cloud Service', () => {
@@ -81,7 +82,7 @@ describe('Task Cloud Service', () => {
setupTestBed({
imports: [
CoreModule.forRoot()
ProcessServiceCloudTestingModule
]
});

View File

@@ -15,14 +15,12 @@
* limitations under the License.
*/
import { Component, CUSTOM_ELEMENTS_SCHEMA, DebugElement, SimpleChange } from '@angular/core';
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 { IdentityUserService, setupTestBed } from '@alfresco/adf-core';
import { ProcessServiceCloudTestingModule } from '../../../testing/process-service-cloud.testing.module';
import { TaskCloudModule } from '../../task-cloud.module';
import { TaskDirectiveModule } from '../../directives/task-directive.module';
import { TaskFormCloudComponent } from './task-form-cloud.component';
import { TaskDetailsCloudModel } from '../../start-task/models/task-details-cloud.model';
import { TaskCloudService } from '../../services/task-cloud.service';
@@ -54,8 +52,7 @@ describe('TaskFormCloudComponent', () => {
let fixture: ComponentFixture<TaskFormCloudComponent>;
setupTestBed({
imports: [ProcessServiceCloudTestingModule, TaskCloudModule, TaskDirectiveModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
imports: [ProcessServiceCloudTestingModule]
});
beforeEach(() => {
@@ -414,91 +411,5 @@ describe('TaskFormCloudComponent', () => {
expect(loadingTemplate).toBeNull();
});
});
});
@Component({
selector: 'adf-cloud-task-form-cloud-with-custom-outcomes',
template: `
<adf-cloud-form #adfCloudForm>
<adf-cloud-form-custom-outcomes>
<button mat-button *ngIf="showCancelButton" id="adf-cloud-cancel-task" (click)="onCancel()">
CANCEL
</button>
<button mat-button *ngIf="canClaimTask()" adf-cloud-claim-task [appName]="appName" [taskId]="taskId" (click)="onClaim()">
CLAIM
</button>
<button mat-button *ngIf="canUnclaimTask()" adf-cloud-unclaim-task [appName]="appName" [taskId]="taskId" (click)="onUnclaim()">
UNCLAIM
</button>
</adf-cloud-form-custom-outcomes>
</adf-cloud-form>`
})
class TaskFormWithCustomOutComesComponent {
appName = 'simple-app';
taskId = 'mock-task-id';
showCancelButton = true;
canClaimTask() { return true; }
canUnclaimTask() { return true; }
onUnclaim() {}
onClaim() {}
onCancel() {}
}
describe('TaskFormWithCustomOutComesComponent', () => {
let fixture: ComponentFixture<TaskFormWithCustomOutComesComponent>;
let component: TaskFormWithCustomOutComesComponent;
let debugElement: DebugElement;
setupTestBed({
imports: [ProcessServiceCloudTestingModule, TaskCloudModule, TaskDirectiveModule],
declarations: [TaskFormWithCustomOutComesComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
});
beforeEach(() => {
fixture = TestBed.createComponent(TaskFormWithCustomOutComesComponent);
component = fixture.componentInstance;
debugElement = fixture.debugElement;
fixture.detectChanges();
});
afterEach(() => {
fixture.destroy();
});
it('should be able to display and click on cancel button', () => {
fixture.detectChanges();
const cancelSpy = spyOn(component, 'onCancel').and.callThrough();
const cancelBtn = debugElement.query(By.css('#adf-cloud-cancel-task'));
cancelBtn.nativeElement.click();
expect(cancelSpy).toHaveBeenCalled();
expect(cancelBtn.nativeElement.innerText).toBe('CANCEL');
});
it('should be able to display and click on claim button', () => {
fixture.detectChanges();
const claimSpy = spyOn(component, 'onClaim').and.callThrough();
const claimBtn = debugElement.query(By.css('[adf-cloud-claim-task]'));
claimBtn.nativeElement.click();
expect(claimSpy).toHaveBeenCalled();
expect(claimBtn.nativeElement.innerText).toBe('CLAIM');
});
it('should be able to display and click on unclaim button', () => {
fixture.detectChanges();
const unClaimSpy = spyOn(component, 'onUnclaim').and.callThrough();
const unclaimBtn = debugElement.query(By.css('[adf-cloud-unclaim-task]'));
unclaimBtn.nativeElement.click();
expect(unClaimSpy).toHaveBeenCalled();
expect(unclaimBtn.nativeElement.innerText).toBe('UNCLAIM');
});
});

View File

@@ -33,7 +33,7 @@
[title]="'ADF_CLOUD_TASK_LIST.LIST.MESSAGES.TITLE' | translate"
[subtitle]="'ADF_CLOUD_TASK_LIST.LIST.MESSAGES.SUBTITLE' | translate">
</adf-empty-content>
<ng-content select="adf-custom-empty-content"></ng-content>
<ng-content select="adf-custom-empty-content-template"></ng-content>
</ng-template>
</adf-no-content-template>
</adf-datatable>

View File

@@ -15,17 +15,17 @@
* limitations under the License.
*/
import { Component, SimpleChange, ViewChild, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { Component, SimpleChange, ViewChild } from '@angular/core';
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { AppConfigService, setupTestBed, CoreModule, DataRowEvent, ObjectDataRow } from '@alfresco/adf-core';
import { AppConfigService, setupTestBed, DataRowEvent, ObjectDataRow } from '@alfresco/adf-core';
import { TaskListCloudService } from '../services/task-list-cloud.service';
import { TaskListCloudComponent } from './task-list-cloud.component';
import { fakeGlobalTask, fakeCustomSchema } from '../mock/fake-task-response.mock';
import { of } from 'rxjs';
import { ProcessServiceCloudTestingModule } from '../../../testing/process-service-cloud.testing.module';
import { TaskListCloudModule } from '../task-list-cloud.module';
import { Person } from '@alfresco/js-api';
import { TaskListModule } from '@alfresco/adf-process-services';
@Component({
template: `
@@ -51,18 +51,18 @@ class CustomTaskListComponent {
}
@Component({
template: `
<adf-tasklist>
<adf-empty-content-holder>
<adf-cloud-task-list>
<adf-custom-empty-content-template>
<p id="custom-id"></p>
</adf-empty-content-holder>
</adf-tasklist>
</adf-custom-empty-content-template>
</adf-cloud-task-list>
`
})
class EmptyTemplateComponent {
}
@Component({
template: `
<adf-cloud-task-list #taskListCloudCopy>
<adf-cloud-task-list>
<data-columns>
<data-column [copyContent]="true" key="entry.id" title="ADF_CLOUD_TASK_LIST.PROPERTIES.ID"></data-column>
<data-column key="entry.name" title="ADF_CLOUD_TASK_LIST.PROPERTIES.NAME"></data-column>
@@ -82,7 +82,11 @@ describe('TaskListCloudComponent', () => {
setupTestBed({
imports: [
ProcessServiceCloudTestingModule, TaskListCloudModule
ProcessServiceCloudTestingModule,
TaskListModule
],
declarations: [
EmptyTemplateComponent
]
});
@@ -293,9 +297,14 @@ describe('TaskListCloudComponent', () => {
let copyFixture: ComponentFixture<CustomCopyContentTaskListComponent>;
setupTestBed({
imports: [CoreModule.forRoot()],
declarations: [TaskListCloudComponent, CustomTaskListComponent, CustomCopyContentTaskListComponent],
providers: [TaskListCloudService]
imports: [
ProcessServiceCloudTestingModule,
TaskListModule
],
declarations: [
CustomTaskListComponent,
CustomCopyContentTaskListComponent
]
});
beforeEach(() => {
@@ -356,13 +365,10 @@ describe('TaskListCloudComponent', () => {
describe('Creating an empty custom template - EmptyTemplateComponent', () => {
let fixtureEmpty: ComponentFixture<EmptyTemplateComponent>;
setupTestBed({
imports: [ProcessServiceCloudTestingModule, TaskListCloudModule],
declarations: [EmptyTemplateComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
});
beforeEach(() => {
const emptyList = {list: {entries: []}};
spyOn(taskListCloudService, 'getTaskByRequest').and.returnValue(of(emptyList));
fixtureEmpty = TestBed.createComponent(EmptyTemplateComponent);
fixtureEmpty.detectChanges();
});
@@ -371,13 +377,17 @@ describe('TaskListCloudComponent', () => {
fixtureEmpty.destroy();
});
it('should render the custom template', async(() => {
// TODO still not working because of the Loading Spinner
// tslint:disable-next-line: ban
xit('should render the custom template', (done) => {
fixtureEmpty.detectChanges();
fixtureEmpty.whenStable().then(() => {
fixtureEmpty.detectChanges();
expect(fixtureEmpty.debugElement.query(By.css('#custom-id'))).not.toBeNull();
expect(fixtureEmpty.debugElement.query(By.css('.adf-empty-content'))).toBeNull();
done();
});
}));
});
});
describe('Copy cell content directive from app.config specifications', () => {
@@ -386,8 +396,7 @@ describe('TaskListCloudComponent', () => {
let taskSpy: jasmine.Spy;
setupTestBed({
imports: [ProcessServiceCloudTestingModule, TaskListCloudModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
imports: [ProcessServiceCloudTestingModule]
});
beforeEach( () => {

View File

@@ -25,21 +25,31 @@ import {
AppConfigServiceMock,
TranslationService,
TranslationMock,
ContextMenuModule,
CoreModule
} from '@alfresco/adf-core';
import { TranslateModule } from '@ngx-translate/core';
import { ProcessServicesCloudModule } from '../process-services-cloud.module';
import { RouterTestingModule } from '@angular/router/testing';
@NgModule({
imports: [
HttpClientModule,
NoopAnimationsModule,
RouterTestingModule,
TranslateModule.forRoot(),
CoreModule.forRoot(),
ContextMenuModule
ProcessServicesCloudModule
],
providers: [
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
{ provide: AppConfigService, useClass: AppConfigServiceMock },
{ provide: TranslationService, useClass: TranslationMock }
],
exports: [
NoopAnimationsModule,
TranslateModule,
CoreModule,
ProcessServicesCloudModule
]
})
export class ProcessServiceCloudTestingModule {}