diff --git a/src/app/core/server-check/server-check.guard.spec.ts b/src/app/core/server-check/server-check.guard.spec.ts index f18b3867538..044609ef427 100644 --- a/src/app/core/server-check/server-check.guard.spec.ts +++ b/src/app/core/server-check/server-check.guard.spec.ts @@ -20,7 +20,8 @@ describe('ServerCheckGuard', () => { }); rootDataServiceStub = jasmine.createSpyObj('RootDataService', { checkServerAvailability: jasmine.createSpy('checkServerAvailability'), - invalidateRootCache: jasmine.createSpy('invalidateRootCache') + invalidateRootCache: jasmine.createSpy('invalidateRootCache'), + findRoot: jasmine.createSpy('findRoot') }); redirectUrlTree = new UrlTree(); router = { @@ -63,18 +64,23 @@ describe('ServerCheckGuard', () => { }); describe(`listenForRouteChanges`, () => { - it(`should invalidate the root cache when the method is first called, and then on every NavigationStart event`, () => { + it(`should retrieve the root endpoint, without using the cache, when the method is first called`, () => { testScheduler.run(() => { guard.listenForRouteChanges(); - expect(rootDataServiceStub.invalidateRootCache).toHaveBeenCalledTimes(1); + expect(rootDataServiceStub.findRoot).toHaveBeenCalledWith(false); + }); + }); + it(`should invalidate the root cache on every NavigationStart event`, () => { + testScheduler.run(() => { + guard.listenForRouteChanges(); eventSubject.next(new NavigationStart(1,'')); eventSubject.next(new NavigationEnd(1,'', '')); eventSubject.next(new NavigationStart(2,'')); eventSubject.next(new NavigationEnd(2,'', '')); eventSubject.next(new NavigationStart(3,'')); }); - expect(rootDataServiceStub.invalidateRootCache).toHaveBeenCalledTimes(4); + expect(rootDataServiceStub.invalidateRootCache).toHaveBeenCalledTimes(3); }); }); }); diff --git a/src/app/core/server-check/server-check.guard.ts b/src/app/core/server-check/server-check.guard.ts index 1cea5f36bab..65ca2b0c498 100644 --- a/src/app/core/server-check/server-check.guard.ts +++ b/src/app/core/server-check/server-check.guard.ts @@ -53,8 +53,10 @@ export class ServerCheckGuard implements CanActivateChild { */ listenForRouteChanges(): void { // we'll always be too late for the first NavigationStart event with the router subscribe below, - // so this statement is for the very first route operation - this.rootDataService.invalidateRootCache(); + // so this statement is for the very first route operation. A `find` without using the cache, + // rather than an invalidateRootCache, because invalidating as the app is bootstrapping can + // break other features + this.rootDataService.findRoot(false); this.router.events.pipe( filter(event => event instanceof NavigationStart),