Compare commits
2
Commits
bf422b8529
...
ba0af1afd9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba0af1afd9 | ||
|
|
3577c9dc16 |
Generated
+1053
-1053
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,6 @@
|
||||
import { DeliveryMode } from '../../product/types/DeliveryMode';
|
||||
import type { CategoriesService } from '../../product/services/CategoriesService';
|
||||
import type { StorefrontProduct } from '../types/StorefrontProduct';
|
||||
import { StorefrontProductViewService } from './StorefrontProductViewService';
|
||||
|
||||
describe('StorefrontProductViewService', () => {
|
||||
@@ -19,4 +21,46 @@ describe('StorefrontProductViewService', () => {
|
||||
{ id: 'category-2', name: 'Physical', href: '/shop/categories/category-2' }
|
||||
]);
|
||||
});
|
||||
|
||||
it('appends product-card anchors to index variant selection hrefs', () => {
|
||||
const product: StorefrontProduct = {
|
||||
id: 'product-1',
|
||||
title: 'Widget',
|
||||
deliveryMode: DeliveryMode.Auto,
|
||||
descriptionHtml: null,
|
||||
variants: [
|
||||
{
|
||||
id: 'variant-1',
|
||||
productId: 'product-1',
|
||||
productTitle: 'Widget',
|
||||
title: 'Default',
|
||||
price: 10,
|
||||
deliveryMode: DeliveryMode.Auto,
|
||||
stockAvailable: 1,
|
||||
stockForSession: 1,
|
||||
thumbnailUrl: null,
|
||||
images: []
|
||||
},
|
||||
{
|
||||
id: 'variant-2',
|
||||
productId: 'product-1',
|
||||
productTitle: 'Widget',
|
||||
title: 'Alt',
|
||||
price: 12,
|
||||
deliveryMode: DeliveryMode.Auto,
|
||||
stockAvailable: 1,
|
||||
stockForSession: 1,
|
||||
thumbnailUrl: null,
|
||||
images: []
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const [view] = service.toProductsIndexView([product], {});
|
||||
|
||||
expect(view.variants.map(variant => variant.selectionHref)).toEqual([
|
||||
'/#product-card-variant-1',
|
||||
'/?sel=product-1%3Avariant-2#product-card-variant-2'
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -220,11 +220,15 @@ export class StorefrontProductViewService {
|
||||
}
|
||||
|
||||
private buildIndexUrl(basePath: string, product: StorefrontProduct, variantId: string): string {
|
||||
const anchor = `#product-card-${variantId}`;
|
||||
|
||||
if (variantId === product.variants[0].id) {
|
||||
return basePath;
|
||||
return `${basePath}${anchor}`;
|
||||
}
|
||||
|
||||
return `${basePath}?${new URLSearchParams({ sel: `${product.id}:${variantId}` }).toString()}`;
|
||||
const params = new URLSearchParams({ sel: `${product.id}:${variantId}` });
|
||||
|
||||
return `${basePath}?${params.toString()}${anchor}`;
|
||||
}
|
||||
|
||||
async resolveProductBackLink(categoryId?: string): Promise<{ backHref: string; backLabel: string }> {
|
||||
|
||||
Generated
+474
-443
File diff suppressed because it is too large
Load Diff
+4
-4
@@ -11,10 +11,10 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@element-plus/icons-vue": "^2.3.2",
|
||||
"@tiptap/extension-link": "^3.22.5",
|
||||
"@tiptap/extension-placeholder": "^3.22.5",
|
||||
"@tiptap/starter-kit": "^3.22.5",
|
||||
"@tiptap/vue-3": "^3.22.5",
|
||||
"@tiptap/extension-link": "^3.35.0",
|
||||
"@tiptap/extension-placeholder": "^3.35.0",
|
||||
"@tiptap/starter-kit": "^3.35.0",
|
||||
"@tiptap/vue-3": "^3.35.0",
|
||||
"axios": "^1.15.1",
|
||||
"dayjs": "^1.11.19",
|
||||
"decimal.js": "^10.6.0",
|
||||
|
||||
Reference in New Issue
Block a user