Skip to content

Commit

Permalink
fix: content page not found when reloading a page with an authenticat…
Browse files Browse the repository at this point in the history
…ed user (#1198)
  • Loading branch information
Eisie96 authored Jun 29, 2022
1 parent 8c74111 commit 1e7af60
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/app/core/store/content/pages/pages.effects.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { CMSService } from 'ish-core/services/cms/cms.service';
import { ContentStoreModule } from 'ish-core/store/content/content-store.module';
import { loadContentPageTreeSuccess } from 'ish-core/store/content/page-tree';
import { CoreStoreModule } from 'ish-core/store/core/core-store.module';
import { personalizationStatusDetermined } from 'ish-core/store/customer/user';
import { makeHttpError } from 'ish-core/utils/dev/api-service-utils';
import { pageTree } from 'ish-core/utils/dev/test-data-utils';
import { HttpStatusCodeService } from 'ish-core/utils/http-status-code/http-status-code.service';
Expand Down Expand Up @@ -57,7 +58,9 @@ describe('Pages Effects', () => {
it('should send fail action when loading action via service is unsuccessful', done => {
when(cmsServiceMock.getContentPage('dummy')).thenReturn(throwError(() => makeHttpError({ message: 'ERROR' })));

actions$ = of(loadContentPage({ contentPageId: 'dummy' }));
const action = loadContentPage({ contentPageId: 'dummy' });

actions$ = of(personalizationStatusDetermined, action);

effects.loadContentPage$.subscribe(action => {
verify(cmsServiceMock.getContentPage('dummy')).once();
Expand All @@ -72,10 +75,10 @@ describe('Pages Effects', () => {
it('should not die when encountering an error', () => {
when(cmsServiceMock.getContentPage('dummy')).thenReturn(throwError(() => makeHttpError({ message: 'ERROR' })));

actions$ = hot('a-a-a-a', { a: loadContentPage({ contentPageId: 'dummy' }) });
actions$ = hot('b-a-a', { a: loadContentPage({ contentPageId: 'dummy' }), b: personalizationStatusDetermined });

expect(effects.loadContentPage$).toBeObservable(
cold('a-a-a-a', { a: loadContentPageFail({ error: makeHttpError({ message: 'ERROR' }) }) })
cold('--a-a', { a: loadContentPageFail({ error: makeHttpError({ message: 'ERROR' }) }) })
);
});
});
Expand Down
10 changes: 8 additions & 2 deletions src/app/core/store/content/pages/pages.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@ import { concatMap, map, mergeMap } from 'rxjs/operators';
import { CMSService } from 'ish-core/services/cms/cms.service';
import { selectRouteParam } from 'ish-core/store/core/router';
import { setBreadcrumbData } from 'ish-core/store/core/viewconf';
import { personalizationStatusDetermined } from 'ish-core/store/customer/user';
import { HttpStatusCodeService } from 'ish-core/utils/http-status-code/http-status-code.service';
import { mapErrorToAction, mapToPayloadProperty, whenTruthy } from 'ish-core/utils/operators';
import {
mapErrorToAction,
mapToPayloadProperty,
useCombinedObservableOnAction,
whenTruthy,
} from 'ish-core/utils/operators';

import { loadContentPage, loadContentPageFail, loadContentPageSuccess } from './pages.actions';
import { getBreadcrumbForContentPage } from './pages.selectors';
Expand All @@ -24,7 +30,7 @@ export class PagesEffects {

loadContentPage$ = createEffect(() =>
this.actions$.pipe(
ofType(loadContentPage),
useCombinedObservableOnAction(this.actions$.pipe(ofType(loadContentPage)), personalizationStatusDetermined),
mapToPayloadProperty('contentPageId'),
mergeMap(contentPageId =>
this.cmsService
Expand Down

0 comments on commit 1e7af60

Please sign in to comment.