saleor-dashboard/cypress/utils/storeFront/storeFrontProductUtils.js

29 lines
992 B
JavaScript
Raw Normal View History

import ProductDetails from "../../apiRequests/storeFront/ProductDetails";
import Search from "../../apiRequests/storeFront/Search";
2021-03-04 12:35:45 +00:00
import { isVisible } from "./utils";
2021-02-12 14:36:13 +00:00
2021-03-04 12:35:45 +00:00
const productDetails = new ProductDetails();
const search = new Search();
2021-02-25 10:40:07 +00:00
2021-03-04 12:35:45 +00:00
export const isProductVisible = (productId, channelSlug, name) =>
isVisible({
request: productDetails.getProductDetails(productId, channelSlug),
respObjectKey: ["product"],
responseValueKey: ["name"],
value: name
});
export const isProductAvailableForPurchase = (productId, channelSlug) =>
isVisible({
request: productDetails.getProductDetails(productId, channelSlug),
respObjectKey: ["product"],
responseValueKey: ["isAvailableForPurchase"]
});
export const isProductVisibleInSearchResult = (productName, channelSlug) =>
isVisible({
request: search.searchInShop(productName, channelSlug),
respObjectKey: ["products"],
responseValueKey: ["edges", 0, "node", "name"],
value: productName
});