Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,80 +5,92 @@ export const platformFacetsResponse = {
content: [],
facets: [
{
facet: 'facetEditorial',
filter: 'editorial',
label: 'Editorial',
facet: 'brand_facet',
filter: 'brand_facet',
label: 'Brand',
type: 'value',
values: [
{
id: 'DEBOLSILLO',
value: 'DEBOLSILLO',
count: 1149,
filter: 'editorial:DEBOLSILLO',
id: 'Nike',
value: 'Nike',
count: 1249,
filter: 'brand_facet:Nike',
},
{
id: 'ALFAGUARA',
value: 'ALFAGUARA',
count: 1005,
filter: 'editorial:ALFAGUARA',
id: 'Adidas',
value: 'Adidas',
count: 1105,
filter: 'brand_facet:Adidas',
},
{
id: 'PLANETA',
value: 'PLANETA',
count: 786,
filter: 'editorial:PLANETA',
id: "Levi's",
value: "Levi's",
count: 886,
filter: "brand_facet:Levi's",
},
],
},
{
facet: 'facetColecciondilve',
filter: 'facetColecciondilve',
label: 'Colección',
facet: 'gender',
filter: 'gender',
label: 'Gender',
type: 'value',
values: [
{
id: 'Best Seller',
value: 'Best Seller',
count: 265,
filter: 'facetColecciondilve:Best Seller',
id: 'men',
value: 'men',
count: 421,
filter: 'gender:men',
},
{
id: 'Jovenes lectores',
value: 'Jovenes lectores',
count: 238,
filter: 'facetColecciondilve:Jovenes lectores',
id: 'women',
value: 'women',
count: 247,
filter: 'gender:women',
},
{
id: 'Ficcion',
value: 'Ficcion',
count: 204,
filter: 'facetColecciondilve:Ficcion',
id: 'boys',
value: 'boys',
count: 35,
filter: 'gender:boys',
},
{
id: 'girls',
value: 'girls',
count: 28,
filter: 'gender:girls',
},
{
id: 'unisex',
value: 'unisex',
count: 5,
filter: 'gender:unisex',
},
],
},
{
facet: 'facetHierarchicalCategories',
filter: 'filterHierarchicalCategories',
label: 'Categorías',
facet: 'categoryPaths',
filter: 'categoryIds',
label: 'Categories',
type: 'hierarchical',
values: [
{
id: '121000000',
value: 'Literatura',
id: '78d9b7366',
value: 'Apparel',
count: 28672,
filter: 'filterHierarchicalCategories:121000000',
filter: 'categoryIds:78d9b7366',
},
{
id: '415000000',
value: 'Libro antiguo y de ocasion',
id: 'b08648dbd',
value: 'Accessories',
count: 14165,
filter: 'filterHierarchicalCategories:415000000',
filter: 'categoryIds:b08648dbd',
},
{
id: '117000000',
value: 'Infantil',
id: 'e5eef62d8',
value: 'Footwear',
count: 10903,
filter: 'filterHierarchicalCategories:117000000',
filter: 'categoryIds:e5eef62d8',
},
],
},
Expand Down
113 changes: 65 additions & 48 deletions packages/x-adapter-platform/src/__tests__/platform.adapter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,12 @@ describe('platformAdapter tests', () => {
lang: 'es',
device: 'mobile',
scope: 'mobile',
facets: true,
},
})
expect(fetchMock).toHaveBeenCalledTimes(1)
expect(fetchMock).toHaveBeenCalledWith(
'https://search.internal.test.empathy.co/query/empathy/search?internal=true&query=chips&origin=popular_search%3Apredictive_layer&start=0&rows=0&sort=price+asc&filter=categoryIds%3Affc61e1e9__be257cb26&filter=gender%3Amen&filter=price%3A10.0-20.0&instance=empathy&env=test&lang=es&device=mobile&scope=mobile',
'https://search.internal.test.empathy.co/query/empathy/search?internal=true&query=chips&origin=popular_search%3Apredictive_layer&start=0&rows=0&sort=price+asc&filter=categoryIds%3Affc61e1e9__be257cb26&filter=gender%3Amen&filter=price%3A10.0-20.0&instance=empathy&env=test&lang=es&device=mobile&scope=mobile&facets=true',
{
signal: expect.anything(),
headers: {
Expand Down Expand Up @@ -838,32 +839,32 @@ describe('platformAdapter tests', () => {
window.fetch = fetchMock as any

const response = await platformAdapter.facets({
query: 'books',
query: 'jeans',
filters: {
editorial: [
brand_facet: [
{
facetId: 'editorial',
id: 'editorial:ALFAGUARA',
label: 'ALFAGUARA',
facetId: 'brand_facet',
id: 'brand_facet:Adidas',
label: 'Adidas',
modelName: 'SimpleFilter',
selected: true,
totalResults: 1005,
totalResults: 1105,
} as Filter,
],
},
origin: 'search_box:none',
extraParams: {
instance: 'empathy',
env: 'test',
lang: 'es',
lang: 'en',
device: 'desktop',
scope: 'desktop',
},
})

expect(fetchMock).toHaveBeenCalledTimes(1)
expect(fetchMock).toHaveBeenCalledWith(
'https://search.internal.test.empathy.co/query/empathy/facets?query=books&origin=search_box%3Anone&filter=editorial%3AALFAGUARA&instance=empathy&env=test&lang=es&device=desktop&scope=desktop',
'https://search.internal.test.empathy.co/query/empathy/facets?query=jeans&origin=search_box%3Anone&filter=brand_facet%3AAdidas&instance=empathy&env=test&lang=en&device=desktop&scope=desktop',
{
signal: expect.anything(),
headers: {
Expand All @@ -877,97 +878,113 @@ describe('platformAdapter tests', () => {
{
filters: [
{
facetId: 'facetEditorial',
id: 'editorial:DEBOLSILLO',
label: 'DEBOLSILLO',
facetId: 'brand_facet',
id: 'brand_facet:Nike',
label: 'Nike',
modelName: 'SimpleFilter',
selected: false,
totalResults: 1149,
totalResults: 1249,
},
{
facetId: 'facetEditorial',
id: 'editorial:ALFAGUARA',
label: 'ALFAGUARA',
facetId: 'brand_facet',
id: 'brand_facet:Adidas',
label: 'Adidas',
modelName: 'SimpleFilter',
selected: false,
totalResults: 1005,
totalResults: 1105,
},
{
facetId: 'facetEditorial',
id: 'editorial:PLANETA',
label: 'PLANETA',
facetId: 'brand_facet',
id: "brand_facet:Levi's",
label: "Levi's",
modelName: 'SimpleFilter',
selected: false,
totalResults: 786,
totalResults: 886,
},
],
id: 'facetEditorial',
label: 'facetEditorial',
id: 'brand_facet',
label: 'brand_facet',
modelName: 'SimpleFacet',
},
{
filters: [
{
facetId: 'facetColecciondilve',
id: 'facetColecciondilve:Best Seller',
label: 'Best Seller',
facetId: 'gender',
id: 'gender:men',
label: 'men',
modelName: 'SimpleFilter',
selected: false,
totalResults: 421,
},
{
facetId: 'gender',
id: 'gender:women',
label: 'women',
modelName: 'SimpleFilter',
selected: false,
totalResults: 247,
},
{
facetId: 'gender',
id: 'gender:boys',
label: 'boys',
modelName: 'SimpleFilter',
selected: false,
totalResults: 265,
totalResults: 35,
},
{
facetId: 'facetColecciondilve',
id: 'facetColecciondilve:Jovenes lectores',
label: 'Jovenes lectores',
facetId: 'gender',
id: 'gender:girls',
label: 'girls',
modelName: 'SimpleFilter',
selected: false,
totalResults: 238,
totalResults: 28,
},
{
facetId: 'facetColecciondilve',
id: 'facetColecciondilve:Ficcion',
label: 'Ficcion',
facetId: 'gender',
id: 'gender:unisex',
label: 'unisex',
modelName: 'SimpleFilter',
selected: false,
totalResults: 204,
totalResults: 5,
},
],
id: 'facetColecciondilve',
label: 'facetColecciondilve',
id: 'gender',
label: 'gender',
modelName: 'SimpleFacet',
},
{
filters: [
{
facetId: 'facetHierarchicalCategories',
id: 'filterHierarchicalCategories:121000000',
label: 'Literatura',
facetId: 'categoryPaths',
id: 'categoryIds:78d9b7366',
label: 'Apparel',
modelName: 'HierarchicalFilter',
parentId: null,
selected: false,
totalResults: 28672,
},
{
facetId: 'facetHierarchicalCategories',
id: 'filterHierarchicalCategories:415000000',
label: 'Libro antiguo y de ocasion',
facetId: 'categoryPaths',
id: 'categoryIds:b08648dbd',
label: 'Accessories',
modelName: 'HierarchicalFilter',
parentId: null,
selected: false,
totalResults: 14165,
},
{
facetId: 'facetHierarchicalCategories',
id: 'filterHierarchicalCategories:117000000',
label: 'Infantil',
facetId: 'categoryPaths',
id: 'categoryIds:e5eef62d8',
label: 'Footwear',
modelName: 'HierarchicalFilter',
parentId: null,
selected: false,
totalResults: 10903,
},
],
id: 'facetHierarchicalCategories',
label: 'facetHierarchicalCategories',
id: 'categoryPaths',
label: 'categoryPaths',
modelName: 'HierarchicalFacet',
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { facetsResponseMapper } from '../mappers/responses/facets-response.mappe
import { getDefaultHeaders, getSearchServiceUrl } from './utils'

/**
* Default adapter for the search endpoint.
* Default adapter for the facet endpoint.
*
* @public
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe('searchRequestMapper tests', () => {
lang: 'en',
device: 'mobile',
scope: 'mobile',
facets: true,
},
})
})
Expand Down
Loading
Loading