mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
[ACS-6576] Local storage prefix is not always created/updated properly in ADW (#3602)
* [ACS-6576] set local storage prefix * [ACS-6576] remove redundant async
This commit is contained in:
parent
dc2c7c9109
commit
c77528c530
@ -31,7 +31,8 @@ import {
|
|||||||
PageTitleService,
|
PageTitleService,
|
||||||
AlfrescoApiServiceMock,
|
AlfrescoApiServiceMock,
|
||||||
TranslationMock,
|
TranslationMock,
|
||||||
TranslationService
|
TranslationService,
|
||||||
|
UserPreferencesService
|
||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
import { BehaviorSubject, Observable, of, Subject } from 'rxjs';
|
import { BehaviorSubject, Observable, of, Subject } from 'rxjs';
|
||||||
import { HttpClientModule } from '@angular/common/http';
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
@ -66,6 +67,7 @@ describe('AppService', () => {
|
|||||||
let sharedLinksApiService: SharedLinksApiService;
|
let sharedLinksApiService: SharedLinksApiService;
|
||||||
let contentApi: ContentApiService;
|
let contentApi: ContentApiService;
|
||||||
let groupService: GroupService;
|
let groupService: GroupService;
|
||||||
|
let preferencesService: UserPreferencesService;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
@ -110,10 +112,12 @@ describe('AppService', () => {
|
|||||||
useValue: {
|
useValue: {
|
||||||
onLogin: new Subject<any>(),
|
onLogin: new Subject<any>(),
|
||||||
onLogout: new Subject<any>(),
|
onLogout: new Subject<any>(),
|
||||||
isLoggedIn: () => false
|
isLoggedIn: () => false,
|
||||||
|
getUsername: () => null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ provide: TranslationService, useClass: TranslationMock }
|
{ provide: TranslationService, useClass: TranslationMock },
|
||||||
|
{ provide: UserPreferencesService, useValue: { setStoragePrefix: () => null } }
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -126,6 +130,7 @@ describe('AppService', () => {
|
|||||||
contentApi = TestBed.inject(ContentApiService);
|
contentApi = TestBed.inject(ContentApiService);
|
||||||
groupService = TestBed.inject(GroupService);
|
groupService = TestBed.inject(GroupService);
|
||||||
service = TestBed.inject(AppService);
|
service = TestBed.inject(AppService);
|
||||||
|
preferencesService = TestBed.inject(UserPreferencesService);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be ready if [withCredentials] mode is used', (done) => {
|
it('should be ready if [withCredentials] mode is used', (done) => {
|
||||||
@ -152,6 +157,14 @@ describe('AppService', () => {
|
|||||||
await expect(isReady).toEqual(true);
|
await expect(isReady).toEqual(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should set local storage prefix after login', () => {
|
||||||
|
spyOn(preferencesService, 'setStoragePrefix');
|
||||||
|
spyOn(auth, 'getUsername').and.returnValue('test-username');
|
||||||
|
auth.onLogin.next();
|
||||||
|
|
||||||
|
expect(preferencesService.setStoragePrefix).toHaveBeenCalledWith('test-username');
|
||||||
|
});
|
||||||
|
|
||||||
it('should reset search to defaults upon logout', async () => {
|
it('should reset search to defaults upon logout', async () => {
|
||||||
const resetToDefaults = spyOn(searchQueryBuilderService, 'resetToDefaults');
|
const resetToDefaults = spyOn(searchQueryBuilderService, 'resetToDefaults');
|
||||||
auth.onLogout.next(true);
|
auth.onLogout.next(true);
|
||||||
|
@ -98,6 +98,7 @@ export class AppService implements OnDestroy {
|
|||||||
|
|
||||||
this.authenticationService.onLogin.subscribe(() => {
|
this.authenticationService.onLogin.subscribe(() => {
|
||||||
this.ready.next(true);
|
this.ready.next(true);
|
||||||
|
this.preferencesService.setStoragePrefix(this.authenticationService.getUsername());
|
||||||
});
|
});
|
||||||
|
|
||||||
this.authenticationService.onLogout.subscribe(() => {
|
this.authenticationService.onLogout.subscribe(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user