Skip to content

Commit

Permalink
CXSPA-4799 avoid 2 connector calls on F5 (#17869)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristophHi authored Sep 22, 2023
1 parent 3005ac4 commit 5f28469
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion feature-libs/quote/core/facade/quote.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class MockQuoteConnector implements Partial<QuoteConnector> {
class MockActiveCartService implements Partial<ActiveCartFacade> {
reloadActiveCart = createSpy().and.stub();
takeActiveCartId = createSpy().and.returnValue(of(cartId));
isStable = createSpy().and.returnValue(of(true));
isStable = createSpy().and.returnValue(of(true, true));
getActive = createSpy().and.returnValue(of(cart));
}

Expand Down Expand Up @@ -310,6 +310,17 @@ describe('QuoteService', () => {
done();
});
});

it('should call connector once if isStable emits twice', () => {
isQuoteCartActive = true;
quoteId = quote.code;
service
.getQuoteDetails()
.pipe()
.subscribe(() => {
expect(connector.getQuote).toHaveBeenCalledTimes(1);
});
});
});

describe('addDiscount', () => {
Expand Down
1 change: 1 addition & 0 deletions feature-libs/quote/core/facade/quote.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ export class QuoteService implements QuoteFacade {
//we need to ensure that the active cart has been loaded, in order to determine if the
//quote is connected to a quote cart (and then directly ready for edit)
this.activeCartService.isStable().pipe(
take(1),
switchMap(() =>
this.routingService.getRouterState().pipe(
//we don't need to cover the intermediate router states where a future route is already known.
Expand Down

0 comments on commit 5f28469

Please sign in to comment.