[ADF-5183] Upgrade to Angular 10 (#1506)

* upgrade preparation fixes

* remove fdescribe

* update browserlist config

* ng8

* ngrx 8

* ng9

* ngrx 9

* remove entryComponents

* unit tests

* ng 10

* latest ADF

* fix unit tests

* fix lint

* update deps and travis

* code fixes

* upgrade webdriver

* cleanup libs

* fix test

* update test

* Use browserTarget as target for lite-serve

* Use the update webdriver with CI condition

* Use version console.log('load', path

* Fix path sh

* Try to use remote env

* Add the . to export variabled

* Use hardcoded chrome version

* Remove the run remote

* Avoid to use the escape

* Skip flaky e2e and raise issue ACA-3615

* SKip failing e2e

* Skip flaky e2e and raise issue ACA-3615

* Fix close app toolbar menu and preconditions + tests of  mark-favorite.test.ts  Personal Files section

* Fix mark-favorite tests

* Fix ext-header test

* Fix new-menu tests

* Fix lint

* no message

* Fix viewer tests

Co-authored-by: maurizio vitale <maurizio.vitale@alfresco.com>
Co-authored-by: Cristina Jalba <cristina.jalba@ness.com>
This commit is contained in:
Denys Vuika
2020-07-09 09:37:06 +01:00
committed by GitHub
parent 4ac1b8d7dd
commit 2854c17cd9
139 changed files with 11641 additions and 7776 deletions

View File

@@ -56,14 +56,14 @@ describe('AppComponent', () => {
}
};
beforeAll(() => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
RouterTestingModule.withRoutes([{ path: 'fake-path', children: [] }])
]
});
router = TestBed.get(Router);
router = TestBed.inject(Router);
component = new AppComponent(
null,
@@ -80,9 +80,7 @@ describe('AppComponent', () => {
null,
storageMock
);
});
beforeEach(() => {
storeMock.dispatch = jasmine.createSpy('dispatch');
});
@@ -144,6 +142,7 @@ describe('AppComponent', () => {
describe('Routing Configuration', () => {
it('Should extension route be included as child of the defined parent path', () => {
component.mapExtensionRoutes(mockRoutesWithParentRoute);
expect(router.config[0]).toEqual({
path: 'fake-path',
children: [

View File

@@ -23,7 +23,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { BrowserModule } from '@angular/platform-browser';
import { BrowserModule, HammerModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { RouterModule, RouteReuseStrategy } from '@angular/router';
import {
@@ -37,10 +37,7 @@ import {
AppConfigService,
DebugAppConfigService
} from '@alfresco/adf-core';
import {
LibraryDialogComponent,
ContentModule
} from '@alfresco/adf-content-services';
import { ContentModule } from '@alfresco/adf-content-services';
import { AppRouteReuseStrategy, SharedModule } from '@alfresco/aca-shared';
import { AppComponent } from './app.component';
@@ -50,7 +47,6 @@ import { FilesComponent } from './components/files/files.component';
import { LibrariesComponent } from './components/libraries/libraries.component';
import { FavoriteLibrariesComponent } from './components/favorite-libraries/favorite-libraries.component';
import { NodeVersionsDialogComponent } from './dialogs/node-versions/node-versions.dialog';
import { CurrentUserComponent } from './components/current-user/current-user.component';
import { AppStoreModule } from './store/app-store.module';
import { MaterialModule } from './material.module';
@@ -130,7 +126,7 @@ registerLocaleData(localeSv);
SharedModule.forRoot(),
AppStoreModule,
CoreExtensionsModule.forRoot(),
ExtensionsModule,
ExtensionsModule.forRoot(),
AppExtensionsModule,
AppLoginModule,
AppCommonModule,
@@ -147,7 +143,8 @@ registerLocaleData(localeSv);
AppSearchInputModule,
AppSearchResultsModule,
AppHeaderModule,
AppNodeVersionModule
AppNodeVersionModule,
HammerModule
],
declarations: [
AppComponent,
@@ -172,12 +169,6 @@ registerLocaleData(localeSv);
}
}
],
entryComponents: [
NodeVersionsDialogComponent,
LibraryDialogComponent,
CreateFromTemplateDialogComponent,
CurrentUserComponent
],
bootstrap: [AppComponent]
})
export class AppModule {}

View File

@@ -51,12 +51,17 @@ export const APP_ROUTES: Routes = [
},
{
path: 'settings',
loadChildren: './components/settings/settings.module#AppSettingsModule'
loadChildren: () =>
import('./components/settings/settings.module').then(
m => m.AppSettingsModule
)
},
{
path: 'preview/s/:id',
loadChildren:
'./components/shared-link-view/shared-link-view.module#AppSharedLinkViewModule'
loadChildren: () =>
import('./components/shared-link-view/shared-link-view.module').then(
m => m.AppSharedLinkViewModule
)
},
{
path: 'view',
@@ -68,7 +73,10 @@ export const APP_ROUTES: Routes = [
children: [
{
path: '',
loadChildren: './components/viewer/viewer.module#AppViewerModule'
loadChildren: () =>
import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
}
]
}
@@ -99,7 +107,10 @@ export const APP_ROUTES: Routes = [
// deprecated, backwards compatibility with ACA 1.8
{
path: 'preview/:nodeId',
loadChildren: './components/preview/preview.module#PreviewModule',
loadChildren: () =>
import('./components/preview/preview.module').then(
m => m.PreviewModule
),
data: {
navigateSource: 'personal-files'
}
@@ -113,8 +124,10 @@ export const APP_ROUTES: Routes = [
data: {
navigateSource: 'personal-files'
},
loadChildren:
'./components/viewer/viewer.module#AppViewerModule'
loadChildren: () =>
import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
}
]
}
@@ -134,7 +147,10 @@ export const APP_ROUTES: Routes = [
// deprecated, backwards compatibility with ACA 1.8
{
path: 'preview/:nodeId',
loadChildren: './components/preview/preview.module#PreviewModule',
loadChildren: () =>
import('./components/preview/preview.module').then(
m => m.PreviewModule
),
data: {
navigateSource: 'personal-files'
}
@@ -142,7 +158,10 @@ export const APP_ROUTES: Routes = [
// deprecated, backwards compatibility with ACA 1.8
{
path: ':folderId/preview/:nodeId',
loadChildren: './components/preview/preview.module#PreviewModule',
loadChildren: () =>
import('./components/preview/preview.module').then(
m => m.PreviewModule
),
data: {
navigateSource: 'personal-files'
}
@@ -156,8 +175,10 @@ export const APP_ROUTES: Routes = [
data: {
navigateSource: 'personal-files'
},
loadChildren:
'./components/viewer/viewer.module#AppViewerModule'
loadChildren: () =>
import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
}
]
}
@@ -190,7 +211,10 @@ export const APP_ROUTES: Routes = [
// deprecated, backwards compatibility with ACA 1.8
{
path: 'preview/:nodeId',
loadChildren: './components/preview/preview.module#PreviewModule',
loadChildren: () =>
import('./components/preview/preview.module').then(
m => m.PreviewModule
),
data: {
navigateSource: 'libraries'
}
@@ -204,8 +228,10 @@ export const APP_ROUTES: Routes = [
data: {
navigateSource: 'libraries'
},
loadChildren:
'./components/viewer/viewer.module#AppViewerModule'
loadChildren: () =>
import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
}
]
}
@@ -249,8 +275,10 @@ export const APP_ROUTES: Routes = [
data: {
navigateSource: 'libraries'
},
loadChildren:
'./components/viewer/viewer.module#AppViewerModule'
loadChildren: () =>
import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
}
]
}
@@ -275,7 +303,10 @@ export const APP_ROUTES: Routes = [
// deprecated, backwards compatibility with ACA 1.8
{
path: 'preview/:nodeId',
loadChildren: './components/preview/preview.module#PreviewModule',
loadChildren: () =>
import('./components/preview/preview.module').then(
m => m.PreviewModule
),
data: {
navigateSource: 'favorites'
}
@@ -289,8 +320,10 @@ export const APP_ROUTES: Routes = [
data: {
navigateSource: 'favorites'
},
loadChildren:
'./components/viewer/viewer.module#AppViewerModule'
loadChildren: () =>
import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
}
]
}
@@ -314,7 +347,10 @@ export const APP_ROUTES: Routes = [
// deprecated, backwards compatibility with ACA 1.8
{
path: 'preview/:nodeId',
loadChildren: './components/preview/preview.module#PreviewModule',
loadChildren: () =>
import('./components/preview/preview.module').then(
m => m.PreviewModule
),
data: {
navigateSource: 'recent-files'
}
@@ -328,8 +364,10 @@ export const APP_ROUTES: Routes = [
data: {
navigateSource: 'recent-files'
},
loadChildren:
'./components/viewer/viewer.module#AppViewerModule'
loadChildren: () =>
import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
}
]
}
@@ -351,7 +389,10 @@ export const APP_ROUTES: Routes = [
// deprecated, backwards compatibility with ACA 1.8
{
path: 'preview/:nodeId',
loadChildren: './components/preview/preview.module#PreviewModule',
loadChildren: () =>
import('./components/preview/preview.module').then(
m => m.PreviewModule
),
data: {
navigateSource: 'shared'
}
@@ -365,8 +406,10 @@ export const APP_ROUTES: Routes = [
data: {
navigateSource: 'shared'
},
loadChildren:
'./components/viewer/viewer.module#AppViewerModule'
loadChildren: () =>
import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
}
]
}
@@ -376,11 +419,15 @@ export const APP_ROUTES: Routes = [
},
{
path: 'trashcan',
loadChildren: './components/trashcan/trashcan.module#AppTrashcanModule'
loadChildren: () =>
import('./components/trashcan/trashcan.module').then(
m => m.AppTrashcanModule
)
},
{
path: 'about',
loadChildren: './components/about/about.module#AboutModule'
loadChildren: () =>
import('./components/about/about.module').then(m => m.AboutModule)
},
{
path: 'search',
@@ -395,7 +442,10 @@ export const APP_ROUTES: Routes = [
// deprecated, backwards compatibility with ACA 1.8
{
path: 'preview/:nodeId',
loadChildren: './components/preview/preview.module#PreviewModule',
loadChildren: () =>
import('./components/preview/preview.module').then(
m => m.PreviewModule
),
data: {
navigateSource: 'search'
}
@@ -409,8 +459,10 @@ export const APP_ROUTES: Routes = [
data: {
navigateSource: 'search'
},
loadChildren:
'./components/viewer/viewer.module#AppViewerModule'
loadChildren: () =>
import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
}
]
}
@@ -435,8 +487,10 @@ export const APP_ROUTES: Routes = [
data: {
navigateSource: 'search'
},
loadChildren:
'./components/viewer/viewer.module#AppViewerModule'
loadChildren: () =>
import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
}
]
}

View File

@@ -53,12 +53,6 @@ import { LogoutComponent } from './logout/logout.component';
ToggleSharedComponent,
LanguagePickerComponent,
LogoutComponent
],
entryComponents: [
LocationLinkComponent,
ToggleSharedComponent,
LanguagePickerComponent,
LogoutComponent
]
})
export class AppCommonModule {}

View File

@@ -56,7 +56,7 @@ describe('LogoutComponent', () => {
]
});
store = TestBed.get(Store);
store = TestBed.inject(Store);
fixture = TestBed.createComponent(LogoutComponent);
component = fixture.componentInstance;
fixture.detectChanges();

View File

@@ -54,7 +54,7 @@ describe('ContextMenuComponent', () => {
fixture = TestBed.createComponent(ContextMenuItemComponent);
component = fixture.componentInstance;
extensionsService = TestBed.get(AppExtensionService);
extensionsService = TestBed.inject(AppExtensionService);
contextItem = {
type: 'button',

View File

@@ -87,8 +87,8 @@ describe('ContextMenuComponent', () => {
fixture = TestBed.createComponent(ContextMenuComponent);
component = fixture.componentInstance;
contextMenuOverlayRef = TestBed.get(ContextMenuOverlayRef);
extensionsService = TestBed.get(AppExtensionService);
contextMenuOverlayRef = TestBed.inject(ContextMenuOverlayRef);
extensionsService = TestBed.inject(AppExtensionService);
spyOn(extensionsService, 'getAllowedContextMenuActions').and.returnValue([
contextItem

View File

@@ -59,7 +59,6 @@ import { ContextActionsModule } from '@alfresco/aca-shared';
ContextMenuComponent,
ContextMenuItemComponent,
ContextActionsModule
],
entryComponents: [ContextMenuComponent]
]
})
export class ContextMenuModule {}

View File

@@ -62,9 +62,9 @@ describe('ContextMenuService', () => {
]
});
injector = TestBed.get(Injector);
overlay = TestBed.get(Overlay);
userPreferencesService = TestBed.get(UserPreferencesService);
injector = TestBed.inject(Injector);
overlay = TestBed.inject(Overlay);
userPreferencesService = TestBed.inject(UserPreferencesService);
});
it('should create a custom overlay', () => {

View File

@@ -61,8 +61,8 @@ describe('CurrentUserComponent', () => {
});
fixture = TestBed.createComponent(CurrentUserComponent);
appExtensionService = TestBed.get(AppExtensionService);
store = TestBed.get(Store);
appExtensionService = TestBed.inject(AppExtensionService);
store = TestBed.inject(Store);
component = fixture.componentInstance;
});

View File

@@ -54,7 +54,7 @@ describe('UserMenuItemComponent', () => {
});
fixture = TestBed.createComponent(UserMenuItemComponent);
appExtensionService = TestBed.get(AppExtensionService);
appExtensionService = TestBed.inject(AppExtensionService);
component = fixture.componentInstance;
});

