[ADF-5415] remove deprecated async method (#7171)

* remove deprecated async method

* fix tests and code

* test fixes

* fix tests
This commit is contained in:
Denys Vuika
2021-07-12 20:09:47 +01:00
committed by GitHub
parent 059aa8ba06
commit a4c3f3a95b
41 changed files with 194 additions and 200 deletions

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { ComponentFixture, TestBed, async } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AppConfigService, setupTestBed } from '@alfresco/adf-core'; import { AppConfigService, setupTestBed } from '@alfresco/adf-core';
import { WebscriptComponent } from './webscript.component'; import { WebscriptComponent } from './webscript.component';
import { ContentTestingModule } from '../testing/content.testing.module'; import { ContentTestingModule } from '../testing/content.testing.module';
@@ -36,7 +36,7 @@ describe('WebscriptComponent', () => {
] ]
}); });
beforeEach(async(() => { beforeEach(() => {
const appConfig: AppConfigService = TestBed.inject(AppConfigService); const appConfig: AppConfigService = TestBed.inject(AppConfigService);
appConfig.config.ecmHost = 'http://localhost:9876/ecm'; appConfig.config.ecmHost = 'http://localhost:9876/ecm';
@@ -48,7 +48,7 @@ describe('WebscriptComponent', () => {
component.scriptPath = 'fakePath'; component.scriptPath = 'fakePath';
component.showData = true; component.showData = true;
fixture.detectChanges(); fixture.detectChanges();
})); });
describe('View', () => { describe('View', () => {
it('html wrapper should be present', () => { it('html wrapper should be present', () => {

View File

@@ -89,7 +89,7 @@ export class WebscriptComponent implements OnChanges {
this.clean(); this.clean();
} }
return new Promise((resolve, reject) => { return new Promise<void>((resolve, reject) => {
this.apiService.getInstance().webScript.executeWebScript('GET', this.scriptPath, this.scriptArgs, this.contextRoot, this.servicePath).then((webScriptData) => { this.apiService.getInstance().webScript.executeWebScript('GET', this.scriptPath, this.scriptArgs, this.contextRoot, this.servicePath).then((webScriptData) => {
this.data = webScriptData; this.data = webScriptData;

View File

@@ -21,7 +21,9 @@ import { AppConfigService } from './app-config.service';
import { AppConfigModule } from './app-config.module'; import { AppConfigModule } from './app-config.module';
import { ExtensionConfig, ExtensionService } from '@alfresco/adf-extensions'; import { ExtensionConfig, ExtensionService } from '@alfresco/adf-extensions';
import { of } from 'rxjs'; import { of } from 'rxjs';
import { Injectable } from '@angular/core';
@Injectable({ providedIn: 'root' })
class TestExtensionService extends ExtensionService { class TestExtensionService extends ExtensionService {
onSetup(config: ExtensionConfig) { onSetup(config: ExtensionConfig) {

View File

@@ -18,7 +18,7 @@
/* tslint:disable:component-selector */ /* tslint:disable:component-selector */
import { Component, Input, SimpleChange } from '@angular/core'; import { Component, Input, SimpleChange } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { CardViewItem } from '../../interfaces/card-view-item.interface'; import { CardViewItem } from '../../interfaces/card-view-item.interface';
import { CardItemTypeService } from '../../services/card-item-types.service'; import { CardItemTypeService } from '../../services/card-item-types.service';
@@ -40,7 +40,7 @@ describe('CardViewItemDispatcherComponent', () => {
let cardItemTypeService: CardItemTypeService; let cardItemTypeService: CardItemTypeService;
let component: CardViewItemDispatcherComponent; let component: CardViewItemDispatcherComponent;
beforeEach(async(() => { beforeEach(() => {
cardItemTypeService = new CardItemTypeService(); cardItemTypeService = new CardItemTypeService();
cardItemTypeService.setComponentTypeResolver('shiny-custom-element', () => CardViewShinyCustomElementItemComponent); cardItemTypeService.setComponentTypeResolver('shiny-custom-element', () => CardViewShinyCustomElementItemComponent);
@@ -54,7 +54,7 @@ describe('CardViewItemDispatcherComponent', () => {
}); });
TestBed.compileComponents(); TestBed.compileComponents();
})); });
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(CardViewItemDispatcherComponent); fixture = TestBed.createComponent(CardViewItemDispatcherComponent);

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ObjectDataTableAdapter } from '../../data/object-datatable-adapter'; import { ObjectDataTableAdapter } from '../../data/object-datatable-adapter';
import { ObjectDataColumn } from '../../data/object-datacolumn.model'; import { ObjectDataColumn } from '../../data/object-datacolumn.model';
@@ -28,8 +28,8 @@ describe('JsonCellComponent', () => {
let component: JsonCellComponent; let component: JsonCellComponent;
let fixture: ComponentFixture<JsonCellComponent>; let fixture: ComponentFixture<JsonCellComponent>;
let dataTableAdapter: ObjectDataTableAdapter; let dataTableAdapter: ObjectDataTableAdapter;
let rowData; let rowData: any;
let columnData; let columnData: any;
setupTestBed({ setupTestBed({
imports: [ imports: [
@@ -38,10 +38,10 @@ describe('JsonCellComponent', () => {
] ]
}); });
beforeEach(async(() => { beforeEach(() => {
fixture = TestBed.createComponent(JsonCellComponent); fixture = TestBed.createComponent(JsonCellComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
})); });
beforeEach(() => { beforeEach(() => {
rowData = { rowData = {

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ObjectDataTableAdapter } from '../../data/object-datatable-adapter'; import { ObjectDataTableAdapter } from '../../data/object-datatable-adapter';
import { ObjectDataColumn } from '../../data/object-datacolumn.model'; import { ObjectDataColumn } from '../../data/object-datacolumn.model';
@@ -28,8 +28,8 @@ describe('LocationCellComponent', () => {
let component: LocationCellComponent; let component: LocationCellComponent;
let fixture: ComponentFixture<LocationCellComponent>; let fixture: ComponentFixture<LocationCellComponent>;
let dataTableAdapter: ObjectDataTableAdapter; let dataTableAdapter: ObjectDataTableAdapter;
let rowData; let rowData: any;
let columnData; let columnData: any;
setupTestBed({ setupTestBed({
imports: [ imports: [
@@ -38,10 +38,10 @@ describe('LocationCellComponent', () => {
] ]
}); });
beforeEach(async(() => { beforeEach(() => {
fixture = TestBed.createComponent(LocationCellComponent); fixture = TestBed.createComponent(LocationCellComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
})); });
beforeEach(() => { beforeEach(() => {
rowData = { rowData = {

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { of } from 'rxjs'; import { of } from 'rxjs';
import { FormService } from '../services/form.service'; import { FormService } from '../services/form.service';
import { FormListComponent } from './form-list.component'; import { FormListComponent } from './form-list.component';
@@ -28,7 +28,7 @@ describe('TaskAttachmentList', () => {
let component: FormListComponent; let component: FormListComponent;
let fixture: ComponentFixture<FormListComponent>; let fixture: ComponentFixture<FormListComponent>;
let service: FormService; let service: FormService;
let element: any; let element: HTMLElement;
setupTestBed({ setupTestBed({
imports: [ imports: [
@@ -37,14 +37,12 @@ describe('TaskAttachmentList', () => {
] ]
}); });
beforeEach(async(() => { beforeEach(() => {
fixture = TestBed.createComponent(FormListComponent); fixture = TestBed.createComponent(FormListComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
element = fixture.debugElement.nativeElement; element = fixture.debugElement.nativeElement;
service = TestBed.inject(FormService); service = TestBed.inject(FormService);
});
}));
it('should show the forms as a list', async () => { it('should show the forms as a list', async () => {
spyOn(service, 'getForms').and.returnValue(of([ spyOn(service, 'getForms').and.returnValue(of([

View File

@@ -16,7 +16,7 @@
*/ */
import { SimpleChange } from '@angular/core'; import { SimpleChange } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { ContentService } from '../../../../services'; import { ContentService } from '../../../../services';
import { of } from 'rxjs'; import { of } from 'rxjs';
@@ -69,10 +69,10 @@ describe('ContentWidgetComponent', () => {
] ]
}); });
beforeEach(async(() => { beforeEach(() => {
serviceContent = TestBed.inject(ContentService); serviceContent = TestBed.inject(ContentService);
processContentService = TestBed.inject(ProcessContentService); processContentService = TestBed.inject(ProcessContentService);
})); });
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(ContentWidgetComponent); fixture = TestBed.createComponent(ContentWidgetComponent);

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { Observable, of } from 'rxjs'; import { Observable, of } from 'rxjs';
import { FormService } from '../../../services/form.service'; import { FormService } from '../../../services/form.service';
@@ -54,14 +54,14 @@ describe('DropdownWidgetComponent', () => {
] ]
}); });
beforeEach(async(() => { beforeEach(() => {
fixture = TestBed.createComponent(DropdownWidgetComponent); fixture = TestBed.createComponent(DropdownWidgetComponent);
widget = fixture.componentInstance; widget = fixture.componentInstance;
element = fixture.nativeElement; element = fixture.nativeElement;
formService = TestBed.inject(FormService); formService = TestBed.inject(FormService);
visibilityService = TestBed.inject(WidgetVisibilityService); visibilityService = TestBed.inject(WidgetVisibilityService);
widget.field = new FormFieldModel(new FormModel()); widget.field = new FormFieldModel(new FormModel());
})); });
it('should require field with restUrl', () => { it('should require field with restUrl', () => {
spyOn(formService, 'getRestFieldValues').and.stub(); spyOn(formService, 'getRestFieldValues').and.stub();
@@ -125,12 +125,12 @@ describe('DropdownWidgetComponent', () => {
describe('when is required', () => { describe('when is required', () => {
beforeEach(async(() => { beforeEach(() => {
widget.field = new FormFieldModel( new FormModel({ taskId: '<id>' }), { widget.field = new FormFieldModel( new FormModel({ taskId: '<id>' }), {
type: FormFieldTypes.DROPDOWN, type: FormFieldTypes.DROPDOWN,
required: true required: true
}); });
})); });
it('should be able to display label with asterix', async () => { it('should be able to display label with asterix', async () => {
const label = 'MyLabel123'; const label = 'MyLabel123';
@@ -165,7 +165,7 @@ describe('DropdownWidgetComponent', () => {
describe('and dropdown is populated via taskId', () => { describe('and dropdown is populated via taskId', () => {
beforeEach(async(() => { beforeEach(() => {
spyOn(visibilityService, 'refreshVisibility').and.stub(); spyOn(visibilityService, 'refreshVisibility').and.stub();
spyOn(formService, 'getRestFieldValues').and.callFake(() => { spyOn(formService, 'getRestFieldValues').and.callFake(() => {
return of(fakeOptionList); return of(fakeOptionList);
@@ -180,7 +180,7 @@ describe('DropdownWidgetComponent', () => {
widget.field.emptyOption = { id: 'empty', name: 'Choose one...' }; widget.field.emptyOption = { id: 'empty', name: 'Choose one...' };
widget.field.isVisible = true; widget.field.isVisible = true;
fixture.detectChanges(); fixture.detectChanges();
})); });
it('should show visible dropdown widget', async () => { it('should show visible dropdown widget', async () => {
expect(element.querySelector('#dropdown-id')).toBeDefined(); expect(element.querySelector('#dropdown-id')).toBeDefined();
@@ -228,7 +228,7 @@ describe('DropdownWidgetComponent', () => {
describe('and dropdown is populated via processDefinitionId', () => { describe('and dropdown is populated via processDefinitionId', () => {
beforeEach(async(() => { beforeEach(() => {
spyOn(visibilityService, 'refreshVisibility').and.stub(); spyOn(visibilityService, 'refreshVisibility').and.stub();
spyOn(formService, 'getRestFieldValuesByProcessId').and.callFake(() => { spyOn(formService, 'getRestFieldValuesByProcessId').and.callFake(() => {
return of(fakeOptionList); return of(fakeOptionList);
@@ -243,7 +243,7 @@ describe('DropdownWidgetComponent', () => {
widget.field.emptyOption = { id: 'empty', name: 'Choose one...' }; widget.field.emptyOption = { id: 'empty', name: 'Choose one...' };
widget.field.isVisible = true; widget.field.isVisible = true;
fixture.detectChanges(); fixture.detectChanges();
})); });
it('should show visible dropdown widget', () => { it('should show visible dropdown widget', () => {
expect(element.querySelector('#dropdown-id')).toBeDefined(); expect(element.querySelector('#dropdown-id')).toBeDefined();

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { tick, fakeAsync, async, ComponentFixture, TestBed, flush } from '@angular/core/testing'; import { tick, fakeAsync, ComponentFixture, TestBed, flush } from '@angular/core/testing';
import { fakeFormJson } from '../../../../mock'; import { fakeFormJson } from '../../../../mock';
import { FormFieldModel } from '../core/form-field.model'; import { FormFieldModel } from '../core/form-field.model';
import { FormModel } from '../core/form.model'; import { FormModel } from '../core/form.model';
@@ -88,7 +88,7 @@ describe('TabsWidgetComponent', () => {
let fakeTabVisible: TabModel; let fakeTabVisible: TabModel;
let fakeTabInvisible: TabModel; let fakeTabInvisible: TabModel;
beforeEach(async(() => { beforeEach(() => {
fixture = TestBed.createComponent(TabsWidgetComponent); fixture = TestBed.createComponent(TabsWidgetComponent);
tabWidgetComponent = fixture.componentInstance; tabWidgetComponent = fixture.componentInstance;
element = fixture.nativeElement; element = fixture.nativeElement;
@@ -105,7 +105,7 @@ describe('TabsWidgetComponent', () => {
fakeTabInvisible.isVisible = false; fakeTabInvisible.isVisible = false;
tabWidgetComponent.tabs.push(fakeTabVisible); tabWidgetComponent.tabs.push(fakeTabVisible);
tabWidgetComponent.tabs.push(fakeTabInvisible); tabWidgetComponent.tabs.push(fakeTabInvisible);
})); });
it('should show only visible tabs', fakeAsync(() => { it('should show only visible tabs', fakeAsync(() => {
fixture.detectChanges(); fixture.detectChanges();

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AuthenticationService } from '../../services/authentication.service'; import { AuthenticationService } from '../../services/authentication.service';
import { LoginDialogPanelComponent } from './login-dialog-panel.component'; import { LoginDialogPanelComponent } from './login-dialog-panel.component';
import { of } from 'rxjs'; import { of } from 'rxjs';
@@ -26,8 +26,9 @@ import { TranslateModule } from '@ngx-translate/core';
describe('LoginDialogPanelComponent', () => { describe('LoginDialogPanelComponent', () => {
let component: LoginDialogPanelComponent; let component: LoginDialogPanelComponent;
let fixture: ComponentFixture<LoginDialogPanelComponent>; let fixture: ComponentFixture<LoginDialogPanelComponent>;
let element: any; let element: HTMLElement;
let usernameInput, passwordInput; let usernameInput: HTMLInputElement;
let passwordInput: HTMLInputElement;
let authService: AuthenticationService; let authService: AuthenticationService;
setupTestBed({ setupTestBed({
@@ -37,23 +38,24 @@ describe('LoginDialogPanelComponent', () => {
] ]
}); });
beforeEach(async(() => { beforeEach(async () => {
fixture = TestBed.createComponent(LoginDialogPanelComponent); fixture = TestBed.createComponent(LoginDialogPanelComponent);
element = fixture.nativeElement; element = fixture.nativeElement;
component = fixture.componentInstance; component = fixture.componentInstance;
authService = TestBed.inject(AuthenticationService); authService = TestBed.inject(AuthenticationService);
fixture.detectChanges(); fixture.detectChanges();
fixture.whenStable().then(() => { await fixture.whenStable();
usernameInput = element.querySelector('#username'); usernameInput = element.querySelector('#username');
passwordInput = element.querySelector('#password'); passwordInput = element.querySelector('#password');
}); });
}));
afterEach(() => { afterEach(() => {
fixture.destroy(); fixture.destroy();
}); });
function loginWithCredentials(username, password) { function loginWithCredentials(username: string, password: string) {
usernameInput.value = username; usernameInput.value = username;
passwordInput.value = password; passwordInput.value = password;

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { async, ComponentFixture, inject, TestBed } from '@angular/core/testing'; import { ComponentFixture, inject, TestBed } from '@angular/core/testing';
import { setupTestBed } from '../../testing/setup-test-bed'; import { setupTestBed } from '../../testing/setup-test-bed';
import { CoreTestingModule } from '../../testing/core.testing.module'; import { CoreTestingModule } from '../../testing/core.testing.module';
import { NotificationHistoryComponent } from './notification-history.component'; import { NotificationHistoryComponent } from './notification-history.component';
@@ -48,7 +48,7 @@ describe('Notification History Component', () => {
] ]
}); });
beforeEach(async(() => { beforeEach(() => {
fixture = TestBed.createComponent(NotificationHistoryComponent); fixture = TestBed.createComponent(NotificationHistoryComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
element = fixture.nativeElement; element = fixture.nativeElement;
@@ -56,7 +56,7 @@ describe('Notification History Component', () => {
storage = TestBed.inject(StorageService); storage = TestBed.inject(StorageService);
notificationService = TestBed.inject(NotificationService); notificationService = TestBed.inject(NotificationService);
component.notifications = []; component.notifications = [];
})); });
beforeEach(inject([OverlayContainer], (oc: OverlayContainer) => { beforeEach(inject([OverlayContainer], (oc: OverlayContainer) => {
overlayContainerElement = oc.getContainerElement(); overlayContainerElement = oc.getContainerElement();

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { async, TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { AppConfigService } from '../app-config/app-config.service'; import { AppConfigService } from '../app-config/app-config.service';
import { UserPreferencesService } from '../services/user-preferences.service'; import { UserPreferencesService } from '../services/user-preferences.service';
import { of } from 'rxjs'; import { of } from 'rxjs';
@@ -36,11 +36,11 @@ describe('DecimalNumberPipe', () => {
] ]
}); });
beforeEach(async(() => { beforeEach(() => {
userPreferences = TestBed.inject(UserPreferencesService); userPreferences = TestBed.inject(UserPreferencesService);
spyOn(userPreferences, 'select').and.returnValue(of('')); spyOn(userPreferences, 'select').and.returnValue(of(''));
pipe = new DecimalNumberPipe(userPreferences, TestBed.inject(AppConfigService)); pipe = new DecimalNumberPipe(userPreferences, TestBed.inject(AppConfigService));
})); });
it('should return number localized and rounded following the default config', () => { it('should return number localized and rounded following the default config', () => {
expect(pipe.transform(1234.567)).toBe('1,234.57'); expect(pipe.transform(1234.567)).toBe('1,234.57');

View File

@@ -16,16 +16,15 @@
*/ */
import { FileTypePipe } from './file-type.pipe'; import { FileTypePipe } from './file-type.pipe';
import { async } from '@angular/core/testing';
describe('FileTypePipe', () => { describe('FileTypePipe', () => {
const altText = 'ft_ic_ms_word'; const altText = 'ft_ic_ms_word';
let pipe: FileTypePipe; let pipe: FileTypePipe;
beforeEach(async(() => { beforeEach(() => {
pipe = new FileTypePipe(); pipe = new FileTypePipe();
})); });
it('should return file type from alt text', () => { it('should return file type from alt text', () => {
expect(pipe.transform(altText)).toBe('word'); expect(pipe.transform(altText)).toBe('word');

View File

@@ -16,15 +16,14 @@
*/ */
import { FullNamePipe } from './full-name.pipe'; import { FullNamePipe } from './full-name.pipe';
import { async } from '@angular/core/testing';
describe('FullNamePipe', () => { describe('FullNamePipe', () => {
let pipe: FullNamePipe; let pipe: FullNamePipe;
beforeEach(async(() => { beforeEach(() => {
pipe = new FullNamePipe(); pipe = new FullNamePipe();
})); });
it('should return empty string when there is no name', () => { it('should return empty string when there is no name', () => {
const user = {}; const user = {};

View File

@@ -16,7 +16,7 @@
*/ */
import { LocalizedDatePipe } from './localized-date.pipe'; import { LocalizedDatePipe } from './localized-date.pipe';
import { async, TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { AppConfigService } from '../app-config/app-config.service'; import { AppConfigService } from '../app-config/app-config.service';
import { UserPreferencesService } from '../services/user-preferences.service'; import { UserPreferencesService } from '../services/user-preferences.service';
import { of } from 'rxjs'; import { of } from 'rxjs';
@@ -39,11 +39,11 @@ describe('LocalizedDatePipe', () => {
] ]
}); });
beforeEach(async(() => { beforeEach(() => {
userPreferences = TestBed.inject(UserPreferencesService); userPreferences = TestBed.inject(UserPreferencesService);
spyOn(userPreferences, 'select').and.returnValue(of('')); spyOn(userPreferences, 'select').and.returnValue(of(''));
pipe = new LocalizedDatePipe(userPreferences, TestBed.inject(AppConfigService)); pipe = new LocalizedDatePipe(userPreferences, TestBed.inject(AppConfigService));
})); });
it('should return time with locale en-US', () => { it('should return time with locale en-US', () => {
const date = new Date('1990-11-03 00:00'); const date = new Date('1990-11-03 00:00');

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { async, TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { ActivatedRouteSnapshot, Router } from '@angular/router'; import { ActivatedRouteSnapshot, Router } from '@angular/router';
import { setupTestBed } from '../testing/setup-test-bed'; import { setupTestBed } from '../testing/setup-test-bed';
import { CoreTestingModule } from '../testing/core.testing.module'; import { CoreTestingModule } from '../testing/core.testing.module';
@@ -49,7 +49,7 @@ describe('Auth Guard SSO role service', () => {
peopleContentService = TestBed.inject(PeopleContentService); peopleContentService = TestBed.inject(PeopleContentService);
}); });
it('Should canActivate be true if the Role is present int the JWT token', async(async () => { it('Should canActivate be true if the Role is present int the JWT token', async () => {
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token'); spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role1'] } }); spyOn(jwtHelperService, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role1'] } });
@@ -57,9 +57,9 @@ describe('Auth Guard SSO role service', () => {
router.data = { 'roles': ['role1', 'role2'] }; router.data = { 'roles': ['role1', 'role2'] };
expect(await authGuard.canActivate(router)).toBeTruthy(); expect(await authGuard.canActivate(router)).toBeTruthy();
})); });
it('Should canActivate be false if the Role is not present int the JWT token', async(async () => { it('Should canActivate be false if the Role is not present int the JWT token', async () => {
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token'); spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role3'] } }); spyOn(jwtHelperService, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role3'] } });
@@ -67,9 +67,9 @@ describe('Auth Guard SSO role service', () => {
router.data = { 'roles': ['role1', 'role2'] }; router.data = { 'roles': ['role1', 'role2'] };
expect(await authGuard.canActivate(router)).toBeFalsy(); expect(await authGuard.canActivate(router)).toBeFalsy();
})); });
it('Should not redirect if canActivate is', async(async () => { it('Should not redirect if canActivate is', async () => {
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token'); spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role1'] } }); spyOn(jwtHelperService, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role1'] } });
spyOn(routerService, 'navigate').and.stub(); spyOn(routerService, 'navigate').and.stub();
@@ -79,27 +79,27 @@ describe('Auth Guard SSO role service', () => {
expect(await authGuard.canActivate(router)).toBeTruthy(); expect(await authGuard.canActivate(router)).toBeTruthy();
expect(routerService.navigate).not.toHaveBeenCalled(); expect(routerService.navigate).not.toHaveBeenCalled();
})); });
it('Should canActivate return false if the data Role to check is empty', async(async () => { it('Should canActivate return false if the data Role to check is empty', async () => {
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token'); spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role1', 'role3'] } }); spyOn(jwtHelperService, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role1', 'role3'] } });
const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot(); const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();
expect(await authGuard.canActivate(router)).toBeFalsy(); expect(await authGuard.canActivate(router)).toBeFalsy();
})); });
it('Should canActivate return false if the realm_access is not present', async(async () => { it('Should canActivate return false if the realm_access is not present', async () => {
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token'); spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue({}); spyOn(jwtHelperService, 'decodeToken').and.returnValue({});
const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot(); const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();
expect(await authGuard.canActivate(router)).toBeFalsy(); expect(await authGuard.canActivate(router)).toBeFalsy();
})); });
it('Should redirect to the redirectURL if canActivate is false and redirectUrl is in data', async(async () => { it('Should redirect to the redirectURL if canActivate is false and redirectUrl is in data', async () => {
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token'); spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue({}); spyOn(jwtHelperService, 'decodeToken').and.returnValue({});
spyOn(routerService, 'navigate').and.stub(); spyOn(routerService, 'navigate').and.stub();
@@ -109,9 +109,9 @@ describe('Auth Guard SSO role service', () => {
expect(await authGuard.canActivate(router)).toBeFalsy(); expect(await authGuard.canActivate(router)).toBeFalsy();
expect(routerService.navigate).toHaveBeenCalledWith(['/no-role-url']); expect(routerService.navigate).toHaveBeenCalledWith(['/no-role-url']);
})); });
it('Should not redirect if canActivate is false and redirectUrl is not in data', async(async () => { it('Should not redirect if canActivate is false and redirectUrl is not in data', async () => {
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token'); spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue({}); spyOn(jwtHelperService, 'decodeToken').and.returnValue({});
spyOn(routerService, 'navigate').and.stub(); spyOn(routerService, 'navigate').and.stub();
@@ -121,7 +121,7 @@ describe('Auth Guard SSO role service', () => {
expect(await authGuard.canActivate(router)).toBeFalsy(); expect(await authGuard.canActivate(router)).toBeFalsy();
expect(routerService.navigate).not.toHaveBeenCalled(); expect(routerService.navigate).not.toHaveBeenCalled();
})); });
it('Should canActivate be false hasRealm is true and hasClientRole is false', async () => { it('Should canActivate be false hasRealm is true and hasClientRole is false', async () => {
const route: ActivatedRouteSnapshot = new ActivatedRouteSnapshot(); const route: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { async, TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { Router, RouterStateSnapshot } from '@angular/router'; import { Router, RouterStateSnapshot } from '@angular/router';
import { AppConfigService } from '../app-config/app-config.service'; import { AppConfigService } from '../app-config/app-config.service';
import { AuthGuard } from './auth-guard.service'; import { AuthGuard } from './auth-guard.service';
@@ -53,33 +53,33 @@ describe('AuthGuardService', () => {
storageService = TestBed.inject(StorageService); storageService = TestBed.inject(StorageService);
}); });
it('if the alfresco js api is logged in should canActivate be true', async(async () => { it('if the alfresco js api is logged in should canActivate be true', async () => {
spyOn(router, 'navigateByUrl'); spyOn(router, 'navigateByUrl');
spyOn(authService, 'isLoggedIn').and.returnValue(true); spyOn(authService, 'isLoggedIn').and.returnValue(true);
expect(await authGuard.canActivate(null, state)).toBeTruthy(); expect(await authGuard.canActivate(null, state)).toBeTruthy();
expect(router.navigateByUrl).not.toHaveBeenCalled(); expect(router.navigateByUrl).not.toHaveBeenCalled();
})); });
it('if the alfresco js api is NOT logged in should canActivate be false', async(async () => { it('if the alfresco js api is NOT logged in should canActivate be false', async () => {
state.url = 'some-url'; state.url = 'some-url';
spyOn(router, 'navigateByUrl'); spyOn(router, 'navigateByUrl');
spyOn(authService, 'isLoggedIn').and.returnValue(false); spyOn(authService, 'isLoggedIn').and.returnValue(false);
expect(await authGuard.canActivate(null, state)).toBeFalsy(); expect(await authGuard.canActivate(null, state)).toBeFalsy();
expect(router.navigateByUrl).toHaveBeenCalled(); expect(router.navigateByUrl).toHaveBeenCalled();
})); });
it('if the alfresco js api is configured with withCredentials true should canActivate be true', async(async () => { it('if the alfresco js api is configured with withCredentials true should canActivate be true', async () => {
spyOn(authService, 'isBpmLoggedIn').and.returnValue(true); spyOn(authService, 'isBpmLoggedIn').and.returnValue(true);
appConfigService.config.auth.withCredentials = true; appConfigService.config.auth.withCredentials = true;
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url' }; const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url' };
expect(await authGuard.canActivate(null, route)).toBeTruthy(); expect(await authGuard.canActivate(null, route)).toBeTruthy();
})); });
it('should not redirect to login', async(async () => { it('should not redirect to login', async () => {
storageService.setItem('loginFragment', 'login'); storageService.setItem('loginFragment', 'login');
spyOn(router, 'navigateByUrl').and.stub(); spyOn(router, 'navigateByUrl').and.stub();
@@ -89,9 +89,9 @@ describe('AuthGuardService', () => {
expect(await authGuard.canActivate(null, state)).toBeTruthy(); expect(await authGuard.canActivate(null, state)).toBeTruthy();
expect(router.navigateByUrl).not.toHaveBeenCalled(); expect(router.navigateByUrl).not.toHaveBeenCalled();
})); });
it('should redirect url if the User is NOT logged in and isOAuthWithoutSilentLogin', async(async () => { it('should redirect url if the User is NOT logged in and isOAuthWithoutSilentLogin', async () => {
spyOn(router, 'navigateByUrl').and.stub(); spyOn(router, 'navigateByUrl').and.stub();
spyOn(authService, 'isLoggedIn').and.returnValue(false); spyOn(authService, 'isLoggedIn').and.returnValue(false);
spyOn(authService, 'isOauth').and.returnValue(true); spyOn(authService, 'isOauth').and.returnValue(true);
@@ -99,9 +99,9 @@ describe('AuthGuardService', () => {
expect(await authGuard.canActivate(null, state)).toBeFalsy(); expect(await authGuard.canActivate(null, state)).toBeFalsy();
expect(router.navigateByUrl).toHaveBeenCalled(); expect(router.navigateByUrl).toHaveBeenCalled();
})); });
it('should redirect url if the User is NOT logged in and isOAuth but no silentLogin configured', async(async () => { it('should redirect url if the User is NOT logged in and isOAuth but no silentLogin configured', async () => {
spyOn(router, 'navigateByUrl').and.stub(); spyOn(router, 'navigateByUrl').and.stub();
spyOn(authService, 'isLoggedIn').and.returnValue(false); spyOn(authService, 'isLoggedIn').and.returnValue(false);
spyOn(authService, 'isOauth').and.returnValue(true); spyOn(authService, 'isOauth').and.returnValue(true);
@@ -109,9 +109,9 @@ describe('AuthGuardService', () => {
expect(await authGuard.canActivate(null, state)).toBeFalsy(); expect(await authGuard.canActivate(null, state)).toBeFalsy();
expect(router.navigateByUrl).toHaveBeenCalled(); expect(router.navigateByUrl).toHaveBeenCalled();
})); });
it('should NOT redirect url if the User is NOT logged in and isOAuth but with silentLogin configured', async(async () => { it('should NOT redirect url if the User is NOT logged in and isOAuth but with silentLogin configured', async () => {
spyOn(authService, 'ssoImplicitLogin').and.stub(); spyOn(authService, 'ssoImplicitLogin').and.stub();
spyOn(authService, 'isLoggedIn').and.returnValue(false); spyOn(authService, 'isLoggedIn').and.returnValue(false);
spyOn(authService, 'isOauth').and.returnValue(true); spyOn(authService, 'isOauth').and.returnValue(true);
@@ -119,9 +119,9 @@ describe('AuthGuardService', () => {
expect(await authGuard.canActivate(null, state)).toBeFalsy(); expect(await authGuard.canActivate(null, state)).toBeFalsy();
expect(authService.ssoImplicitLogin).toHaveBeenCalledTimes(1); expect(authService.ssoImplicitLogin).toHaveBeenCalledTimes(1);
})); });
it('should set redirect url', async(async () => { it('should set redirect url', async () => {
state.url = 'some-url'; state.url = 'some-url';
appConfigService.config.loginRoute = 'login'; appConfigService.config.loginRoute = 'login';
@@ -134,9 +134,9 @@ describe('AuthGuardService', () => {
provider: 'ALL', url: 'some-url' provider: 'ALL', url: 'some-url'
}); });
expect(router.navigateByUrl).toHaveBeenCalledWith(router.parseUrl('/login?redirectUrl=some-url')); expect(router.navigateByUrl).toHaveBeenCalledWith(router.parseUrl('/login?redirectUrl=some-url'));
})); });
it('should set redirect url with query params', async(async () => { it('should set redirect url with query params', async () => {
state.url = 'some-url;q=query'; state.url = 'some-url;q=query';
appConfigService.config.loginRoute = 'login'; appConfigService.config.loginRoute = 'login';
appConfigService.config.provider = 'ALL'; appConfigService.config.provider = 'ALL';
@@ -150,9 +150,9 @@ describe('AuthGuardService', () => {
provider: 'ALL', url: 'some-url;q=query' provider: 'ALL', url: 'some-url;q=query'
}); });
expect(router.navigateByUrl).toHaveBeenCalledWith(router.parseUrl('/login?redirectUrl=some-url;q=query')); expect(router.navigateByUrl).toHaveBeenCalledWith(router.parseUrl('/login?redirectUrl=some-url;q=query'));
})); });
it('should get redirect url from config if there is one configured', async(async () => { it('should get redirect url from config if there is one configured', async () => {
state.url = 'some-url'; state.url = 'some-url';
appConfigService.config.loginRoute = 'fakeLoginRoute'; appConfigService.config.loginRoute = 'fakeLoginRoute';
@@ -165,9 +165,9 @@ describe('AuthGuardService', () => {
provider: 'ALL', url: 'some-url' provider: 'ALL', url: 'some-url'
}); });
expect(router.navigateByUrl).toHaveBeenCalledWith(router.parseUrl('/fakeLoginRoute?redirectUrl=some-url')); expect(router.navigateByUrl).toHaveBeenCalledWith(router.parseUrl('/fakeLoginRoute?redirectUrl=some-url'));
})); });
it('should pass actual redirect when no state segments exists', async(async () => { it('should pass actual redirect when no state segments exists', async () => {
state.url = '/'; state.url = '/';
spyOn(router, 'navigateByUrl'); spyOn(router, 'navigateByUrl');
@@ -178,5 +178,5 @@ describe('AuthGuardService', () => {
expect(authService.setRedirect).toHaveBeenCalledWith({ expect(authService.setRedirect).toHaveBeenCalledWith({
provider: 'ALL', url: '/' provider: 'ALL', url: '/'
}); });
})); });
}); });

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { async, TestBed } from '@angular/core/testing'; import { fakeAsync, TestBed } from '@angular/core/testing';
import { setupTestBed, AlfrescoApiService, IdentityGroupService, IdentityGroupSearchParam } from '@alfresco/adf-core'; import { setupTestBed, AlfrescoApiService, IdentityGroupService, IdentityGroupSearchParam } from '@alfresco/adf-core';
import { HttpErrorResponse } from '@angular/common/http'; import { HttpErrorResponse } from '@angular/common/http';
import { throwError, of } from 'rxjs'; import { throwError, of } from 'rxjs';
@@ -46,7 +46,7 @@ describe('IdentityGroupService', () => {
] ]
}); });
beforeEach(async(() => { beforeEach(fakeAsync(() => {
service = TestBed.inject(IdentityGroupService); service = TestBed.inject(IdentityGroupService);
apiService = TestBed.inject(AlfrescoApiService); apiService = TestBed.inject(AlfrescoApiService);
})); }));

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By, DomSanitizer } from '@angular/platform-browser'; import { By, DomSanitizer } from '@angular/platform-browser';
import { AuthenticationService, ContentService } from '../../services'; import { AuthenticationService, ContentService } from '../../services';
import { InitialUsernamePipe } from '../../pipes'; import { InitialUsernamePipe } from '../../pipes';
@@ -94,7 +94,7 @@ describe('User info component', () => {
] ]
}); });
beforeEach(async(() => { beforeEach(() => {
fixture = TestBed.createComponent(UserInfoComponent); fixture = TestBed.createComponent(UserInfoComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
element = fixture.nativeElement; element = fixture.nativeElement;
@@ -108,7 +108,7 @@ describe('User info component', () => {
spyOn(window, 'requestAnimationFrame').and.returnValue(1); spyOn(window, 'requestAnimationFrame').and.returnValue(1);
spyOn(bpmUserService, 'getCurrentUserProfileImage').and.returnValue('app/rest/admin/profile-picture'); spyOn(bpmUserService, 'getCurrentUserProfileImage').and.returnValue('app/rest/admin/profile-picture');
spyOn(contentService, 'getContentUrl').and.returnValue('alfresco-logo.svg'); spyOn(contentService, 'getContentUrl').and.returnValue('alfresco-logo.svg');
})); });
afterEach(() => { afterEach(() => {
fixture.destroy(); fixture.destroy();
@@ -209,13 +209,13 @@ describe('User info component', () => {
describe('and has image', () => { describe('and has image', () => {
beforeEach(async(() => { beforeEach(() => {
isOauthStub.and.returnValue(false); isOauthStub.and.returnValue(false);
isEcmLoggedInStub.and.returnValue(true); isEcmLoggedInStub.and.returnValue(true);
isLoggedInStub.and.returnValue(true); isLoggedInStub.and.returnValue(true);
getCurrenEcmtUserInfoStub.and.returnValue(of(fakeEcmUser)); getCurrenEcmtUserInfoStub.and.returnValue(of(fakeEcmUser));
fixture.detectChanges(); fixture.detectChanges();
})); });
it('should get the ecm current user image from the service', async () => { it('should get the ecm current user image from the service', async () => {
await fixture.whenStable(); await fixture.whenStable();
@@ -316,15 +316,15 @@ describe('User info component', () => {
describe('when user is logged on bpm', () => { describe('when user is logged on bpm', () => {
let getCurrentUserInfoStub; let getCurrentUserInfoStub: jasmine.Spy;
beforeEach(async(() => { beforeEach(() => {
isOauthStub.and.returnValue(false); isOauthStub.and.returnValue(false);
isBpmLoggedInStub.and.returnValue(true); isBpmLoggedInStub.and.returnValue(true);
isLoggedInStub.and.returnValue(true); isLoggedInStub.and.returnValue(true);
isEcmLoggedInStub.and.returnValue(false); isEcmLoggedInStub.and.returnValue(false);
getCurrentUserInfoStub = spyOn(bpmUserService, 'getCurrentUserInfo').and.returnValue(of(fakeBpmUser)); getCurrentUserInfoStub = spyOn(bpmUserService, 'getCurrentUserInfo').and.returnValue(of(fakeBpmUser));
})); });
it('should fetch bpm userInfo', (done) => { it('should fetch bpm userInfo', (done) => {
getCurrentUserInfoStub.and.returnValue(of(fakeBpmUser)); getCurrentUserInfoStub.and.returnValue(of(fakeBpmUser));
@@ -427,7 +427,7 @@ describe('User info component', () => {
describe('when user is logged on bpm and ecm', () => { describe('when user is logged on bpm and ecm', () => {
beforeEach(async(() => { beforeEach(() => {
isOauthStub.and.returnValue(false); isOauthStub.and.returnValue(false);
isEcmLoggedInStub.and.returnValue(true); isEcmLoggedInStub.and.returnValue(true);
isBpmLoggedInStub.and.returnValue(true); isBpmLoggedInStub.and.returnValue(true);
@@ -435,7 +435,7 @@ describe('User info component', () => {
getCurrenEcmtUserInfoStub.and.returnValue(of(fakeEcmUser)); getCurrenEcmtUserInfoStub.and.returnValue(of(fakeEcmUser));
spyOn(bpmUserService, 'getCurrentUserInfo').and.returnValue(of(fakeBpmUser)); spyOn(bpmUserService, 'getCurrentUserInfo').and.returnValue(of(fakeBpmUser));
})); });
it('should able to fetch ecm userInfo', (done) => { it('should able to fetch ecm userInfo', (done) => {
fixture.detectChanges(); fixture.detectChanges();
@@ -537,14 +537,14 @@ describe('User info component', () => {
describe('when identity user is logged in', () => { describe('when identity user is logged in', () => {
let getCurrentUserInfoStub; let getCurrentUserInfoStub: jasmine.Spy;
beforeEach(async(() => { beforeEach(() => {
isOauthStub.and.returnValue(true); isOauthStub.and.returnValue(true);
isLoggedInStub.and.returnValue(true); isLoggedInStub.and.returnValue(true);
isEcmLoggedInStub.and.returnValue(false); isEcmLoggedInStub.and.returnValue(false);
getCurrentUserInfoStub = spyOn(identityUserService, 'getCurrentUserInfo').and.returnValue(identityUserMock); getCurrentUserInfoStub = spyOn(identityUserService, 'getCurrentUserInfo').and.returnValue(identityUserMock);
})); });
it('should show the identity user initials if is not ecm user', async () => { it('should show the identity user initials if is not ecm user', async () => {
fixture.detectChanges(); fixture.detectChanges();

View File

@@ -16,7 +16,7 @@
*/ */
import { DomSanitizer } from '@angular/platform-browser'; import { DomSanitizer } from '@angular/platform-browser';
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PdfThumbComponent } from './pdf-viewer-thumb.component'; import { PdfThumbComponent } from './pdf-viewer-thumb.component';
import { setupTestBed } from '../../testing/setup-test-bed'; import { setupTestBed } from '../../testing/setup-test-bed';
import { CoreTestingModule } from '../../testing/core.testing.module'; import { CoreTestingModule } from '../../testing/core.testing.module';
@@ -52,10 +52,10 @@ describe('PdfThumbComponent', () => {
] ]
}); });
beforeEach(async(() => { beforeEach(() => {
fixture = TestBed.createComponent(PdfThumbComponent); fixture = TestBed.createComponent(PdfThumbComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
})); });
it('should have resolve image data', (done) => { it('should have resolve image data', (done) => {
component.page = page; component.page = page;

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { PdfThumbListComponent } from './pdf-viewer-thumbnails.component'; import { PdfThumbListComponent } from './pdf-viewer-thumbnails.component';
import { setupTestBed } from '../../testing/setup-test-bed'; import { setupTestBed } from '../../testing/setup-test-bed';
@@ -69,7 +69,7 @@ describe('PdfThumbListComponent', () => {
] ]
}); });
beforeEach(async(() => { beforeEach(() => {
fixture = TestBed.createComponent(PdfThumbListComponent); fixture = TestBed.createComponent(PdfThumbListComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
component.pdfViewer = viewerMock; component.pdfViewer = viewerMock;
@@ -80,7 +80,7 @@ describe('PdfThumbListComponent', () => {
fixture.nativeElement.style.overflow = 'scroll'; fixture.nativeElement.style.overflow = 'scroll';
fixture.debugElement.query(By.css('.adf-pdf-thumbnails__content')) fixture.debugElement.query(By.css('.adf-pdf-thumbnails__content'))
.nativeElement.style.height = '2000px'; .nativeElement.style.height = '2000px';
})); });
it('should render initial rage of items', () => { it('should render initial rage of items', () => {
fixture.nativeElement.scrollTop = 0; fixture.nativeElement.scrollTop = 0;

View File

@@ -38,7 +38,7 @@ export class TxtViewerComponent implements OnChanges {
constructor(private http: HttpClient, private appConfigService: AppConfigService) { constructor(private http: HttpClient, private appConfigService: AppConfigService) {
} }
ngOnChanges(changes: SimpleChanges): Promise<any> { ngOnChanges(changes: SimpleChanges): Promise<void> {
const blobFile = changes['blobFile']; const blobFile = changes['blobFile'];
if (blobFile && blobFile.currentValue) { if (blobFile && blobFile.currentValue) {
@@ -57,7 +57,7 @@ export class TxtViewerComponent implements OnChanges {
return Promise.resolve(); return Promise.resolve();
} }
private getUrlContent(url: string): Promise<any> { private getUrlContent(url: string): Promise<void> {
const withCredentialsMode = this.appConfigService.get<boolean>('auth.withCredentials', false); const withCredentialsMode = this.appConfigService.get<boolean>('auth.withCredentials', false);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@@ -70,7 +70,7 @@ export class TxtViewerComponent implements OnChanges {
}); });
} }
private readBlob(blob: Blob): Promise<any> { private readBlob(blob: Blob): Promise<void> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const reader = new FileReader(); const reader = new FileReader();

View File

@@ -18,7 +18,7 @@
import { Location } from '@angular/common'; import { Location } from '@angular/common';
import { SpyLocation } from '@angular/common/testing'; import { SpyLocation } from '@angular/common/testing';
import { ElementRef } from '@angular/core'; import { ElementRef } from '@angular/core';
import { async, TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { ViewerComponent } from '../components/viewer.component'; import { ViewerComponent } from '../components/viewer.component';
import { ViewerExtensionDirective } from './viewer-extension.directive'; import { ViewerExtensionDirective } from './viewer-extension.directive';
import { setupTestBed } from '../../testing/setup-test-bed'; import { setupTestBed } from '../../testing/setup-test-bed';
@@ -47,10 +47,10 @@ describe('ExtensionViewerDirective', () => {
] ]
}); });
beforeEach(async(() => { beforeEach(() => {
extensionViewerDirective = TestBed.inject(ViewerExtensionDirective); extensionViewerDirective = TestBed.inject(ViewerExtensionDirective);
extensionViewerDirective.templateModel = {template: '', isVisible: false}; extensionViewerDirective.templateModel = {template: '', isVisible: false};
})); });
it('is defined', () => { it('is defined', () => {
expect(extensionViewerDirective).toBeDefined(); expect(extensionViewerDirective).toBeDefined();

View File

@@ -24,7 +24,7 @@ import {
SimpleChange, SimpleChange,
ComponentFactoryResolver ComponentFactoryResolver
} from '@angular/core'; } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { DynamicExtensionComponent } from './dynamic.component'; import { DynamicExtensionComponent } from './dynamic.component';
import { ComponentRegisterService } from '../../services/component-register.service'; import { ComponentRegisterService } from '../../services/component-register.service';
@@ -50,7 +50,7 @@ describe('DynamicExtensionComponent', () => {
let component: DynamicExtensionComponent; let component: DynamicExtensionComponent;
let componentFactoryResolver: ComponentFactoryResolver; let componentFactoryResolver: ComponentFactoryResolver;
beforeEach(async(() => { beforeEach(() => {
componentRegister = new ComponentRegisterService(); componentRegister = new ComponentRegisterService();
componentRegister.setComponents({ 'test-component': TestComponent }); componentRegister.setComponents({ 'test-component': TestComponent });
@@ -61,7 +61,7 @@ describe('DynamicExtensionComponent', () => {
}); });
TestBed.compileComponents(); TestBed.compileComponents();
})); });
describe('Sub-component creation', () => { describe('Sub-component creation', () => {

View File

@@ -17,7 +17,7 @@
import { Component, DebugElement, SimpleChange, NgModule, Injector, ComponentFactoryResolver, ViewChild } from '@angular/core'; import { Component, DebugElement, SimpleChange, NgModule, Injector, ComponentFactoryResolver, ViewChild } from '@angular/core';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable, of, throwError } from 'rxjs'; import { Observable, of, throwError } from 'rxjs';
import { import {
CoreModule, CoreModule,
@@ -118,7 +118,7 @@ describe('FormCloudComponent', () => {
] ]
}); });
beforeEach(async(() => { beforeEach(() => {
const apiService = TestBed.inject(AlfrescoApiService); const apiService = TestBed.inject(AlfrescoApiService);
spyOn(apiService, 'getInstance').and.returnValue(mockOauth2Auth); spyOn(apiService, 'getInstance').and.returnValue(mockOauth2Auth);
@@ -133,7 +133,7 @@ describe('FormCloudComponent', () => {
fixture = TestBed.createComponent(FormCloudComponent); fixture = TestBed.createComponent(FormCloudComponent);
formComponent = fixture.componentInstance; formComponent = fixture.componentInstance;
fixture.detectChanges(); fixture.detectChanges();
})); });
it('should register custom [upload] widget', () => { it('should register custom [upload] widget', () => {
const widget = buildWidget('upload', fixture.componentRef.injector); const widget = buildWidget('upload', fixture.componentRef.injector);
@@ -1154,7 +1154,7 @@ describe('retrieve metadata on submit', () => {
} }
}; };
beforeEach(async(() => { beforeEach(() => {
const apiService = TestBed.inject(AlfrescoApiService); const apiService = TestBed.inject(AlfrescoApiService);
spyOn(apiService, 'getInstance').and.returnValue(mockOauth2Auth); spyOn(apiService, 'getInstance').and.returnValue(mockOauth2Auth);
@@ -1164,7 +1164,7 @@ describe('retrieve metadata on submit', () => {
formComponent = fixture.componentInstance; formComponent = fixture.componentInstance;
formComponent.form = formComponent.parseForm(fakeMetadataForm); formComponent.form = formComponent.parseForm(fakeMetadataForm);
fixture.detectChanges(); fixture.detectChanges();
})); });
it('should set values when updateFormValuesRequested is updated', async () => { it('should set values when updateFormValuesRequested is updated', async () => {
formComponent.form.values['pfx_property_three'] = {}; formComponent.form.values['pfx_property_three'] = {};

View File

@@ -405,7 +405,7 @@ describe('AttachFileCloudWidgetComponent', () => {
expect(widget.rootNodeId).toEqual('-my-'); expect(widget.rootNodeId).toEqual('-my-');
}); });
it('should return the application name in case -appname- placeholder is present', async() => { it('should return the application name in case -appname- placeholder is present', () => {
appConfigService.config = Object.assign(appConfigService.config, { appConfigService.config = Object.assign(appConfigService.config, {
'alfresco-deployed-apps': [ 'alfresco-deployed-apps': [
{ {
@@ -417,7 +417,7 @@ describe('AttachFileCloudWidgetComponent', () => {
expect(widget.replaceAppNameAliasWithValue('/myfiles/-appname-/folder')).toBe('/myfiles/fakeapp/folder'); expect(widget.replaceAppNameAliasWithValue('/myfiles/-appname-/folder')).toBe('/myfiles/fakeapp/folder');
}); });
it('should return the same value in case -appname- placeholder is NOT present', async() => { it('should return the same value in case -appname- placeholder is NOT present', () => {
expect(widget.replaceAppNameAliasWithValue('/myfiles/fakepath/folder')).toBe('/myfiles/fakepath/folder'); expect(widget.replaceAppNameAliasWithValue('/myfiles/fakepath/folder')).toBe('/myfiles/fakepath/folder');
}); });

View File

@@ -30,7 +30,7 @@ describe('ProcessNameCloudPipe', () => {
const defaultName = 'default-name'; const defaultName = 'default-name';
const datetimeIdentifier = '%{datetime}'; const datetimeIdentifier = '%{datetime}';
const processDefinitionIdentifier = '%{processDefinition}'; const processDefinitionIdentifier = '%{processDefinition}';
const mockCurrentDate = new Date('Wed Oct 23 2019'); const mockCurrentDate: number = new Date('Wed Oct 23 2019').getTime();
const mockLocalizedCurrentDate = 'Oct 23, 2019, 12:00:00 AM'; const mockLocalizedCurrentDate = 'Oct 23, 2019, 12:00:00 AM';
const nameWithProcessDefinitionIdentifier = `${defaultName} - ${processDefinitionIdentifier}`; const nameWithProcessDefinitionIdentifier = `${defaultName} - ${processDefinitionIdentifier}`;
const nameWithDatetimeIdentifier = `${defaultName} - ${datetimeIdentifier}`; const nameWithDatetimeIdentifier = `${defaultName} - ${datetimeIdentifier}`;

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { async, TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { setupTestBed, IdentityUserService } from '@alfresco/adf-core'; import { setupTestBed, IdentityUserService } from '@alfresco/adf-core';
import { of } from 'rxjs'; import { of } from 'rxjs';
import { ProcessFilterCloudService } from './process-filter-cloud.service'; import { ProcessFilterCloudService } from './process-filter-cloud.service';
@@ -50,7 +50,7 @@ describe('ProcessFilterCloudService', () => {
] ]
}); });
beforeEach(async(() => { beforeEach(() => {
service = TestBed.inject(ProcessFilterCloudService); service = TestBed.inject(ProcessFilterCloudService);
const preferenceCloudService = service.preferenceService; const preferenceCloudService = service.preferenceService;
@@ -61,7 +61,7 @@ describe('ProcessFilterCloudService', () => {
getPreferenceByKeySpy = spyOn(preferenceCloudService, 'getPreferenceByKey').and.returnValue(of(fakeProcessCloudFilters)); getPreferenceByKeySpy = spyOn(preferenceCloudService, 'getPreferenceByKey').and.returnValue(of(fakeProcessCloudFilters));
getPreferencesSpy = spyOn(preferenceCloudService, 'getPreferences').and.returnValue(of(fakeProcessCloudFilterEntries)); getPreferencesSpy = spyOn(preferenceCloudService, 'getPreferences').and.returnValue(of(fakeProcessCloudFilterEntries));
getCurrentUserInfoSpy = spyOn(identityUserService, 'getCurrentUserInfo').and.returnValue(identityUserMock); getCurrentUserInfoSpy = spyOn(identityUserService, 'getCurrentUserInfo').and.returnValue(identityUserMock);
})); });
it('should create processfilter key by using appName and the username', (done) => { it('should create processfilter key by using appName and the username', (done) => {
service.getProcessFilters('mock-appName').subscribe((res: any) => { service.getProcessFilters('mock-appName').subscribe((res: any) => {

View File

@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { async, TestBed } from '@angular/core/testing'; import { fakeAsync, TestBed } from '@angular/core/testing';
import { setupTestBed, AlfrescoApiService } from '@alfresco/adf-core'; import { setupTestBed, AlfrescoApiService } from '@alfresco/adf-core';
import { ProcessListCloudService } from './process-list-cloud.service'; import { ProcessListCloudService } from './process-list-cloud.service';
import { ProcessQueryCloudRequestModel } from '../models/process-cloud-query-request.model'; import { ProcessQueryCloudRequestModel } from '../models/process-cloud-query-request.model';
@@ -56,13 +56,13 @@ describe('ProcessListCloudService', () => {
] ]
}); });
beforeEach(async(() => { beforeEach(fakeAsync(() => {
alfrescoApiService = TestBed.inject(AlfrescoApiService); alfrescoApiService = TestBed.inject(AlfrescoApiService);
service = TestBed.inject(ProcessListCloudService); service = TestBed.inject(ProcessListCloudService);
})); }));
it('should append to the call all the parameters', (done) => { it('should append to the call all the parameters', (done) => {
const processRequest: ProcessQueryCloudRequestModel = <ProcessQueryCloudRequestModel> { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' }; const processRequest = { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' } as ProcessQueryCloudRequestModel;
spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallQueryParameters); spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallQueryParameters);
service.getProcessByRequest(processRequest).subscribe((res) => { service.getProcessByRequest(processRequest).subscribe((res) => {
expect(res).toBeDefined(); expect(res).toBeDefined();
@@ -75,7 +75,7 @@ describe('ProcessListCloudService', () => {
}); });
it('should concat the app name to the request url', (done) => { it('should concat the app name to the request url', (done) => {
const processRequest: ProcessQueryCloudRequestModel = <ProcessQueryCloudRequestModel> { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' }; const processRequest = { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' } as ProcessQueryCloudRequestModel;
spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallUrl); spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallUrl);
service.getProcessByRequest(processRequest).subscribe((requestUrl) => { service.getProcessByRequest(processRequest).subscribe((requestUrl) => {
expect(requestUrl).toBeDefined(); expect(requestUrl).toBeDefined();
@@ -86,10 +86,10 @@ describe('ProcessListCloudService', () => {
}); });
it('should concat the sorting to append as parameters', (done) => { it('should concat the sorting to append as parameters', (done) => {
const processRequest: ProcessQueryCloudRequestModel = <ProcessQueryCloudRequestModel> { const processRequest = {
appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service', appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service',
sorting: [{ orderBy: 'NAME', direction: 'DESC' }, { orderBy: 'TITLE', direction: 'ASC' }] sorting: [{ orderBy: 'NAME', direction: 'DESC' }, { orderBy: 'TITLE', direction: 'ASC' }]
}; } as ProcessQueryCloudRequestModel;
spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallQueryParameters); spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallQueryParameters);
service.getProcessByRequest(processRequest).subscribe((res) => { service.getProcessByRequest(processRequest).subscribe((res) => {
expect(res).toBeDefined(); expect(res).toBeDefined();
@@ -100,7 +100,7 @@ describe('ProcessListCloudService', () => {
}); });
it('should return an error when app name is not specified', (done) => { it('should return an error when app name is not specified', (done) => {
const processRequest: ProcessQueryCloudRequestModel = <ProcessQueryCloudRequestModel> { appName: null }; const processRequest = { appName: null } as ProcessQueryCloudRequestModel;
spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallUrl); spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallUrl);
service.getProcessByRequest(processRequest).subscribe( service.getProcessByRequest(processRequest).subscribe(
() => { }, () => { },

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { TestBed, async } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { AlfrescoApiService, setupTestBed } from '@alfresco/adf-core'; import { AlfrescoApiService, setupTestBed } from '@alfresco/adf-core';
import { ProcessServiceCloudTestingModule } from '../testing/process-service-cloud.testing.module'; import { ProcessServiceCloudTestingModule } from '../testing/process-service-cloud.testing.module';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
@@ -60,7 +60,7 @@ describe('NotificationCloudService', () => {
] ]
}); });
beforeEach(async(() => { beforeEach(() => {
service = TestBed.inject(NotificationCloudService); service = TestBed.inject(NotificationCloudService);
apollo = TestBed.inject(Apollo); apollo = TestBed.inject(Apollo);
apiService = TestBed.inject(AlfrescoApiService); apiService = TestBed.inject(AlfrescoApiService);
@@ -69,7 +69,7 @@ describe('NotificationCloudService', () => {
service.appsListening = []; service.appsListening = [];
apolloCreateSpy = spyOn(apollo, 'createNamed'); apolloCreateSpy = spyOn(apollo, 'createNamed');
apolloSubscribeSpy = spyOn(apollo, 'use').and.returnValue(useMock); apolloSubscribeSpy = spyOn(apollo, 'use').and.returnValue(useMock);
})); });
it('should not create more than one websocket per app if it was already created', () => { it('should not create more than one websocket per app if it was already created', () => {
service.makeGQLQuery('myAppName', queryMock); service.makeGQLQuery('myAppName', queryMock);

View File

@@ -15,8 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { TestBed, async } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { UserPreferenceCloudService } from './user-preference-cloud.service'; import { UserPreferenceCloudService } from './user-preference-cloud.service';
import { setupTestBed, AlfrescoApiService } from '@alfresco/adf-core'; import { setupTestBed, AlfrescoApiService } from '@alfresco/adf-core';
import { mockPreferences, getMockPreference, createMockPreference, updateMockPreference } from '../mock/user-preference.mock'; import { mockPreferences, getMockPreference, createMockPreference, updateMockPreference } from '../mock/user-preference.mock';
@@ -63,11 +62,11 @@ describe('PreferenceService', () => {
] ]
}); });
beforeEach(async(() => { beforeEach(() => {
service = TestBed.inject(UserPreferenceCloudService); service = TestBed.inject(UserPreferenceCloudService);
alfrescoApiMock = TestBed.inject(AlfrescoApiService); alfrescoApiMock = TestBed.inject(AlfrescoApiService);
getInstanceSpy = spyOn(alfrescoApiMock, 'getInstance').and.returnValue(apiMock(mockPreferences)); getInstanceSpy = spyOn(alfrescoApiMock, 'getInstance').and.returnValue(apiMock(mockPreferences));
})); });
it('should return the preferences', (done) => { it('should return the preferences', (done) => {
service.getPreferences('mock-app-name').subscribe((res: any) => { service.getPreferences('mock-app-name').subscribe((res: any) => {

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { async, TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { setupTestBed, AlfrescoApiService } from '@alfresco/adf-core'; import { setupTestBed, AlfrescoApiService } from '@alfresco/adf-core';
import { ServiceTaskListCloudService } from './service-task-list-cloud.service'; import { ServiceTaskListCloudService } from './service-task-list-cloud.service';
import { ServiceTaskQueryCloudRequestModel } from '../models/service-task-cloud.model'; import { ServiceTaskQueryCloudRequestModel } from '../models/service-task-cloud.model';
@@ -59,10 +59,10 @@ describe('Activiti ServiceTaskList Cloud Service', () => {
] ]
}); });
beforeEach(async(() => { beforeEach(() => {
alfrescoApiService = TestBed.inject(AlfrescoApiService); alfrescoApiService = TestBed.inject(AlfrescoApiService);
service = TestBed.inject(ServiceTaskListCloudService); service = TestBed.inject(ServiceTaskListCloudService);
})); });
it('should append to the call all the parameters', (done) => { it('should append to the call all the parameters', (done) => {
const taskRequest: ServiceTaskQueryCloudRequestModel = <ServiceTaskQueryCloudRequestModel> { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' }; const taskRequest: ServiceTaskQueryCloudRequestModel = <ServiceTaskQueryCloudRequestModel> { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' };

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { ContentModule, ContentNodeSelectorPanelComponent, DocumentListService } from '@alfresco/adf-content-services'; import { ContentModule, ContentNodeSelectorPanelComponent, DocumentListService } from '@alfresco/adf-content-services';
import { EventEmitter, NO_ERRORS_SCHEMA } from '@angular/core'; import { EventEmitter, NO_ERRORS_SCHEMA } from '@angular/core';
@@ -63,7 +63,7 @@ describe('AttachFileWidgetDialogComponent', () => {
schemas: [NO_ERRORS_SCHEMA] schemas: [NO_ERRORS_SCHEMA]
}); });
beforeEach(async(() => { beforeEach(() => {
fixture = TestBed.createComponent(AttachFileWidgetDialogComponent); fixture = TestBed.createComponent(AttachFileWidgetDialogComponent);
widget = fixture.componentInstance; widget = fixture.componentInstance;
element = fixture.nativeElement; element = fixture.nativeElement;
@@ -83,7 +83,7 @@ describe('AttachFileWidgetDialogComponent', () => {
spyOn(widget, 'isLoggedIn').and.callFake(() => { spyOn(widget, 'isLoggedIn').and.callFake(() => {
return isLogged; return isLogged;
}); });
})); });
afterEach(() => { afterEach(() => {
fixture.destroy(); fixture.destroy();
@@ -96,10 +96,10 @@ describe('AttachFileWidgetDialogComponent', () => {
describe('When is not logged in', () => { describe('When is not logged in', () => {
beforeEach(async(() => { beforeEach(() => {
fixture.detectChanges(); fixture.detectChanges();
isLogged = false; isLogged = false;
})); });
it('should show the login form', () => { it('should show the login form', () => {
expect(element.querySelector('#attach-file-login-panel')).not.toBeNull(); expect(element.querySelector('#attach-file-login-panel')).not.toBeNull();
@@ -135,11 +135,11 @@ describe('AttachFileWidgetDialogComponent', () => {
let contentNodePanel; let contentNodePanel;
beforeEach(async(() => { beforeEach(() => {
isLogged = true; isLogged = true;
fixture.detectChanges(); fixture.detectChanges();
contentNodePanel = fixture.debugElement.query(By.directive(ContentNodeSelectorPanelComponent)); contentNodePanel = fixture.debugElement.query(By.directive(ContentNodeSelectorPanelComponent));
})); });
it('should show the content node selector', () => { it('should show the content node selector', () => {
expect(element.querySelector('#attach-file-content-node')).not.toBeNull(); expect(element.querySelector('#attach-file-content-node')).not.toBeNull();
@@ -175,21 +175,21 @@ describe('AttachFileWidgetDialogComponent', () => {
}); });
describe('login only', () => { describe('login only', () => {
beforeEach(async(() => { beforeEach(() => {
spyOn(authService, 'login').and.returnValue(of({ type: 'type', ticket: 'ticket'})); spyOn(authService, 'login').and.returnValue(of({ type: 'type', ticket: 'ticket'}));
spyOn(matDialogRef, 'close').and.callThrough(); spyOn(matDialogRef, 'close').and.callThrough();
fixture.detectChanges(); fixture.detectChanges();
widget.data.loginOnly = true; widget.data.loginOnly = true;
widget.data.registerExternalHost = () => {}; widget.data.registerExternalHost = () => {};
isLogged = false; isLogged = false;
})); });
it('should close the dialog once user loggedIn', () => { it('should close the dialog once user loggedIn', () => {
fixture.detectChanges(); fixture.detectChanges();
isLogged = true; isLogged = true;
const loginButton: HTMLButtonElement = element.querySelector('button[data-automation-id="attach-file-dialog-actions-login"]'); const loginButton = element.querySelector<HTMLButtonElement>('button[data-automation-id="attach-file-dialog-actions-login"]');
const usernameInput: HTMLInputElement = element.querySelector('#username'); const usernameInput = element.querySelector<HTMLInputElement>('#username');
const passwordInput: HTMLInputElement = element.querySelector('#password'); const passwordInput = element.querySelector<HTMLInputElement>('#password');
usernameInput.value = 'fake-user'; usernameInput.value = 'fake-user';
passwordInput.value = 'fake-user'; passwordInput.value = 'fake-user';
usernameInput.dispatchEvent(new Event('input')); usernameInput.dispatchEvent(new Event('input'));
@@ -211,9 +211,9 @@ describe('AttachFileWidgetDialogComponent', () => {
describe('Attach button', () => { describe('Attach button', () => {
beforeEach(async(() => { beforeEach(() => {
isLogged = true; isLogged = true;
})); });
it('should be disabled by default', () => { it('should be disabled by default', () => {
fixture.detectChanges(); fixture.detectChanges();

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { UserProcessModel, setupTestBed, DataRowActionEvent, DataRowEvent, ObjectDataRow } from '@alfresco/adf-core'; import { UserProcessModel, setupTestBed, DataRowActionEvent, DataRowEvent, ObjectDataRow } from '@alfresco/adf-core';
import { UserEventModel } from '../../../task-list/models/user-event.model'; import { UserEventModel } from '../../../task-list/models/user-event.model';
import { PeopleListComponent } from './people-list.component'; import { PeopleListComponent } from './people-list.component';
@@ -41,11 +41,11 @@ describe('PeopleListComponent', () => {
] ]
}); });
beforeEach(async(() => { beforeEach(() => {
fixture = TestBed.createComponent(PeopleListComponent); fixture = TestBed.createComponent(PeopleListComponent);
peopleListComponent = fixture.componentInstance; peopleListComponent = fixture.componentInstance;
fixture.detectChanges(); fixture.detectChanges();
})); });
it('should emit row click event', (done) => { it('should emit row click event', (done) => {
const row = new ObjectDataRow(fakeUser); const row = new ObjectDataRow(fakeUser);

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { UserProcessModel, setupTestBed } from '@alfresco/adf-core'; import { UserProcessModel, setupTestBed } from '@alfresco/adf-core';
import { of } from 'rxjs'; import { of } from 'rxjs';
import { PeopleSearchComponent } from './people-search.component'; import { PeopleSearchComponent } from './people-search.component';
@@ -51,13 +51,13 @@ describe('PeopleSearchComponent', () => {
] ]
}); });
beforeEach(async(() => { beforeEach(() => {
fixture = TestBed.createComponent(PeopleSearchComponent); fixture = TestBed.createComponent(PeopleSearchComponent);
peopleSearchComponent = fixture.componentInstance; peopleSearchComponent = fixture.componentInstance;
element = fixture.nativeElement; element = fixture.nativeElement;
peopleSearchComponent.results = of([]); peopleSearchComponent.results = of([]);
fixture.detectChanges(); fixture.detectChanges();
})); });
it('should show input search text', () => { it('should show input search text', () => {
expect(element.querySelector('#userSearchText')).toBeDefined(); expect(element.querySelector('#userSearchText')).toBeDefined();

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { async, TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { ProcessNamePipe } from './process-name.pipe'; import { ProcessNamePipe } from './process-name.pipe';
import { setupTestBed } from 'core'; import { setupTestBed } from 'core';
import { CoreTestingModule } from 'core/testing/core.testing.module'; import { CoreTestingModule } from 'core/testing/core.testing.module';
@@ -30,7 +30,7 @@ describe('ProcessNamePipe', () => {
const defaultName = 'default-name'; const defaultName = 'default-name';
const datetimeIdentifier = '%{datetime}'; const datetimeIdentifier = '%{datetime}';
const processDefinitionIdentifier = '%{processDefinition}'; const processDefinitionIdentifier = '%{processDefinition}';
const mockCurrentDate = new Date('Wed Oct 23 2019'); const mockCurrentDate: number = new Date('Wed Oct 23 2019').getTime();
const mockLocalizedCurrentDate = 'Oct 23, 2019, 12:00:00 AM'; const mockLocalizedCurrentDate = 'Oct 23, 2019, 12:00:00 AM';
const nameWithProcessDefinitionIdentifier = `${defaultName} - ${processDefinitionIdentifier}`; const nameWithProcessDefinitionIdentifier = `${defaultName} - ${processDefinitionIdentifier}`;
const nameWithDatetimeIdentifier = `${defaultName} - ${datetimeIdentifier}`; const nameWithDatetimeIdentifier = `${defaultName} - ${datetimeIdentifier}`;
@@ -44,10 +44,10 @@ describe('ProcessNamePipe', () => {
] ]
}); });
beforeEach(async(() => { beforeEach(() => {
const localizedDatePipe = TestBed.inject(LocalizedDatePipe); const localizedDatePipe = TestBed.inject(LocalizedDatePipe);
processNamePipe = new ProcessNamePipe(localizedDatePipe); processNamePipe = new ProcessNamePipe(localizedDatePipe);
})); });
it('should not modify the name when there is no identifier', () => { it('should not modify the name when there is no identifier', () => {
const transformResult = processNamePipe.transform(defaultName); const transformResult = processNamePipe.transform(defaultName);

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { setupTestBed, LogService } from '@alfresco/adf-core'; import { setupTestBed, LogService } from '@alfresco/adf-core';
import { of, throwError } from 'rxjs'; import { of, throwError } from 'rxjs';
import { TaskListService } from '../services/tasklist.service'; import { TaskListService } from '../services/tasklist.service';
@@ -56,7 +56,7 @@ describe('StartTaskComponent', () => {
] ]
}); });
beforeEach(async(() => { beforeEach(() => {
fixture = TestBed.createComponent(StartTaskComponent); fixture = TestBed.createComponent(StartTaskComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
element = fixture.nativeElement; element = fixture.nativeElement;
@@ -67,7 +67,7 @@ describe('StartTaskComponent', () => {
getFormListSpy = spyOn(service, 'getFormList').and.returnValue(of(fakeForms$)); getFormListSpy = spyOn(service, 'getFormList').and.returnValue(of(fakeForms$));
fixture.detectChanges(); fixture.detectChanges();
})); });
afterEach(() => { afterEach(() => {
fixture.destroy(); fixture.destroy();

View File

@@ -16,12 +16,7 @@
*/ */
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
async,
ComponentFixture,
fakeAsync,
TestBed
} from '@angular/core/testing';
import { of } from 'rxjs'; import { of } from 'rxjs';
import { TaskListService } from './../services/tasklist.service'; import { TaskListService } from './../services/tasklist.service';
import { setupTestBed } from '@alfresco/adf-core'; import { setupTestBed } from '@alfresco/adf-core';
@@ -83,13 +78,13 @@ describe('TaskAuditDirective', () => {
declarations: [BasicButtonComponent] declarations: [BasicButtonComponent]
}); });
beforeEach(async(() => { beforeEach(() => {
fixture = TestBed.createComponent(BasicButtonComponent); fixture = TestBed.createComponent(BasicButtonComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
service = TestBed.inject(TaskListService); service = TestBed.inject(TaskListService);
jasmine.Ajax.install(); jasmine.Ajax.install();
})); });
afterEach(() => { afterEach(() => {
jasmine.Ajax.uninstall(); jasmine.Ajax.uninstall();

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { async, TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { fakeAppPromise } from '../../mock'; import { fakeAppPromise } from '../../mock';
import { fakeFiltersResponse, fakeAppFilter } from '../../mock/task/task-filters.mock'; import { fakeFiltersResponse, fakeAppFilter } from '../../mock/task/task-filters.mock';
import { FilterRepresentationModel } from '../models/filter.model'; import { FilterRepresentationModel } from '../models/filter.model';
@@ -36,10 +36,10 @@ describe('Activiti Task filter Service', () => {
] ]
}); });
beforeEach(async(() => { beforeEach(() => {
service = TestBed.inject(TaskFilterService); service = TestBed.inject(TaskFilterService);
jasmine.Ajax.install(); jasmine.Ajax.install();
})); });
afterEach(() => { afterEach(() => {
jasmine.Ajax.uninstall(); jasmine.Ajax.uninstall();

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { async, TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { UserProcessModel, setupTestBed, CoreModule } from '@alfresco/adf-core'; import { UserProcessModel, setupTestBed, CoreModule } from '@alfresco/adf-core';
import { of } from 'rxjs'; import { of } from 'rxjs';
import { import {
@@ -49,10 +49,10 @@ describe('Activiti TaskList Service', () => {
] ]
}); });
beforeEach(async(() => { beforeEach(() => {
service = TestBed.inject(TaskListService); service = TestBed.inject(TaskListService);
jasmine.Ajax.install(); jasmine.Ajax.install();
})); });
afterEach(() => { afterEach(() => {
jasmine.Ajax.uninstall(); jasmine.Ajax.uninstall();