>;
removeItemFromCart(
input: RemoveItemFromCartInput,
diff --git a/packages/api-client/tsconfig.eslint.json b/packages/api-client/tsconfig.eslint.json
new file mode 100644
index 000000000..a47730729
--- /dev/null
+++ b/packages/api-client/tsconfig.eslint.json
@@ -0,0 +1,7 @@
+{
+ "extends": "../../tsconfig.json",
+ "exclude": [
+ "lib",
+ "node_modules"
+ ]
+}
diff --git a/packages/composables/__tests__/_mountComposable.ts b/packages/composables/__tests__/_mountComposable.ts
index b2e35eeca..cfebcb992 100644
--- a/packages/composables/__tests__/_mountComposable.ts
+++ b/packages/composables/__tests__/_mountComposable.ts
@@ -1,12 +1,12 @@
import { shallowMount } from '@vue/test-utils';
-import { createComponent } from '@vue/composition-api';
+import { defineComponent } from '@vue/composition-api';
const mountComposable = (composableFn) => {
- const component = createComponent({
- template: 'my component
',
+ const component = defineComponent({
setup() {
return composableFn();
},
+ template: 'my component
',
});
return shallowMount(component);
diff --git a/packages/composables/__tests__/getters/productHelpers.spec.ts b/packages/composables/__tests__/getters/productHelpers.spec.ts
index b4233c7cd..d09b187f1 100644
--- a/packages/composables/__tests__/getters/productHelpers.spec.ts
+++ b/packages/composables/__tests__/getters/productHelpers.spec.ts
@@ -1,144 +1,131 @@
+import { Product } from '@vue-storefront/magento-api';
import {
getAttributes,
- getAverageRating,
- getBreadcrumbs,
- getCategory,
getCategoryIds,
getCoverImage,
- getDescription,
getFiltered,
- getFormattedPrice,
getGallery,
getId,
getName,
getPrice,
- getProductRelatedProduct,
- getProductSku,
- getProductThumbnailImage,
- getProductUpsellProduct,
- getShortDescription,
getSlug,
- getTotalReviews,
- getTypeId,
- getSwatchData,
- getGroupedProducts,
- getBundleProducts,
} from '../../src/getters/productGetters';
const product = {
- "options_container": null,
- "meta_description": null,
- "meta_keyword": null,
- "meta_title": null,
- "description": {
- "html": "The sporty Joust Duffle Bag can't be beat - not in the gym, not on the luggage carousel, not anywhere. Big enough to haul a basketball or soccer ball and some sneakers with plenty of room to spare, it's ideal for athletes with places to go.
\n
\n- Dual top handles.
\n- Adjustable shoulder strap.
\n- Full-length zipper.
\n- L 29\" x W 13\" x H 11\".
\n
",
- "__typename": "ComplexTextValue"
+ options_container: null,
+ meta_description: null,
+ meta_keyword: null,
+ meta_title: null,
+ description: {
+ html: 'The sporty Joust Duffle Bag can\'t be beat - not in the gym, not on the luggage carousel, not anywhere. Big enough to haul a basketball or soccer ball and some sneakers with plenty of room to spare, it\'s ideal for athletes with places to go.
\n
\n- Dual top handles.
\n- Adjustable shoulder strap.
\n- Full-length zipper.
\n- L 29" x W 13" x H 11".
\n
',
+ __typename: 'ComplexTextValue',
},
- "short_description": { "html": "", "__typename": "ComplexTextValue" },
- "uid": "MQ==",
- "__typename": "SimpleProduct",
- "sku": "24-MB01",
- "name": "Joust Duffle Bag",
- "stock_status": "IN_STOCK",
- "only_x_left_in_stock": null,
- "rating_summary": 50,
- "thumbnail": {
- "url": "https://m2.caravelx.com/media/catalog/product/cache/746ba992681b73af7e339699b3e0caf7/m/b/mb01-blue-0.jpg",
- "position": null,
- "disabled": null,
- "label": "Joust Duffle Bag",
- "__typename": "ProductImage"
+ short_description: { html: '', __typename: 'ComplexTextValue' },
+ uid: 'MQ==',
+ __typename: 'SimpleProduct',
+ sku: '24-MB01',
+ name: 'Joust Duffle Bag',
+ stock_status: 'IN_STOCK',
+ only_x_left_in_stock: null,
+ rating_summary: 50,
+ thumbnail: {
+ url: 'https://m2.caravelx.com/media/catalog/product/cache/746ba992681b73af7e339699b3e0caf7/m/b/mb01-blue-0.jpg',
+ position: null,
+ disabled: null,
+ label: 'Joust Duffle Bag',
+ __typename: 'ProductImage',
},
- "price_range": {
- "maximum_price": {
- "final_price": {
- "currency": "USD",
- "value": 34,
- "__typename": "Money"
+ price_range: {
+ maximum_price: {
+ final_price: {
+ currency: 'USD',
+ value: 34,
+ __typename: 'Money',
},
- "regular_price": { "currency": "USD", "value": 34, "__typename": "Money" },
- "__typename": "ProductPrice"
+ regular_price: { currency: 'USD', value: 34, __typename: 'Money' },
+ __typename: 'ProductPrice',
},
- "minimum_price": {
- "final_price": {
- "currency": "USD",
- "value": 34,
- "__typename": "Money"
+ minimum_price: {
+ final_price: {
+ currency: 'USD',
+ value: 34,
+ __typename: 'Money',
},
- "regular_price": { "currency": "USD", "value": 34, "__typename": "Money" },
- "__typename": "ProductPrice"
+ regular_price: { currency: 'USD', value: 34, __typename: 'Money' },
+ __typename: 'ProductPrice',
},
- "__typename": "PriceRange"
+ __typename: 'PriceRange',
},
- "url_key": "joust-duffle-bag",
- "url_rewrites": [{
- "url": "joust-duffle-bag.html",
- "__typename": "UrlRewrite"
+ url_key: 'joust-duffle-bag',
+ url_rewrites: [{
+ url: 'joust-duffle-bag.html',
+ __typename: 'UrlRewrite',
}, {
- "url": "gear/joust-duffle-bag.html",
- "__typename": "UrlRewrite"
- }, { "url": "gear/bags/joust-duffle-bag.html", "__typename": "UrlRewrite" }],
- "categories": [{
- "uid": "Mw==",
- "name": "Gear",
- "url_suffix": ".html",
- "url_path": "gear",
- "breadcrumbs": null,
- "__typename": "CategoryTree"
+ url: 'gear/joust-duffle-bag.html',
+ __typename: 'UrlRewrite',
+ }, { url: 'gear/bags/joust-duffle-bag.html', __typename: 'UrlRewrite' }],
+ categories: [{
+ uid: 'Mw==',
+ name: 'Gear',
+ url_suffix: '.html',
+ url_path: 'gear',
+ breadcrumbs: null,
+ __typename: 'CategoryTree',
}, {
- "uid": "NA==",
- "name": "Bags",
- "url_suffix": ".html",
- "url_path": "gear/bags",
- "breadcrumbs": [{
- "category_name": "Gear",
- "category_url_path": "gear",
- "__typename": "Breadcrumb"
+ uid: 'NA==',
+ name: 'Bags',
+ url_suffix: '.html',
+ url_path: 'gear/bags',
+ breadcrumbs: [{
+ category_name: 'Gear',
+ category_url_path: 'gear',
+ __typename: 'Breadcrumb',
}],
- "__typename": "CategoryTree"
+ __typename: 'CategoryTree',
}],
- "review_count": 2,
- "reviews": {
- "items": [{
- "average_rating": 60,
- "ratings_breakdown": [{
- "name": "Rating",
- "value": "3",
- "__typename": "ProductReviewRating"
+ review_count: 2,
+ reviews: {
+ items: [{
+ average_rating: 60,
+ ratings_breakdown: [{
+ name: 'Rating',
+ value: '3',
+ __typename: 'ProductReviewRating',
}],
- "__typename": "ProductReview"
+ __typename: 'ProductReview',
}, {
- "average_rating": 40,
- "ratings_breakdown": [{
- "name": "Rating",
- "value": "2",
- "__typename": "ProductReviewRating"
+ average_rating: 40,
+ ratings_breakdown: [{
+ name: 'Rating',
+ value: '2',
+ __typename: 'ProductReviewRating',
}],
- "__typename": "ProductReview"
- }], "__typename": "ProductReviews"
+ __typename: 'ProductReview',
+ }],
+ __typename: 'ProductReviews',
},
- "small_image": {
- "url": "https://m2.caravelx.com/media/catalog/product/cache/746ba992681b73af7e339699b3e0caf7/m/b/mb01-blue-0.jpg",
- "position": null,
- "disabled": null,
- "label": "Joust Duffle Bag",
- "__typename": "ProductImage"
+ small_image: {
+ url: 'https://m2.caravelx.com/media/catalog/product/cache/746ba992681b73af7e339699b3e0caf7/m/b/mb01-blue-0.jpg',
+ position: null,
+ disabled: null,
+ label: 'Joust Duffle Bag',
+ __typename: 'ProductImage',
},
- "image": {
- "url": "https://m2.caravelx.com/media/catalog/product/cache/746ba992681b73af7e339699b3e0caf7/m/b/mb01-blue-0.jpg",
- "position": null,
- "disabled": null,
- "label": "Joust Duffle Bag",
- "__typename": "ProductImage"
+ image: {
+ url: 'https://m2.caravelx.com/media/catalog/product/cache/746ba992681b73af7e339699b3e0caf7/m/b/mb01-blue-0.jpg',
+ position: null,
+ disabled: null,
+ label: 'Joust Duffle Bag',
+ __typename: 'ProductImage',
},
- "media_gallery": [{
- "url": "https://m2.caravelx.com/media/catalog/product/cache/746ba992681b73af7e339699b3e0caf7/m/b/mb01-blue-0.jpg",
- "position": 1,
- "disabled": false,
- "label": "Image",
- "__typename": "ProductImage"
- }]
-} as any;
+ media_gallery: [{
+ url: 'https://m2.caravelx.com/media/catalog/product/cache/746ba992681b73af7e339699b3e0caf7/m/b/mb01-blue-0.jpg',
+ position: 1,
+ disabled: false,
+ label: 'Image',
+ __typename: 'ProductImage',
+ }],
+} as unknown as Product;
describe('[magento-getters] product getters', () => {
it('returns default values', () => {
@@ -165,20 +152,21 @@ describe('[magento-getters] product getters', () => {
{
small: 'https://m2.caravelx.com/media/catalog/product/cache/746ba992681b73af7e339699b3e0caf7/m/b/mb01-blue-0.jpg',
normal: 'https://m2.caravelx.com/media/catalog/product/cache/746ba992681b73af7e339699b3e0caf7/m/b/mb01-blue-0.jpg',
- big: 'https://m2.caravelx.com/media/catalog/product/cache/746ba992681b73af7e339699b3e0caf7/m/b/mb01-blue-0.jpg'
- }
+ big: 'https://m2.caravelx.com/media/catalog/product/cache/746ba992681b73af7e339699b3e0caf7/m/b/mb01-blue-0.jpg',
+ },
]);
});
it('returns cover image', () => {
- expect(getCoverImage({ images: [] } as any)).toEqual(null);
+ // @ts-expect-error intentional lack of image
+ expect(getCoverImage({})).toEqual(null);
expect(getCoverImage(product)).toEqual('https://m2.caravelx.com/media/catalog/product/cache/746ba992681b73af7e339699b3e0caf7/m/b/mb01-blue-0.jpg');
});
it('returns product categories', () => {
expect(getCategoryIds(product)).toEqual([
'Mw==',
- 'NA=='
+ 'NA==',
]);
});
diff --git a/packages/composables/babel.config.js b/packages/composables/babel.config.js
index d3540f51b..6c66aa368 100644
--- a/packages/composables/babel.config.js
+++ b/packages/composables/babel.config.js
@@ -1,9 +1,10 @@
+// eslint-disable-next-line unicorn/prefer-module
module.exports = {
presets: [
['@babel/preset-env', {
targets: {
- node: 'current'
- }
- }]
- ]
+ node: 'current',
+ },
+ }],
+ ],
};
diff --git a/packages/composables/jest.config.js b/packages/composables/jest.config.js
index 65abac5c8..3e0bbf46f 100644
--- a/packages/composables/jest.config.js
+++ b/packages/composables/jest.config.js
@@ -22,7 +22,7 @@ module.exports = {
testEnvironment: 'jsdom',
transform: {
'^.+\\.(m)js$': 'babel-jest',
- '^.+\\.ts$': 'ts-jest'
+ '^.+\\.ts$': 'ts-jest',
},
transformIgnorePatterns: [
'node_modules',
diff --git a/packages/composables/nuxt/cookie.js b/packages/composables/nuxt/cookie.js
index 203e3ec44..21bcd8ed3 100644
--- a/packages/composables/nuxt/cookie.js
+++ b/packages/composables/nuxt/cookie.js
@@ -1,3 +1,4 @@
+/* eslint-disable @typescript-eslint/no-unsafe-argument */
import CookieUniversal from 'cookie-universal';
const baseSetCookieOptions = {
diff --git a/packages/composables/nuxt/helpers/index.js b/packages/composables/nuxt/helpers/index.js
index 397921d94..5abbf3f89 100644
--- a/packages/composables/nuxt/helpers/index.js
+++ b/packages/composables/nuxt/helpers/index.js
@@ -1,3 +1,4 @@
+// eslint-disable-next-line import/no-extraneous-dependencies
import defaultConfig from '@vue-storefront/magento/nuxt/defaultConfig';
export const getLocaleSettings = (app, moduleOptions) => {
diff --git a/packages/composables/nuxt/index.js b/packages/composables/nuxt/index.js
index 57c828263..aaed24be7 100644
--- a/packages/composables/nuxt/index.js
+++ b/packages/composables/nuxt/index.js
@@ -11,7 +11,7 @@ const getMissingFields = (options) => [
'locales',
].filter((o) => options[o] === undefined);
-export default function (moduleOptions) {
+export default function composablesModule(moduleOptions) {
const options = isNuxtI18nUsed(moduleOptions)
? {
...moduleOptions,
diff --git a/packages/composables/nuxt/plugin.js b/packages/composables/nuxt/plugin.js
index d3b40aa7f..669d6994e 100644
--- a/packages/composables/nuxt/plugin.js
+++ b/packages/composables/nuxt/plugin.js
@@ -1,4 +1,6 @@
-import { integrationPlugin } from '@vue-storefront/magento-theme/helpers/integrationPlugin'
+/* eslint-disable import/no-extraneous-dependencies */
+// for removal of reliance on Vue Storefront Core
+import { integrationPlugin } from '@vue-storefront/magento-theme/helpers/integrationPlugin';
import { mapConfigToSetupObject } from '@vue-storefront/magento/nuxt/helpers';
import defaultConfig from '@vue-storefront/magento/nuxt/defaultConfig';
import cookie from '@vue-storefront/magento/nuxt/cookie';
@@ -6,7 +8,9 @@ import cookie from '@vue-storefront/magento/nuxt/cookie';
const moduleOptions = JSON.parse('<%= JSON.stringify(options) %>');
// TODO should be moved to THEME and expose consistent cookie management API
-export default integrationPlugin(({ app, res, req, integration }) => {
+export default integrationPlugin(({
+ app, res, req, integration,
+}) => {
const cartCookieName = moduleOptions.cookies?.cartCookieName || defaultConfig.cookies.cartCookieName;
const customerCookieName = moduleOptions.cookies?.customerCookieName || defaultConfig.cookies.customerCookieName;
const storeCookieName = moduleOptions.cookies?.storeCookieName || defaultConfig.cookies.storeCookieName;
@@ -22,34 +26,34 @@ export default integrationPlugin(({ app, res, req, integration }) => {
const getCartId = () => getCookies(cartCookieName);
- const setCartId = (id) => !id ? removeCookie(cartCookieName) : setCookie(cartCookieName, id);
+ const setCartId = (id) => (!id ? removeCookie(cartCookieName) : setCookie(cartCookieName, id));
const getCustomerToken = () => getCookies(customerCookieName);
- const setCustomerToken = (token) => !token ? removeCookie(customerCookieName) : setCookie(customerCookieName, token);
+ const setCustomerToken = (token) => (!token ? removeCookie(customerCookieName) : setCookie(customerCookieName, token));
const getStore = () => getCookies(storeCookieName);
- const setStore = (id) => !id ? removeCookie(storeCookieName) : setCookie(storeCookieName, id);
+ const setStore = (id) => (!id ? removeCookie(storeCookieName) : setCookie(storeCookieName, id));
const getCurrency = () => getCookies(currencyCookieName);
- const setCurrency = (id) => !id ? removeCookie(currencyCookieName) : setCookie(currencyCookieName, id);
+ const setCurrency = (id) => (!id ? removeCookie(currencyCookieName) : setCookie(currencyCookieName, id));
const getLocale = () => getCookies(localeCookieName);
- const setLocale = (id) => !id ? removeCookie(localeCookieName) : setCookie(localeCookieName, id);
+ const setLocale = (id) => (!id ? removeCookie(localeCookieName) : setCookie(localeCookieName, id));
const getCountry = () => getCookies(countryCookieName);
- const setCountry = id => !id ? removeCookie(countryCookieName) : setCookie(countryCookieName, id);
+ const setCountry = (id) => (!id ? removeCookie(countryCookieName) : setCookie(countryCookieName, id));
const settings = mapConfigToSetupObject({
moduleOptions,
app,
additionalProperties: {
state: {
- //Cart
+ // Cart
getCartId,
setCartId,
// Customer
@@ -65,7 +69,7 @@ export default integrationPlugin(({ app, res, req, integration }) => {
getCountry,
setCountry,
},
- }
+ },
});
integration.configure('magento', settings);
diff --git a/packages/composables/package.json b/packages/composables/package.json
index 525729113..f16b21171 100644
--- a/packages/composables/package.json
+++ b/packages/composables/package.json
@@ -1,6 +1,6 @@
{
"name": "@vue-storefront/magento",
- "version": "1.0.0-rc.7",
+ "version": "1.0.0-rc.8",
"license": "MIT",
"homepage": "https://github.com/vuestorefront/magento2",
"bugs": {
diff --git a/packages/composables/src/composables/useCart/index.ts b/packages/composables/src/composables/useCart/index.ts
index 34466777f..3409fa882 100644
--- a/packages/composables/src/composables/useCart/index.ts
+++ b/packages/composables/src/composables/useCart/index.ts
@@ -67,6 +67,7 @@ const factoryParams: UseCartFactoryParams = {
return createVirtualCart();
}
+ // eslint-disable-next-line no-param-reassign
cartId = await createRealCart();
apiState.setCartId(cartId);
}
diff --git a/packages/composables/src/composables/useCategorySearch/index.ts b/packages/composables/src/composables/useCategorySearch/index.ts
index 29c6eae27..8c24ad440 100644
--- a/packages/composables/src/composables/useCategorySearch/index.ts
+++ b/packages/composables/src/composables/useCategorySearch/index.ts
@@ -20,6 +20,7 @@ const factoryParams: UseCategorySearchFactory UseCategorySearch = useCategorySearchFactory(factoryParams);
export default useCategorySearch;
diff --git a/packages/composables/src/composables/useCurrency/index.ts b/packages/composables/src/composables/useCurrency/index.ts
index 008da2dbd..e736b0e7f 100644
--- a/packages/composables/src/composables/useCurrency/index.ts
+++ b/packages/composables/src/composables/useCurrency/index.ts
@@ -7,7 +7,7 @@ import { useCurrencyFactory, UseCurrencyFactoryParams } from '../../factories/us
import { UseCurrency } from '../../types/composables';
const factoryParams: UseCurrencyFactoryParams = {
- load: async (context: Context, params): Promise => {
+ load: async (context: Context, _params): Promise => {
const { data } = await context.$magento.api.currency();
return data.currency || {};
diff --git a/packages/composables/src/composables/useExternalCheckout/index.ts b/packages/composables/src/composables/useExternalCheckout/index.ts
index b42f4ca86..e655aa072 100644
--- a/packages/composables/src/composables/useExternalCheckout/index.ts
+++ b/packages/composables/src/composables/useExternalCheckout/index.ts
@@ -12,6 +12,7 @@ const factoryParams: UseExternalCheckoutFactoryParams = {
cart: useCart(),
};
},
+ // eslint-disable-next-line @typescript-eslint/require-await
initializeCheckout: async (context: Context, params) => {
Logger.debug('[Magento]: Initialize external checkout', { params });
diff --git a/packages/composables/src/composables/useReview/index.ts b/packages/composables/src/composables/useReview/index.ts
index ee2b930c3..a768922ca 100644
--- a/packages/composables/src/composables/useReview/index.ts
+++ b/packages/composables/src/composables/useReview/index.ts
@@ -46,7 +46,7 @@ ProductReviewRatingMetadata> = {
return data?.createProductReview?.review ?? {};
},
- loadReviewMetadata: async (context: Context, params) => {
+ loadReviewMetadata: async (context: Context, _params) => {
Logger.debug('[Magento] load review metadata');
const { data } = await context.$magento.api.productReviewRatingsMetadata();
diff --git a/packages/composables/src/composables/useUserShipping/index.ts b/packages/composables/src/composables/useUserShipping/index.ts
index de231d6c1..07859bd94 100644
--- a/packages/composables/src/composables/useUserShipping/index.ts
+++ b/packages/composables/src/composables/useUserShipping/index.ts
@@ -31,7 +31,7 @@ const factoryParams: UseUserShippingFactoryParams = {
deleteAddress: async (context: Context, params) => {
Logger.debug('[Magento] delete shipping address', { params });
- const { data } = await context.$magento.api.deleteCustomerAddress(params.address.id);
+ const { data } = await context.$magento.api.deleteCustomerAddress(params.address.id as number);
return data?.deleteCustomerAddress ?? {};
},
diff --git a/packages/composables/src/composables/useWishlist/index.ts b/packages/composables/src/composables/useWishlist/index.ts
index a238636aa..182be3a56 100644
--- a/packages/composables/src/composables/useWishlist/index.ts
+++ b/packages/composables/src/composables/useWishlist/index.ts
@@ -121,10 +121,7 @@ const factoryParams: UseWishlistFactoryParams = {
}
},
removeItem: async (context, params) => {
- const {
- product,
- currentWishlist,
- } = params;
+ const { currentWishlist } = params;
Logger.debug('[Magento Storefront]: useWishlist.removeItem params->', params);
const itemOnWishlist = findItemOnWishlist(currentWishlist, params.product);
@@ -137,8 +134,8 @@ const factoryParams: UseWishlistFactoryParams = {
return data?.removeProductsFromWishlist?.wishlist ?? {};
},
- clear: async ({ currentWishlist }) => ({}),
- isInWishlist: (context, params) => {
+ clear: () => (Promise.resolve()),
+ isInWishlist: (_context, params) => {
const {
currentWishlist,
product,
diff --git a/packages/composables/src/factories/useCurrencyFactory.ts b/packages/composables/src/factories/useCurrencyFactory.ts
index 294b4ea5b..51f652f6f 100644
--- a/packages/composables/src/factories/useCurrencyFactory.ts
+++ b/packages/composables/src/factories/useCurrencyFactory.ts
@@ -1,3 +1,4 @@
+/* eslint-disable @typescript-eslint/no-misused-promises */
/**
* @deprecated since version 1.0.0
*/
diff --git a/packages/composables/src/factories/useForgotPasswordFactory.ts b/packages/composables/src/factories/useForgotPasswordFactory.ts
index d8414b60f..a0fc0173f 100644
--- a/packages/composables/src/factories/useForgotPasswordFactory.ts
+++ b/packages/composables/src/factories/useForgotPasswordFactory.ts
@@ -6,7 +6,6 @@ import {
ComposableFunctionArgs,
configureFactoryParams,
Context,
- CustomQuery,
FactoryParams,
Logger,
sharedRef,
diff --git a/packages/composables/src/factories/useStoreFactory.ts b/packages/composables/src/factories/useStoreFactory.ts
index 76f193a22..c5fa07ece 100644
--- a/packages/composables/src/factories/useStoreFactory.ts
+++ b/packages/composables/src/factories/useStoreFactory.ts
@@ -39,7 +39,7 @@ export function useStoreFactory): Promise => {
+ const change = (store: ComposableFunctionArgs) => {
loading.value = true;
try {
_factoryParams.change(store);
diff --git a/packages/composables/src/factories/useWishlistFactory.ts b/packages/composables/src/factories/useWishlistFactory.ts
index 2bf155c17..81f053679 100644
--- a/packages/composables/src/factories/useWishlistFactory.ts
+++ b/packages/composables/src/factories/useWishlistFactory.ts
@@ -12,6 +12,7 @@ import {
ComposableFunctionArgs,
PlatformApi,
} from '@vue-storefront/core';
+import { Wishlist } from '@vue-storefront/magento-api';
import { UseWishlist, UseWishlistErrors } from '../types/composables';
export interface UseWishlistFactoryParams(
factoryParams: UseWishlistFactoryParams,
) => {
- const calculateWishlistTotal = (wishlists) => wishlists.reduce((prev, next) => (prev?.items_count ?? 0) + (next?.items_count ?? 0), 0);
+ const calculateWishlistTotal = (wishlists: Wishlist[]) => wishlists.reduce((prev, next) => prev + (next?.items_count ?? 0), 0);
const useWishlist = (ssrKey = 'useWishlistFactory'): UseWishlist => {
const loading: Ref = sharedRef(false, `useWishlist-loading-${ssrKey}`);
@@ -135,9 +136,9 @@ export const useWishlistFactory = {
Logger.debug(`useWishlist/${ssrKey}/loadItemsCount`);
try {
- const loadedWishlist = await _factoryParams.loadItemsCount(params);
- itemsCount.value = calculateWishlistTotal(loadedWishlist);
+ const loadedWishlist : WISHLIST = await _factoryParams.loadItemsCount(params);
+ itemsCount.value = calculateWishlistTotal([loadedWishlist]);
error.value.loadItemsCount = null;
} catch (err) {
error.value.loadItemsCount = err;
diff --git a/packages/composables/src/getters/categoryGetters.ts b/packages/composables/src/getters/categoryGetters.ts
index 4298c4c6e..8d95164bf 100644
--- a/packages/composables/src/getters/categoryGetters.ts
+++ b/packages/composables/src/getters/categoryGetters.ts
@@ -2,11 +2,11 @@
* @deprecated since version 1.0.0
*/
import { CategoryGetters, AgnosticCategoryTree, AgnosticBreadcrumb } from '@vue-storefront/core';
-import { Category } from '@vue-storefront/magento-api';
+import { CategoryTree } from '@vue-storefront/magento-api';
import { buildCategoryTree } from '../helpers/buildCategoryTree';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
-export const getTree = (category: Category): AgnosticCategoryTree | null => {
+export const getTree = (category: CategoryTree): AgnosticCategoryTree | null => {
if (!category) {
return null;
}
@@ -14,7 +14,7 @@ export const getTree = (category: Category): AgnosticCategoryTree | null => {
};
export const getCategoryTree = (
- category: Category,
+ category: CategoryTree,
currentCategory: string = '',
withProducts = false,
): AgnosticCategoryTree | null => (
@@ -45,7 +45,7 @@ export const getCategoryBreadcrumbs = (category: any): AgnosticBreadcrumb[] => {
return breadcrumbs;
};
-const categoryGetters: CategoryGetters = {
+const categoryGetters: CategoryGetters = {
getTree,
getBreadcrumbs: getCategoryBreadcrumbs,
getCategoryTree,
diff --git a/packages/composables/src/getters/facetGetters.ts b/packages/composables/src/getters/facetGetters.ts
index 59192e0df..7353e45ef 100644
--- a/packages/composables/src/getters/facetGetters.ts
+++ b/packages/composables/src/getters/facetGetters.ts
@@ -24,7 +24,7 @@ import {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const getAll = (searchData: SearchData, criteria?: string[]): AgnosticFacet[] => buildFacets(searchData, reduceForFacets, criteria);
-const getGrouped = (searchData, criteria?: string[]): AgnosticGroupedFacet[] => buildFacets(searchData, reduceForGroupedFacets, criteria)
+const getGrouped = (searchData: SearchData, criteria?: string[]): AgnosticGroupedFacet[] => buildFacets(searchData, reduceForGroupedFacets, criteria)
?.filter((facet) => facet.options && facet.options.length > 0);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
diff --git a/packages/composables/src/getters/orderGetters.ts b/packages/composables/src/getters/orderGetters.ts
index 6512be9ec..a07c36c0a 100644
--- a/packages/composables/src/getters/orderGetters.ts
+++ b/packages/composables/src/getters/orderGetters.ts
@@ -2,24 +2,25 @@
* @deprecated since version 1.0.0
*/
import { AgnosticPagination } from '@vue-storefront/core';
+import { CustomerOrder, OrderItemInterface } from '@vue-storefront/magento-api';
-export const getDate = (order: any): string => new Date(order?.created_at).toLocaleDateString() || '';
+export const getDate = (order: CustomerOrder): string => new Date(order?.created_at).toLocaleDateString() || '';
-export const getId = (order: any): string => String(Number.parseInt(order?.order_number, 10) || Math.floor(Math.random() * 100));
+export const getId = (order: CustomerOrder): string => String(Number.parseInt(order?.order_number, 10) || Math.floor(Math.random() * 100));
-export const getStatus = (order: any): string => order?.status || 'Failed';
+export const getStatus = (order: CustomerOrder): string => order?.status || 'Failed';
-export const getPrice = (order: any): number | null => order?.grand_total || 0;
+export const getPrice = (order: CustomerOrder): number | null => order?.grand_total || 0;
-export const getItems = (order: any): any[] => order?.items || [];
+export const getItems = (order: CustomerOrder): OrderItemInterface[] => order?.items || [];
-export const getItemSku = (item: any): string => item?.product_sku || 0;
+export const getItemSku = (item: OrderItemInterface): string => item?.product_sku || '';
-export const getItemName = (item: any): string => item?.product_name || 0;
+export const getItemName = (item: OrderItemInterface): string => item?.product_name || '';
-export const getItemQty = (item: any): number => item?.quantity_ordered || 0;
+export const getItemQty = (item: OrderItemInterface): number => item?.quantity_ordered || 0;
-export const getItemPrice = (item: any): number => item?.product_sale_price?.value || 0;
+export const getItemPrice = (item: OrderItemInterface): number => item?.product_sale_price?.value || 0;
export const getFormattedPrice = (price: number) => String(price);
diff --git a/packages/composables/src/getters/productGetters.ts b/packages/composables/src/getters/productGetters.ts
index 630016e1f..b158918c1 100644
--- a/packages/composables/src/getters/productGetters.ts
+++ b/packages/composables/src/getters/productGetters.ts
@@ -10,7 +10,7 @@ import {
} from '@vue-storefront/core';
import {
BundleProduct,
- Category, GroupedProduct,
+ Category, CategoryTree, GroupedProduct,
Product,
} from '@vue-storefront/magento-api';
@@ -105,7 +105,7 @@ export const getProductThumbnailImage = (product: Product): string => {
return product.thumbnail.url;
};
-export const getFiltered = (products: Product[], filters: ProductVariantFilters | any = {}): Product[] => {
+export const getFiltered = (products: Product[], _filters: ProductVariantFilters | any = {}): Product[] => {
if (!products) {
return [];
}
@@ -213,7 +213,7 @@ export const getFormattedPrice = (price: number) => {
}).format(price);
};
-export const getBreadcrumbs = (product: any, category?: Category): AgnosticBreadcrumb[] => {
+export const getBreadcrumbs = (product: Product, category?: CategoryTree): AgnosticBreadcrumb[] => {
let breadcrumbs = [];
if (!product) {
@@ -221,7 +221,7 @@ export const getBreadcrumbs = (product: any, category?: Category): AgnosticBread
}
if (category) {
- breadcrumbs = categoryGetters.getBreadcrumbs(category) as AgnosticBreadcrumb[];
+ breadcrumbs = categoryGetters.getBreadcrumbs(category);
}
breadcrumbs.push({
diff --git a/packages/composables/src/getters/reviewGetters.ts b/packages/composables/src/getters/reviewGetters.ts
index 2bf2ca85c..348e3d616 100644
--- a/packages/composables/src/getters/reviewGetters.ts
+++ b/packages/composables/src/getters/reviewGetters.ts
@@ -27,7 +27,7 @@ export const getReviewDate = (item: ProductReview): string => item.created_at;
export const getTotalReviews = (review: ProductReviews): number => review?.review_count || 0;
-export const getAverageRating = (review): number => (review?.reviews?.items?.reduce((acc, curr) => Number.parseInt(`${acc}`, 10) + getReviewRating(curr), 0)) / (review?.review_count || 1) || 0;
+export const getAverageRating = (review: ProductReviews): number => (review?.reviews?.items?.reduce((acc, curr) => Number.parseInt(`${acc}`, 10) + getReviewRating(curr as ProductReview), 0) ?? 0) / (review?.review_count || 1) || 0;
export const getRatesCount = (_review: ProductReviews): AgnosticRateCount[] => [];
diff --git a/packages/composables/src/getters/wishlistGetters.ts b/packages/composables/src/getters/wishlistGetters.ts
index 97763ad9a..f08b91371 100644
--- a/packages/composables/src/getters/wishlistGetters.ts
+++ b/packages/composables/src/getters/wishlistGetters.ts
@@ -7,19 +7,19 @@ import {
AgnosticTotals, AgnosticPagination,
} from '@vue-storefront/core';
import {
- Wishlist, WishlistQuery,
+ Wishlist, WishlistItemInterface,
} from '@vue-storefront/magento-api';
-export type WishlistProduct = WishlistQuery['customer']['wishlists'][0]['items_v2']['items'][0] & { variant: any };
+export type WishlistProduct = WishlistItemInterface;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
-export const getItems = (wishlist): WishlistProduct[] => wishlist.items_v2.items;
+export const getItems = (wishlist: Wishlist): WishlistItemInterface[] => wishlist.items_v2.items;
-export const getItemName = (product: WishlistProduct): string => product?.product?.name || '';
+export const getItemName = (product: WishlistItemInterface): string => product?.product?.name || '';
-export const getItemImage = (product: WishlistProduct): string => product?.product?.thumbnail.url || '';
+export const getItemImage = (product: WishlistItemInterface): string => product?.product?.thumbnail.url || '';
-export const getItemPrice = (product: WishlistProduct): AgnosticPrice => {
+export const getItemPrice = (product: WishlistItemInterface): AgnosticPrice => {
let regular = 0;
let special = null;
@@ -38,22 +38,16 @@ export const getItemPrice = (product: WishlistProduct): AgnosticPrice => {
};
};
-// eslint-disable-next-line @typescript-eslint/no-unused-vars
-export const getItemQty = (product: WishlistProduct): number => product.quantity;
+export const getItemQty = (product: WishlistItemInterface): number => product.quantity;
-// eslint-disable-next-line @typescript-eslint/no-unused-vars
-export const getItemAttributes = (product: WishlistProduct, filterByAttributeName?: string[]) => ({ '': '' });
+export const getItemAttributes = (_product: WishlistItemInterface, _filterByAttributeName?: string[]) => ({ '': '' });
-// eslint-disable-next-line @typescript-eslint/no-unused-vars
-export const getItemSku = (product: WishlistProduct): string => product?.product?.sku || '';
+export const getItemSku = (product: WishlistItemInterface): string => product?.product?.sku || '';
-// eslint-disable-next-line @typescript-eslint/no-unused-vars
-export const getTotals = (wishlist): AgnosticTotals => {
+export const getTotals = (wishlist: Wishlist | Wishlist[]): AgnosticTotals => {
if (Array.isArray(wishlist)) {
return wishlist[0]?.items_v2?.items.reduce((acc, curr) => ({
- // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
total: acc.total + getItemPrice(curr).special,
- // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
subtotal: acc.subtotal + getItemPrice(curr).regular,
}), ({ total: 0, subtotal: 0 }));
}
@@ -63,14 +57,11 @@ export const getTotals = (wishlist): AgnosticTotals => {
}), ({ total: 0, subtotal: 0 }));
};
-// eslint-disable-next-line @typescript-eslint/no-unused-vars
-export const getShippingPrice = (wishlist: Wishlist): number => 0;
+export const getShippingPrice = (_wishlist: Wishlist): number => 0;
-// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const getTotalItems = (wishlist: Wishlist): number => (Array.isArray(wishlist) ? wishlist[0]?.items_count : (wishlist?.items_count || 0));
-// eslint-disable-next-line @typescript-eslint/no-unused-vars
-export const getFormattedPrice = (price: number): string => '';
+export const getFormattedPrice = (_price: number): string => '';
const getPagination = (wishlistData: Wishlist): AgnosticPagination => ({
currentPage: wishlistData?.items_v2?.page_info?.current_page || 1,
@@ -81,22 +72,24 @@ const getPagination = (wishlistData: Wishlist): AgnosticPagination => ({
});
const getProducts = (wishlistData: Wishlist[] | Wishlist): {
- product: WishlistProduct;
+ product: WishlistItemInterface;
quantity: number;
added_at: string;
}[] => {
if (!wishlistData || (Array.isArray(wishlistData) && wishlistData.length === 0)) {
return [];
}
-
- const reducer = (acc, curr) => [...acc, ...curr?.items_v2?.items.map((item) => ({
+ const reducer = (
+ acc,
+ curr: Wishlist,
+ ) => [...acc, ...curr?.items_v2?.items.map((item) => ({
product: item.product,
quantity: item.quantity,
added_at: item.added_at,
id: item.id,
- }))];
+ })) ?? []];
- const mapper = (item) => ({
+ const mapper = (item: WishlistItemInterface) => ({
product: item.product,
quantity: item.quantity,
added_at: item.added_at,
@@ -104,19 +97,19 @@ const getProducts = (wishlistData: Wishlist[] | Wishlist): {
});
return Array.isArray(wishlistData)
- ? wishlistData.reduce((acc, curr) => reducer(acc, curr), [])
- : wishlistData?.items_v2?.items.map((e) => mapper(e));
+ ? wishlistData.reduce((accumulator, element) => reducer(accumulator, element), [])
+ : wishlistData?.items_v2?.items.map((element) => mapper(element));
};
-export interface WishlistGetters extends BaseWishlistGetters {
+export interface WishlistGetters extends BaseWishlistGetters {
getShippingPrice(wishlist: Wishlist): number;
- getItemQty(product: WishlistProduct): number;
+ getItemQty(product: WishlistItemInterface): number;
getPagination(wishlistData): AgnosticPagination;
getProducts(wishlistData): {
- product: WishlistProduct;
+ product: WishlistItemInterface;
quantity: number;
added_at: string;
}[];
diff --git a/packages/composables/src/helpers/buildCategoryTree.ts b/packages/composables/src/helpers/buildCategoryTree.ts
index 272b5556a..1c67c8b79 100644
--- a/packages/composables/src/helpers/buildCategoryTree.ts
+++ b/packages/composables/src/helpers/buildCategoryTree.ts
@@ -2,9 +2,10 @@
* @deprecated since version 1.0.0
*/
import { AgnosticCategoryTree } from '@vue-storefront/core';
+import { CategoryTree } from '@vue-storefront/magento-api';
import { htmlDecode } from './htmlDecoder';
-export const buildCategoryTree = (rootCategory: any, currentCategory: string, withProducts = false): AgnosticCategoryTree => {
+export const buildCategoryTree = (rootCategory: CategoryTree, currentCategory: string, withProducts = false): AgnosticCategoryTree => {
const hasChildren = Array.isArray(rootCategory.children) && rootCategory.children.length > 0;
const isCurrent = rootCategory.uid === currentCategory;
const label = htmlDecode(rootCategory.name);
diff --git a/packages/composables/src/helpers/htmlDecoder.ts b/packages/composables/src/helpers/htmlDecoder.ts
index 2e23e5247..7f6ee5622 100644
--- a/packages/composables/src/helpers/htmlDecoder.ts
+++ b/packages/composables/src/helpers/htmlDecoder.ts
@@ -1,7 +1,7 @@
/**
* @deprecated since version 1.0.0
*/
-export function htmlDecode(input) {
+export function htmlDecode(input: string) {
const formatName = () => {
try {
const domParser = new DOMParser();
diff --git a/packages/composables/tsconfig.eslint.json b/packages/composables/tsconfig.eslint.json
new file mode 100644
index 000000000..a47730729
--- /dev/null
+++ b/packages/composables/tsconfig.eslint.json
@@ -0,0 +1,7 @@
+{
+ "extends": "../../tsconfig.json",
+ "exclude": [
+ "lib",
+ "node_modules"
+ ]
+}
diff --git a/packages/theme/app/router.scrollBehavior.js b/packages/theme/app/router.scrollBehavior.js
index 4e0816d4c..64be137d8 100644
--- a/packages/theme/app/router.scrollBehavior.js
+++ b/packages/theme/app/router.scrollBehavior.js
@@ -1,6 +1,6 @@
-export default function (_to, _from, savedPosition) {
+export default function scrollBehavior(_to, _from, savedPosition) {
return savedPosition || {
x: 0,
y: 0,
};
-};
+}
diff --git a/packages/theme/components/AddToWishlist.vue b/packages/theme/components/AddToWishlist.vue
index f7137a114..f9e88c2b3 100644
--- a/packages/theme/components/AddToWishlist.vue
+++ b/packages/theme/components/AddToWishlist.vue
@@ -17,7 +17,7 @@
-
diff --git a/packages/theme/components/CartSidebar.vue b/packages/theme/components/CartSidebar.vue
index 292189ef9..06f3f7481 100644
--- a/packages/theme/components/CartSidebar.vue
+++ b/packages/theme/components/CartSidebar.vue
@@ -238,7 +238,7 @@
-
diff --git a/packages/theme/components/CurrencySelector.vue b/packages/theme/components/CurrencySelector.vue
index f7c9c6e2a..ebbc34a72 100644
--- a/packages/theme/components/CurrencySelector.vue
+++ b/packages/theme/components/CurrencySelector.vue
@@ -14,7 +14,7 @@
/>
-
@@ -82,15 +109,27 @@ export default defineComponent({
width: 100%;
min-height: 14rem;
color: var(--c-text);
- background-image: var(--hero-background-image, var(--hero-background-image-mobile));
- background-repeat: no-repeat;
- background-size: cover;
+
+ &__image {
+ position: absolute;
+ left: 0;
+ top: 0;
+ width: 100%;
+ height: 100%;
+
+ ::v-deep img {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ }
+ }
&__wrapper {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: center;
+ position: relative;
width: 100%;
padding: var(--spacer-sm);
text-decoration: none;
@@ -130,7 +169,6 @@ export default defineComponent({
}
@include for-desktop {
- background-image: var(--hero-background-image);
min-height: 36.625rem;
&__wrapper {
diff --git a/packages/theme/components/InstagramFeed.vue b/packages/theme/components/InstagramFeed.vue
index a1f0bbf5e..1dc2c30ab 100644
--- a/packages/theme/components/InstagramFeed.vue
+++ b/packages/theme/components/InstagramFeed.vue
@@ -92,7 +92,7 @@
-
diff --git a/packages/theme/components/TopBar/useTopBar.ts b/packages/theme/components/TopBar/useTopBar.ts
index 6c5f1137e..37ee4ae6d 100644
--- a/packages/theme/components/TopBar/useTopBar.ts
+++ b/packages/theme/components/TopBar/useTopBar.ts
@@ -1,20 +1,25 @@
import { ref, onMounted } from '@nuxtjs/composition-api';
+import type { Currency, StoreConfig } from '~/modules/GraphQL/types';
-import useApi from '~/composables/useApi';
+import { useApi } from '~/composables/useApi';
import checkStoresAndCurrencyQuery from './checkStoresAndCurrency.gql';
+type StoresAndCurrencyQueryResponse = {
+ availableStores: Pick[],
+ currency: Pick,
+};
+
export const useTopBar = () => {
const { query } = useApi();
- const hasStoresToSelect = ref(null);
- const hasCurrencyToSelect = ref(null);
+ const hasStoresToSelect = ref(null);
+ const hasCurrencyToSelect = ref(null);
onMounted(() => {
- query(checkStoresAndCurrencyQuery)
+ query(checkStoresAndCurrencyQuery)
+ // eslint-disable-next-line promise/always-return
.then((data) => {
- hasStoresToSelect.value = data?.availableStores?.length;
- hasCurrencyToSelect.value = data?.currency?.available_currency_codes?.length > 1;
-
- return data;
+ hasStoresToSelect.value = data.availableStores.length > 1;
+ hasCurrencyToSelect.value = data.currency.available_currency_codes.length > 1;
})
.catch(() => {
hasStoresToSelect.value = false;
diff --git a/packages/theme/components/UserAddressDetails.vue b/packages/theme/components/UserAddressDetails.vue
index beea8b071..1be1d1039 100644
--- a/packages/theme/components/UserAddressDetails.vue
+++ b/packages/theme/components/UserAddressDetails.vue
@@ -37,15 +37,17 @@
-
+
diff --git a/packages/theme/modules/catalog/category/components/breadcrumbs/__tests__/CategoryBreadcrumbs.spec.ts b/packages/theme/modules/catalog/category/components/breadcrumbs/__tests__/CategoryBreadcrumbs.spec.ts
new file mode 100644
index 000000000..98408f455
--- /dev/null
+++ b/packages/theme/modules/catalog/category/components/breadcrumbs/__tests__/CategoryBreadcrumbs.spec.ts
@@ -0,0 +1,67 @@
+import { mount } from '@vue/test-utils';
+import * as composables from '@nuxtjs/composition-api';
+import {
+ categoryAncestorsFirstLevelMock,
+ categoryAncestorsSecondLevelMock,
+ categoryAncestorsThirdLevelMock,
+ useTraverseCategoryMock,
+} from '~/test-utils/mocks/useTraverseCategoryMock';
+import { useUiHelpers } from '~/composables';
+import { useTraverseCategory } from '~/modules/catalog/category/helpers/useTraverseCategory';
+import CategoryBreadcrumbs from '~/modules/catalog/category/components/breadcrumbs/CategoryBreadcrumbs.vue';
+import type { CategoryTree } from '~/modules/GraphQL/types';
+
+jest.mock('@nuxtjs/composition-api', () => {
+ const originalComposables = jest.requireActual('@nuxtjs/composition-api');
+ return {
+ ...originalComposables,
+ useContext: jest.fn(),
+ };
+});
+jest.mock('~/composables');
+jest.mock('~/modules/catalog/category/helpers/useTraverseCategory');
+
+(composables.useContext as jest.Mock).mockReturnValue({
+ localePath: jest.fn((path: string) => path),
+});
+(useUiHelpers as jest.Mock).mockReturnValue({
+ getCatLink: jest.fn(
+ (category: CategoryTree): string => `/c/${category.url_path}${category.url_suffix || ''}`,
+ ),
+});
+
+describe('CategoryBreadcrumbs.vue', () => {
+ it('Breadcrumbs should not render if there is only a first level category', () => {
+ (useTraverseCategory as jest.Mock).mockReturnValue(useTraverseCategoryMock(categoryAncestorsFirstLevelMock));
+ const wrapper = mount(CategoryBreadcrumbs);
+ expect(wrapper).toBeDefined();
+ expect(wrapper.find('li').exists()).toBeFalsy();
+ });
+
+ it('Breadcrumbs must have one item for the second level category', () => {
+ (useTraverseCategory as jest.Mock).mockReturnValue(useTraverseCategoryMock(categoryAncestorsSecondLevelMock));
+ const wrapper = mount(CategoryBreadcrumbs);
+ expect(wrapper.findAll('li')).toHaveLength(1);
+ });
+
+ it('Breadcrumbs must have two item for the third level category', () => {
+ (useTraverseCategory as jest.Mock).mockReturnValue(useTraverseCategoryMock(categoryAncestorsThirdLevelMock));
+ const wrapper = mount(CategoryBreadcrumbs);
+ expect(wrapper.findAll('li')).toHaveLength(2);
+ });
+
+ it('Breadcrumb must have link that should have href attribute', () => {
+ (useTraverseCategory as jest.Mock).mockReturnValue(useTraverseCategoryMock(categoryAncestorsSecondLevelMock));
+ const wrapper = mount(CategoryBreadcrumbs);
+ const link = wrapper.find('a');
+ expect(link).toBeDefined();
+ expect(link.attributes('href')).toBeDefined();
+ });
+
+ it('The last breadcrumb must have \'current\' class', () => {
+ (useTraverseCategory as jest.Mock).mockReturnValue(useTraverseCategoryMock(categoryAncestorsThirdLevelMock));
+ const wrapper = mount(CategoryBreadcrumbs);
+ const links = wrapper.findAll('a');
+ expect(links.at(-1).classes()).toContain('current');
+ });
+});
diff --git a/packages/theme/modules/catalog/category/components/cms/__tests__/CmsContent.spec.ts b/packages/theme/modules/catalog/category/components/cms/__tests__/CmsContent.spec.ts
new file mode 100644
index 000000000..9203bc26d
--- /dev/null
+++ b/packages/theme/modules/catalog/category/components/cms/__tests__/CmsContent.spec.ts
@@ -0,0 +1,6 @@
+import { cmsContentTest } from '~/test-utils/tests/cmsContent';
+import CmsContent from '~/modules/catalog/category/components/cms/CmsContent.vue';
+
+describe('CmsContent.vue', () => {
+ cmsContentTest(CmsContent);
+});
diff --git a/packages/theme/modules/catalog/category/components/cms/categoryContent.gql.ts b/packages/theme/modules/catalog/category/components/cms/categoryContent.gql.ts
index 0cfc6c001..d0413f313 100644
--- a/packages/theme/modules/catalog/category/components/cms/categoryContent.gql.ts
+++ b/packages/theme/modules/catalog/category/components/cms/categoryContent.gql.ts
@@ -1,9 +1,9 @@
import { gql } from 'graphql-request';
export default gql`
- query category($id: Int!) {
- category(id: $id) {
- id
+ query getCategoryContentData($filters: CategoryFilterInput) {
+ categoryList(filters: $filters) {
+ uid
display_mode
landing_page
cms_block {
diff --git a/packages/theme/modules/catalog/category/components/cms/useCategoryContent.ts b/packages/theme/modules/catalog/category/components/cms/useCategoryContent.ts
index bc062e01a..dbe633aa1 100644
--- a/packages/theme/modules/catalog/category/components/cms/useCategoryContent.ts
+++ b/packages/theme/modules/catalog/category/components/cms/useCategoryContent.ts
@@ -21,10 +21,11 @@ interface CmsContentInterface {
export const useCategoryContent = () => {
const { query } = useApi();
- const getContentData = async (id: number): Promise => {
- const data = await query(categoryContentQuery, { id });
- const cmsBlock = data?.category?.cms_block ?? { cmsBlock: { content: '' } };
- const displayMode = data?.category?.display_mode ?? displayModesEnum.PRODUCTS;
+ const getContentData = async (uid: string): Promise => {
+ const data = await query(categoryContentQuery, { filters: { category_uid: { eq: uid } } });
+ const category = data.categoryList[0] ?? {};
+ const cmsBlock = category?.cms_block ?? { cmsBlock: { content: '' } };
+ const displayMode = category?.display_mode ?? displayModesEnum.PRODUCTS;
const isShowCms = displayMode === displayModesEnum.PAGE || displayMode === displayModesEnum.PRODUCTS_AND_PAGE;
const isShowProducts = displayMode === displayModesEnum.PRODUCTS || displayMode === displayModesEnum.PRODUCTS_AND_PAGE;
diff --git a/packages/theme/modules/catalog/category/components/filters/CategoryFilters.vue b/packages/theme/modules/catalog/category/components/filters/CategoryFilters.vue
index 1e54535ce..a33d2603c 100644
--- a/packages/theme/modules/catalog/category/components/filters/CategoryFilters.vue
+++ b/packages/theme/modules/catalog/category/components/filters/CategoryFilters.vue
@@ -63,8 +63,10 @@
+