mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
ACS-8404: Introduce App Settings service (#3939)
This commit is contained in:
@@ -23,28 +23,26 @@
|
||||
*/
|
||||
|
||||
import { HomeComponent } from './home.component';
|
||||
import { AppConfigService, AppConfigServiceMock } from '@alfresco/adf-core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { Router } from '@angular/router';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { AppSettingsService } from '@alfresco/aca-shared';
|
||||
|
||||
describe('HomeComponent', () => {
|
||||
let appConfig: AppConfigService;
|
||||
let appSettings: AppSettingsService;
|
||||
let fixture: ComponentFixture<HomeComponent>;
|
||||
let router: Router;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [HttpClientModule, RouterTestingModule, HomeComponent],
|
||||
providers: [{ provide: AppConfigService, useClass: AppConfigServiceMock }]
|
||||
imports: [HttpClientModule, RouterTestingModule, HomeComponent]
|
||||
});
|
||||
appSettings = TestBed.inject(AppSettingsService);
|
||||
spyOnProperty(appSettings, 'landingPage', 'get').and.returnValue('/my-mock-landing-page');
|
||||
|
||||
fixture = TestBed.createComponent(HomeComponent);
|
||||
router = TestBed.inject(Router);
|
||||
appConfig = TestBed.inject(AppConfigService);
|
||||
appConfig.config = Object.assign(appConfig.config, {
|
||||
landingPage: '/my-mock-landing-page'
|
||||
});
|
||||
});
|
||||
|
||||
it('should navigate to the landing page from the app config', () => {
|
||||
@@ -53,12 +51,4 @@ describe('HomeComponent', () => {
|
||||
|
||||
expect(navigateSpy).toHaveBeenCalledWith('/my-mock-landing-page');
|
||||
});
|
||||
|
||||
it('should navigate to personal files by default when there is no landingPage defined', () => {
|
||||
appConfig.config = {};
|
||||
const navigateSpy = spyOn(router, 'navigateByUrl');
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(navigateSpy).toHaveBeenCalledWith('/personal-files');
|
||||
});
|
||||
});
|
||||
|
@@ -22,9 +22,9 @@
|
||||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, inject, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { AppConfigService } from '@alfresco/adf-core';
|
||||
import { AppSettingsService } from '@alfresco/aca-shared';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
@@ -32,12 +32,10 @@ import { AppConfigService } from '@alfresco/adf-core';
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class HomeComponent implements OnInit {
|
||||
readonly DEFAULT_LANDING_PAGE = '/personal-files';
|
||||
|
||||
constructor(private appConfig: AppConfigService, private router: Router) {}
|
||||
private appSettings = inject(AppSettingsService);
|
||||
private router = inject(Router);
|
||||
|
||||
ngOnInit() {
|
||||
const landingPage = this.appConfig.get('landingPage', this.DEFAULT_LANDING_PAGE);
|
||||
this.router.navigateByUrl(landingPage);
|
||||
this.router.navigateByUrl(this.appSettings.landingPage);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user