saleor-dashboard/cypress/utils/storeFront/storeFrontProductUtils.js
Karolina 588175df30
Saleor 1737 tests for shipping methods (#1013)
* remove classes in shipping & products utils

* remove classes

* add tests plans

* add const

* tests for shipping methods

* test for shipping

* test for shipping

* tests for shipping

* install eslint-plugin-chai-friendly

* update stories

* add missing imports
2021-04-02 13:01:38 +02:00

35 lines
1.1 KiB
JavaScript

import { getProductDetails } from "../../apiRequests/storeFront/ProductDetails";
export const isProductVisible = (resp, name) => {
const product = resp.body.data.product;
return product !== null && product.name === name;
};
export const isProductAvailableForPurchase = resp => {
const product = resp.body.data.product;
return product.isAvailableForPurchase;
};
export const isProductVisibleInSearchResult = (resp, productName) => {
const productsList = resp.body.data.products;
return (
productsList.totalCount !== 0 &&
productsList.edges[0].node.name === productName
);
};
export const getProductVariants = (productId, channelSlug) => {
getProductDetails(productId, channelSlug).then(resp => {
const variantsList = resp.body.data.product.variants;
return variantsList.map(element => ({
name: element.name,
price: element.pricing.price.gross.amount
}));
});
};
export const getProductPrice = (productId, channelSlug) => {
getProductDetails(productId, channelSlug).then(
resp => resp.body.data.product.variants[0].pricing.price.gross.amount
);
};