From 1bc60d31cbddff6fa7313be8437d8272da9dbda6 Mon Sep 17 00:00:00 2001 From: Tiago Gimenes Date: Wed, 15 Jun 2022 09:50:50 -0300 Subject: [PATCH] fix tests --- packages/api/src/__generated__/schema.ts | 553 +++++++++--------- .../test/__snapshots__/queries.test.ts.snap | 23 - packages/api/test/schema.test.ts | 6 +- packages/sdk/test/search/Provider.test.tsx | 143 ++++- packages/ui/src/atoms/Slider/Slider.test.tsx | 15 +- .../molecules/PriceRange/PriceRange.test.tsx | 10 +- 6 files changed, 427 insertions(+), 323 deletions(-) diff --git a/packages/api/src/__generated__/schema.ts b/packages/api/src/__generated__/schema.ts index 50ecee5f26..94e1082e4b 100644 --- a/packages/api/src/__generated__/schema.ts +++ b/packages/api/src/__generated__/schema.ts @@ -1,303 +1,304 @@ -export type Maybe = T | null -export type Exact = { - [K in keyof T]: T[K] -} -export type MakeOptional = Omit & { - [SubKey in K]?: Maybe -} -export type MakeMaybe = Omit & { - [SubKey in K]: Maybe -} +export type Maybe = T | null; +export type Exact = { [K in keyof T]: T[K] }; +export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; +export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; /** All built-in and custom scalars, mapped to their actual values */ export type Scalars = { - ID: string - String: string - Boolean: boolean - Int: number - Float: number - ObjectOrString: any -} + ID: string; + String: string; + Boolean: boolean; + Int: number; + Float: number; + ObjectOrString: any; +}; /** Shopping cart input. */ export type IStoreCart = { /** Order information, including `orderNumber` and `acceptedOffer`. */ - order: IStoreOrder -} + order: IStoreOrder; +}; export type IStoreCurrency = { /** Currency code (e.g: USD). */ - code: Scalars['String'] + code: Scalars['String']; /** Currency symbol (e.g: $). */ - symbol: Scalars['String'] -} + symbol: Scalars['String']; +}; /** Image input. */ export type IStoreImage = { /** Alias for the input image. */ - alternateName: Scalars['String'] + alternateName: Scalars['String']; /** Image input URL. */ - url: Scalars['String'] -} + url: Scalars['String']; +}; /** Offer input. */ export type IStoreOffer = { /** Information on the item being offered. */ - itemOffered: IStoreProduct + itemOffered: IStoreProduct; /** This is displayed as the "from" price in the context of promotions' price comparison. This may change before it reaches the shelf. */ - listPrice: Scalars['Float'] + listPrice: Scalars['Float']; /** Also known as spot price. */ - price: Scalars['Float'] + price: Scalars['Float']; /** Number of items offered. */ - quantity: Scalars['Int'] + quantity: Scalars['Int']; /** Seller responsible for the offer. */ - seller: IStoreOrganization -} + seller: IStoreOrganization; +}; /** Order input. */ export type IStoreOrder = { /** Array with information on each accepted offer. */ - acceptedOffer: Array + acceptedOffer: Array; /** ID of the order in [VTEX order management](https://help.vtex.com/en/tutorial/license-manager-resources-oms--60QcBsvWeum02cFi3GjBzg#). */ - orderNumber: Scalars['String'] -} + orderNumber: Scalars['String']; +}; /** Organization input. */ export type IStoreOrganization = { /** Organization ID. */ - identifier: Scalars['String'] -} + identifier: Scalars['String']; +}; /** Client profile data. */ export type IStorePerson = { /** Client email. */ - email: Scalars['String'] + email: Scalars['String']; /** Client last name. */ - familyName: Scalars['String'] + familyName: Scalars['String']; /** Client first name. */ - givenName: Scalars['String'] + givenName: Scalars['String']; /** Client ID. */ - id: Scalars['String'] -} + id: Scalars['String']; +}; /** Product input. Products are variants within product groups, equivalent to VTEX [SKUs](https://help.vtex.com/en/tutorial/what-is-an-sku--1K75s4RXAQyOuGUYKMM68u#). For example, you may have a **Shirt** product group with associated products such as **Blue shirt size L**, **Green shirt size XL** and so on. */ export type IStoreProduct = { /** Custom Product Additional Properties. */ - additionalProperty?: Maybe> + additionalProperty?: Maybe>; /** Array of product images. */ - image: Array + image: Array; /** Product name. */ - name: Scalars['String'] + name: Scalars['String']; /** Stock Keeping Unit. Merchant-specific ID for the product. */ - sku: Scalars['String'] -} + sku: Scalars['String']; +}; export type IStorePropertyValue = { /** Property name. */ - name: Scalars['String'] + name: Scalars['String']; /** Property id. This propert changes according to the content of the object. */ - propertyID?: Maybe + propertyID?: Maybe; /** Property value. May hold a string or the string representation of an object. */ - value: Scalars['ObjectOrString'] + value: Scalars['ObjectOrString']; /** Specifies the nature of the value */ - valueReference: Scalars['String'] -} + valueReference: Scalars['String']; +}; /** Selected search facet input. */ export type IStoreSelectedFacet = { /** Selected search facet key. */ - key: Scalars['String'] + key: Scalars['String']; /** Selected search facet value. */ - value: Scalars['String'] -} + value: Scalars['String']; +}; /** Session input. */ export type IStoreSession = { /** Session input channel. */ - channel?: Maybe + channel?: Maybe; /** Session input country. */ - country: Scalars['String'] + country: Scalars['String']; /** Session input currency. */ - currency: IStoreCurrency + currency: IStoreCurrency; /** Session input locale. */ - locale: Scalars['String'] + locale: Scalars['String']; /** Session input postal code. */ - person?: Maybe + person?: Maybe; /** Session input postal code. */ - postalCode?: Maybe -} + postalCode?: Maybe; +}; export type Mutation = { - __typename?: 'Mutation' + __typename?: 'Mutation'; /** Checks for changes between the cart presented in the UI and the cart stored in the ecommerce platform. If changes are detected, it returns the cart stored on the platform. Otherwise, it returns `null`. */ - validateCart?: Maybe + validateCart?: Maybe; /** Updates a web session with the specified values. */ - validateSession?: Maybe -} + validateSession?: Maybe; +}; + export type MutationValidateCartArgs = { - cart: IStoreCart -} + cart: IStoreCart; +}; + export type MutationValidateSessionArgs = { - search: Scalars['String'] - session: IStoreSession -} + search: Scalars['String']; + session: IStoreSession; +}; export type Query = { - __typename?: 'Query' + __typename?: 'Query'; /** Returns information about all collections. */ - allCollections: StoreCollectionConnection + allCollections: StoreCollectionConnection; /** Returns information about all products. */ - allProducts: StoreProductConnection + allProducts: StoreProductConnection; /** Returns the details of a collection based on the collection slug. */ - collection: StoreCollection + collection: StoreCollection; /** Returns the details of a product based on the specified locator. */ - product: StoreProduct + product: StoreProduct; /** Returns the result of a product, facet, or suggestion search. */ - search: StoreSearchResult -} + search: StoreSearchResult; +}; + export type QueryAllCollectionsArgs = { - after?: Maybe - first: Scalars['Int'] -} + after?: Maybe; + first: Scalars['Int']; +}; + export type QueryAllProductsArgs = { - after?: Maybe - first: Scalars['Int'] -} + after?: Maybe; + first: Scalars['Int']; +}; + export type QueryCollectionArgs = { - slug: Scalars['String'] -} + slug: Scalars['String']; +}; + export type QueryProductArgs = { - locator: Array -} + locator: Array; +}; + export type QuerySearchArgs = { - after?: Maybe - first: Scalars['Int'] - selectedFacets?: Maybe> - sort?: Maybe - term?: Maybe -} + after?: Maybe; + first: Scalars['Int']; + selectedFacets?: Maybe>; + sort?: Maybe; + term?: Maybe; +}; /** Aggregate offer information, for a given SKU that is available to be fulfilled by multiple sellers. */ export type StoreAggregateOffer = { - __typename?: 'StoreAggregateOffer' + __typename?: 'StoreAggregateOffer'; /** Highest price among all sellers. */ - highPrice: Scalars['Float'] + highPrice: Scalars['Float']; /** Lowest price among all sellers. */ - lowPrice: Scalars['Float'] + lowPrice: Scalars['Float']; /** Number of sellers selling this SKU. */ - offerCount: Scalars['Int'] + offerCount: Scalars['Int']; /** Array with information on each available offer. */ - offers: Array + offers: Array; /** ISO code of the currency used for the offer prices. */ - priceCurrency: Scalars['String'] -} + priceCurrency: Scalars['String']; +}; /** Average rating, based on multiple ratings or reviews. */ export type StoreAggregateRating = { - __typename?: 'StoreAggregateRating' + __typename?: 'StoreAggregateRating'; /** Value of the aggregate rating. */ - ratingValue: Scalars['Float'] + ratingValue: Scalars['Float']; /** Total number of ratings. */ - reviewCount: Scalars['Int'] -} + reviewCount: Scalars['Int']; +}; /** information about the author of a product review or rating. */ export type StoreAuthor = { - __typename?: 'StoreAuthor' + __typename?: 'StoreAuthor'; /** Author name. */ - name: Scalars['String'] -} + name: Scalars['String']; +}; /** Brand of a given product. */ export type StoreBrand = { - __typename?: 'StoreBrand' + __typename?: 'StoreBrand'; /** Brand name. */ - name: Scalars['String'] -} + name: Scalars['String']; +}; /** List of items consisting of chain linked web pages, ending with the current page. */ export type StoreBreadcrumbList = { - __typename?: 'StoreBreadcrumbList' + __typename?: 'StoreBreadcrumbList'; /** Array with breadcrumb elements. */ - itemListElement: Array + itemListElement: Array; /** Number of breadcrumbs in the list. */ - numberOfItems: Scalars['Int'] -} + numberOfItems: Scalars['Int']; +}; /** Shopping cart information. */ export type StoreCart = { - __typename?: 'StoreCart' + __typename?: 'StoreCart'; /** List of shopping cart messages. */ - messages: Array + messages: Array; /** Order information, including `orderNumber` and `acceptedOffer`. */ - order: StoreOrder -} + order: StoreOrder; +}; /** Shopping cart message. */ export type StoreCartMessage = { - __typename?: 'StoreCartMessage' + __typename?: 'StoreCartMessage'; /** Shopping cart message status, which can be `INFO`, `WARNING` or `ERROR`. */ - status: StoreStatus + status: StoreStatus; /** Shopping cart message text. */ - text: Scalars['String'] -} + text: Scalars['String']; +}; /** Product collection information. */ export type StoreCollection = { - __typename?: 'StoreCollection' + __typename?: 'StoreCollection'; /** List of items consisting of chain linked web pages, ending with the current page. */ - breadcrumbList: StoreBreadcrumbList + breadcrumbList: StoreBreadcrumbList; /** Collection ID. */ - id: Scalars['ID'] + id: Scalars['ID']; /** Collection meta information. Used for search. */ - meta: StoreCollectionMeta + meta: StoreCollectionMeta; /** Meta tag data. */ - seo: StoreSeo + seo: StoreSeo; /** Corresponding collection URL slug, with which to retrieve this entity. */ - slug: Scalars['String'] + slug: Scalars['String']; /** Collection type. */ - type: StoreCollectionType -} + type: StoreCollectionType; +}; /** Collection connections, including pagination information and collections returned by the query. */ export type StoreCollectionConnection = { - __typename?: 'StoreCollectionConnection' + __typename?: 'StoreCollectionConnection'; /** Array with collection connection page edges, each containing a collection and a corresponding cursor.. */ - edges: Array + edges: Array; /** Collection pagination information. */ - pageInfo: StorePageInfo -} + pageInfo: StorePageInfo; +}; /** Each collection edge contains a `node`, with product collection information, and a `cursor`, that can be used as a reference for pagination. */ export type StoreCollectionEdge = { - __typename?: 'StoreCollectionEdge' + __typename?: 'StoreCollectionEdge'; /** Collection cursor. Used as pagination reference. */ - cursor: Scalars['String'] + cursor: Scalars['String']; /** Each collection node contains the information of a product collection returned by the query. */ - node: StoreCollection -} + node: StoreCollection; +}; /** Product collection facet, used for search. */ export type StoreCollectionFacet = { - __typename?: 'StoreCollectionFacet' + __typename?: 'StoreCollectionFacet'; /** Facet key. */ - key: Scalars['String'] + key: Scalars['String']; /** Facet value. */ - value: Scalars['String'] -} + value: Scalars['String']; +}; /** Collection meta information. Used for search. */ export type StoreCollectionMeta = { - __typename?: 'StoreCollectionMeta' + __typename?: 'StoreCollectionMeta'; /** List of selected collection facets. */ - selectedFacets: Array -} + selectedFacets: Array; +}; /** Product collection type. Possible values are `Department`, `Category`, `Brand` or `Cluster`. */ export const enum StoreCollectionType { @@ -308,17 +309,17 @@ export const enum StoreCollectionType { /** Product cluster. */ Cluster = 'Cluster', /** First level of product categorization. */ - Department = 'Department', -} + Department = 'Department' +}; /** Currency information. */ export type StoreCurrency = { - __typename?: 'StoreCurrency' + __typename?: 'StoreCurrency'; /** Currency code (e.g: USD). */ - code: Scalars['String'] + code: Scalars['String']; /** Currency symbol (e.g: $). */ - symbol: Scalars['String'] -} + symbol: Scalars['String']; +}; export type StoreFacet = StoreFacetBoolean | StoreFacetRange; @@ -337,7 +338,7 @@ export type StoreFacetBoolean = { export type StoreFacetRange = { __typename?: 'StoreFacetRange'; /** Facet key. */ - key: Scalars['String'] + key: Scalars['String']; /** Facet label. */ label: Scalars['String']; max: StoreFacetValueRange; @@ -350,21 +351,21 @@ export const enum StoreFacetType { /** Indicates boolean search facet. */ Boolean = 'BOOLEAN', /** Indicates range type search facet. */ - Range = 'RANGE', -} + Range = 'RANGE' +}; /** Information of a specific facet value. */ export type StoreFacetValueBoolean = { __typename?: 'StoreFacetValueBoolean'; /** Facet value label. */ - label: Scalars['String'] + label: Scalars['String']; /** Number of items with this facet. */ - quantity: Scalars['Int'] + quantity: Scalars['Int']; /** Indicates whether facet is selected. */ - selected: Scalars['Boolean'] + selected: Scalars['Boolean']; /** Facet value. */ - value: Scalars['String'] -} + value: Scalars['String']; +}; export type StoreFacetValueRange = { __typename?: 'StoreFacetValueRange'; @@ -374,230 +375,230 @@ export type StoreFacetValueRange = { /** Image. */ export type StoreImage = { - __typename?: 'StoreImage' + __typename?: 'StoreImage'; /** Alias for the image. */ - alternateName: Scalars['String'] + alternateName: Scalars['String']; /** Image URL. */ - url: Scalars['String'] -} + url: Scalars['String']; +}; /** Item of a list. */ export type StoreListItem = { - __typename?: 'StoreListItem' + __typename?: 'StoreListItem'; /** List item value. */ - item: Scalars['String'] + item: Scalars['String']; /** Name of the list item. */ - name: Scalars['String'] + name: Scalars['String']; /** Position of the item in the list. */ - position: Scalars['Int'] -} + position: Scalars['Int']; +}; /** Offer information. */ export type StoreOffer = { - __typename?: 'StoreOffer' + __typename?: 'StoreOffer'; /** Offer item availability. */ - availability: Scalars['String'] + availability: Scalars['String']; /** Offer item condition. */ - itemCondition: Scalars['String'] + itemCondition: Scalars['String']; /** Information on the item being offered. */ - itemOffered: StoreProduct + itemOffered: StoreProduct; /** This is displayed as the "from" price in the context of promotions' price comparison. This may change before it reaches the shelf. */ - listPrice: Scalars['Float'] + listPrice: Scalars['Float']; /** Also known as spot price. */ - price: Scalars['Float'] + price: Scalars['Float']; /** ISO code of the currency used for the offer prices. */ - priceCurrency: Scalars['String'] + priceCurrency: Scalars['String']; /** Next date in which price is scheduled to change. If there is no scheduled change, this will be set a year in the future from current time. */ - priceValidUntil: Scalars['String'] + priceValidUntil: Scalars['String']; /** Number of items offered. */ - quantity: Scalars['Int'] + quantity: Scalars['Int']; /** Seller responsible for the offer. */ - seller: StoreOrganization + seller: StoreOrganization; /** Computed price before applying coupons, taxes or benefits. This may change before it reaches the shelf. */ - sellingPrice: Scalars['Float'] -} + sellingPrice: Scalars['Float']; +}; /** Information of a specific order. */ export type StoreOrder = { - __typename?: 'StoreOrder' + __typename?: 'StoreOrder'; /** Array with information on each accepted offer. */ - acceptedOffer: Array + acceptedOffer: Array; /** ID of the order in [VTEX order management](https://help.vtex.com/en/tutorial/license-manager-resources-oms--60QcBsvWeum02cFi3GjBzg#). */ - orderNumber: Scalars['String'] -} + orderNumber: Scalars['String']; +}; /** Organization. */ export type StoreOrganization = { - __typename?: 'StoreOrganization' + __typename?: 'StoreOrganization'; /** Organization ID. */ - identifier: Scalars['String'] -} + identifier: Scalars['String']; +}; /** Whenever you make a query that allows for pagination, such as `allProducts` or `allCollections`, you can check `StorePageInfo` to learn more about the complete set of items and use it to paginate your queries. */ export type StorePageInfo = { - __typename?: 'StorePageInfo' + __typename?: 'StorePageInfo'; /** Cursor corresponding to the last possible item. */ - endCursor: Scalars['String'] + endCursor: Scalars['String']; /** Indicates whether there is at least one more page with items after the ones returned in the current query. */ - hasNextPage: Scalars['Boolean'] + hasNextPage: Scalars['Boolean']; /** Indicates whether there is at least one more page with items before the ones returned in the current query. */ - hasPreviousPage: Scalars['Boolean'] + hasPreviousPage: Scalars['Boolean']; /** Cursor corresponding to the first possible item. */ - startCursor: Scalars['String'] + startCursor: Scalars['String']; /** Total number of items (products or collections), not pages. */ - totalCount: Scalars['Int'] -} + totalCount: Scalars['Int']; +}; /** Client profile data. */ export type StorePerson = { - __typename?: 'StorePerson' + __typename?: 'StorePerson'; /** Client email. */ - email: Scalars['String'] + email: Scalars['String']; /** Client last name. */ - familyName: Scalars['String'] + familyName: Scalars['String']; /** Client first name. */ - givenName: Scalars['String'] + givenName: Scalars['String']; /** Client ID. */ - id: Scalars['String'] -} + id: Scalars['String']; +}; /** Product information. Products are variants within product groups, equivalent to VTEX [SKUs](https://help.vtex.com/en/tutorial/what-is-an-sku--1K75s4RXAQyOuGUYKMM68u#). For example, you may have a **Shirt** product group with associated products such as **Blue shirt size L**, **Green shirt size XL** and so on. */ export type StoreProduct = { - __typename?: 'StoreProduct' + __typename?: 'StoreProduct'; /** Array of additional properties. */ - additionalProperty: Array + additionalProperty: Array; /** Aggregate ratings data. */ - aggregateRating: StoreAggregateRating + aggregateRating: StoreAggregateRating; /** Product brand. */ - brand: StoreBrand + brand: StoreBrand; /** List of items consisting of chain linked web pages, ending with the current page. */ - breadcrumbList: StoreBreadcrumbList + breadcrumbList: StoreBreadcrumbList; /** Product description. */ - description: Scalars['String'] + description: Scalars['String']; /** Global Trade Item Number. */ - gtin: Scalars['String'] + gtin: Scalars['String']; /** Array of images. */ - image: Array + image: Array; /** Indicates product group related to this product. */ - isVariantOf: StoreProductGroup + isVariantOf: StoreProductGroup; /** Product name. */ - name: Scalars['String'] + name: Scalars['String']; /** Aggregate offer information. */ - offers: StoreAggregateOffer + offers: StoreAggregateOffer; /** Product ID, such as [ISBN](https://www.isbn-international.org/content/what-isbn) or similar global IDs. */ - productID: Scalars['String'] + productID: Scalars['String']; /** Array with review information. */ - review: Array + review: Array; /** Meta tag data. */ - seo: StoreSeo + seo: StoreSeo; /** Stock Keeping Unit. Merchant-specific ID for the product. */ - sku: Scalars['String'] + sku: Scalars['String']; /** Corresponding collection URL slug, with which to retrieve this entity. */ - slug: Scalars['String'] -} + slug: Scalars['String']; +}; /** Product connections, including pagination information and products returned by the query. */ export type StoreProductConnection = { - __typename?: 'StoreProductConnection' + __typename?: 'StoreProductConnection'; /** Array with product connection edges, each containing a product and a corresponding cursor. */ - edges: Array + edges: Array; /** Product pagination information. */ - pageInfo: StorePageInfo -} + pageInfo: StorePageInfo; +}; /** Each product edge contains a `node`, with product information, and a `cursor`, that can be used as a reference for pagination. */ export type StoreProductEdge = { - __typename?: 'StoreProductEdge' + __typename?: 'StoreProductEdge'; /** Product cursor. Used as pagination reference. */ - cursor: Scalars['String'] + cursor: Scalars['String']; /** Each product node contains the information of a product returned by the query. */ - node: StoreProduct -} + node: StoreProduct; +}; /** Product group information. Product groups are catalog entities that may contain variants. They are equivalent to VTEX [Products](https://help.vtex.com/en/tutorial/what-is-a-product--2zrB2gFCHyQokCKKE8kuAw#), whereas each variant is equivalent to a VTEX [SKU](https://help.vtex.com/en/tutorial/what-is-an-sku--1K75s4RXAQyOuGUYKMM68u#). For example, you may have a **Shirt** product group with associated products such as **Blue shirt size L**, **Green shirt size XL** and so on. */ export type StoreProductGroup = { - __typename?: 'StoreProductGroup' + __typename?: 'StoreProductGroup'; /** Array of additional properties. */ - additionalProperty: Array + additionalProperty: Array; /** Array of variants related to product group. Variants are equivalent to VTEX [SKUs](https://help.vtex.com/en/tutorial/what-is-an-sku--1K75s4RXAQyOuGUYKMM68u#). */ - hasVariant: Array + hasVariant: Array; /** Product group name. */ - name: Scalars['String'] + name: Scalars['String']; /** Product group ID. */ - productGroupID: Scalars['String'] -} + productGroupID: Scalars['String']; +}; /** Properties that can be associated with products and products groups. */ export type StorePropertyValue = { - __typename?: 'StorePropertyValue' + __typename?: 'StorePropertyValue'; /** Property name. */ - name: Scalars['String'] + name: Scalars['String']; /** Property id. This propert changes according to the content of the object. */ - propertyID: Scalars['String'] + propertyID: Scalars['String']; /** Property value. May hold a string or the string representation of an object. */ - value: Scalars['ObjectOrString'] + value: Scalars['ObjectOrString']; /** Specifies the nature of the value */ - valueReference: Scalars['String'] -} + valueReference: Scalars['String']; +}; /** Information of a given review. */ export type StoreReview = { - __typename?: 'StoreReview' + __typename?: 'StoreReview'; /** Review author. */ - author: StoreAuthor + author: StoreAuthor; /** Review rating information. */ - reviewRating: StoreReviewRating -} + reviewRating: StoreReviewRating; +}; /** Information of a given review rating. */ export type StoreReviewRating = { - __typename?: 'StoreReviewRating' + __typename?: 'StoreReviewRating'; /** Best rating value. */ - bestRating: Scalars['Float'] + bestRating: Scalars['Float']; /** Rating value. */ - ratingValue: Scalars['Float'] -} + ratingValue: Scalars['Float']; +}; /** Search result. */ export type StoreSearchResult = { - __typename?: 'StoreSearchResult' + __typename?: 'StoreSearchResult'; /** Array of search result facets. */ - facets: Array + facets: Array; /** Search result products. */ - products: StoreProductConnection + products: StoreProductConnection; /** Search result suggestions. */ - suggestions: StoreSuggestions -} + suggestions: StoreSuggestions; +}; /** Search Engine Optimization (SEO) tags data. */ export type StoreSeo = { - __typename?: 'StoreSeo' + __typename?: 'StoreSeo'; /** Canonical tag. */ - canonical: Scalars['String'] + canonical: Scalars['String']; /** Description tag. */ - description: Scalars['String'] + description: Scalars['String']; /** Title tag. */ - title: Scalars['String'] + title: Scalars['String']; /** Title template tag. */ - titleTemplate: Scalars['String'] -} + titleTemplate: Scalars['String']; +}; /** Session information. */ export type StoreSession = { - __typename?: 'StoreSession' + __typename?: 'StoreSession'; /** Session channel. */ - channel?: Maybe + channel?: Maybe; /** Session country. */ - country: Scalars['String'] + country: Scalars['String']; /** Session currency. */ - currency: StoreCurrency + currency: StoreCurrency; /** Session locale. */ - locale: Scalars['String'] + locale: Scalars['String']; /** Session postal code. */ - person?: Maybe + person?: Maybe; /** Session postal code. */ - postalCode?: Maybe -} + postalCode?: Maybe; +}; /** Product search results sorting options. */ export const enum StoreSort { @@ -616,30 +617,30 @@ export const enum StoreSort { /** Sort by release date, from highest to lowest. */ ReleaseDesc = 'release_desc', /** Sort by product score, from highest to lowest. */ - ScoreDesc = 'score_desc', -} + ScoreDesc = 'score_desc' +}; /** Status used to indicate a message type. For instance, a shopping cart informative or error message. */ export const enum StoreStatus { Error = 'ERROR', Info = 'INFO', - Warning = 'WARNING', -} + Warning = 'WARNING' +}; /** Suggestion term. */ export type StoreSuggestionTerm = { - __typename?: 'StoreSuggestionTerm' + __typename?: 'StoreSuggestionTerm'; /** Its occurrences count. */ - count: Scalars['Int'] + count: Scalars['Int']; /** The term. */ - value: Scalars['String'] -} + value: Scalars['String']; +}; /** Suggestions information. */ export type StoreSuggestions = { - __typename?: 'StoreSuggestions' + __typename?: 'StoreSuggestions'; /** Array with suggestion products' information. */ - products: Array + products: Array; /** Array with suggestion terms. */ - terms: Array -} + terms: Array; +}; diff --git a/packages/api/test/__snapshots__/queries.test.ts.snap b/packages/api/test/__snapshots__/queries.test.ts.snap index f2dd88f8ec..943153d582 100644 --- a/packages/api/test/__snapshots__/queries.test.ts.snap +++ b/packages/api/test/__snapshots__/queries.test.ts.snap @@ -621,32 +621,10 @@ Object { Object { "key": "price", "label": "Pre�o", - "type": "RANGE", - "values": Array [ - Object { - "label": "unknown", - "quantity": 646, - "selected": false, - "value": "0.23-to-150", - }, - Object { - "label": "unknown", - "quantity": 601, - "selected": false, - "value": "360-to-995.92", - }, - Object { - "label": "unknown", - "quantity": 579, - "selected": false, - "value": "150-to-360", - }, - ], }, Object { "key": "category-2", "label": "Categoria", - "type": "BOOLEAN", "values": Array [ Object { "label": "Chairs", @@ -665,7 +643,6 @@ Object { Object { "key": "brand", "label": "Marca", - "type": "BOOLEAN", "values": Array [ Object { "label": "Acer", diff --git a/packages/api/test/schema.test.ts b/packages/api/test/schema.test.ts index ce112217e1..135ec210e9 100644 --- a/packages/api/test/schema.test.ts +++ b/packages/api/test/schema.test.ts @@ -18,7 +18,10 @@ const TYPES = [ 'StoreCollectionMeta', 'StoreCollection', 'StoreFacet', - 'StoreFacetValue', + 'StoreFacetRange', + 'StoreFacetBoolean', + 'StoreFacetValueRange', + 'StoreFacetValueBoolean', 'StoreImage', 'IStoreImage', 'StoreOffer', @@ -38,7 +41,6 @@ const TYPES = [ 'StoreCollectionConnection', 'StoreSort', 'IStoreSelectedFacet', - 'StoreFacetType', 'StoreSearchResult', 'StoreReviewRating', 'StoreReview', diff --git a/packages/sdk/test/search/Provider.test.tsx b/packages/sdk/test/search/Provider.test.tsx index 1212d7a36a..f4f5262cbf 100644 --- a/packages/sdk/test/search/Provider.test.tsx +++ b/packages/sdk/test/search/Provider.test.tsx @@ -6,7 +6,11 @@ import type { ComponentPropsWithoutRef } from 'react' import { formatSearchState, initSearchState, + removeFacet, SearchProvider, + setFacet, + toggleFacet, + toggleFacets, useSearch, } from '../../src' @@ -34,7 +38,12 @@ test('SearchProvider: change sort ordering', async () => { expect(result.current.state.sort).toBe('score_desc') - act(() => result.current.setSort('name_asc')) + act(() => { + result.current.setState({ + ...result.current.state, + sort: 'name_asc', + }) + }) expect(mock).toBeCalledWith(formatSearchState({ ...state, sort: 'name_asc' })) }) @@ -51,10 +60,20 @@ test('SearchProvider: Set full text term', async () => { expect(result.current.state.term).toBeNull() - act(() => result.current.setTerm(null)) + act(() => { + result.current.setState({ + ...result.current.state, + term: null, + }) + }) expect(mock).not.toHaveBeenCalled() - act(() => result.current.setTerm(fullTextTerm)) + act(() => { + result.current.setState({ + ...result.current.state, + term: fullTextTerm, + }) + }) expect(mock).toBeCalledWith( formatSearchState({ ...state, term: fullTextTerm }) ) @@ -72,7 +91,12 @@ test('SearchProvider: Set current page', async () => { expect(result.current.state.page).toBe(0) - act(() => result.current.setPage(page)) + act(() => { + result.current.setState({ + ...result.current.state, + page, + }) + }) expect(mock).toBeCalledWith(formatSearchState({ ...state, page })) }) @@ -92,7 +116,12 @@ test('SearchProvider: selects a simple facet', async () => { expect(result.current.state.selectedFacets).toHaveLength(0) - act(() => result.current.setFacet(facet1)) + act(() => { + result.current.setState({ + ...result.current.state, + selectedFacets: setFacet(result.current.state.selectedFacets, facet1), + }) + }) expect(mock).toBeCalledWith( formatSearchState({ ...state, selectedFacets: [facet1] }) ) @@ -120,7 +149,12 @@ test('SearchProvider: selects a simple facet when more facets are inside the sta ), }) - act(() => result.current.setFacet(facet2)) + act(() => { + result.current.setState({ + ...result.current.state, + selectedFacets: setFacet(result.current.state.selectedFacets, facet2), + }) + }) expect(mock).toBeCalledWith( formatSearchState({ ...state, selectedFacets: [facet1, facet2] }) ) @@ -148,10 +182,24 @@ test('SearchProvider: Facet uniqueness', async () => { ), }) - act(() => result.current.setFacet(facet2, true)) + act(() => { + result.current.setState({ + ...result.current.state, + selectedFacets: setFacet( + result.current.state.selectedFacets, + facet2, + true + ), + }) + }) expect(mock).not.toHaveBeenCalled() - act(() => result.current.setFacet(facet1)) + act(() => { + result.current.setState({ + ...result.current.state, + selectedFacets: setFacet(result.current.state.selectedFacets, facet1), + }) + }) expect(mock).toBeCalledWith( formatSearchState({ ...state, selectedFacets: [facet2, facet1] }) ) @@ -179,7 +227,12 @@ test('SearchProvider: Remove facet selection', async () => { ), }) - act(() => result.current.removeFacet(facet2)) + act(() => { + result.current.setState({ + ...result.current.state, + selectedFacets: removeFacet(result.current.state.selectedFacets, facet2), + }) + }) expect(mock).toBeCalledWith( formatSearchState({ ...state, selectedFacets: [facet1, facet2] }) ) @@ -208,7 +261,12 @@ test('SearchProvider: Remove initial facet', async () => { }) /** Cannot remove the first facet */ - act(() => result.current.removeFacet(facet1)) + act(() => { + result.current.setState({ + ...result.current.state, + selectedFacets: removeFacet(result.current.state.selectedFacets, facet1), + }) + }) expect(mock).not.toHaveBeenCalled() }) @@ -242,15 +300,30 @@ test('SearchProvider: Toggle Facet', async () => { expect(result.current.state.selectedFacets).toEqual([facet1, facet2]) /** Cannot remove the first facet */ - act(() => result.current.toggleFacet(facet1)) + act(() => { + result.current.setState({ + ...result.current.state, + selectedFacets: toggleFacet(result.current.state.selectedFacets, facet1), + }) + }) expect(mock).not.toHaveBeenCalled() - act(() => result.current.toggleFacet(facet2)) + act(() => { + result.current.setState({ + ...result.current.state, + selectedFacets: toggleFacet(result.current.state.selectedFacets, facet2), + }) + }) expect(mock).toBeCalledWith( formatSearchState({ ...state, selectedFacets: [facet1] }) ) - act(() => result.current.toggleFacet(facet3)) + act(() => { + result.current.setState({ + ...result.current.state, + selectedFacets: toggleFacet(result.current.state.selectedFacets, facet3), + }) + }) expect(mock).toBeCalledWith( formatSearchState({ ...state, selectedFacets: [facet1, facet2, facet3] }) ) @@ -283,12 +356,28 @@ test('SearchProvider: Toggle Facets', async () => { ), }) - act(() => result.current.toggleFacets([facet2, facet3])) + act(() => { + result.current.setState({ + ...result.current.state, + selectedFacets: toggleFacets(result.current.state.selectedFacets, [ + facet2, + facet3, + ]), + }) + }) expect(mock).toBeCalledWith( formatSearchState({ ...state, selectedFacets: [facet1] }) ) - act(() => result.current.toggleFacets([facet1, facet2])) + act(() => { + result.current.setState({ + ...result.current.state, + selectedFacets: toggleFacets(result.current.state.selectedFacets, [ + facet1, + facet2, + ]), + }) + }) expect(mock).toBeCalledWith( formatSearchState({ ...state, selectedFacets: [facet1] }) ) @@ -316,8 +405,26 @@ test('SearchProvider: onChange is called', async () => { expect(mock).toHaveBeenCalledTimes(0) - act(() => result.current.setSort('name_asc')) - act(() => result.current.setFacet({ key: 'size', value: 'xm' })) - act(() => result.current.setPage(10)) + act(() => { + result.current.setState({ + ...result.current.state, + sort: 'name_asc', + }) + }) + act(() => { + result.current.setState({ + ...result.current.state, + selectedFacets: setFacet(result.current.state.selectedFacets, { + key: 'size', + value: 'xm', + }), + }) + }) + act(() => { + result.current.setState({ + ...result.current.state, + page: 10, + }) + }) expect(mock).toHaveBeenCalledTimes(3) }) diff --git a/packages/ui/src/atoms/Slider/Slider.test.tsx b/packages/ui/src/atoms/Slider/Slider.test.tsx index fe6b197da2..86f44c9387 100644 --- a/packages/ui/src/atoms/Slider/Slider.test.tsx +++ b/packages/ui/src/atoms/Slider/Slider.test.tsx @@ -4,16 +4,27 @@ import React from 'react' import Slider from './Slider' +const props = { + min: { + absolute: 0, + selected: 0, + }, + max: { + absolute: 100, + selected: 100, + }, +} + describe('Slider', () => { it('`data-store-slider` is present', () => { - const { getByTestId } = render() + const { getByTestId } = render() expect(getByTestId('store-slider')).toHaveAttribute('data-store-slider') }) describe('Accessibility', () => { it('should have no violations', async () => { - const { getByTestId } = render() + const { getByTestId } = render() expect(await axe(getByTestId('store-slider'))).toHaveNoViolations() }) diff --git a/packages/ui/src/molecules/PriceRange/PriceRange.test.tsx b/packages/ui/src/molecules/PriceRange/PriceRange.test.tsx index faf449fde3..36970c5c21 100644 --- a/packages/ui/src/molecules/PriceRange/PriceRange.test.tsx +++ b/packages/ui/src/molecules/PriceRange/PriceRange.test.tsx @@ -13,8 +13,14 @@ function formatter(price: number) { const props = { formatter, - min: 0, - max: 100, + min: { + absolute: 0, + selected: 0, + }, + max: { + absolute: 100, + selected: 100, + }, ariaLabel: 'My price range', }