AAE-37293 switch to provider api (#4735)

This commit is contained in:
Denys Vuika
2025-08-08 08:58:59 -04:00
committed by GitHub
parent 38fd3547eb
commit 0b6604a43e
14 changed files with 61 additions and 154 deletions
@@ -24,7 +24,7 @@
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { RuleSetPickerOptions, RuleSetPickerSmartComponent } from './rule-set-picker.smart-component';
import { NoopAuthModule, NoopTranslateModule, NotificationService, UnitTestingUtils } from '@alfresco/adf-core';
import { NoopTranslateModule, NotificationService, provideCoreAuthTesting, UnitTestingUtils } from '@alfresco/adf-core';
import { folderToLinkMock, otherFolderMock } from '../mock/node.mock';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { of } from 'rxjs';
@@ -76,9 +76,10 @@ describe('RuleSetPickerSmartComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [NoopTranslateModule, NoopAuthModule, RuleSetPickerSmartComponent],
imports: [NoopTranslateModule, RuleSetPickerSmartComponent],
providers: [
provideRouter([]),
provideCoreAuthTesting(),
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
{ provide: MatDialogRef, useValue: dialogRef },
{ provide: MAT_DIALOG_DATA, useValue: dialogOptions },
@@ -24,7 +24,7 @@
import { TestBed } from '@angular/core/testing';
import { AosEditOnlineService } from './aos-extension.service';
import { AppConfigService, AuthenticationService, AuthModule, NotificationService } from '@alfresco/adf-core';
import { AppConfigService, AuthenticationService, NotificationService, provideCoreAuthTesting } from '@alfresco/adf-core';
import { LibTestingModule } from '@alfresco/aca-shared';
import { MatSnackBarModule } from '@angular/material/snack-bar';
@@ -37,7 +37,8 @@ describe('AosEditOnlineService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [LibTestingModule, MatSnackBarModule, AuthModule.forRoot()]
imports: [LibTestingModule, MatSnackBarModule],
providers: [provideCoreAuthTesting()]
});
aosEditOnlineService = TestBed.inject(AosEditOnlineService);
@@ -27,7 +27,7 @@ import { Overlay } from '@angular/cdk/overlay';
import { Injector } from '@angular/core';
import { Store } from '@ngrx/store';
import { of } from 'rxjs';
import { NoopTranslateModule, UserPreferencesService, NoopAuthModule } from '@alfresco/adf-core';
import { NoopTranslateModule, UserPreferencesService, provideCoreAuthTesting } from '@alfresco/adf-core';
import { ContextMenuService } from './context-menu.service';
import { ContextMenuComponent } from './context-menu.component';
import { ContextmenuOverlayConfig } from './interfaces';
@@ -62,8 +62,8 @@ describe('ContextMenuService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [NoopTranslateModule, ContextMenuComponent, NoopAuthModule],
providers: [Overlay, { provide: Store, useValue: { select: () => of() } }, UserPreferencesService]
imports: [NoopTranslateModule, ContextMenuComponent],
providers: [provideCoreAuthTesting(), Overlay, { provide: Store, useValue: { select: () => of() } }, UserPreferencesService]
});
injector = TestBed.inject(Injector);
@@ -92,7 +92,7 @@ describe('ContextMenuService', () => {
contextMenuService.open(overlayConfig);
expect(document.body.querySelector('div[dir="ltr"]')).not.toBe(null);
expect(document.body.querySelector('div[dir="ltr"]')).not.toEqual(null);
});
it('should change direction on textOrientation event', () => {
@@ -27,17 +27,13 @@ import { AppTestingModule } from '../../testing/app-testing.module';
import { DetailsComponent } from './details.component';
import { ActivatedRoute } from '@angular/router';
import { BehaviorSubject, of, Subject } from 'rxjs';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { Store } from '@ngrx/store';
import { AppExtensionService, AppHookService, ContentApiService } from '@alfresco/aca-shared';
import { NavigateToFolder, SetSelectedNodesAction } from '@alfresco/aca-shared/store';
import { Node, NodeEntry, PathElement } from '@alfresco/js-api';
import { RouterTestingModule } from '@angular/router/testing';
import { AuthenticationService, CORE_PIPES, PageTitleService } from '@alfresco/adf-core';
import { BreadcrumbComponent, ContentService, NodesApiService, SearchQueryBuilderService } from '@alfresco/adf-content-services';
import { By } from '@angular/platform-browser';
import { ContentActionRef } from '@alfresco/adf-extensions';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { Location } from '@angular/common';
describe('DetailsComponent', () => {
@@ -63,9 +59,8 @@ describe('DetailsComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [AppTestingModule, DetailsComponent, ...CORE_PIPES, MatSnackBarModule],
imports: [AppTestingModule, DetailsComponent],
providers: [
RouterTestingModule,
SearchQueryBuilderService,
{ provide: Store, useValue: storeMock },
{
@@ -74,22 +69,8 @@ describe('DetailsComponent', () => {
snapshot: { data: { preferencePrefix: 'prefix' } },
params: of({ nodeId: 'someId', activeTab: 'permissions' })
}
},
{
provide: PageTitleService,
useValue: {}
},
{
provide: AuthenticationService,
useValue: {
onLogin: new Subject<any>(),
onLogout: new Subject<any>(),
isLoggedIn: () => true
}
},
...CORE_PIPES
],
schemas: [NO_ERRORS_SCHEMA]
}
]
});
const appExtensionService = TestBed.inject(AppExtensionService);
@@ -25,13 +25,11 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { DatatableCellBadgesComponent } from './datatable-cell-badges.component';
import { AppExtensionService } from '@alfresco/aca-shared';
import { NoopAuthModule, NoopTranslateModule } from '@alfresco/adf-core';
import { Actions } from '@ngrx/effects';
import { NoopTranslateModule, provideCoreAuthTesting } from '@alfresco/adf-core';
import { NodeEntry } from '@alfresco/js-api';
import { of } from 'rxjs';
import { By } from '@angular/platform-browser';
import { ContentActionType } from '@alfresco/adf-extensions';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { provideStore } from '@ngrx/store';
const mockNode = {
@@ -55,10 +53,9 @@ describe('DatatableCellBadgesComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [NoopTranslateModule, NoopAuthModule, DatatableCellBadgesComponent],
imports: [NoopTranslateModule, DatatableCellBadgesComponent],
providers: [
Actions,
provideHttpClient(withInterceptorsFromDi()),
provideCoreAuthTesting(),
provideStore(
{ app: (state) => state },
{
@@ -23,23 +23,10 @@
*/
import { CustomNameColumnComponent } from './name-column.component';
import { Actions } from '@ngrx/effects';
import { provideStore } from '@ngrx/store';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { By } from '@angular/platform-browser';
import { AuthModule, NoopTranslateModule } from '@alfresco/adf-core';
import { Component, Input } from '@angular/core';
import { NodeEntry } from '@alfresco/js-api';
@Component({
selector: 'aca-datatable-cell-badges',
standalone: true,
template: ''
})
class MockDatatableCellBadgesComponent {
@Input() node: NodeEntry;
}
import { NoopTranslateModule, provideCoreAuth } from '@alfresco/adf-core';
describe('CustomNameColumnComponent', () => {
let fixture: ComponentFixture<CustomNameColumnComponent>;
@@ -47,10 +34,9 @@ describe('CustomNameColumnComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [NoopTranslateModule, CustomNameColumnComponent, MockDatatableCellBadgesComponent, AuthModule.forRoot()],
imports: [NoopTranslateModule, CustomNameColumnComponent],
providers: [
Actions,
provideHttpClient(withInterceptorsFromDi()),
provideCoreAuth(),
provideStore(
{ app: (state) => state },
{
@@ -28,8 +28,8 @@ import { AppSettingsService } from '@alfresco/aca-shared';
import { VersionListDataSource, VersionManagerComponent } from '@alfresco/adf-content-services';
import { By } from '@angular/platform-browser';
import { of } from 'rxjs';
import { NoopAuthModule, NoopTranslateModule } from '@alfresco/adf-core';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { NoopTranslateModule, provideCoreAuthTesting } from '@alfresco/adf-core';
import { provideNoopAnimations } from '@angular/platform-browser/animations';
describe('VersionsTabComponent', () => {
let component: VersionsTabComponent;
@@ -38,7 +38,8 @@ describe('VersionsTabComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [NoopTranslateModule, NoopAuthModule, NoopAnimationsModule, VersionsTabComponent]
imports: [NoopTranslateModule, VersionsTabComponent],
providers: [provideNoopAnimations(), provideCoreAuthTesting()]
});
fixture = TestBed.createComponent(VersionsTabComponent);
@@ -23,7 +23,7 @@
*/
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { NoopAuthModule, NoopTranslateModule } from '@alfresco/adf-core';
import { NoopTranslateModule, provideCoreAuthTesting } from '@alfresco/adf-core';
import { BehaviorSubject, ReplaySubject, Subject } from 'rxjs';
import { By } from '@angular/platform-browser';
import { SavedSearchesService, SavedSearch } from '@alfresco/adf-content-services';
@@ -56,8 +56,9 @@ describe('SavedSearchesSmartListComponent', () => {
infoDrawerOpened: false
};
TestBed.configureTestingModule({
imports: [NoopTranslateModule, NoopAuthModule, SavedSearchesSmartListComponent],
imports: [NoopTranslateModule, SavedSearchesSmartListComponent],
providers: [
provideCoreAuthTesting(),
provideMockStore({
initialState: { app: appState }
}),
@@ -23,27 +23,27 @@
*/
import { NgModule } from '@angular/core';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { AuthenticationService, NoopTranslateModule, PageTitleService } from '@alfresco/adf-core';
import { provideNoopAnimations } from '@angular/platform-browser/animations';
import { NoopTranslateModule, PageTitleService, provideCoreAuthTesting } from '@alfresco/adf-core';
import { AlfrescoApiService, AlfrescoApiServiceMock, DiscoveryApiService, SearchQueryBuilderService } from '@alfresco/adf-content-services';
import { RepositoryInfo, VersionInfo } from '@alfresco/js-api';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { provideStore } from '@ngrx/store';
import { appReducer } from '../store/reducers/app.reducer';
import { RouterTestingModule } from '@angular/router/testing';
import { provideEffects } from '@ngrx/effects';
import { INITIAL_STATE } from '../store/initial-state';
import { BehaviorSubject, Observable, of, Subject } from 'rxjs';
import { BehaviorSubject, Observable, of } from 'rxjs';
import { ContentManagementService } from '../services/content-management.service';
import { DocumentBasePageService } from '@alfresco/aca-shared';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { MatDialogModule } from '@angular/material/dialog';
import { MatIconTestingModule } from '@angular/material/icon/testing';
import { provideRouter } from '@angular/router';
@NgModule({
exports: [RouterTestingModule],
imports: [NoopAnimationsModule, NoopTranslateModule, RouterTestingModule, MatSnackBarModule, MatDialogModule, MatIconTestingModule],
imports: [NoopTranslateModule, MatSnackBarModule, MatDialogModule, MatIconTestingModule],
providers: [
provideNoopAnimations(),
provideRouter([]),
provideStore(
{ app: appReducer },
{
@@ -72,24 +72,11 @@ import { MatIconTestingModule } from '@angular/material/icon/testing';
)
}
},
{
provide: AuthenticationService,
useValue: {
isEcmLoggedIn: (): boolean => true,
getRedirect: (): string | null => null,
setRedirect() {},
isOauth: (): boolean => false,
isOAuthWithoutSilentLogin: (): boolean => false,
onLogin: new Subject<any>(),
onLogout: new Subject<any>(),
isLoggedIn: () => true
}
},
provideCoreAuthTesting(),
{
provide: PageTitleService,
useValue: {}
},
provideHttpClient(withInterceptorsFromDi())
}
]
})
export class AppTestingModule {}