Skip to content

Commit

Permalink
fix: resolved the issue of infinite loading in SmartEdit when accessi…
Browse files Browse the repository at this point in the history
…ng the PDP (#19720)
  • Loading branch information
kpawelczak authored Dec 6, 2024
1 parent ebcd0f5 commit 790fe55
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,26 @@ describe('ProductMultiDimensionalSelectorGuard', () => {
});

describe('canActivate', () => {
it('should return false if no product code is provided', () => {
it('should return false if no product code is provided and queryParams are empty', () => {
const route = new ActivatedRouteSnapshot();
route.params = {};
route.queryParams = {};

guard.canActivate(route).subscribe((result) => {
expect(result).toBe(false);
});
});

it('should return true if no product code is provided and is in SmartEdit', () => {
const route = new ActivatedRouteSnapshot();
route.params = {};
route.queryParams = { cmsTicketId: '123' };

guard.canActivate(route).subscribe((result) => {
expect(result).toBe(true);
});
});

it('should return true if product is purchasable', () => {
const route = new ActivatedRouteSnapshot();
route.params = { productCode: 'testProductCode' };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ export class ProductMultiDimensionalSelectorGuard {
activatedRoute: ActivatedRouteSnapshot
): Observable<boolean | UrlTree> {
const productCode = activatedRoute.params?.productCode;

if (!productCode) {
return of(false);
// Refuse entry unless it is within a SmartEdit environment
return of(!!activatedRoute.queryParams?.cmsTicketId);
}

return this.productService
Expand Down

0 comments on commit 790fe55

Please sign in to comment.