diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7c96e88ca..e1c156d87 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased]
+### Added
+
+- `variant` to `facets` query, used to execute A/B tests.
+
## [3.133.1] - 2024-10-02
### Fixed
diff --git a/react/__tests__/Gallery.test.js b/react/__tests__/Gallery.test.js
index 5294d91ae..f10c83334 100644
--- a/react/__tests__/Gallery.test.js
+++ b/react/__tests__/Gallery.test.js
@@ -19,6 +19,7 @@ beforeEach(() => {
jest.clearAllMocks()
mockUseRuntime.mockImplementation(() => ({
+ route: { routeId: 'routeId' },
getSettings: () => ({}),
}))
diff --git a/react/__tests__/components/PriceRange.test.js b/react/__tests__/components/PriceRange.test.js
index 8598e4ac9..00cf97427 100644
--- a/react/__tests__/components/PriceRange.test.js
+++ b/react/__tests__/components/PriceRange.test.js
@@ -5,13 +5,17 @@ import { useRuntime } from 'vtex.render-runtime'
import PriceRange from '../../components/PriceRange'
const mockUseRuntime = useRuntime
-const mockSetQuery = jest.fn()
+const mockOnChangePriceRange = jest.fn()
+
+jest.spyOn(window, 'scroll').mockImplementation(jest.fn())
beforeEach(() => {
jest.clearAllMocks()
mockUseRuntime.mockImplementation(() => ({
- setQuery: mockSetQuery,
+ query: {
+ priceRange: {},
+ },
getSettings: () => ({}),
culture: { country: 'USA', currency: 'USD' },
}))
@@ -62,6 +66,7 @@ const mockProps = {
},
],
preventRouteChange: false,
+ onChangePriceRange: mockOnChangePriceRange,
}
describe('', () => {
@@ -78,11 +83,11 @@ describe('', () => {
fireEvent.click(getByText('$1.00 $10.00'))
- expect(mockSetQuery).not.toBeCalled()
+ expect(mockOnChangePriceRange).not.toBeCalled()
jest.runAllTimers()
- expect(mockSetQuery).toHaveBeenCalledTimes(1)
+ expect(mockOnChangePriceRange).toHaveBeenCalledTimes(1)
})
it('should call setQuery on Slider change only once after multiple interactions', () => {
@@ -93,11 +98,11 @@ describe('', () => {
fireEvent.click(getByText('$1.00 $10.00'))
fireEvent.click(getByText('$1.00 $10.00'))
- expect(mockSetQuery).not.toBeCalled()
+ expect(mockOnChangePriceRange).not.toBeCalled()
jest.runAllTimers()
- expect(mockSetQuery).toHaveBeenCalledTimes(1)
+ expect(mockOnChangePriceRange).toHaveBeenCalledTimes(1)
})
it('should render defaultValues', () => {
diff --git a/react/components/SearchQuery.js b/react/components/SearchQuery.js
index c710be21f..5a8a0d291 100644
--- a/react/components/SearchQuery.js
+++ b/react/components/SearchQuery.js
@@ -232,6 +232,7 @@ const useQueries = (variables, facetsArgs, price) => {
fuzzy: variables.fuzzy,
searchState: variables.searchState || undefined,
initialAttributes: getInitialAttributes(),
+ variant: getCookie('sp-variant'),
},
skip: !facetsArgs.withFacets,
})
diff --git a/react/hooks/useSession.ts b/react/hooks/useSession.ts
index ed1ea938e..ceced56aa 100644
--- a/react/hooks/useSession.ts
+++ b/react/hooks/useSession.ts
@@ -27,7 +27,7 @@ const useSession = () => {
}
return JSON.parse(data.namespaces.public.shippingOption.value)
- }, [])
+ }, [rootPath])
return { getSession }
}
diff --git a/react/package.json b/react/package.json
index 6ed1ad7b3..03100b80f 100644
--- a/react/package.json
+++ b/react/package.json
@@ -63,7 +63,7 @@
"vtex.store-drawer": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-drawer@0.16.2/public/@types/vtex.store-drawer",
"vtex.store-graphql": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-graphql@2.156.1/public/@types/vtex.store-graphql",
"vtex.store-icons": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-icons@0.18.0/public/@types/vtex.store-icons",
- "vtex.store-resources": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-resources@0.95.0/public/@types/vtex.store-resources",
+ "vtex.store-resources": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-resources@0.101.0/public/@types/vtex.store-resources",
"vtex.structured-data": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.structured-data@0.9.1/public/@types/vtex.structured-data",
"vtex.styleguide": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.146.3/public/@types/vtex.styleguide",
"vtex.tab-layout": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.tab-layout@0.4.3/public/@types/vtex.tab-layout"
diff --git a/react/utils/compatibilityLayer.js b/react/utils/compatibilityLayer.js
index c1f2d9f1c..583bff626 100644
--- a/react/utils/compatibilityLayer.js
+++ b/react/utils/compatibilityLayer.js
@@ -54,7 +54,7 @@ export const buildSelectedFacetsAndFullText = (query, map, priceRange) => {
}
const addMap = facet => {
- facet['map'] = facet.key
+ facet.map = facet.key
if (facet.children) {
facet.children.forEach(facetChild => addMap(facetChild))
diff --git a/react/yarn.lock b/react/yarn.lock
index 8ff11e17b..5ad7f72e4 100644
--- a/react/yarn.lock
+++ b/react/yarn.lock
@@ -5624,9 +5624,9 @@ validate-npm-package-license@^3.0.1:
version "0.18.0"
resolved "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-icons@0.18.0/public/@types/vtex.store-icons#0ee94d549aa283ce3a13ab987c13eac4fdfd1bba"
-"vtex.store-resources@http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-resources@0.95.0/public/@types/vtex.store-resources":
- version "0.95.0"
- resolved "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-resources@0.95.0/public/@types/vtex.store-resources#74a95451b866ad56d7032e78298eba2174e5e2a0"
+"vtex.store-resources@http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-resources@0.101.0/public/@types/vtex.store-resources":
+ version "0.101.0"
+ resolved "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-resources@0.101.0/public/@types/vtex.store-resources#d692dadaabcbbd879a611dc5bec3dcd0d4f3fb31"
"vtex.structured-data@http://vtex.vtexassets.com/_v/public/typings/v1/vtex.structured-data@0.9.1/public/@types/vtex.structured-data":
version "0.9.1"