View File

@@ -40,7 +40,6 @@ import { CoreModule } from '@alfresco/adf-core';
LockedByModule
],
declarations: [CustomNameColumnComponent],
exports: [CustomNameColumnComponent],
entryComponents: [CustomNameColumnComponent]
exports: [CustomNameColumnComponent]
})
export class DocumentListCustomComponentsModule {}

View File

@@ -83,12 +83,12 @@ describe('FavoriteLibrariesComponent', () => {
fixture = TestBed.createComponent(FavoriteLibrariesComponent);
component = fixture.componentInstance;
alfrescoApi = TestBed.get(AlfrescoApiService);
contentApiService = TestBed.get(ContentApiService);
userPreference = TestBed.get(UserPreferencesService);
contentManagementService = TestBed.get(ContentManagementService);
alfrescoApi = TestBed.inject(AlfrescoApiService);
contentApiService = TestBed.inject(ContentApiService);
userPreference = TestBed.inject(UserPreferencesService);
contentManagementService = TestBed.inject(ContentManagementService);
alfrescoApi.reset();
router = TestBed.get(Router);
router = TestBed.inject(Router);
spyOn(contentApiService, 'getNode').and.returnValue(
of({ entry: { id: 'libraryId' } } as NodeEntry)
@@ -116,7 +116,9 @@ describe('FavoriteLibrariesComponent', () => {
expect(contentApiService.getFavoriteLibraries).toHaveBeenCalledWith(
'-me-',
{ maxItems: userPreference.paginationSize }
{
maxItems: userPreference.paginationSize
}
);
});

View File

@@ -101,15 +101,15 @@ describe('FavoritesComponent', () => {
fixture = TestBed.createComponent(FavoritesComponent);
component = fixture.componentInstance;
alfrescoApi = TestBed.get(AlfrescoApiService);
alfrescoApi = TestBed.inject(AlfrescoApiService);
alfrescoApi.reset();
spyOn(alfrescoApi.favoritesApi, 'getFavorites').and.returnValue(
Promise.resolve(page)
);
contentApi = TestBed.get(ContentApiService);
uploadService = TestBed.get(UploadService);
router = TestBed.get(Router);
contentApi = TestBed.inject(ContentApiService);
uploadService = TestBed.inject(UploadService);
router = TestBed.inject(Router);
});
describe('Node navigation', () => {

View File

@@ -35,7 +35,9 @@ import {
NodeFavoriteDirective,
DataTableComponent,
UploadService,
AppConfigPipe
AppConfigPipe,
AlfrescoApiService,
AlfrescoApiServiceMock
} from '@alfresco/adf-core';
import { DocumentListComponent } from '@alfresco/adf-content-services';
import { NodeActionsService } from '../../services/node-actions.service';
@@ -51,7 +53,7 @@ describe('FilesComponent', () => {
let uploadService: UploadService;
let nodeActionsService: NodeActionsService;
let contentApi: ContentApiService;
let router = {
let router: any = {
url: '',
navigate: jasmine.createSpy('navigate')
};
@@ -67,6 +69,7 @@ describe('FilesComponent', () => {
AppConfigPipe
],
providers: [
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
{
provide: Router,
useValue: router
@@ -85,18 +88,22 @@ describe('FilesComponent', () => {
fixture = TestBed.createComponent(FilesComponent);
component = fixture.componentInstance;
uploadService = TestBed.get(UploadService);
router = TestBed.get(Router);
nodeActionsService = TestBed.get(NodeActionsService);
contentApi = TestBed.get(ContentApiService);
uploadService = TestBed.inject(UploadService);
router = TestBed.inject(Router);
nodeActionsService = TestBed.inject(NodeActionsService);
contentApi = TestBed.inject(ContentApiService);
});
beforeEach(() => {
node = { id: 'node-id', isFolder: true };
spyOn(component.documentList, 'loadFolder').and.callFake(() => {});
});
describe('Current page is valid', () => {
beforeEach(() => {
fixture.detectChanges();
spyOn(component.documentList, 'loadFolder').and.callFake(() => {});
});
it('should be a valid current page', fakeAsync(() => {
spyOn(contentApi, 'getNode').and.returnValue(throwError(null));
@@ -111,24 +118,29 @@ describe('FilesComponent', () => {
spyOn(contentApi, 'getNode').and.returnValue(of({ entry: node }));
component.ngOnInit();
tick();
fixture.detectChanges();
tick();
expect(component.isValidPath).toBe(true);
}));
});
describe('OnInit', () => {
beforeEach(() => {
router.navigate['calls'].reset();
});
it('should set current node', () => {
spyOn(contentApi, 'getNode').and.returnValue(of({ entry: node }));
fixture.detectChanges();
expect(component.node).toBe(node);
});
it('if should navigate to parent if node is not a folder', () => {
node.isFolder = false;
node.parentId = 'parent-id';
spyOn(contentApi, 'getNode').and.returnValue(of({ entry: node }));
it('should navigate to parent if node is not a folder', () => {
const nodeEntry = { isFolder: false, parentId: 'parent-id' };
spyOn(contentApi, 'getNode').and.returnValue(
of({ entry: nodeEntry } as any)
);
fixture.detectChanges();

View File

@@ -64,7 +64,6 @@ export function components() {
SharedInfoDrawerModule
],
declarations: [...components()],
exports: [...components(), SharedInfoDrawerModule],
entryComponents: [...components()]
exports: [...components(), SharedInfoDrawerModule]
})
export class AppInfoDrawerModule {}

View File

@@ -57,7 +57,7 @@ describe('LibraryMetadataFormComponent', () => {
fixture = TestBed.createComponent(LibraryMetadataFormComponent);
component = fixture.componentInstance;
alfrescoApiService = TestBed.get(AlfrescoApiService);
alfrescoApiService = TestBed.inject(AlfrescoApiService);
});
afterEach(() => {

View File

@@ -55,8 +55,8 @@ describe('MetadataTabComponent', () => {
describe('content-metadata configuration', () => {
beforeEach(() => {
appConfig = TestBed.get(AppConfigService);
extensions = TestBed.get(AppExtensionService);
appConfig = TestBed.inject(AppConfigService);
extensions = TestBed.inject(AppExtensionService);
});
it('should remain unchanged when metadata extension is missing', () => {
@@ -136,7 +136,7 @@ describe('MetadataTabComponent', () => {
describe('displayAspect', () => {
beforeEach(() => {
fixture = TestBed.createComponent(MetadataTabComponent);
store = TestBed.get(Store);
store = TestBed.inject(Store);
component = fixture.componentInstance;
});

View File

@@ -14,7 +14,7 @@
role="heading"
aria-level="1"
*ngIf="!hideSidenav"
(toggleClicked)="layout.toggleMenu($event)"
(toggleClicked)="layout.toggleMenu()"
[expandedSidenav]="!isMenuMinimized()"
>
</app-header>

View File

@@ -73,10 +73,10 @@ describe('AppLayoutComponent', () => {
fixture = TestBed.createComponent(AppLayoutComponent);
component = fixture.componentInstance;
appConfig = TestBed.get(AppConfigService);
store = TestBed.get(Store);
router = TestBed.get(Router);
userPreference = TestBed.get(UserPreferencesService);
appConfig = TestBed.inject(AppConfigService);
store = TestBed.inject(Store);
router = TestBed.inject(Router);
userPreference = TestBed.inject(UserPreferencesService);
});
beforeEach(() => {

View File

@@ -55,7 +55,7 @@ import { Directionality } from '@angular/cdk/bidi';
host: { class: 'app-layout' }
})
export class AppLayoutComponent implements OnInit, OnDestroy {
@ViewChild('layout')
@ViewChild('layout', { static: true })
layout: SidenavLayoutComponent;
onDestroy$: Subject<boolean> = new Subject<boolean>();

View File

@@ -70,9 +70,9 @@ describe('LibrariesComponent', () => {
fixture = TestBed.createComponent(LibrariesComponent);
component = fixture.componentInstance;
alfrescoApi = TestBed.get(AlfrescoApiService);
alfrescoApi = TestBed.inject(AlfrescoApiService);
alfrescoApi.reset();
router = TestBed.get(Router);
router = TestBed.inject(Router);
spyOn(alfrescoApi.sitesApi, 'getSites').and.returnValue(
Promise.resolve(page)

View File

@@ -50,8 +50,6 @@ import { NgModule } from '@angular/core';
MatInputModule
],
exports: [AppNodeVersionFormComponent],
declarations: [AppNodeVersionFormComponent],
providers: [],
entryComponents: [AppNodeVersionFormComponent]
declarations: [AppNodeVersionFormComponent]
})
export class AppNodeVersionModule {}

View File

@@ -69,7 +69,7 @@ describe('PageComponent', () => {
providers: [ContentManagementService, AppExtensionService]
});
store = TestBed.get(Store);
store = TestBed.inject(Store);
fixture = TestBed.createComponent(TestComponent);
component = fixture.componentInstance;
});

View File

@@ -34,7 +34,8 @@ import {
OnInit,
OnChanges,
ViewChild,
SimpleChanges
SimpleChanges,
Directive
} from '@angular/core';
import { Store } from '@ngrx/store';
import {
@@ -60,6 +61,8 @@ import {
} from '@alfresco/aca-shared/store';
import { isLocked, isLibrary, AppExtensionService } from '@alfresco/aca-shared';
/* tslint:disable:directive-class-suffix */
@Directive()
export abstract class PageComponent implements OnInit, OnDestroy, OnChanges {
onDestroy$: Subject<boolean> = new Subject<boolean>();

View File

@@ -40,7 +40,7 @@ import { NodePermissionsDialogComponent } from '../permission-dialog/node-permis
templateUrl: './permission-manager.component.html'
})
export class PermissionsManagerComponent implements OnInit {
@ViewChild('permissionList')
@ViewChild('permissionList', { static: true })
permissionList: PermissionListComponent;
@Input()

View File

@@ -33,7 +33,6 @@ import { PermissionsManagerComponent } from './permission-manager/permission-man
@NgModule({
imports: [CommonModule, CoreModule.forChild(), ContentModule.forChild()],
declarations: [PermissionsManagerComponent, NodePermissionsDialogComponent],
exports: [PermissionsManagerComponent, NodePermissionsDialogComponent],
entryComponents: [NodePermissionsDialogComponent]
exports: [PermissionsManagerComponent, NodePermissionsDialogComponent]
})
export class AppPermissionsModule {}

View File

@@ -80,14 +80,14 @@ describe('PreviewComponent', () => {
fixture = TestBed.createComponent(PreviewComponent);
component = fixture.componentInstance;
router = TestBed.get(Router);
route = TestBed.get(ActivatedRoute);
preferences = TestBed.get(UserPreferencesService);
contentApi = TestBed.get(ContentApiService);
uploadService = TestBed.get(UploadService);
alfrescoApiService = TestBed.get(AlfrescoApiService);
contentManagementService = TestBed.get(ContentManagementService);
store = TestBed.get(Store);
router = TestBed.inject(Router);
route = TestBed.inject(ActivatedRoute);
preferences = TestBed.inject(UserPreferencesService);
contentApi = TestBed.inject(ContentApiService);
uploadService = TestBed.inject(UploadService);
alfrescoApiService = TestBed.inject(AlfrescoApiService);
contentManagementService = TestBed.inject(ContentManagementService);
store = TestBed.inject(Store);
});
it('should extract the property path root', () => {

View File

@@ -84,8 +84,8 @@ describe('RecentFilesComponent', () => {
fixture = TestBed.createComponent(RecentFilesComponent);
component = fixture.componentInstance;
alfrescoApi = TestBed.get(AlfrescoApiService);
uploadService = TestBed.get(UploadService);
alfrescoApi = TestBed.inject(AlfrescoApiService);
uploadService = TestBed.inject(UploadService);
alfrescoApi.reset();
spyOn(alfrescoApi.peopleApi, 'getPerson').and.returnValue(

View File

@@ -64,7 +64,7 @@ export class SearchInputControlComponent implements OnDestroy {
@Output()
searchChange: EventEmitter<string> = new EventEmitter();
@ViewChild('searchInput')
@ViewChild('searchInput', { static: true })
searchInput: ElementRef;
searchTerm = '';

View File

@@ -59,9 +59,9 @@ describe('SearchInputComponent', () => {
})
.compileComponents()
.then(() => {
actions$ = TestBed.get(Actions);
actions$ = TestBed.inject(Actions);
fixture = TestBed.createComponent(SearchInputComponent);
content = TestBed.get(ContentManagementService);
content = TestBed.inject(ContentManagementService);
component = fixture.componentInstance;
fixture.detectChanges();
});

View File

@@ -91,10 +91,10 @@ export class SearchInputComponent implements OnInit, OnDestroy {
}
];
@ViewChild('searchInputControl')
@ViewChild('searchInputControl', { static: true })
searchInputControl: SearchInputControlComponent;
@ViewChild(MatMenuTrigger)
@ViewChild(MatMenuTrigger, { static: true })
trigger: MatMenuTrigger;
constructor(

View File

@@ -42,7 +42,7 @@ describe('SearchLibrariesQueryBuilderService', () => {
imports: [AppTestingModule]
});
apiService = TestBed.get(AlfrescoApiService);
apiService = TestBed.inject(AlfrescoApiService);
apiService.reset();
queriesApi = apiService.getInstance().core.queriesApi;
builder = new SearchLibrariesQueryBuilderService(apiService);

View File

@@ -93,12 +93,12 @@ describe('SearchComponent', () => {
]
});
config = TestBed.get(AppConfigService);
store = TestBed.get(Store);
queryBuilder = TestBed.get(SearchQueryBuilderService);
alfrescoApi = TestBed.get(AlfrescoApiService);
translate = TestBed.get(TranslationService);
router = TestBed.get(Router);
config = TestBed.inject(AppConfigService);
store = TestBed.inject(Store);
queryBuilder = TestBed.inject(SearchQueryBuilderService);
alfrescoApi = TestBed.inject(AlfrescoApiService);
translate = TestBed.inject(TranslationService);
router = TestBed.inject(Router);
fixture = TestBed.createComponent(SearchResultsComponent);
component = fixture.componentInstance;

View File

@@ -54,7 +54,7 @@ import { AppExtensionService } from '@alfresco/aca-shared';
styleUrls: ['./search-results.component.scss']
})
export class SearchResultsComponent extends PageComponent implements OnInit {
@ViewChild('searchFilter')
@ViewChild('searchFilter', { static: true })
searchFilter: SearchFilterComponent;
showFacetFilter$: Observable<boolean>;

View File

@@ -62,8 +62,8 @@ describe('SettingsComponent', () => {
fixture = TestBed.createComponent(SettingsComponent);
component = fixture.componentInstance;
storage = TestBed.get(StorageService);
appExtensions = TestBed.get(AppExtensionService);
storage = TestBed.inject(StorageService);
appExtensions = TestBed.inject(AppExtensionService);
stringParam = {
key: 'key',

View File

@@ -32,6 +32,7 @@ import {
import { NO_ERRORS_SCHEMA } from '@angular/core';
import {
AlfrescoApiService,
AlfrescoApiServiceMock,
NodeFavoriteDirective,
DataTableComponent,
AppConfigPipe,
@@ -74,6 +75,7 @@ describe('SharedFilesComponent', () => {
AppConfigPipe
],
providers: [
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
{
provide: Router,
useValue: mockRouter
@@ -83,11 +85,11 @@ describe('SharedFilesComponent', () => {
});
fixture = TestBed.createComponent(SharedFilesComponent);
uploadService = TestBed.get(UploadService);
contentManagementService = TestBed.get(ContentManagementService);
uploadService = TestBed.inject(UploadService);
contentManagementService = TestBed.inject(ContentManagementService);
component = fixture.componentInstance;
alfrescoApi = TestBed.get(AlfrescoApiService);
alfrescoApi = TestBed.inject(AlfrescoApiService);
alfrescoApi.reset();
spyOn(alfrescoApi.sharedLinksApi, 'findSharedLinks').and.returnValue(

View File

@@ -78,8 +78,8 @@ describe('SharedLinkViewComponent', () => {
fixture = TestBed.createComponent(SharedLinkViewComponent);
component = fixture.componentInstance;
alfrescoApiService = TestBed.get(AlfrescoApiService);
appExtensionService = TestBed.get(AppExtensionService);
alfrescoApiService = TestBed.inject(AlfrescoApiService);
appExtensionService = TestBed.inject(AppExtensionService);
spyGetSharedLink = spyOn(
alfrescoApiService.sharedLinksApi,

View File

@@ -52,7 +52,7 @@ describe('ButtonMenuComponent', () => {
fixture = TestBed.createComponent(ButtonMenuComponent);
component = fixture.componentInstance;
router = TestBed.get(Router);
router = TestBed.inject(Router);
spyOn(router, 'navigate');
});

View File

@@ -52,7 +52,7 @@ describe('ExpandMenuComponent', () => {
fixture = TestBed.createComponent(ExpandMenuComponent);
component = fixture.componentInstance;
router = TestBed.get(Router);
router = TestBed.inject(Router);
spyOn(router, 'navigate');
});

View File

@@ -26,6 +26,7 @@
import { Directive, Input, HostListener } from '@angular/core';
import { PRIMARY_OUTLET, Router } from '@angular/router';
import { Store } from '@ngrx/store';
import { AppStore } from '@alfresco/aca-shared/store';
@Directive({
/* tslint:disable-next-line */
@@ -47,7 +48,7 @@ export class ActionDirective {
}
}
constructor(private router: Router, private store: Store<any>) {}
constructor(private router: Router, private store: Store<AppStore>) {}
private getNavigationCommands(url: string): any[] {
const urlTree = this.router.parseUrl(url);

View File

@@ -74,7 +74,7 @@ describe('ActionDirective', () => {
});
fixture = TestBed.createComponent(TestComponent);
router = TestBed.get(Router);
router = TestBed.inject(Router);
});
it('should add active route class name', () => {

View File

@@ -31,7 +31,8 @@ import {
Renderer2,
ContentChildren,
QueryList,
AfterContentInit
AfterContentInit,
Optional
} from '@angular/core';
import { Router, NavigationEnd } from '@angular/router';
import { filter, takeUntil } from 'rxjs/operators';
@@ -53,7 +54,8 @@ export class ActiveLinkDirective implements OnInit, AfterContentInit {
constructor(
private router: Router,
private element: ElementRef,
private renderer: Renderer2
private renderer: Renderer2,
@Optional() private action?: ActionDirective
) {}
ngOnInit() {
@@ -68,21 +70,27 @@ export class ActiveLinkDirective implements OnInit, AfterContentInit {
}
private update(url: string) {
if (this.action) {
const itemUrl = this.resolveUrl(this.action);
this.render(url, itemUrl);
}
this.links.map(item => {
const itemUrl = this.resolveUrl(item);
if (url && url.substring(1).startsWith(itemUrl)) {
this.isLinkActive = true;
this.renderer.addClass(this.element.nativeElement, this.acaActiveLink);
} else {
this.isLinkActive = false;
this.renderer.removeClass(
this.element.nativeElement,
this.acaActiveLink
);
}
this.render(url, itemUrl);
});
}
private render(routerUrl: string, actionUrl: string) {
if (routerUrl && routerUrl.substring(1).startsWith(actionUrl)) {
this.isLinkActive = true;
this.renderer.addClass(this.element.nativeElement, this.acaActiveLink);
} else {
this.isLinkActive = false;
this.renderer.removeClass(this.element.nativeElement, this.acaActiveLink);
}
}
ngAfterContentInit() {
this.links.changes.subscribe(() => this.update(this.router.url));
this.update(this.router.url);
@@ -90,7 +98,7 @@ export class ActiveLinkDirective implements OnInit, AfterContentInit {
private resolveUrl(item): string {
return (
(item.action && (item.action.click && item.action.click.payload)) ||
(item.action && item.action.click && item.action.click.payload) ||
item.action.route
);
}

View File

@@ -54,7 +54,7 @@ describe('SidenavComponent', () => {
.then(() => {
fixture = TestBed.createComponent(SidenavComponent);
component = fixture.componentInstance;
extensionService = TestBed.get(AppExtensionService);
extensionService = TestBed.inject(AppExtensionService);
extensionService.navbar = navbarMock;

View File

@@ -55,7 +55,9 @@ export class SidenavComponent implements OnInit, OnDestroy {
@ContentChild(ExpandedTemplateDirective, { read: TemplateRef })
expandedTemplate;
@ContentChild(CollapsedTemplateDirective, { read: TemplateRef })
@ContentChild(CollapsedTemplateDirective, {
read: TemplateRef
})
collapsedTemplate;
groups: Array<NavBarGroupRef> = [];

View File

@@ -29,6 +29,7 @@ import { setupTestBed, CoreModule } from '@alfresco/adf-core';
import { TestBed } from '@angular/core/testing';
import { of } from 'rxjs';
import { Store } from '@ngrx/store';
import { NodeEntry } from '@alfresco/js-api';
import {
DownloadNodesAction,
EditOfflineAction,
@@ -39,9 +40,10 @@ import { TranslateModule } from '@ngx-translate/core';
describe('ToggleEditOfflineComponent', () => {
let fixture;
let component;
let selection;
let store;
let dispatchSpy;
let selectSpy;
const selection = { file: { entry: { name: 'test', properties: {} } } };
setupTestBed({
imports: [TranslateModule.forRoot(), CoreModule.forRoot()],
@@ -50,7 +52,7 @@ describe('ToggleEditOfflineComponent', () => {
{
provide: Store,
useValue: {
select: () => of(selection),
select: () => {},
dispatch: () => {}
}
}
@@ -60,9 +62,10 @@ describe('ToggleEditOfflineComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(ToggleEditOfflineComponent);
component = fixture.componentInstance;
store = TestBed.get(Store);
store = TestBed.inject(Store);
dispatchSpy = spyOn(store, 'dispatch');
selectSpy = spyOn(store, 'select');
});
afterEach(() => {
@@ -70,7 +73,7 @@ describe('ToggleEditOfflineComponent', () => {
});
it('should initialized with data from store', () => {
selection = { file: { entry: { properties: {} } } };
selectSpy.and.returnValue(of(selection));
fixture.detectChanges();
@@ -78,7 +81,8 @@ describe('ToggleEditOfflineComponent', () => {
});
it('should download content if node is locked', () => {
component.selection = { entry: { properties: {} } };
selectSpy.and.returnValue(of(selection));
fixture.detectChanges();
const isLocked = true;
component.onToggleEvent(isLocked);
@@ -86,12 +90,13 @@ describe('ToggleEditOfflineComponent', () => {
fixture.detectChanges();
expect(dispatchSpy.calls.argsFor(0)).toEqual([
new DownloadNodesAction([component.selection])
new DownloadNodesAction([selection.file as NodeEntry])
]);
});
it('should not download content if node is not locked', () => {
component.selection = { entry: { properties: {} } };
selectSpy.and.returnValue(of(selection));
fixture.detectChanges();
const isLocked = false;
component.onToggleEvent(isLocked);
@@ -99,12 +104,13 @@ describe('ToggleEditOfflineComponent', () => {
fixture.detectChanges();
expect(dispatchSpy.calls.argsFor(0)).not.toEqual([
new DownloadNodesAction([component.selection])
new DownloadNodesAction([selection.file as NodeEntry])
]);
});
it('should dispatch EditOfflineAction action', () => {
component.selection = { entry: { properties: {} } };
selectSpy.and.returnValue(of(selection));
fixture.detectChanges();
const isLocked = false;
component.onToggleEvent(isLocked);
@@ -112,14 +118,13 @@ describe('ToggleEditOfflineComponent', () => {
fixture.detectChanges();
expect(dispatchSpy.calls.argsFor(0)).toEqual([
new EditOfflineAction(component.selection)
new EditOfflineAction(selection.file as NodeEntry)
]);
});
it('should raise notification on lock error', () => {
component.selection = {
entry: { name: 'test' }
};
selectSpy.and.returnValue(of(selection));
fixture.detectChanges();
component.onLockError();
fixture.detectChanges();
@@ -132,9 +137,8 @@ describe('ToggleEditOfflineComponent', () => {
});
it('should raise notification on unlock error', () => {
component.selection = {
entry: { name: 'test' }
};
selectSpy.and.returnValue(of(selection));
fixture.detectChanges();
component.onUnlockLockError();
fixture.detectChanges();

View File

@@ -23,7 +23,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { TestBed } from '@angular/core/testing';
import { TestBed, ComponentFixture } from '@angular/core/testing';
import {
CoreModule,
AlfrescoApiService,
@@ -40,7 +40,7 @@ import { Router } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core';
describe('ToggleFavoriteLibraryComponent', () => {
let fixture;
let fixture: ComponentFixture<ToggleFavoriteLibraryComponent>;
let component;
let contentManagementService;
const selection = { library: { entry: { id: 'libraryId' } } };
@@ -82,33 +82,34 @@ describe('ToggleFavoriteLibraryComponent', () => {
fixture = TestBed.createComponent(ToggleFavoriteLibraryComponent);
component = fixture.componentInstance;
contentManagementService = TestBed.get(ContentManagementService);
const api = TestBed.get(AlfrescoApiService);
spyOn(api.peopleApi, 'getFavoriteSite').and.returnValue(Promise.resolve());
contentManagementService = TestBed.inject(ContentManagementService);
const api = TestBed.inject(AlfrescoApiService);
spyOn(api.peopleApi, 'getFavoriteSite').and.returnValue(
Promise.resolve(null)
);
});
it('should get library selection from Store', done => {
it('should get library selection from Store', async () => {
fixture.detectChanges();
component.selection$.subscribe(selected => {
expect(selected.library.entry.id).toEqual(selection.library.entry.id);
done();
});
await fixture.whenStable();
expect(component.library.entry.id).toEqual(selection.library.entry.id);
});
it('should mark selection as favorite when on favorite libraries route', done => {
it('should mark selection as favorite when on favorite libraries route', async () => {
mockRouter.url = '/favorite/libraries';
fixture.detectChanges();
await fixture.whenStable();
component.selection$.subscribe(selected => {
expect(selected.library.isFavorite).toBe(true);
done();
});
expect(component.library.isFavorite).toBe(true);
});
it('should emit onToggleEvent() event', () => {
fixture.detectChanges();
it('should emit onToggleEvent() event', async () => {
spyOn(contentManagementService.favoriteLibraryToggle, 'next');
fixture.detectChanges();
await fixture.whenStable();
component.onToggleEvent();
expect(

View File

@@ -23,43 +23,44 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { Component, ViewEncapsulation, OnInit } from '@angular/core';
import { Component, ViewEncapsulation, OnInit, OnDestroy } from '@angular/core';
import { Store } from '@ngrx/store';
import { AppStore, getAppSelection } from '@alfresco/aca-shared/store';
import { Observable } from 'rxjs';
import { SelectionState } from '@alfresco/adf-extensions';
import { ContentManagementService } from '../../../services/content-management.service';
import { distinctUntilChanged, map } from 'rxjs/operators';
import { distinctUntilChanged, takeUntil } from 'rxjs/operators';
import { Router } from '@angular/router';
import { Subject } from 'rxjs';
@Component({
selector: 'app-toggle-favorite-library',
template: `
<button
mat-menu-item
#favoriteLibrary="favoriteLibrary"
(toggle)="onToggleEvent()"
[acaFavoriteLibrary]="(selection$ | async).library"
[acaFavoriteLibrary]="library"
[attr.title]="
favoriteLibrary.isFavorite()
library.isFavorite
? ('APP.ACTIONS.REMOVE_FAVORITE' | translate)
: ('APP.ACTIONS.FAVORITE' | translate)
"
>
<mat-icon *ngIf="favoriteLibrary.isFavorite()">star</mat-icon>
<mat-icon *ngIf="!favoriteLibrary.isFavorite()">star_border</mat-icon>
<mat-icon *ngIf="library.isFavorite">star</mat-icon>
<mat-icon *ngIf="!library.isFavorite">star_border</mat-icon>
<span>{{
(favoriteLibrary.isFavorite()
(library.isFavorite
? 'APP.ACTIONS.REMOVE_FAVORITE'
: 'APP.ACTIONS.FAVORITE') | translate
: 'APP.ACTIONS.FAVORITE'
) | translate
}}</span>
</button>
`,
encapsulation: ViewEncapsulation.None,
host: { class: 'app-toggle-favorite-library' }
})
export class ToggleFavoriteLibraryComponent implements OnInit {
selection$: Observable<SelectionState>;
export class ToggleFavoriteLibraryComponent implements OnInit, OnDestroy {
library;
private onDestroy$: Subject<boolean> = new Subject<boolean>();
constructor(
private store: Store<AppStore>,
@@ -72,17 +73,22 @@ export class ToggleFavoriteLibraryComponent implements OnInit {
'/favorite/libraries'
);
this.selection$ = this.store.select(getAppSelection).pipe(
distinctUntilChanged(),
map(selection => {
this.store
.select(getAppSelection)
.pipe(distinctUntilChanged(), takeUntil(this.onDestroy$))
.subscribe((selection: SelectionState) => {
this.library = { ...selection.library };
// favorite libraries list should already be marked as favorite
if (selection.library && isFavoriteLibraries) {
(selection.library as any).isFavorite = true;
return selection;
this.library.isFavorite = true;
}
return selection;
})
);
});
}
ngOnDestroy() {
this.onDestroy$.next(true);
this.onDestroy$.complete();
}
onToggleEvent() {

View File

@@ -66,7 +66,7 @@ describe('ToggleFavoriteComponent', () => {
fixture = TestBed.createComponent(ToggleFavoriteComponent);
component = fixture.componentInstance;
router = TestBed.get(Router);
router = TestBed.inject(Router);
});
afterEach(() => {
@@ -79,6 +79,7 @@ describe('ToggleFavoriteComponent', () => {
it('should not dispatch reload if route is not specified', () => {
component.data = "['/reload_on_this_route']";
router.url = '/somewhere_over_the_rainbow';
fixture.detectChanges();
component.onToggleEvent();

View File

@@ -48,7 +48,8 @@ import { Router } from '@angular/router';
<span>{{
(favorites.hasFavorites()
? 'APP.ACTIONS.REMOVE_FAVORITE'
: 'APP.ACTIONS.FAVORITE') | translate
: 'APP.ACTIONS.FAVORITE'
) | translate
}}</span>
</button>
`,

View File

@@ -72,8 +72,8 @@ describe('ToggleJoinLibraryComponent', () => {
fixture = TestBed.createComponent(ToggleJoinLibraryButtonComponent);
component = fixture.componentInstance;
alfrescoApi = TestBed.get(AlfrescoApiService);
contentManagementService = TestBed.get(ContentManagementService);
alfrescoApi = TestBed.inject(AlfrescoApiService);
contentManagementService = TestBed.inject(ContentManagementService);
spyOn(alfrescoApi.peopleApi, 'getSiteMembershipRequest').and.stub();
});

View File

@@ -62,7 +62,6 @@ export function components() {
DirectivesModule
],
declarations: components(),
exports: [components(), SharedToolbarModule],
entryComponents: components()
exports: [components(), SharedToolbarModule]
})
export class AppToolbarModule {}

View File

@@ -31,7 +31,7 @@ import { Router } from '@angular/router';
import { of } from 'rxjs';
import { TranslateModule } from '@ngx-translate/core';
describe('ToggleFavoriteComponent', () => {
describe('ViewNodeComponent', () => {
let component: ViewNodeComponent;
let fixture;
const mockRouter = {

View File

@@ -65,7 +65,7 @@ describe('TrashcanComponent', () => {
fixture = TestBed.createComponent(TrashcanComponent);
component = fixture.componentInstance;
alfrescoApi = TestBed.get(AlfrescoApiService);
alfrescoApi = TestBed.inject(AlfrescoApiService);
alfrescoApi.reset();
component.documentList = {

View File

@@ -188,10 +188,7 @@ export class AppViewerComponent implements OnInit, OnDestroy {
.subscribe(() => this.navigateToFileLocation());
this.uploadService.fileUploadComplete
.pipe(
debounceTime(300),
takeUntil(this.onDestroy$)
)
.pipe(debounceTime(300), takeUntil(this.onDestroy$))
.subscribe(file => {
this.apiService.nodeUpdated.next(file.data.entry);
this.displayNode(file.data.entry.id);

View File

@@ -96,7 +96,7 @@ describe('CreateFileFromTemplateDialogComponent', () => {
});
fixture = TestBed.createComponent(CreateFromTemplateDialogComponent);
store = TestBed.get(Store);
store = TestBed.inject(Store);
component = fixture.componentInstance;
component.data = data as Node;
});

View File

@@ -24,7 +24,7 @@
*/
import { Component, ViewEncapsulation, Inject, OnInit } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { Node } from '@alfresco/js-api';
import {
FormBuilder,

View File

@@ -102,7 +102,7 @@ describe('NodeVersionsDialogComponent', () => {
]
});
store = TestBed.get(Store);
store = TestBed.inject(Store);
fixture = TestBed.createComponent(NodeVersionsDialogComponent);
component = fixture.componentInstance;
component.node = {
@@ -128,7 +128,7 @@ describe('NodeVersionsDialogComponent', () => {
lastModified: 13,
size: 1351,
slice: null
};
} as File;
});
it('should display adf upload version if isTypeList is passed as false from parent component', () => {

View File

@@ -69,7 +69,7 @@ describe('LibraryFavoriteDirective', () => {
beforeEach(() => {
fixture = TestBed.createComponent(TestComponent);
component = fixture.componentInstance;
api = TestBed.get(AlfrescoApiService);
api = TestBed.inject(AlfrescoApiService);
selection = { entry: { guid: 'guid', id: 'id' } };
});

View File

@@ -34,7 +34,7 @@ import {
import { SiteBody, FavoriteBody, FavoriteEntry, Site } from '@alfresco/js-api';
import { AlfrescoApiService } from '@alfresco/adf-core';
interface LibraryEntity {
export interface LibraryEntity {
entry: Site;
isLibrary: boolean;
isFavorite: boolean;

View File

@@ -67,7 +67,7 @@ describe('LockNodeDirective', () => {
fixture = TestBed.createComponent(TestComponent);
component = fixture.componentInstance;
component.selection = null;
api = TestBed.get(AlfrescoApiService);
api = TestBed.inject(AlfrescoApiService);
});
it('should return false if selection is null', () => {

View File

@@ -66,7 +66,7 @@ export function setupExtensions(service: AppExtensionService): Function {
imports: [CommonModule, CoreModule.forChild(), ExtensionsModule]
})
export class CoreExtensionsModule {
static forRoot(): ModuleWithProviders {
static forRoot(): ModuleWithProviders<CoreExtensionsModule> {
return {
ngModule: CoreExtensionsModule,
providers: [
@@ -80,7 +80,7 @@ export class CoreExtensionsModule {
};
}
static forChild(): ModuleWithProviders {
static forChild(): ModuleWithProviders<CoreExtensionsModule> {
return {
ngModule: CoreExtensionsModule
};

View File

@@ -80,16 +80,16 @@ describe('ContentManagementService', () => {
imports: [AppTestingModule, EffectsModule.forRoot([NodeEffects])]
});
contentApi = TestBed.get(ContentApiService);
actions$ = TestBed.get(Actions);
store = TestBed.get(Store);
contentManagementService = TestBed.get(ContentManagementService);
snackBar = TestBed.get(MatSnackBar);
nodeActions = TestBed.get(NodeActionsService);
translationService = TestBed.get(TranslationService);
alfrescoApiService = TestBed.get(AlfrescoApiService);
contentApi = TestBed.inject(ContentApiService);
actions$ = TestBed.inject(Actions);
store = TestBed.inject(Store);
contentManagementService = TestBed.inject(ContentManagementService);
snackBar = TestBed.inject(MatSnackBar);
nodeActions = TestBed.inject(NodeActionsService);
translationService = TestBed.inject(TranslationService);
alfrescoApiService = TestBed.inject(AlfrescoApiService);
dialog = TestBed.get(MatDialog);
dialog = TestBed.inject(MatDialog);
});
describe('Copy node action', () => {

View File

@@ -106,10 +106,13 @@ export class ContentManagementService {
addFavorite(nodes: Array<MinimalNodeEntity>) {
if (nodes && nodes.length > 0) {
this.contentApi.addFavorite(nodes).subscribe(() => {
nodes.forEach(node => {
node.entry.isFavorite = true;
const favoriteNodes = nodes.map(node => {
const newNode = JSON.parse(JSON.stringify(node));
newNode.entry.isFavorite = true;
return newNode;
});
this.store.dispatch(new SetSelectedNodesAction(nodes));
this.store.dispatch(new SetSelectedNodesAction(favoriteNodes));
});
}
}
@@ -117,10 +120,13 @@ export class ContentManagementService {
removeFavorite(nodes: Array<MinimalNodeEntity>) {
if (nodes && nodes.length > 0) {
this.contentApi.removeFavorite(nodes).subscribe(() => {
nodes.forEach(node => {
node.entry.isFavorite = false;
const favoriteNodes = nodes.map(node => {
const newNode = JSON.parse(JSON.stringify(node));
newNode.entry.isFavorite = false;
return newNode;
});
this.store.dispatch(new SetSelectedNodesAction(nodes));
this.store.dispatch(new SetSelectedNodesAction(favoriteNodes));
});
}
}

View File

@@ -133,11 +133,11 @@ describe('NodeActionsService', () => {
imports: [AppTestingModule]
});
contentApi = TestBed.get(ContentApiService);
contentApi = TestBed.inject(ContentApiService);
service = TestBed.get(NodeActionsService);
apiService = TestBed.get(AlfrescoApiService);
dialog = TestBed.get(MatDialog);
service = TestBed.inject(NodeActionsService);
apiService = TestBed.inject(AlfrescoApiService);
dialog = TestBed.inject(MatDialog);
apiService.reset();
nodesApi = apiService.getInstance().nodes;
@@ -400,7 +400,7 @@ describe('NodeActionsService', () => {
fileToCopy = new TestNode(fileId, isFile, 'file-name');
folderToCopy = new TestNode();
destinationFolder = new TestNode(folderDestinationId);
translationService = TestBed.get(TranslationService);
translationService = TestBed.inject(TranslationService);
spyOn(translationService, 'instant').and.callFake(key => {
return key;
@@ -472,7 +472,10 @@ describe('NodeActionsService', () => {
);
expect(translationService.instant).toHaveBeenCalledWith(
'NODE_SELECTOR.COPY_ITEMS',
{ name: '', number: 2 }
{
name: '',
number: 2
}
);
destinationFolder.entry['allowableOperations'] = ['update'];
@@ -508,7 +511,10 @@ describe('NodeActionsService', () => {
);
expect(translationService.instant).toHaveBeenCalledWith(
'NODE_SELECTOR.COPY_ITEM',
{ name: 'entry-name', number: 1 }
{
name: 'entry-name',
number: 1
}
);
});
@@ -537,7 +543,10 @@ describe('NodeActionsService', () => {
);
expect(translationService.instant).toHaveBeenCalledWith(
'NODE_SELECTOR.COPY_ITEMS',
{ name: '', number: 1 }
{
name: '',
number: 1
}
);
});
});
@@ -768,9 +777,9 @@ describe('NodeActionsService', () => {
spyOn(nodesApi, 'getNodeChildren').and.callFake(
helper.fakeGetNodeChildren(testFamilyNodes)
);
spyOn(service, 'getChildByName').and.returnValue(of(
existingFolder
) as any);
spyOn(service, 'getChildByName').and.returnValue(
of(existingFolder) as any
);
copyObservable
.toPromise()
@@ -868,9 +877,9 @@ describe('NodeActionsService', () => {
spyOn(nodesApi, 'getNodeChildren').and.callFake(
helper.fakeGetNodeChildren(testFamilyNodes)
);
spyOn(service, 'getChildByName').and.returnValue(of(
existingFolder
) as any);
spyOn(service, 'getChildByName').and.returnValue(
of(existingFolder) as any
);
copyObservable
.toPromise()
@@ -925,7 +934,7 @@ describe('NodeActionsService', () => {
folderToMove = new TestNode('fid', !isFile, 'folder-name');
destinationFolder = new TestNode(folderDestinationId);
documentListService = TestBed.get(DocumentListService);
documentListService = TestBed.inject(DocumentListService);
spyOnBatchOperation = spyOn(
service,
'doBatchOperation'
@@ -1439,9 +1448,7 @@ describe('NodeActionsService', () => {
}
];
testData.forEach(data => {
it(`new name should be \'${data.expected}\' for given name: \'${
data.name
}\', and baseName: \'${data.baseName}\'`, () => {
it(`new name should be \'${data.expected}\' for given name: \'${data.name}\', and baseName: \'${data.baseName}\'`, () => {
const result = service.getNewNameFrom(data.name, data.baseName);
expect(result).toBe(data.expected);
});
@@ -1468,9 +1475,7 @@ describe('NodeActionsService', () => {
];
testData.forEach(data => {
it(`flattened array should be \'${data.expected}\' for given data: \'${
data.nDimArray
}\'`, () => {
it(`flattened array should be \'${data.expected}\' for given data: \'${data.nDimArray}\'`, () => {
const result = service.flatten(data.nDimArray);
expect(result.length).toBe(data.expected.length);
@@ -1562,9 +1567,7 @@ describe('NodeActionsService', () => {
];
testData.forEach(response => {
it(`processed response should be \'${
response.expected
}\' for given input: \'${response.data}\'`, () => {
it(`processed response should be \'${response.expected}\' for given input: \'${response.data}\'`, () => {
const result = service.processResponse(response.data);
expect(JSON.stringify(result)).toEqual(

View File

@@ -57,10 +57,10 @@ describe('NodeTemplateService', () => {
]
});
store = TestBed.get(Store);
alfrescoApiService = TestBed.get(AlfrescoApiService);
dialog = TestBed.get(MatDialog);
nodeTemplateService = TestBed.get(NodeTemplateService);
store = TestBed.inject(Store);
alfrescoApiService = TestBed.inject(AlfrescoApiService);
dialog = TestBed.inject(MatDialog);
nodeTemplateService = TestBed.inject(NodeTemplateService);
});
it('should open dialog with parent node `id` as data property', fakeAsync(() => {

View File

@@ -26,7 +26,10 @@
import { NgModule } from '@angular/core';
import { StoreModule } from '@ngrx/store';
import { appReducer } from './reducers/app.reducer';
import { StoreRouterConnectingModule } from '@ngrx/router-store';
import {
StoreRouterConnectingModule,
DefaultRouterStateSerializer
} from '@ngrx/router-store';
import { EffectsModule } from '@ngrx/effects';
import { environment } from '../../environments/environment';
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
@@ -47,8 +50,20 @@ import { INITIAL_STATE } from './initial-state';
@NgModule({
imports: [
StoreModule.forRoot({ app: appReducer }, { initialState: INITIAL_STATE }),
StoreRouterConnectingModule.forRoot({ stateKey: 'router' }),
StoreModule.forRoot(
{ app: appReducer },
{
initialState: INITIAL_STATE,
runtimeChecks: {
strictStateImmutability: false,
strictActionImmutability: false
}
}
),
StoreRouterConnectingModule.forRoot({
serializer: DefaultRouterStateSerializer,
stateKey: 'router'
}),
SharedStoreModule,
EffectsModule.forRoot([
AppEffects,

View File

@@ -65,9 +65,10 @@ export class AppEffects {
logout$ = this.actions$.pipe(
ofType<LogoutAction>(AppActionTypes.Logout),
map(() => {
this.auth
.logout()
.subscribe(() => this.redirectToLogin(), () => this.redirectToLogin());
this.auth.logout().subscribe(
() => this.redirectToLogin(),
() => this.redirectToLogin()
);
})
);

View File

@@ -44,8 +44,8 @@ describe('ContextMenuEffects', () => {
providers: [ContextMenuService]
});
store = TestBed.get(Store);
contextMenuService = TestBed.get(ContextMenuService);
store = TestBed.inject(Store);
contextMenuService = TestBed.inject(ContextMenuService);
spyOn(overlayRefMock, 'close').and.callFake(() => {});
spyOn(contextMenuService, 'open').and.returnValue(overlayRefMock);

View File

@@ -64,15 +64,13 @@ describe('NodeEffects', () => {
SharedStoreModule,
EffectsModule.forRoot([NodeEffects, ViewerEffects])
],
declarations: [],
providers: [ViewUtilService]
});
// actions$ = TestBed.get(Actions);
store = TestBed.get(Store);
contentService = TestBed.get(ContentManagementService);
viewUtilService = TestBed.get(ViewUtilService);
viewerEffects = TestBed.get(ViewerEffects);
store = TestBed.inject(Store);
contentService = TestBed.inject(ContentManagementService);
viewUtilService = TestBed.inject(ViewUtilService);
viewerEffects = TestBed.inject(ViewerEffects);
});
describe('shareNode$', () => {
@@ -250,9 +248,11 @@ describe('NodeEffects', () => {
});
describe('createFolder$', () => {
it('should create folder from the payload', () => {
beforeEach(() => {
spyOn(contentService, 'createFolder').and.stub();
});
it('should create folder from the payload', () => {
const currentFolder = 'folder1';
store.dispatch(new CreateFolderAction(currentFolder));
@@ -260,8 +260,6 @@ describe('NodeEffects', () => {
});
it('should create folder in the active selected one', fakeAsync(() => {
spyOn(contentService, 'createFolder').and.stub();
const currentFolder: any = { isFolder: true, id: 'folder1' };
store.dispatch(new SetCurrentFolderAction(currentFolder));
@@ -272,14 +270,6 @@ describe('NodeEffects', () => {
currentFolder.id
);
}));
it('should do nothing if invoking delete with no data', () => {
spyOn(contentService, 'createFolder').and.stub();
store.dispatch(new CreateFolderAction(null));
expect(contentService.createFolder).not.toHaveBeenCalled();
});
});
describe('editFolder$', () => {

View File

@@ -43,8 +43,8 @@ describe('SearchEffects', () => {
imports: [AppTestingModule, EffectsModule.forRoot([SearchEffects])]
});
store = TestBed.get(Store);
router = TestBed.get(Router);
store = TestBed.inject(Store);
router = TestBed.inject(Router);
spyOn(router, 'navigateByUrl').and.stub();
});

View File

@@ -93,11 +93,11 @@ describe('TemplateEffects', () => {
]
});
store = TestBed.get(Store);
nodeTemplateService = TestBed.get(NodeTemplateService);
alfrescoApiService = TestBed.get(AlfrescoApiService);
contentManagementService = TestBed.get(ContentManagementService);
matDialog = TestBed.get(MatDialog);
store = TestBed.inject(Store);
nodeTemplateService = TestBed.inject(NodeTemplateService);
alfrescoApiService = TestBed.inject(AlfrescoApiService);
contentManagementService = TestBed.inject(ContentManagementService);
matDialog = TestBed.inject(MatDialog);
subject = new Subject<Node[]>();
spyOn(store, 'dispatch').and.callThrough();

View File

@@ -52,15 +52,15 @@ describe('UploadEffects', () => {
imports: [AppTestingModule, EffectsModule.forRoot([UploadEffects])]
});
zone = TestBed.get(NgZone);
zone = TestBed.inject(NgZone);
spyOn(zone, 'run').and.callFake((fn: () => any) => {
return fn();
});
contentManagementService = TestBed.get(ContentManagementService);
store = TestBed.get(Store);
uploadService = TestBed.get(UploadService);
effects = TestBed.get(UploadEffects);
contentManagementService = TestBed.inject(ContentManagementService);
store = TestBed.inject(Store);
uploadService = TestBed.inject(UploadService);
effects = TestBed.inject(UploadEffects);
});
beforeEach(() => {
@@ -195,14 +195,14 @@ describe('UploadEffects', () => {
lastModified: 1589273450599,
size: 1351,
slice: null
}),
} as File),
entry: new FileModel({
name: 'Fake New file',
type: 'image/png',
lastModified: 1589273450599,
size: 1351,
slice: null
})
} as File)
}
],
data: {

View File

@@ -45,8 +45,8 @@ describe('ViewerEffects', () => {
imports: [AppTestingModule, EffectsModule.forRoot([ViewerEffects])]
});
store = TestBed.get(Store);
router = TestBed.get(Router);
store = TestBed.inject(Store);
router = TestBed.inject(Router);
spyOn(router, 'navigateByUrl').and.stub();
});

View File

@@ -107,32 +107,35 @@ export function appReducer(
newState = hideSearchFilter(state);
break;
default:
newState = Object.assign({}, state);
newState = { ...state };
}
return newState;
}
function toggleSearchFilter(state: AppState): AppState {
const newState = Object.assign({}, state);
newState.showFacetFilter = !newState.showFacetFilter;
return newState;
return {
...state,
showFacetFilter: !state.showFacetFilter
};
}
function hideSearchFilter(state: AppState): AppState {
const newState = Object.assign({}, state);
newState.showFacetFilter = false;
return newState;
return {
...state,
showFacetFilter: false
};
}
function showSearchFilter(state: AppState): AppState {
const newState = Object.assign({}, state);
newState.showFacetFilter = true;
return newState;
return {
...state,
showFacetFilter: true
};
}
function updateUser(state: AppState, action: SetUserProfileAction): AppState {
const newState = Object.assign({}, state);
const newState = { ...state };
const user = action.payload.person;
const groups = [...(action.payload.groups || [])];
@@ -159,19 +162,19 @@ function updateUser(state: AppState, action: SetUserProfileAction): AppState {
}
function updateCurrentFolder(state: AppState, action: SetCurrentFolderAction) {
const newState = Object.assign({}, state);
const newState = { ...state };
newState.navigation.currentFolder = action.payload;
return newState;
}
function updateCurrentUrl(state: AppState, action: SetCurrentUrlAction) {
const newState = Object.assign({}, state);
const newState = { ...state };
newState.navigation.url = action.payload;
return newState;
}
function toggleInfoDrawer(state: AppState) {
const newState = Object.assign({}, state);
const newState = { ...state };
let value = state.infoDrawerOpened;
if (state.selection.isEmpty) {
@@ -186,17 +189,18 @@ function toggleInfoDrawer(state: AppState) {
}
function toggleDocumentDisplayMode(state: AppState) {
const newState = Object.assign({}, state);
newState.documentDisplayMode =
newState.documentDisplayMode === 'list' ? 'gallery' : 'list';
return newState;
return {
...state,
documentDisplayMode:
state.documentDisplayMode === 'list' ? 'gallery' : 'list'
};
}
function updateSelectedNodes(
state: AppState,
action: SetSelectedNodesAction
): AppState {
const newState = Object.assign({}, state);
const newState = { ...state };
const nodes = [...action.payload];
const count = nodes.length;
const isEmpty = nodes.length === 0;
@@ -228,7 +232,7 @@ function updateSelectedNodes(
(node: any) => node.isLibrary
);
if (libraries.length === 1) {
library = libraries[0];
library = libraries[0] as any;
}
if (isEmpty) {
@@ -250,25 +254,27 @@ function updateSelectedNodes(
}
function setInfoDrawer(state: AppState, action: SetInfoDrawerStateAction) {
const newState = Object.assign({}, state);
newState.infoDrawerOpened = action.payload;
return newState;
return {
...state,
infoDrawerOpened: action.payload
};
}
function setInfoDrawerAspect(
state: AppState,
action: SetInfoDrawerMetadataAspectAction
) {
const newState = Object.assign({}, state);
newState.infoDrawerMetadataAspect = action.payload;
return newState;
return {
...state,
infoDrawerMetadataAspect: action.payload
};
}
function updateRepositoryStatus(
state: AppState,
action: SetRepositoryInfoAction
) {
const newState = Object.assign({}, state);
const newState = { ...state };
newState.repository = action.payload;
return newState;
}

View File

@@ -63,7 +63,16 @@ import { TranslateServiceMock } from './translation.service';
HttpClientModule,
RouterTestingModule,
MaterialModule,
StoreModule.forRoot({ app: appReducer }, { initialState: INITIAL_STATE }),
StoreModule.forRoot(
{ app: appReducer },
{
initialState: INITIAL_STATE,
runtimeChecks: {
strictStateImmutability: false,
strictActionImmutability: false
}
}
),
EffectsModule.forRoot([]),
PipeModule
],

View File

@@ -30,7 +30,7 @@ import { Observable, of } from 'rxjs';
@Injectable()
export class TranslateServiceMock extends TranslateService {
constructor() {
super(null, null, null, null, null);
super(null, null, null, null, null, null, null, null, null);
}
get(