mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-5415] remove deprecated async method (#7171)
* remove deprecated async method * fix tests and code * test fixes * fix tests
This commit is contained in:
@@ -21,7 +21,9 @@ import { AppConfigService } from './app-config.service';
|
||||
import { AppConfigModule } from './app-config.module';
|
||||
import { ExtensionConfig, ExtensionService } from '@alfresco/adf-extensions';
|
||||
import { of } from 'rxjs';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
class TestExtensionService extends ExtensionService {
|
||||
|
||||
onSetup(config: ExtensionConfig) {
|
||||
|
@@ -18,7 +18,7 @@
|
||||
/* tslint:disable:component-selector */
|
||||
|
||||
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 { CardViewItem } from '../../interfaces/card-view-item.interface';
|
||||
import { CardItemTypeService } from '../../services/card-item-types.service';
|
||||
@@ -40,7 +40,7 @@ describe('CardViewItemDispatcherComponent', () => {
|
||||
let cardItemTypeService: CardItemTypeService;
|
||||
let component: CardViewItemDispatcherComponent;
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
cardItemTypeService = new CardItemTypeService();
|
||||
cardItemTypeService.setComponentTypeResolver('shiny-custom-element', () => CardViewShinyCustomElementItemComponent);
|
||||
|
||||
@@ -54,7 +54,7 @@ describe('CardViewItemDispatcherComponent', () => {
|
||||
});
|
||||
|
||||
TestBed.compileComponents();
|
||||
}));
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(CardViewItemDispatcherComponent);
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* 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 { ObjectDataColumn } from '../../data/object-datacolumn.model';
|
||||
|
||||
@@ -28,8 +28,8 @@ describe('JsonCellComponent', () => {
|
||||
let component: JsonCellComponent;
|
||||
let fixture: ComponentFixture<JsonCellComponent>;
|
||||
let dataTableAdapter: ObjectDataTableAdapter;
|
||||
let rowData;
|
||||
let columnData;
|
||||
let rowData: any;
|
||||
let columnData: any;
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
@@ -38,10 +38,10 @@ describe('JsonCellComponent', () => {
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(JsonCellComponent);
|
||||
component = fixture.componentInstance;
|
||||
}));
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
rowData = {
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* 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 { ObjectDataColumn } from '../../data/object-datacolumn.model';
|
||||
|
||||
@@ -28,8 +28,8 @@ describe('LocationCellComponent', () => {
|
||||
let component: LocationCellComponent;
|
||||
let fixture: ComponentFixture<LocationCellComponent>;
|
||||
let dataTableAdapter: ObjectDataTableAdapter;
|
||||
let rowData;
|
||||
let columnData;
|
||||
let rowData: any;
|
||||
let columnData: any;
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
@@ -38,10 +38,10 @@ describe('LocationCellComponent', () => {
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(LocationCellComponent);
|
||||
component = fixture.componentInstance;
|
||||
}));
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
rowData = {
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { of } from 'rxjs';
|
||||
import { FormService } from '../services/form.service';
|
||||
import { FormListComponent } from './form-list.component';
|
||||
@@ -28,7 +28,7 @@ describe('TaskAttachmentList', () => {
|
||||
let component: FormListComponent;
|
||||
let fixture: ComponentFixture<FormListComponent>;
|
||||
let service: FormService;
|
||||
let element: any;
|
||||
let element: HTMLElement;
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
@@ -37,14 +37,12 @@ describe('TaskAttachmentList', () => {
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(async(() => {
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(FormListComponent);
|
||||
component = fixture.componentInstance;
|
||||
element = fixture.debugElement.nativeElement;
|
||||
service = TestBed.inject(FormService);
|
||||
|
||||
}));
|
||||
});
|
||||
|
||||
it('should show the forms as a list', async () => {
|
||||
spyOn(service, 'getForms').and.returnValue(of([
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
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 { ContentService } from '../../../../services';
|
||||
import { of } from 'rxjs';
|
||||
@@ -69,10 +69,10 @@ describe('ContentWidgetComponent', () => {
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
serviceContent = TestBed.inject(ContentService);
|
||||
processContentService = TestBed.inject(ProcessContentService);
|
||||
}));
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ContentWidgetComponent);
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { FormService } from '../../../services/form.service';
|
||||
@@ -54,14 +54,14 @@ describe('DropdownWidgetComponent', () => {
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(DropdownWidgetComponent);
|
||||
widget = fixture.componentInstance;
|
||||
element = fixture.nativeElement;
|
||||
formService = TestBed.inject(FormService);
|
||||
visibilityService = TestBed.inject(WidgetVisibilityService);
|
||||
widget.field = new FormFieldModel(new FormModel());
|
||||
}));
|
||||
});
|
||||
|
||||
it('should require field with restUrl', () => {
|
||||
spyOn(formService, 'getRestFieldValues').and.stub();
|
||||
@@ -125,12 +125,12 @@ describe('DropdownWidgetComponent', () => {
|
||||
|
||||
describe('when is required', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
widget.field = new FormFieldModel( new FormModel({ taskId: '<id>' }), {
|
||||
type: FormFieldTypes.DROPDOWN,
|
||||
required: true
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
it('should be able to display label with asterix', async () => {
|
||||
const label = 'MyLabel123';
|
||||
@@ -165,7 +165,7 @@ describe('DropdownWidgetComponent', () => {
|
||||
|
||||
describe('and dropdown is populated via taskId', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
spyOn(visibilityService, 'refreshVisibility').and.stub();
|
||||
spyOn(formService, 'getRestFieldValues').and.callFake(() => {
|
||||
return of(fakeOptionList);
|
||||
@@ -180,7 +180,7 @@ describe('DropdownWidgetComponent', () => {
|
||||
widget.field.emptyOption = { id: 'empty', name: 'Choose one...' };
|
||||
widget.field.isVisible = true;
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
});
|
||||
|
||||
it('should show visible dropdown widget', async () => {
|
||||
expect(element.querySelector('#dropdown-id')).toBeDefined();
|
||||
@@ -228,7 +228,7 @@ describe('DropdownWidgetComponent', () => {
|
||||
|
||||
describe('and dropdown is populated via processDefinitionId', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
spyOn(visibilityService, 'refreshVisibility').and.stub();
|
||||
spyOn(formService, 'getRestFieldValuesByProcessId').and.callFake(() => {
|
||||
return of(fakeOptionList);
|
||||
@@ -243,7 +243,7 @@ describe('DropdownWidgetComponent', () => {
|
||||
widget.field.emptyOption = { id: 'empty', name: 'Choose one...' };
|
||||
widget.field.isVisible = true;
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
});
|
||||
|
||||
it('should show visible dropdown widget', () => {
|
||||
expect(element.querySelector('#dropdown-id')).toBeDefined();
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* 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 { FormFieldModel } from '../core/form-field.model';
|
||||
import { FormModel } from '../core/form.model';
|
||||
@@ -88,7 +88,7 @@ describe('TabsWidgetComponent', () => {
|
||||
let fakeTabVisible: TabModel;
|
||||
let fakeTabInvisible: TabModel;
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(TabsWidgetComponent);
|
||||
tabWidgetComponent = fixture.componentInstance;
|
||||
element = fixture.nativeElement;
|
||||
@@ -105,7 +105,7 @@ describe('TabsWidgetComponent', () => {
|
||||
fakeTabInvisible.isVisible = false;
|
||||
tabWidgetComponent.tabs.push(fakeTabVisible);
|
||||
tabWidgetComponent.tabs.push(fakeTabInvisible);
|
||||
}));
|
||||
});
|
||||
|
||||
it('should show only visible tabs', fakeAsync(() => {
|
||||
fixture.detectChanges();
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* 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 { LoginDialogPanelComponent } from './login-dialog-panel.component';
|
||||
import { of } from 'rxjs';
|
||||
@@ -26,8 +26,9 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
describe('LoginDialogPanelComponent', () => {
|
||||
let component: LoginDialogPanelComponent;
|
||||
let fixture: ComponentFixture<LoginDialogPanelComponent>;
|
||||
let element: any;
|
||||
let usernameInput, passwordInput;
|
||||
let element: HTMLElement;
|
||||
let usernameInput: HTMLInputElement;
|
||||
let passwordInput: HTMLInputElement;
|
||||
let authService: AuthenticationService;
|
||||
|
||||
setupTestBed({
|
||||
@@ -37,23 +38,24 @@ describe('LoginDialogPanelComponent', () => {
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(async () => {
|
||||
fixture = TestBed.createComponent(LoginDialogPanelComponent);
|
||||
element = fixture.nativeElement;
|
||||
component = fixture.componentInstance;
|
||||
authService = TestBed.inject(AuthenticationService);
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
usernameInput = element.querySelector('#username');
|
||||
passwordInput = element.querySelector('#password');
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
usernameInput = element.querySelector('#username');
|
||||
passwordInput = element.querySelector('#password');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
function loginWithCredentials(username, password) {
|
||||
function loginWithCredentials(username: string, password: string) {
|
||||
usernameInput.value = username;
|
||||
passwordInput.value = password;
|
||||
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* 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 { CoreTestingModule } from '../../testing/core.testing.module';
|
||||
import { NotificationHistoryComponent } from './notification-history.component';
|
||||
@@ -48,7 +48,7 @@ describe('Notification History Component', () => {
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(NotificationHistoryComponent);
|
||||
component = fixture.componentInstance;
|
||||
element = fixture.nativeElement;
|
||||
@@ -56,7 +56,7 @@ describe('Notification History Component', () => {
|
||||
storage = TestBed.inject(StorageService);
|
||||
notificationService = TestBed.inject(NotificationService);
|
||||
component.notifications = [];
|
||||
}));
|
||||
});
|
||||
|
||||
beforeEach(inject([OverlayContainer], (oc: OverlayContainer) => {
|
||||
overlayContainerElement = oc.getContainerElement();
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* 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 { UserPreferencesService } from '../services/user-preferences.service';
|
||||
import { of } from 'rxjs';
|
||||
@@ -36,11 +36,11 @@ describe('DecimalNumberPipe', () => {
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
userPreferences = TestBed.inject(UserPreferencesService);
|
||||
spyOn(userPreferences, 'select').and.returnValue(of(''));
|
||||
pipe = new DecimalNumberPipe(userPreferences, TestBed.inject(AppConfigService));
|
||||
}));
|
||||
});
|
||||
|
||||
it('should return number localized and rounded following the default config', () => {
|
||||
expect(pipe.transform(1234.567)).toBe('1,234.57');
|
||||
|
@@ -16,16 +16,15 @@
|
||||
*/
|
||||
|
||||
import { FileTypePipe } from './file-type.pipe';
|
||||
import { async } from '@angular/core/testing';
|
||||
|
||||
describe('FileTypePipe', () => {
|
||||
|
||||
const altText = 'ft_ic_ms_word';
|
||||
let pipe: FileTypePipe;
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
pipe = new FileTypePipe();
|
||||
}));
|
||||
});
|
||||
|
||||
it('should return file type from alt text', () => {
|
||||
expect(pipe.transform(altText)).toBe('word');
|
||||
|
@@ -16,15 +16,14 @@
|
||||
*/
|
||||
|
||||
import { FullNamePipe } from './full-name.pipe';
|
||||
import { async } from '@angular/core/testing';
|
||||
|
||||
describe('FullNamePipe', () => {
|
||||
|
||||
let pipe: FullNamePipe;
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
pipe = new FullNamePipe();
|
||||
}));
|
||||
});
|
||||
|
||||
it('should return empty string when there is no name', () => {
|
||||
const user = {};
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
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 { UserPreferencesService } from '../services/user-preferences.service';
|
||||
import { of } from 'rxjs';
|
||||
@@ -39,11 +39,11 @@ describe('LocalizedDatePipe', () => {
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
userPreferences = TestBed.inject(UserPreferencesService);
|
||||
spyOn(userPreferences, 'select').and.returnValue(of(''));
|
||||
pipe = new LocalizedDatePipe(userPreferences, TestBed.inject(AppConfigService));
|
||||
}));
|
||||
});
|
||||
|
||||
it('should return time with locale en-US', () => {
|
||||
const date = new Date('1990-11-03 00:00');
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { async, TestBed } from '@angular/core/testing';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { ActivatedRouteSnapshot, Router } from '@angular/router';
|
||||
import { setupTestBed } from '../testing/setup-test-bed';
|
||||
import { CoreTestingModule } from '../testing/core.testing.module';
|
||||
@@ -49,7 +49,7 @@ describe('Auth Guard SSO role service', () => {
|
||||
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, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role1'] } });
|
||||
|
||||
@@ -57,9 +57,9 @@ describe('Auth Guard SSO role service', () => {
|
||||
router.data = { 'roles': ['role1', 'role2'] };
|
||||
|
||||
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, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role3'] } });
|
||||
|
||||
@@ -67,9 +67,9 @@ describe('Auth Guard SSO role service', () => {
|
||||
router.data = { 'roles': ['role1', 'role2'] };
|
||||
|
||||
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, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role1'] } });
|
||||
spyOn(routerService, 'navigate').and.stub();
|
||||
@@ -79,27 +79,27 @@ describe('Auth Guard SSO role service', () => {
|
||||
|
||||
expect(await authGuard.canActivate(router)).toBeTruthy();
|
||||
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, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role1', 'role3'] } });
|
||||
|
||||
const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();
|
||||
|
||||
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, 'decodeToken').and.returnValue({});
|
||||
|
||||
const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();
|
||||
|
||||
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, 'decodeToken').and.returnValue({});
|
||||
spyOn(routerService, 'navigate').and.stub();
|
||||
@@ -109,9 +109,9 @@ describe('Auth Guard SSO role service', () => {
|
||||
|
||||
expect(await authGuard.canActivate(router)).toBeFalsy();
|
||||
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, 'decodeToken').and.returnValue({});
|
||||
spyOn(routerService, 'navigate').and.stub();
|
||||
@@ -121,7 +121,7 @@ describe('Auth Guard SSO role service', () => {
|
||||
|
||||
expect(await authGuard.canActivate(router)).toBeFalsy();
|
||||
expect(routerService.navigate).not.toHaveBeenCalled();
|
||||
}));
|
||||
});
|
||||
|
||||
it('Should canActivate be false hasRealm is true and hasClientRole is false', async () => {
|
||||
const route: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { async, TestBed } from '@angular/core/testing';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { Router, RouterStateSnapshot } from '@angular/router';
|
||||
import { AppConfigService } from '../app-config/app-config.service';
|
||||
import { AuthGuard } from './auth-guard.service';
|
||||
@@ -53,33 +53,33 @@ describe('AuthGuardService', () => {
|
||||
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(authService, 'isLoggedIn').and.returnValue(true);
|
||||
|
||||
expect(await authGuard.canActivate(null, state)).toBeTruthy();
|
||||
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';
|
||||
spyOn(router, 'navigateByUrl');
|
||||
spyOn(authService, 'isLoggedIn').and.returnValue(false);
|
||||
|
||||
expect(await authGuard.canActivate(null, state)).toBeFalsy();
|
||||
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);
|
||||
appConfigService.config.auth.withCredentials = true;
|
||||
|
||||
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url' };
|
||||
|
||||
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');
|
||||
|
||||
spyOn(router, 'navigateByUrl').and.stub();
|
||||
@@ -89,9 +89,9 @@ describe('AuthGuardService', () => {
|
||||
|
||||
expect(await authGuard.canActivate(null, state)).toBeTruthy();
|
||||
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(authService, 'isLoggedIn').and.returnValue(false);
|
||||
spyOn(authService, 'isOauth').and.returnValue(true);
|
||||
@@ -99,9 +99,9 @@ describe('AuthGuardService', () => {
|
||||
|
||||
expect(await authGuard.canActivate(null, state)).toBeFalsy();
|
||||
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(authService, 'isLoggedIn').and.returnValue(false);
|
||||
spyOn(authService, 'isOauth').and.returnValue(true);
|
||||
@@ -109,9 +109,9 @@ describe('AuthGuardService', () => {
|
||||
|
||||
expect(await authGuard.canActivate(null, state)).toBeFalsy();
|
||||
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, 'isLoggedIn').and.returnValue(false);
|
||||
spyOn(authService, 'isOauth').and.returnValue(true);
|
||||
@@ -119,9 +119,9 @@ describe('AuthGuardService', () => {
|
||||
|
||||
expect(await authGuard.canActivate(null, state)).toBeFalsy();
|
||||
expect(authService.ssoImplicitLogin).toHaveBeenCalledTimes(1);
|
||||
}));
|
||||
});
|
||||
|
||||
it('should set redirect url', async(async () => {
|
||||
it('should set redirect url', async () => {
|
||||
state.url = 'some-url';
|
||||
appConfigService.config.loginRoute = 'login';
|
||||
|
||||
@@ -134,9 +134,9 @@ describe('AuthGuardService', () => {
|
||||
provider: 'ALL', url: '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';
|
||||
appConfigService.config.loginRoute = 'login';
|
||||
appConfigService.config.provider = 'ALL';
|
||||
@@ -150,9 +150,9 @@ describe('AuthGuardService', () => {
|
||||
provider: 'ALL', url: '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';
|
||||
appConfigService.config.loginRoute = 'fakeLoginRoute';
|
||||
|
||||
@@ -165,9 +165,9 @@ describe('AuthGuardService', () => {
|
||||
provider: 'ALL', url: '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 = '/';
|
||||
|
||||
spyOn(router, 'navigateByUrl');
|
||||
@@ -178,5 +178,5 @@ describe('AuthGuardService', () => {
|
||||
expect(authService.setRedirect).toHaveBeenCalledWith({
|
||||
provider: 'ALL', url: '/'
|
||||
});
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* 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 { HttpErrorResponse } from '@angular/common/http';
|
||||
import { throwError, of } from 'rxjs';
|
||||
@@ -46,7 +46,7 @@ describe('IdentityGroupService', () => {
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(fakeAsync(() => {
|
||||
service = TestBed.inject(IdentityGroupService);
|
||||
apiService = TestBed.inject(AlfrescoApiService);
|
||||
}));
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By, DomSanitizer } from '@angular/platform-browser';
|
||||
import { AuthenticationService, ContentService } from '../../services';
|
||||
import { InitialUsernamePipe } from '../../pipes';
|
||||
@@ -94,7 +94,7 @@ describe('User info component', () => {
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(UserInfoComponent);
|
||||
component = fixture.componentInstance;
|
||||
element = fixture.nativeElement;
|
||||
@@ -108,7 +108,7 @@ describe('User info component', () => {
|
||||
spyOn(window, 'requestAnimationFrame').and.returnValue(1);
|
||||
spyOn(bpmUserService, 'getCurrentUserProfileImage').and.returnValue('app/rest/admin/profile-picture');
|
||||
spyOn(contentService, 'getContentUrl').and.returnValue('alfresco-logo.svg');
|
||||
}));
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
@@ -209,13 +209,13 @@ describe('User info component', () => {
|
||||
|
||||
describe('and has image', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
isOauthStub.and.returnValue(false);
|
||||
isEcmLoggedInStub.and.returnValue(true);
|
||||
isLoggedInStub.and.returnValue(true);
|
||||
getCurrenEcmtUserInfoStub.and.returnValue(of(fakeEcmUser));
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
});
|
||||
|
||||
it('should get the ecm current user image from the service', async () => {
|
||||
await fixture.whenStable();
|
||||
@@ -316,15 +316,15 @@ describe('User info component', () => {
|
||||
|
||||
describe('when user is logged on bpm', () => {
|
||||
|
||||
let getCurrentUserInfoStub;
|
||||
let getCurrentUserInfoStub: jasmine.Spy;
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
isOauthStub.and.returnValue(false);
|
||||
isBpmLoggedInStub.and.returnValue(true);
|
||||
isLoggedInStub.and.returnValue(true);
|
||||
isEcmLoggedInStub.and.returnValue(false);
|
||||
getCurrentUserInfoStub = spyOn(bpmUserService, 'getCurrentUserInfo').and.returnValue(of(fakeBpmUser));
|
||||
}));
|
||||
});
|
||||
|
||||
it('should fetch bpm userInfo', (done) => {
|
||||
getCurrentUserInfoStub.and.returnValue(of(fakeBpmUser));
|
||||
@@ -427,7 +427,7 @@ describe('User info component', () => {
|
||||
|
||||
describe('when user is logged on bpm and ecm', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
isOauthStub.and.returnValue(false);
|
||||
isEcmLoggedInStub.and.returnValue(true);
|
||||
isBpmLoggedInStub.and.returnValue(true);
|
||||
@@ -435,7 +435,7 @@ describe('User info component', () => {
|
||||
|
||||
getCurrenEcmtUserInfoStub.and.returnValue(of(fakeEcmUser));
|
||||
spyOn(bpmUserService, 'getCurrentUserInfo').and.returnValue(of(fakeBpmUser));
|
||||
}));
|
||||
});
|
||||
|
||||
it('should able to fetch ecm userInfo', (done) => {
|
||||
fixture.detectChanges();
|
||||
@@ -537,14 +537,14 @@ describe('User info component', () => {
|
||||
|
||||
describe('when identity user is logged in', () => {
|
||||
|
||||
let getCurrentUserInfoStub;
|
||||
let getCurrentUserInfoStub: jasmine.Spy;
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
isOauthStub.and.returnValue(true);
|
||||
isLoggedInStub.and.returnValue(true);
|
||||
isEcmLoggedInStub.and.returnValue(false);
|
||||
getCurrentUserInfoStub = spyOn(identityUserService, 'getCurrentUserInfo').and.returnValue(identityUserMock);
|
||||
}));
|
||||
});
|
||||
|
||||
it('should show the identity user initials if is not ecm user', async () => {
|
||||
fixture.detectChanges();
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
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 { setupTestBed } from '../../testing/setup-test-bed';
|
||||
import { CoreTestingModule } from '../../testing/core.testing.module';
|
||||
@@ -52,10 +52,10 @@ describe('PdfThumbComponent', () => {
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(PdfThumbComponent);
|
||||
component = fixture.componentInstance;
|
||||
}));
|
||||
});
|
||||
|
||||
it('should have resolve image data', (done) => {
|
||||
component.page = page;
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { PdfThumbListComponent } from './pdf-viewer-thumbnails.component';
|
||||
import { setupTestBed } from '../../testing/setup-test-bed';
|
||||
@@ -69,7 +69,7 @@ describe('PdfThumbListComponent', () => {
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(PdfThumbListComponent);
|
||||
component = fixture.componentInstance;
|
||||
component.pdfViewer = viewerMock;
|
||||
@@ -80,7 +80,7 @@ describe('PdfThumbListComponent', () => {
|
||||
fixture.nativeElement.style.overflow = 'scroll';
|
||||
fixture.debugElement.query(By.css('.adf-pdf-thumbnails__content'))
|
||||
.nativeElement.style.height = '2000px';
|
||||
}));
|
||||
});
|
||||
|
||||
it('should render initial rage of items', () => {
|
||||
fixture.nativeElement.scrollTop = 0;
|
||||
|
@@ -38,7 +38,7 @@ export class TxtViewerComponent implements OnChanges {
|
||||
constructor(private http: HttpClient, private appConfigService: AppConfigService) {
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): Promise<any> {
|
||||
ngOnChanges(changes: SimpleChanges): Promise<void> {
|
||||
|
||||
const blobFile = changes['blobFile'];
|
||||
if (blobFile && blobFile.currentValue) {
|
||||
@@ -57,7 +57,7 @@ export class TxtViewerComponent implements OnChanges {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
private getUrlContent(url: string): Promise<any> {
|
||||
private getUrlContent(url: string): Promise<void> {
|
||||
const withCredentialsMode = this.appConfigService.get<boolean>('auth.withCredentials', false);
|
||||
|
||||
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) => {
|
||||
const reader = new FileReader();
|
||||
|
||||
|
@@ -18,7 +18,7 @@
|
||||
import { Location } from '@angular/common';
|
||||
import { SpyLocation } from '@angular/common/testing';
|
||||
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 { ViewerExtensionDirective } from './viewer-extension.directive';
|
||||
import { setupTestBed } from '../../testing/setup-test-bed';
|
||||
@@ -47,10 +47,10 @@ describe('ExtensionViewerDirective', () => {
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
extensionViewerDirective = TestBed.inject(ViewerExtensionDirective);
|
||||
extensionViewerDirective.templateModel = {template: '', isVisible: false};
|
||||
}));
|
||||
});
|
||||
|
||||
it('is defined', () => {
|
||||
expect(extensionViewerDirective).toBeDefined();
|
||||
|
Reference in New Issue
Block a user