Skip to content

Commit 32fc28e

Browse files
committed
fix dev mode issue where retrieving the login options fails
1 parent 8fbe8c1 commit 32fc28e

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

src/app/core/server-check/server-check.guard.spec.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ describe('ServerCheckGuard', () => {
2020
});
2121
rootDataServiceStub = jasmine.createSpyObj('RootDataService', {
2222
checkServerAvailability: jasmine.createSpy('checkServerAvailability'),
23-
invalidateRootCache: jasmine.createSpy('invalidateRootCache')
23+
invalidateRootCache: jasmine.createSpy('invalidateRootCache'),
24+
findRoot: jasmine.createSpy('findRoot')
2425
});
2526
redirectUrlTree = new UrlTree();
2627
router = {
@@ -63,18 +64,23 @@ describe('ServerCheckGuard', () => {
6364
});
6465

6566
describe(`listenForRouteChanges`, () => {
66-
it(`should invalidate the root cache when the method is first called, and then on every NavigationStart event`, () => {
67+
it(`should retrieve the root endpoint, without using the cache, when the method is first called`, () => {
6768
testScheduler.run(() => {
6869
guard.listenForRouteChanges();
69-
expect(rootDataServiceStub.invalidateRootCache).toHaveBeenCalledTimes(1);
70+
expect(rootDataServiceStub.findRoot).toHaveBeenCalledWith(false);
71+
});
72+
});
7073

74+
it(`should invalidate the root cache on every NavigationStart event`, () => {
75+
testScheduler.run(() => {
76+
guard.listenForRouteChanges();
7177
eventSubject.next(new NavigationStart(1,''));
7278
eventSubject.next(new NavigationEnd(1,'', ''));
7379
eventSubject.next(new NavigationStart(2,''));
7480
eventSubject.next(new NavigationEnd(2,'', ''));
7581
eventSubject.next(new NavigationStart(3,''));
7682
});
77-
expect(rootDataServiceStub.invalidateRootCache).toHaveBeenCalledTimes(4);
83+
expect(rootDataServiceStub.invalidateRootCache).toHaveBeenCalledTimes(3);
7884
});
7985
});
8086
});

src/app/core/server-check/server-check.guard.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ export class ServerCheckGuard implements CanActivateChild {
5353
*/
5454
listenForRouteChanges(): void {
5555
// we'll always be too late for the first NavigationStart event with the router subscribe below,
56-
// so this statement is for the very first route operation
57-
this.rootDataService.invalidateRootCache();
56+
// so this statement is for the very first route operation. A `find` without using the cache,
57+
// rather than an invalidateRootCache, because invalidating as the app is bootstrapping can
58+
// break other features
59+
this.rootDataService.findRoot(false);
5860

5961
this.router.events.pipe(
6062
filter(event => event instanceof NavigationStart),

0 commit comments

Comments
 (0)