From f1890de82c42dba7d52a46014adb1ee1520dd07c Mon Sep 17 00:00:00 2001 From: beatrizmaselli Date: Mon, 21 Oct 2024 10:38:50 +0200 Subject: [PATCH 01/10] update sku selector logic + fix tests --- react/__mocks__/vtex.render-runtime.js | 8 +++ .../__tests__/components/SKUSelector.test.tsx | 27 +++++-- .../__snapshots__/InfoCard.test.js.snap | 2 + .../__snapshots__/SKUSelector.test.tsx.snap | 10 +-- .../__snapshots__/SearchBar.test.js.snap | 1 + .../SKUSelector/components/SKUSelector.tsx | 11 ++- react/package.json | 23 +++--- react/yarn.lock | 70 ++++++++++--------- 8 files changed, 96 insertions(+), 56 deletions(-) diff --git a/react/__mocks__/vtex.render-runtime.js b/react/__mocks__/vtex.render-runtime.js index 7646d6f43..632b22456 100644 --- a/react/__mocks__/vtex.render-runtime.js +++ b/react/__mocks__/vtex.render-runtime.js @@ -10,6 +10,14 @@ const runtime = { culture: { currency: 'USD' }, query: 'foo', navigate: jest.fn(), + getSettings: () => ({ + 'vtex.store': { + storeName: 'Store Theme - VTEX Base Store', + titleTag: 'Store Theme - VTEX Base Store', + metaTagDescription: 'Store Theme - VTEX Base Store', + metaTagKeywords: 'store theme, vtex, store, vtex io, base store, vtex', + }, + }), } export const withRuntimeContext = Comp => diff --git a/react/__tests__/components/SKUSelector.test.tsx b/react/__tests__/components/SKUSelector.test.tsx index 96899bf69..eeb1fc9b3 100644 --- a/react/__tests__/components/SKUSelector.test.tsx +++ b/react/__tests__/components/SKUSelector.test.tsx @@ -33,7 +33,10 @@ describe('', () => { }) it('should render the options an select one', async () => { - const defaultSeller = { commertialOffer: { Price: 15 } } + const defaultSeller = { + commertialOffer: { Price: 15, AvailableQuantity: 1 }, + } + const skuItems = [ { itemId: '1', @@ -109,7 +112,10 @@ describe('', () => { }) it('should render only three main variations', async () => { - const defaultSeller = { commertialOffer: { Price: 15 } } + const defaultSeller = { + commertialOffer: { Price: 15, AvailableQuantity: 1 }, + } + const skuItems = [ { itemId: '1', @@ -173,7 +179,10 @@ describe('', () => { }) it('should render show 8 items for variation and see more button', async () => { - const defaultSeller = { commertialOffer: { Price: 15 } } + const defaultSeller = { + commertialOffer: { Price: 15, AvailableQuantity: 1 }, + } + const skuItems = [ { itemId: '1', @@ -637,7 +646,10 @@ describe('', () => { }) it('should show all variations when count is inside threshold', async () => { - const defaultSeller = { commertialOffer: { Price: 15 } } + const defaultSeller = { + commertialOffer: { Price: 15, AvailableQuantity: 1 }, + } + const skuItems = [ { itemId: '1', @@ -1410,6 +1422,10 @@ describe('', () => { }) it('must order sku specification to be sorted in alphabetical order', async () => { + const defaultSeller = { + commertialOffer: { Price: 15, AvailableQuantity: 1 }, + } + const skuItems = [ { itemId: '1', @@ -1419,6 +1435,7 @@ describe('', () => { { name: 'Color', values: ['Gray'] }, ], images: [], + sellers: [defaultSeller], }, { itemId: '4', @@ -1431,6 +1448,7 @@ describe('', () => { { name: 'Color', values: ['Gray'] }, ], images: [], + sellers: [defaultSeller], }, { itemId: '4', @@ -1443,6 +1461,7 @@ describe('', () => { { name: 'Color', values: ['Gray'] }, ], images: [], + sellers: [defaultSeller], }, ] diff --git a/react/__tests__/components/__snapshots__/InfoCard.test.js.snap b/react/__tests__/components/__snapshots__/InfoCard.test.js.snap index 99c5f4fb2..bcd6a7a24 100644 --- a/react/__tests__/components/__snapshots__/InfoCard.test.js.snap +++ b/react/__tests__/components/__snapshots__/InfoCard.test.js.snap @@ -236,6 +236,7 @@ exports[` should render with image and text side by side 1`] = ` alt="CLICK HERE" class="infoCardImage" data-testid="half-image" + fetchpriority="auto" src="my-image.com/image.png" style="object-fit: cover;" /> @@ -315,6 +316,7 @@ exports[` should wrap half image in a link with imageActionUrl 1`] = alt="CLICK HERE" class="infoCardImage" data-testid="half-image" + fetchpriority="auto" src="my-image.com/image.png" style="object-fit: cover;" /> diff --git a/react/__tests__/components/__snapshots__/SKUSelector.test.tsx.snap b/react/__tests__/components/__snapshots__/SKUSelector.test.tsx.snap index c6aa3133a..08efc53c0 100644 --- a/react/__tests__/components/__snapshots__/SKUSelector.test.tsx.snap +++ b/react/__tests__/components/__snapshots__/SKUSelector.test.tsx.snap @@ -24,7 +24,7 @@ exports[` should consider order from skuSpecifications 1`] = ` class="skuSelectorOptionsList w-100 inline-flex flex-wrap ml2 items-center" >
@@ -45,7 +45,7 @@ exports[` should consider order from skuSpecifications 1`] = `
@@ -66,7 +66,7 @@ exports[` should consider order from skuSpecifications 1`] = `
@@ -108,7 +108,7 @@ exports[` should consider order from skuSpecifications 1`] = ` class="skuSelectorOptionsList w-100 inline-flex flex-wrap ml2 items-center" >
@@ -129,7 +129,7 @@ exports[` should consider order from skuSpecifications 1`] = `
diff --git a/react/__tests__/components/__snapshots__/SearchBar.test.js.snap b/react/__tests__/components/__snapshots__/SearchBar.test.js.snap index 67348110f..ce83af81e 100644 --- a/react/__tests__/components/__snapshots__/SearchBar.test.js.snap +++ b/react/__tests__/components/__snapshots__/SearchBar.test.js.snap @@ -35,6 +35,7 @@ exports[` should match snapshot 1`] = ` class="suffixWrapper flex h-100" >