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
+12 -45
View File
@@ -22,18 +22,9 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>. * from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { importProvidersFrom, ApplicationConfig, Provider, EnvironmentProviders } from '@angular/core'; import { importProvidersFrom, ApplicationConfig } from '@angular/core';
import { provideNoopAnimations, provideAnimations } from '@angular/platform-browser/animations'; import { provideNoopAnimations, provideAnimations } from '@angular/platform-browser/animations';
import { import { AuthGuard, provideAppConfig, provideCoreAuth, provideI18N } from '@alfresco/adf-core';
AuthGuard,
AuthModule,
provideTranslations,
provideAppConfig,
FORM_FIELD_MODEL_RENDER_MIDDLEWARE,
DecimalRenderMiddlewareService,
AuthenticationService,
TranslateLoaderService
} from '@alfresco/adf-core';
import { AppService, provideContentAppExtensions } from '@alfresco/aca-shared'; import { AppService, provideContentAppExtensions } from '@alfresco/aca-shared';
import { provideApplicationExtensions } from './extensions.module'; import { provideApplicationExtensions } from './extensions.module';
import { environment } from '../environments/environment'; import { environment } from '../environments/environment';
@@ -59,10 +50,7 @@ import { CONTENT_LAYOUT_ROUTES, ContentServiceExtensionModule, ContentUrlService
import { ContentVersionService } from '@alfresco/adf-content-services'; import { ContentVersionService } from '@alfresco/adf-content-services';
import { SHELL_APP_SERVICE, SHELL_AUTH_TOKEN, provideShellRoutes } from '@alfresco/adf-core/shell'; import { SHELL_APP_SERVICE, SHELL_AUTH_TOKEN, provideShellRoutes } from '@alfresco/adf-core/shell';
import { APP_ROUTES } from './app.routes'; import { APP_ROUTES } from './app.routes';
import { HTTP_INTERCEPTORS, HttpClient, provideHttpClient, withInterceptorsFromDi, withXsrfConfiguration } from '@angular/common/http';
import { MAT_SNACK_BAR_DEFAULT_OPTIONS } from '@angular/material/snack-bar'; import { MAT_SNACK_BAR_DEFAULT_OPTIONS } from '@angular/material/snack-bar';
import { Authentication, AuthenticationInterceptor } from '@alfresco/adf-core/auth';
import { provideTranslateService, TranslateLoader } from '@ngx-translate/core';
registerLocaleData(localeFr); registerLocaleData(localeFr);
registerLocaleData(localeDe); registerLocaleData(localeDe);
@@ -81,40 +69,14 @@ registerLocaleData(localeFi);
registerLocaleData(localeDa); registerLocaleData(localeDa);
registerLocaleData(localeSv); registerLocaleData(localeSv);
/* The replacement for the CoreModule.forRoot() */
function provideAdfCore(): (Provider | EnvironmentProviders)[] {
return [
provideAppConfig(),
provideHttpClient(withInterceptorsFromDi(), withXsrfConfiguration({ cookieName: 'CSRF-TOKEN', headerName: 'X-CSRF-TOKEN' })),
{ provide: HTTP_INTERCEPTORS, useClass: AuthenticationInterceptor, multi: true },
{ provide: Authentication, useClass: AuthenticationService },
{
provide: MAT_SNACK_BAR_DEFAULT_OPTIONS,
useValue: {
duration: 10000
}
},
{
provide: FORM_FIELD_MODEL_RENDER_MIDDLEWARE,
useClass: DecimalRenderMiddlewareService,
multi: true
}
];
}
export const AppConfig: ApplicationConfig = { export const AppConfig: ApplicationConfig = {
providers: [ providers: [
importProvidersFrom(AuthModule.forRoot({ useHash: true })), provideCoreAuth({ useHash: true }),
provideAppConfig(),
importProvidersFrom(ContentServiceExtensionModule), importProvidersFrom(ContentServiceExtensionModule),
provideTranslateService({ provideI18N({
loader: { assets: [['app', 'assets']]
provide: TranslateLoader,
useClass: TranslateLoaderService,
deps: [HttpClient]
},
defaultLanguage: 'en'
}), }),
provideAdfCore(),
provideContentAppExtensions(), provideContentAppExtensions(),
provideApplicationExtensions(), provideApplicationExtensions(),
provideRouter(APP_ROUTES, withHashLocation()), provideRouter(APP_ROUTES, withHashLocation()),
@@ -129,6 +91,11 @@ export const AppConfig: ApplicationConfig = {
provide: SHELL_AUTH_TOKEN, provide: SHELL_AUTH_TOKEN,
useValue: AuthGuard useValue: AuthGuard
}, },
provideTranslations('app', 'assets') {
provide: MAT_SNACK_BAR_DEFAULT_OPTIONS,
useValue: {
duration: 10000
}
}
] ]
}; };
@@ -24,7 +24,7 @@
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { RuleSetPickerOptions, RuleSetPickerSmartComponent } from './rule-set-picker.smart-component'; 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 { folderToLinkMock, otherFolderMock } from '../mock/node.mock';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { of } from 'rxjs'; import { of } from 'rxjs';
@@ -76,9 +76,10 @@ describe('RuleSetPickerSmartComponent', () => {
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [NoopTranslateModule, NoopAuthModule, RuleSetPickerSmartComponent], imports: [NoopTranslateModule, RuleSetPickerSmartComponent],
providers: [ providers: [
provideRouter([]), provideRouter([]),
provideCoreAuthTesting(),
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }, { provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
{ provide: MatDialogRef, useValue: dialogRef }, { provide: MatDialogRef, useValue: dialogRef },
{ provide: MAT_DIALOG_DATA, useValue: dialogOptions }, { provide: MAT_DIALOG_DATA, useValue: dialogOptions },
@@ -24,7 +24,7 @@
import { TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { AosEditOnlineService } from './aos-extension.service'; 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 { LibTestingModule } from '@alfresco/aca-shared';
import { MatSnackBarModule } from '@angular/material/snack-bar'; import { MatSnackBarModule } from '@angular/material/snack-bar';
@@ -37,7 +37,8 @@ describe('AosEditOnlineService', () => {
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [LibTestingModule, MatSnackBarModule, AuthModule.forRoot()] imports: [LibTestingModule, MatSnackBarModule],
providers: [provideCoreAuthTesting()]
}); });
aosEditOnlineService = TestBed.inject(AosEditOnlineService); aosEditOnlineService = TestBed.inject(AosEditOnlineService);
@@ -27,7 +27,7 @@ import { Overlay } from '@angular/cdk/overlay';
import { Injector } from '@angular/core'; import { Injector } from '@angular/core';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { of } from 'rxjs'; 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 { ContextMenuService } from './context-menu.service';
import { ContextMenuComponent } from './context-menu.component'; import { ContextMenuComponent } from './context-menu.component';
import { ContextmenuOverlayConfig } from './interfaces'; import { ContextmenuOverlayConfig } from './interfaces';
@@ -62,8 +62,8 @@ describe('ContextMenuService', () => {
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [NoopTranslateModule, ContextMenuComponent, NoopAuthModule], imports: [NoopTranslateModule, ContextMenuComponent],
providers: [Overlay, { provide: Store, useValue: { select: () => of() } }, UserPreferencesService] providers: [provideCoreAuthTesting(), Overlay, { provide: Store, useValue: { select: () => of() } }, UserPreferencesService]
}); });
injector = TestBed.inject(Injector); injector = TestBed.inject(Injector);
@@ -92,7 +92,7 @@ describe('ContextMenuService', () => {
contextMenuService.open(overlayConfig); 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', () => { it('should change direction on textOrientation event', () => {
@@ -27,17 +27,13 @@ import { AppTestingModule } from '../../testing/app-testing.module';
import { DetailsComponent } from './details.component'; import { DetailsComponent } from './details.component';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { BehaviorSubject, of, Subject } from 'rxjs'; import { BehaviorSubject, of, Subject } from 'rxjs';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { AppExtensionService, AppHookService, ContentApiService } from '@alfresco/aca-shared'; import { AppExtensionService, AppHookService, ContentApiService } from '@alfresco/aca-shared';
import { NavigateToFolder, SetSelectedNodesAction } from '@alfresco/aca-shared/store'; import { NavigateToFolder, SetSelectedNodesAction } from '@alfresco/aca-shared/store';
import { Node, NodeEntry, PathElement } from '@alfresco/js-api'; 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 { BreadcrumbComponent, ContentService, NodesApiService, SearchQueryBuilderService } from '@alfresco/adf-content-services';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { ContentActionRef } from '@alfresco/adf-extensions'; import { ContentActionRef } from '@alfresco/adf-extensions';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { Location } from '@angular/common'; import { Location } from '@angular/common';
describe('DetailsComponent', () => { describe('DetailsComponent', () => {
@@ -63,9 +59,8 @@ describe('DetailsComponent', () => {
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [AppTestingModule, DetailsComponent, ...CORE_PIPES, MatSnackBarModule], imports: [AppTestingModule, DetailsComponent],
providers: [ providers: [
RouterTestingModule,
SearchQueryBuilderService, SearchQueryBuilderService,
{ provide: Store, useValue: storeMock }, { provide: Store, useValue: storeMock },
{ {
@@ -74,22 +69,8 @@ describe('DetailsComponent', () => {
snapshot: { data: { preferencePrefix: 'prefix' } }, snapshot: { data: { preferencePrefix: 'prefix' } },
params: of({ nodeId: 'someId', activeTab: 'permissions' }) 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); const appExtensionService = TestBed.inject(AppExtensionService);
@@ -25,13 +25,11 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { DatatableCellBadgesComponent } from './datatable-cell-badges.component'; import { DatatableCellBadgesComponent } from './datatable-cell-badges.component';
import { AppExtensionService } from '@alfresco/aca-shared'; import { AppExtensionService } from '@alfresco/aca-shared';
import { NoopAuthModule, NoopTranslateModule } from '@alfresco/adf-core'; import { NoopTranslateModule, provideCoreAuthTesting } from '@alfresco/adf-core';
import { Actions } from '@ngrx/effects';
import { NodeEntry } from '@alfresco/js-api'; import { NodeEntry } from '@alfresco/js-api';
import { of } from 'rxjs'; import { of } from 'rxjs';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { ContentActionType } from '@alfresco/adf-extensions'; import { ContentActionType } from '@alfresco/adf-extensions';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { provideStore } from '@ngrx/store'; import { provideStore } from '@ngrx/store';
const mockNode = { const mockNode = {
@@ -55,10 +53,9 @@ describe('DatatableCellBadgesComponent', () => {
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [NoopTranslateModule, NoopAuthModule, DatatableCellBadgesComponent], imports: [NoopTranslateModule, DatatableCellBadgesComponent],
providers: [ providers: [
Actions, provideCoreAuthTesting(),
provideHttpClient(withInterceptorsFromDi()),
provideStore( provideStore(
{ app: (state) => state }, { app: (state) => state },
{ {
@@ -23,23 +23,10 @@
*/ */
import { CustomNameColumnComponent } from './name-column.component'; import { CustomNameColumnComponent } from './name-column.component';
import { Actions } from '@ngrx/effects';
import { provideStore } from '@ngrx/store'; import { provideStore } from '@ngrx/store';
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { AuthModule, NoopTranslateModule } from '@alfresco/adf-core'; import { NoopTranslateModule, provideCoreAuth } 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;
}
describe('CustomNameColumnComponent', () => { describe('CustomNameColumnComponent', () => {
let fixture: ComponentFixture<CustomNameColumnComponent>; let fixture: ComponentFixture<CustomNameColumnComponent>;
@@ -47,10 +34,9 @@ describe('CustomNameColumnComponent', () => {
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [NoopTranslateModule, CustomNameColumnComponent, MockDatatableCellBadgesComponent, AuthModule.forRoot()], imports: [NoopTranslateModule, CustomNameColumnComponent],
providers: [ providers: [
Actions, provideCoreAuth(),
provideHttpClient(withInterceptorsFromDi()),
provideStore( provideStore(
{ app: (state) => state }, { app: (state) => state },
{ {
@@ -28,8 +28,8 @@ import { AppSettingsService } from '@alfresco/aca-shared';
import { VersionListDataSource, VersionManagerComponent } from '@alfresco/adf-content-services'; import { VersionListDataSource, VersionManagerComponent } from '@alfresco/adf-content-services';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { of } from 'rxjs'; import { of } from 'rxjs';
import { NoopAuthModule, NoopTranslateModule } from '@alfresco/adf-core'; import { NoopTranslateModule, provideCoreAuthTesting } from '@alfresco/adf-core';
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { provideNoopAnimations } from '@angular/platform-browser/animations';
describe('VersionsTabComponent', () => { describe('VersionsTabComponent', () => {
let component: VersionsTabComponent; let component: VersionsTabComponent;
@@ -38,7 +38,8 @@ describe('VersionsTabComponent', () => {
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [NoopTranslateModule, NoopAuthModule, NoopAnimationsModule, VersionsTabComponent] imports: [NoopTranslateModule, VersionsTabComponent],
providers: [provideNoopAnimations(), provideCoreAuthTesting()]
}); });
fixture = TestBed.createComponent(VersionsTabComponent); fixture = TestBed.createComponent(VersionsTabComponent);
@@ -23,7 +23,7 @@
*/ */
import { ComponentFixture, TestBed } from '@angular/core/testing'; 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 { BehaviorSubject, ReplaySubject, Subject } from 'rxjs';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { SavedSearchesService, SavedSearch } from '@alfresco/adf-content-services'; import { SavedSearchesService, SavedSearch } from '@alfresco/adf-content-services';
@@ -56,8 +56,9 @@ describe('SavedSearchesSmartListComponent', () => {
infoDrawerOpened: false infoDrawerOpened: false
}; };
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [NoopTranslateModule, NoopAuthModule, SavedSearchesSmartListComponent], imports: [NoopTranslateModule, SavedSearchesSmartListComponent],
providers: [ providers: [
provideCoreAuthTesting(),
provideMockStore({ provideMockStore({
initialState: { app: appState } initialState: { app: appState }
}), }),
@@ -23,27 +23,27 @@
*/ */
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { provideNoopAnimations } from '@angular/platform-browser/animations';
import { AuthenticationService, NoopTranslateModule, PageTitleService } from '@alfresco/adf-core'; import { NoopTranslateModule, PageTitleService, provideCoreAuthTesting } from '@alfresco/adf-core';
import { AlfrescoApiService, AlfrescoApiServiceMock, DiscoveryApiService, SearchQueryBuilderService } from '@alfresco/adf-content-services'; import { AlfrescoApiService, AlfrescoApiServiceMock, DiscoveryApiService, SearchQueryBuilderService } from '@alfresco/adf-content-services';
import { RepositoryInfo, VersionInfo } from '@alfresco/js-api'; import { RepositoryInfo, VersionInfo } from '@alfresco/js-api';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { provideStore } from '@ngrx/store'; import { provideStore } from '@ngrx/store';
import { appReducer } from '../store/reducers/app.reducer'; import { appReducer } from '../store/reducers/app.reducer';
import { RouterTestingModule } from '@angular/router/testing';
import { provideEffects } from '@ngrx/effects'; import { provideEffects } from '@ngrx/effects';
import { INITIAL_STATE } from '../store/initial-state'; 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 { ContentManagementService } from '../services/content-management.service';
import { DocumentBasePageService } from '@alfresco/aca-shared'; import { DocumentBasePageService } from '@alfresco/aca-shared';
import { MatSnackBarModule } from '@angular/material/snack-bar'; import { MatSnackBarModule } from '@angular/material/snack-bar';
import { MatDialogModule } from '@angular/material/dialog'; import { MatDialogModule } from '@angular/material/dialog';
import { MatIconTestingModule } from '@angular/material/icon/testing'; import { MatIconTestingModule } from '@angular/material/icon/testing';
import { provideRouter } from '@angular/router';
@NgModule({ @NgModule({
exports: [RouterTestingModule], imports: [NoopTranslateModule, MatSnackBarModule, MatDialogModule, MatIconTestingModule],
imports: [NoopAnimationsModule, NoopTranslateModule, RouterTestingModule, MatSnackBarModule, MatDialogModule, MatIconTestingModule],
providers: [ providers: [
provideNoopAnimations(),
provideRouter([]),
provideStore( provideStore(
{ app: appReducer }, { app: appReducer },
{ {
@@ -72,24 +72,11 @@ import { MatIconTestingModule } from '@angular/material/icon/testing';
) )
} }
}, },
{ provideCoreAuthTesting(),
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
}
},
{ {
provide: PageTitleService, provide: PageTitleService,
useValue: {} useValue: {}
}, }
provideHttpClient(withInterceptorsFromDi())
] ]
}) })
export class AppTestingModule {} export class AppTestingModule {}
@@ -25,14 +25,14 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PageComponent } from './document-base-page.component'; import { PageComponent } from './document-base-page.component';
import { AppState, SetSelectedNodesAction, ViewNodeAction } from '@alfresco/aca-shared/store'; import { AppState, SetSelectedNodesAction, ViewNodeAction } from '@alfresco/aca-shared/store';
import { AppExtensionService, LibTestingModule, discoveryApiServiceMockValue, DocumentBasePageServiceMock } from '@alfresco/aca-shared'; import { LibTestingModule, discoveryApiServiceMockValue, DocumentBasePageServiceMock } from '@alfresco/aca-shared';
import { NodeEntry, NodePaging } from '@alfresco/js-api'; import { NodeEntry, NodePaging } from '@alfresco/js-api';
import { DocumentBasePageService } from './document-base-page.service'; import { DocumentBasePageService } from './document-base-page.service';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { DiscoveryApiService, DocumentListComponent, DocumentListService, SearchAiInputState, SearchAiService } from '@alfresco/adf-content-services'; import { DiscoveryApiService, DocumentListComponent, DocumentListService, SearchAiInputState, SearchAiService } from '@alfresco/adf-content-services';
import { MockStore, provideMockStore } from '@ngrx/store/testing'; import { MockStore, provideMockStore } from '@ngrx/store/testing';
import { AuthModule, UserPreferencesService } from '@alfresco/adf-core'; import { provideCoreAuth, UserPreferencesService } from '@alfresco/adf-core';
import { of, Subscription } from 'rxjs'; import { of, Subscription } from 'rxjs';
import { MatDialogModule } from '@angular/material/dialog'; import { MatDialogModule } from '@angular/material/dialog';
import { NavigationHistoryService } from '../../services/navigation-history.service'; import { NavigationHistoryService } from '../../services/navigation-history.service';
@@ -76,12 +76,12 @@ describe('PageComponent', () => {
searchAiService.toggleSearchAiInput$ = of({ active: false }); searchAiService.toggleSearchAiInput$ = of({ active: false });
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [LibTestingModule, AuthModule.forRoot(), MatDialogModule], imports: [LibTestingModule, MatDialogModule],
declarations: [TestComponent], declarations: [TestComponent],
providers: [ providers: [
provideCoreAuth(),
{ provide: DocumentBasePageService, useClass: DocumentBasePageServiceMock }, { provide: DocumentBasePageService, useClass: DocumentBasePageServiceMock },
{ provide: DiscoveryApiService, useValue: discoveryApiServiceMockValue }, { provide: DiscoveryApiService, useValue: discoveryApiServiceMockValue },
AppExtensionService,
{ {
provide: UserPreferencesService, provide: UserPreferencesService,
useValue: userPreferencesService useValue: userPreferencesService
@@ -318,11 +318,11 @@ describe('Info Drawer state', () => {
}; };
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [LibTestingModule, AuthModule.forRoot(), MatDialogModule], imports: [LibTestingModule, MatDialogModule],
declarations: [TestComponent], declarations: [TestComponent],
providers: [ providers: [
provideCoreAuth(),
{ provide: DocumentBasePageService, useClass: DocumentBasePageServiceMock }, { provide: DocumentBasePageService, useClass: DocumentBasePageServiceMock },
AppExtensionService,
{ provide: DiscoveryApiService, useValue: discoveryApiServiceMockValue }, { provide: DiscoveryApiService, useValue: discoveryApiServiceMockValue },
provideMockStore({ provideMockStore({
initialState: { app: appState } initialState: { app: appState }
@@ -39,7 +39,7 @@ import {
reduceSeparators, reduceSeparators,
sortByOrder sortByOrder
} from '@alfresco/adf-extensions'; } from '@alfresco/adf-extensions';
import { AppConfigService, AuthModule, LogService } from '@alfresco/adf-core'; import { AppConfigService, LogService, provideCoreAuth } from '@alfresco/adf-core';
import { provideMockStore } from '@ngrx/store/testing'; import { provideMockStore } from '@ngrx/store/testing';
import { hasQuickShareEnabled } from '@alfresco/aca-shared/rules'; import { hasQuickShareEnabled } from '@alfresco/aca-shared/rules';
import { MatIconRegistry } from '@angular/material/icon'; import { MatIconRegistry } from '@angular/material/icon';
@@ -58,8 +58,8 @@ describe('AppExtensionService', () => {
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [LibTestingModule, AuthModule.forRoot()], imports: [LibTestingModule],
providers: [provideMockStore({ initialState })] providers: [provideMockStore({ initialState }), provideCoreAuth()]
}); });
iconRegistry = TestBed.inject(MatIconRegistry); iconRegistry = TestBed.inject(MatIconRegistry);
@@ -26,10 +26,10 @@ import { AppService } from './app.service';
import { TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { import {
AuthenticationService, AuthenticationService,
NoopAuthModule,
NoopTranslateModule, NoopTranslateModule,
NotificationService, NotificationService,
PageTitleService, PageTitleService,
provideCoreAuthTesting,
StorageService, StorageService,
UserPreferencesService UserPreferencesService
} from '@alfresco/adf-core'; } from '@alfresco/adf-core';
@@ -69,8 +69,9 @@ describe('AppService', () => {
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [NoopTranslateModule, NoopAuthModule, MatDialogModule, MatSnackBarModule], imports: [NoopTranslateModule, MatDialogModule, MatSnackBarModule],
providers: [ providers: [
provideCoreAuthTesting(),
SearchQueryBuilderService, SearchQueryBuilderService,
provideMockStore({}), provideMockStore({}),
{ {
@@ -23,15 +23,13 @@
*/ */
import { Injectable, NgModule } from '@angular/core'; import { Injectable, NgModule } from '@angular/core';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { TranslateLoaderService, TranslationMock, TranslationService } from '@alfresco/adf-core'; import { NoopTranslateModule } from '@alfresco/adf-core';
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services'; import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'; import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { RouterTestingModule } from '@angular/router/testing'; import { RouterTestingModule } from '@angular/router/testing';
import { provideEffects } from '@ngrx/effects'; import { provideEffects } from '@ngrx/effects';
import { provideStore } from '@ngrx/store'; import { provideStore } from '@ngrx/store';
import { CommonModule } from '@angular/common';
import { MatIconTestingModule } from '@angular/material/icon/testing'; import { MatIconTestingModule } from '@angular/material/icon/testing';
import { OverlayModule } from '@angular/cdk/overlay'; import { OverlayModule } from '@angular/cdk/overlay';
import { RepositoryInfo, VersionInfo } from '@alfresco/js-api'; import { RepositoryInfo, VersionInfo } from '@alfresco/js-api';
@@ -93,20 +91,7 @@ export class DocumentBasePageServiceMock extends DocumentBasePageService {
} }
@NgModule({ @NgModule({
exports: [TranslateModule], imports: [NoopAnimationsModule, NoopTranslateModule, RouterTestingModule, MatIconTestingModule, OverlayModule],
imports: [
NoopAnimationsModule,
CommonModule,
RouterTestingModule,
MatIconTestingModule,
OverlayModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useClass: TranslateLoaderService
}
})
],
providers: [ providers: [
provideStore( provideStore(
{ app: null }, { app: null },
@@ -120,7 +105,6 @@ export class DocumentBasePageServiceMock extends DocumentBasePageService {
), ),
provideEffects([]), provideEffects([]),
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }, { provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
{ provide: TranslationService, useClass: TranslationMock },
provideHttpClient(withInterceptorsFromDi()) provideHttpClient(withInterceptorsFromDi())
] ]
}) })