Skip to content

Commit

Permalink
[PWA-2468][Cypress] Add cypress integration mock data test for Rating…
Browse files Browse the repository at this point in the history
…s summary (magento#3644)

* Added mocked product data

* added productRatingSummary.spec.js

* lint adjusts

* fixed baseUrl

Co-authored-by: Devagouda <[email protected]>
Co-authored-by: Mikhaël Bois <[email protected]>
  • Loading branch information
3 people authored Jan 17, 2022
1 parent 9872825 commit e40c973
Show file tree
Hide file tree
Showing 5 changed files with 382 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/venia-ui/lib/components/Rating/rating.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Rating = props => {
const classes = useStyle(defaultClasses, props.classes);

return (
<div className={classes.ratingAverage}>
<div className={classes.ratingAverage} data-cy="ratingSummary">
<span className={classes.ratingValue}>
{((rating * 5) / 100).toFixed(1)}
</span>{' '}
Expand Down
8 changes: 8 additions & 0 deletions venia-integration-tests/src/assertions/categoryPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
productsNoProductsFound,
productsPagination,
productsPaginationTileActive,
productRatingSummary,
productSortSortItemActive,
searchBarSuggestedProduct
} from '../../fields/categoryPage';
Expand Down Expand Up @@ -125,3 +126,10 @@ export const assertNoProductSuggestion = () => {
export const assertActiveSortItem = sortLabel => {
cy.get(productSortSortItemActive).should('contain', sortLabel);
};

export const assertRatingSummary = productName => {
cy.contains(productName)
.children()
.get(productRatingSummary)
.should('exist');
};
2 changes: 2 additions & 0 deletions venia-integration-tests/src/fields/categoryPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ export const productSortSortItem =
export const productSortSortItemActive =
'[data-cy="ProductSort-root"] [data-cy="SortItem-activeButton"]';

export const productRatingSummary = '[data-cy="ratingSummary"]';

export const searchBarSuggestedProduct =
'[data-cy="SearchBar-root"] [data-cy="SuggestedProduct-root"]';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,326 @@
{
"data": {
"categories": {
"items": [
{
"uid": "OQ==",
"meta_title": null,
"meta_keywords": null,
"meta_description": null,
"__typename": "CategoryTree"
}
],
"__typename": "CategoryResult"
},
"products": {
"items": [
{
"id": 1116,
"uid": "MTExNg==",
"name": "Carina Cardigan",
"price_range": {
"maximum_price": {
"regular_price": {
"currency": "USD",
"value": 78,
"__typename": "Money"
},
"__typename": "ProductPrice"
},
"__typename": "PriceRange"
},
"sku": "VSW01",
"small_image": {
"url": "https://master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud/media/catalog/product/cache/d3ba9f7bcd3b0724e976dc5144b29c7d/v/s/vsw01-rn_main_2.jpg",
"__typename": "ProductImage"
},
"stock_status": "IN_STOCK",
"rating_summary": 100,
"__typename": "ConfigurableProduct",
"url_key": "carina-cardigan"
},
{
"id": 1115,
"uid": "MTExNQ==",
"name": "Juno Sweater",
"price_range": {
"maximum_price": {
"regular_price": {
"currency": "USD",
"value": 68,
"__typename": "Money"
},
"__typename": "ProductPrice"
},
"__typename": "PriceRange"
},
"sku": "VSW02",
"small_image": {
"url": "https://master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud/media/catalog/product/cache/d3ba9f7bcd3b0724e976dc5144b29c7d/v/s/vsw02-pe_main_2.jpg",
"__typename": "ProductImage"
},
"stock_status": "IN_STOCK",
"rating_summary": 0,
"__typename": "ConfigurableProduct",
"url_key": "juno-sweater"
},
{
"id": 1114,
"uid": "MTExNA==",
"name": "Phoebe Cardigan",
"price_range": {
"maximum_price": {
"regular_price": {
"currency": "USD",
"value": 88,
"__typename": "Money"
},
"__typename": "ProductPrice"
},
"__typename": "PriceRange"
},
"sku": "VSW03",
"small_image": {
"url": "https://master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud/media/catalog/product/cache/d3ba9f7bcd3b0724e976dc5144b29c7d/v/s/vsw03-kh_main_2.jpg",
"__typename": "ProductImage"
},
"stock_status": "IN_STOCK",
"rating_summary": 0,
"__typename": "ConfigurableProduct",
"url_key": "phoebe-cardigan"
},
{
"id": 1113,
"uid": "MTExMw==",
"name": "Rosalina Cardigan",
"price_range": {
"maximum_price": {
"regular_price": {
"currency": "USD",
"value": 98,
"__typename": "Money"
},
"__typename": "ProductPrice"
},
"__typename": "PriceRange"
},
"sku": "VSW04",
"small_image": {
"url": "https://master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud/media/catalog/product/cache/d3ba9f7bcd3b0724e976dc5144b29c7d/v/s/vsw04-pe_main_2.jpg",
"__typename": "ProductImage"
},
"stock_status": "IN_STOCK",
"rating_summary": 0,
"__typename": "ConfigurableProduct",
"url_key": "rosalina-cardigan"
},
{
"id": 1112,
"uid": "MTExMg==",
"name": "Hanna Sweater",
"price_range": {
"maximum_price": {
"regular_price": {
"currency": "USD",
"value": 98,
"__typename": "Money"
},
"__typename": "ProductPrice"
},
"__typename": "PriceRange"
},
"sku": "VSW05",
"small_image": {
"url": "https://master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud/media/catalog/product/cache/d3ba9f7bcd3b0724e976dc5144b29c7d/v/s/vsw05-kh_main_2.jpg",
"__typename": "ProductImage"
},
"stock_status": "IN_STOCK",
"rating_summary": 0,
"__typename": "ConfigurableProduct",
"url_key": "hanna-sweater"
},
{
"id": 1111,
"uid": "MTExMQ==",
"name": "Sabina Hooded Cardigan",
"price_range": {
"maximum_price": {
"regular_price": {
"currency": "USD",
"value": 108,
"__typename": "Money"
},
"__typename": "ProductPrice"
},
"__typename": "PriceRange"
},
"sku": "VSW06",
"small_image": {
"url": "https://master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud/media/catalog/product/cache/d3ba9f7bcd3b0724e976dc5144b29c7d/v/s/vsw06-rn_main_2.jpg",
"__typename": "ProductImage"
},
"stock_status": "IN_STOCK",
"rating_summary": 0,
"__typename": "ConfigurableProduct",
"url_key": "sabina-hooded-cardigan"
},
{
"id": 1110,
"uid": "MTExMA==",
"name": "Brigid Boucle Cardigan",
"price_range": {
"maximum_price": {
"regular_price": {
"currency": "USD",
"value": 118,
"__typename": "Money"
},
"__typename": "ProductPrice"
},
"__typename": "PriceRange"
},
"sku": "VSW07",
"small_image": {
"url": "https://master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud/media/catalog/product/cache/d3ba9f7bcd3b0724e976dc5144b29c7d/v/s/vsw07-mt_main_2.jpg",
"__typename": "ProductImage"
},
"stock_status": "IN_STOCK",
"rating_summary": 0,
"__typename": "ConfigurableProduct",
"url_key": "brigid-boucle-cardigan"
},
{
"id": 1109,
"uid": "MTEwOQ==",
"name": "Roxana Cropped Sweater",
"price_range": {
"maximum_price": {
"regular_price": {
"currency": "USD",
"value": 78,
"__typename": "Money"
},
"__typename": "ProductPrice"
},
"__typename": "PriceRange"
},
"sku": "VSW08",
"small_image": {
"url": "https://master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud/media/catalog/product/cache/d3ba9f7bcd3b0724e976dc5144b29c7d/v/s/vsw08-ll_main_2.jpg",
"__typename": "ProductImage"
},
"stock_status": "IN_STOCK",
"rating_summary": 0,
"__typename": "ConfigurableProduct",
"url_key": "roxana-cropped-sweater"
},
{
"id": 1108,
"uid": "MTEwOA==",
"name": "Helena Cardigan",
"price_range": {
"maximum_price": {
"regular_price": {
"currency": "USD",
"value": 98,
"__typename": "Money"
},
"__typename": "ProductPrice"
},
"__typename": "PriceRange"
},
"sku": "VSW09",
"small_image": {
"url": "https://master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud/media/catalog/product/cache/d3ba9f7bcd3b0724e976dc5144b29c7d/v/s/vsw09-rn_main_2.jpg",
"__typename": "ProductImage"
},
"stock_status": "IN_STOCK",
"rating_summary": 0,
"__typename": "ConfigurableProduct",
"url_key": "helena-cardigan"
},
{
"id": 1107,
"uid": "MTEwNw==",
"name": "Corina Lace-Back Sweater",
"price_range": {
"maximum_price": {
"regular_price": {
"currency": "USD",
"value": 108,
"__typename": "Money"
},
"__typename": "ProductPrice"
},
"__typename": "PriceRange"
},
"sku": "VSW10",
"small_image": {
"url": "https://master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud/media/catalog/product/cache/d3ba9f7bcd3b0724e976dc5144b29c7d/v/s/vsw10-ly_main_2.jpg",
"__typename": "ProductImage"
},
"stock_status": "IN_STOCK",
"rating_summary": 0,
"__typename": "ConfigurableProduct",
"url_key": "corina-lace-back-sweater"
},
{
"id": 1106,
"uid": "MTEwNg==",
"name": "Echo Sweater",
"price_range": {
"maximum_price": {
"regular_price": {
"currency": "USD",
"value": 78,
"__typename": "Money"
},
"__typename": "ProductPrice"
},
"__typename": "PriceRange"
},
"sku": "VSW11",
"small_image": {
"url": "https://master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud/media/catalog/product/cache/d3ba9f7bcd3b0724e976dc5144b29c7d/v/s/vsw11-pe_main_2.jpg",
"__typename": "ProductImage"
},
"stock_status": "IN_STOCK",
"rating_summary": 0,
"__typename": "ConfigurableProduct",
"url_key": "echo-sweater"
},
{
"id": 1105,
"uid": "MTEwNQ==",
"name": "Lorena Cardigan",
"price_range": {
"maximum_price": {
"regular_price": {
"currency": "USD",
"value": 98,
"__typename": "Money"
},
"__typename": "ProductPrice"
},
"__typename": "PriceRange"
},
"sku": "VSW12",
"small_image": {
"url": "https://master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud/media/catalog/product/cache/d3ba9f7bcd3b0724e976dc5144b29c7d/v/s/vsw12-pe_main_2.jpg",
"__typename": "ProductImage"
},
"stock_status": "IN_STOCK",
"rating_summary": 0,
"__typename": "ConfigurableProduct",
"url_key": "lorena-cardigan"
}
],
"page_info": {
"total_pages": 1,
"__typename": "SearchResultPageInfo"
},
"total_count": 12,
"__typename": "Products"
}
}
}
Loading

0 comments on commit e40c973

Please sign in to comment.