tests for products
This commit is contained in:
parent
b9c567d377
commit
9f5c1b544e
14 changed files with 362 additions and 496 deletions
32
cypress/apiRequests/frontShop/ProductDetails.js
Normal file
32
cypress/apiRequests/frontShop/ProductDetails.js
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
class ProductDetails {
|
||||||
|
getProductDetails(productId, channelId) {
|
||||||
|
return cy.request({
|
||||||
|
method: "POST",
|
||||||
|
url: Cypress.env("API_URI"),
|
||||||
|
headers: {
|
||||||
|
authorization: `JWT ${window.localStorage.getItem("token")}`
|
||||||
|
},
|
||||||
|
body: [
|
||||||
|
{
|
||||||
|
operationName: "ProductDetails",
|
||||||
|
variables: {
|
||||||
|
channel: channelId,
|
||||||
|
id: productId
|
||||||
|
},
|
||||||
|
query:
|
||||||
|
"fragment BasicProductFields on Product {\n id\n name\n thumbnail {\n url\n alt\n __typename\n }\n thumbnail2x: thumbnail(size: 510) {\n url\n __typename\n }\n __typename\n}\n\nfragment SelectedAttributeFields on SelectedAttribute {\n attribute {\n id\n name\n __typename\n }\n values {\n id\n name\n __typename\n }\n __typename\n}\n\nfragment Price on TaxedMoney {\n gross {\n amount\n currency\n __typename\n }\n net {\n amount\n currency\n __typename\n }\n __typename\n}\n\nfragment ProductVariantFields on ProductVariant {\n id\n sku\n name\n quantityAvailable(countryCode: $countryCode)\n images {\n id\n url\n alt\n __typename\n }\n pricing {\n onSale\n priceUndiscounted {\n ...Price\n __typename\n }\n price {\n ...Price\n __typename\n }\n __typename\n }\n attributes(variantSelection: VARIANT_SELECTION) {\n attribute {\n id\n name\n slug\n __typename\n }\n values {\n id\n name\n value: name\n __typename\n }\n __typename\n }\n __typename\n}\n\nfragment ProductPricingField on Product {\n pricing {\n onSale\n priceRangeUndiscounted {\n start {\n ...Price\n __typename\n }\n stop {\n ...Price\n __typename\n }\n __typename\n }\n priceRange {\n start {\n ...Price\n __typename\n }\n stop {\n ...Price\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n}\n\nquery ProductDetails($id: ID!, $channel: String, $countryCode: CountryCode) {\n product(id: $id, channel: $channel) {\n ...BasicProductFields\n ...ProductPricingField\n description\n category {\n id\n name\n products(first: 3, channel: $channel) {\n edges {\n node {\n ...BasicProductFields\n ...ProductPricingField\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n images {\n id\n alt\n url\n __typename\n }\n attributes {\n ...SelectedAttributeFields\n __typename\n }\n variants {\n ...ProductVariantFields\n __typename\n }\n seoDescription\n seoTitle\n isAvailable\n isAvailableForPurchase\n availableForPurchase\n __typename\n }\n}\n"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
isAvailableForPurchaseFromResp(resp) {
|
||||||
|
return resp.body[0].data.product.isAvailableForPurchase;
|
||||||
|
}
|
||||||
|
isProductExist(resp, name) {
|
||||||
|
return (
|
||||||
|
resp.body[0].data.product !== null &&
|
||||||
|
resp.body[0].data.product.name === name
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default ProductDetails;
|
34
cypress/apiRequests/frontShop/Search.js
Normal file
34
cypress/apiRequests/frontShop/Search.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
class Search {
|
||||||
|
searchInShop(searchQuery) {
|
||||||
|
return cy.request({
|
||||||
|
method: "POST",
|
||||||
|
url: Cypress.env("API_URI"),
|
||||||
|
headers: {
|
||||||
|
authorization: `JWT ${window.localStorage.getItem("token")}`
|
||||||
|
},
|
||||||
|
body: [
|
||||||
|
{
|
||||||
|
operationName: "SearchProducts",
|
||||||
|
variables: {
|
||||||
|
attributes: {},
|
||||||
|
channel: "default-channel",
|
||||||
|
pageSize: 6,
|
||||||
|
priceGte: null,
|
||||||
|
priceLte: null,
|
||||||
|
query: searchQuery,
|
||||||
|
sortBy: null
|
||||||
|
},
|
||||||
|
query:
|
||||||
|
"fragment Price on TaxedMoney {\n gross {\n amount\n currency\n __typename\n }\n net {\n amount\n currency\n __typename\n }\n __typename\n}\n\nfragment ProductPricingField on Product {\n pricing {\n onSale\n priceRangeUndiscounted {\n start {\n ...Price\n __typename\n }\n stop {\n ...Price\n __typename\n }\n __typename\n }\n priceRange {\n start {\n ...Price\n __typename\n }\n stop {\n ...Price\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n}\n\nquery SearchProducts($query: String!, $channel: String!, $attributes: [AttributeInput], $pageSize: Int, $sortBy: ProductOrder, $after: String) {\n products(channel: $channel, filter: {search: $query, attributes: $attributes}, first: $pageSize, sortBy: $sortBy, after: $after) {\n totalCount\n edges {\n node {\n ...ProductPricingField\n id\n name\n thumbnail {\n url\n alt\n __typename\n }\n thumbnail2x: thumbnail(size: 510) {\n url\n __typename\n }\n category {\n id\n name\n __typename\n }\n __typename\n }\n __typename\n }\n pageInfo {\n endCursor\n hasNextPage\n __typename\n }\n __typename\n }\n attributes(filter: {filterableInStorefront: true}, first: 100) {\n edges {\n node {\n id\n name\n slug\n values {\n id\n name\n slug\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n}\n"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
isProductExist(resp, name) {
|
||||||
|
return (
|
||||||
|
resp.body[0].data.products.totalCount !== 0 &&
|
||||||
|
resp.body[0].data.products.edges[0].node.name === name
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default Search;
|
|
@ -25,8 +25,8 @@ export const PRODUCTS_SELECTORS = {
|
||||||
assignedChannels: "[data-test='channel-availability-item']",
|
assignedChannels: "[data-test='channel-availability-item']",
|
||||||
publishedRadioButtons: "[name*='isPublished']",
|
publishedRadioButtons: "[name*='isPublished']",
|
||||||
availableForPurchaseRadioButtons: "[name*='isAvailableForPurchase']",
|
availableForPurchaseRadioButtons: "[name*='isAvailableForPurchase']",
|
||||||
radioButtonsValueTrue: "[value:'true']",
|
radioButtonsValueTrue: "[value='true']",
|
||||||
radioButtonsValueFalse: "[value:'false']",
|
radioButtonsValueFalse: "[value='false']",
|
||||||
visibleInListingsButton: "[name*='visibleInListings']",
|
visibleInListingsButton: "[name*='visibleInListings']",
|
||||||
emptyProductRow: "[class*='Skeleton']"
|
emptyProductRow: "[class*='Skeleton']"
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
// <reference types="cypress" />
|
|
||||||
import { LEFT_MENU_SELECTORS } from "../elements/account/left-menu/left-menu-selectors";
|
|
||||||
import { PRODUCTS_SELECTORS } from "../elements/catalog/product-selectors";
|
|
||||||
import { urlList } from "../url/urlList";
|
|
||||||
|
|
||||||
describe("Products", () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
cy.clearSessionData().loginUserViaRequest();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should navigate to channels page", () => {
|
|
||||||
cy.visit(urlList.homePage)
|
|
||||||
.get(LEFT_MENU_SELECTORS.catalog)
|
|
||||||
.click()
|
|
||||||
.get(LEFT_MENU_SELECTORS.products)
|
|
||||||
.click()
|
|
||||||
.location("pathname")
|
|
||||||
.should("contain", "/products");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should add new visible product", () => {
|
|
||||||
cy.visit(urlList.products)
|
|
||||||
.get(PRODUCTS_SELECTORS.createProductBtn)
|
|
||||||
.click()
|
|
||||||
.get(PRODUCTS_SELECTORS.productNameInput)
|
|
||||||
.click()
|
|
||||||
.type("Visible test product")
|
|
||||||
.get(PRODUCTS_SELECTORS.productTypeInput)
|
|
||||||
.click()
|
|
||||||
.get(PRODUCTS_SELECTORS.autocompleteDropdown) // trying to fill autocomplete before dropdown will cause error
|
|
||||||
.get(PRODUCTS_SELECTORS.productTypeInput)
|
|
||||||
.click()
|
|
||||||
.type("Cushion")
|
|
||||||
.get(PRODUCTS_SELECTORS.categoryItem)
|
|
||||||
.should("have.length", 1)
|
|
||||||
.get(PRODUCTS_SELECTORS.firstCategoryItem)
|
|
||||||
.click()
|
|
||||||
.get(PRODUCTS_SELECTORS.categoryInput)
|
|
||||||
.click()
|
|
||||||
.get(PRODUCTS_SELECTORS.categoryItem)
|
|
||||||
.first()
|
|
||||||
.click()
|
|
||||||
.get(PRODUCTS_SELECTORS.channelAvailabilityItem)
|
|
||||||
.first()
|
|
||||||
.click()
|
|
||||||
.get(PRODUCTS_SELECTORS.visibleRadioBtn)
|
|
||||||
.first()
|
|
||||||
.click()
|
|
||||||
.get(PRODUCTS_SELECTORS.saveBtn)
|
|
||||||
.click()
|
|
||||||
.get(PRODUCTS_SELECTORS.confirmationMsg)
|
|
||||||
.contains("Product created");
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,17 +1,19 @@
|
||||||
import faker from "faker";
|
import faker from "faker";
|
||||||
|
|
||||||
import { PRODUCTS_SELECTORS } from "../../elements/catalog/product-selectors";
|
import ProductSteps from "../../steps/productSteps";
|
||||||
import { URL_LIST } from "../../url/url-list";
|
import { URL_LIST } from "../../url/url-list";
|
||||||
import ChannelsUtils from "../../utils/channelsUtils";
|
import ChannelsUtils from "../../utils/channelsUtils";
|
||||||
|
import FrontShopProductUtils from "../../utils/frontShop/frontShopProductUtils";
|
||||||
import ProductsUtils from "../../utils/productsUtils";
|
import ProductsUtils from "../../utils/productsUtils";
|
||||||
import ShippingUtils from "../../utils/shippingUtils";
|
import ShippingUtils from "../../utils/shippingUtils";
|
||||||
|
|
||||||
// <reference types="cypress" />
|
// <reference types="cypress" />
|
||||||
describe("Products", () => {
|
describe("Products available in listings", () => {
|
||||||
const shippingUtils = new ShippingUtils();
|
const shippingUtils = new ShippingUtils();
|
||||||
const channelsUtils = new ChannelsUtils();
|
const channelsUtils = new ChannelsUtils();
|
||||||
const productsUtils = new ProductsUtils();
|
const productsUtils = new ProductsUtils();
|
||||||
|
const productSteps = new ProductSteps();
|
||||||
|
const frontShopProductUtils = new FrontShopProductUtils();
|
||||||
const startsWith = "Cy-";
|
const startsWith = "Cy-";
|
||||||
const name = `${startsWith}${faker.random.number()}`;
|
const name = `${startsWith}${faker.random.number()}`;
|
||||||
let productTypeId;
|
let productTypeId;
|
||||||
|
@ -46,7 +48,7 @@ describe("Products", () => {
|
||||||
cy.clearSessionData().loginUserViaRequest();
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be possible to add to cart available for purchase product", () => {
|
it("should update product to available for purchase", () => {
|
||||||
const productName = `${startsWith}${faker.random.number()}`;
|
const productName = `${startsWith}${faker.random.number()}`;
|
||||||
productsUtils
|
productsUtils
|
||||||
.createProductInChannel(
|
.createProductInChannel(
|
||||||
|
@ -66,31 +68,19 @@ describe("Products", () => {
|
||||||
const productUrl = `${
|
const productUrl = `${
|
||||||
URL_LIST.products
|
URL_LIST.products
|
||||||
}${productsUtils.getCreatedProductId()}`;
|
}${productsUtils.getCreatedProductId()}`;
|
||||||
cy.visit(productUrl)
|
productSteps.updateProductIsAvailableForPurchase(productUrl, true);
|
||||||
.get(PRODUCTS_SELECTORS.assignedChannels)
|
frontShopProductUtils
|
||||||
.click()
|
.isProductAvailableForPurchase(
|
||||||
.get(
|
|
||||||
`${PRODUCTS_SELECTORS.availableForPurchaseRadioButtons}${PRODUCTS_SELECTORS.radioButtonsValueTrue}`
|
|
||||||
)
|
|
||||||
.click()
|
|
||||||
.get(PRODUCTS_SELECTORS.saveBtn)
|
|
||||||
.click()
|
|
||||||
.waitForGraph("ProductChannelListingUpdate")
|
|
||||||
.getProductDetails(
|
|
||||||
productsUtils.getCreatedProductId(),
|
productsUtils.getCreatedProductId(),
|
||||||
defaultChannel.slug
|
defaultChannel.slug,
|
||||||
|
productName
|
||||||
)
|
)
|
||||||
.then(productDetailsResp => {
|
.then(isProductVisible => {
|
||||||
expect(productDetailsResp.body[0].data.product.name).to.equal(
|
expect(isProductVisible).to.be.eq(true);
|
||||||
productName
|
|
||||||
);
|
|
||||||
expect(
|
|
||||||
productDetailsResp.body[0].data.product.isAvailableForPurchase
|
|
||||||
).to.be.eq(true);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
xit("shouldn't be possible to add to cart not available for purchase product", () => {
|
it("should update product to not available for purchase", () => {
|
||||||
const productName = `${startsWith}${faker.random.number()}`;
|
const productName = `${startsWith}${faker.random.number()}`;
|
||||||
productsUtils
|
productsUtils
|
||||||
.createProductInChannel(
|
.createProductInChannel(
|
||||||
|
@ -110,28 +100,15 @@ describe("Products", () => {
|
||||||
const productUrl = `${
|
const productUrl = `${
|
||||||
URL_LIST.products
|
URL_LIST.products
|
||||||
}${productsUtils.getCreatedProductId()}`;
|
}${productsUtils.getCreatedProductId()}`;
|
||||||
cy.visit(productUrl)
|
productSteps.updateProductIsAvailableForPurchase(productUrl, false);
|
||||||
.get(PRODUCTS_SELECTORS.assignedChannels)
|
frontShopProductUtils
|
||||||
.click()
|
.isProductAvailableForPurchase(
|
||||||
.get(
|
|
||||||
`${PRODUCTS_SELECTORS.availableForPurchaseRadioButtons}${PRODUCTS_SELECTORS.radioButtonsValueFalse}`
|
|
||||||
)
|
|
||||||
.click()
|
|
||||||
.get(PRODUCTS_SELECTORS.saveBtn)
|
|
||||||
.click()
|
|
||||||
.waitForGraph("ProductChannelListingUpdate")
|
|
||||||
.get("@shopUrl")
|
|
||||||
.getProductDetails(
|
|
||||||
productsUtils.getCreatedProductId(),
|
productsUtils.getCreatedProductId(),
|
||||||
defaultChannel.slug
|
defaultChannel.slug,
|
||||||
|
productName
|
||||||
)
|
)
|
||||||
.then(productDetailsResp => {
|
.then(isProductVisible => {
|
||||||
expect(productDetailsResp.body[0].data.product.name).to.equal(
|
expect(isProductVisible).to.be.eq(false);
|
||||||
productName
|
|
||||||
);
|
|
||||||
expect(
|
|
||||||
productDetailsResp.body[0].data.product.isAvailableForPurchase
|
|
||||||
).to.be.eq(false);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
|
@ -1,37 +1,25 @@
|
||||||
import faker from "faker";
|
// <reference types="cypress" />
|
||||||
|
|
||||||
import Channels from "../../apiRequests/Channels";
|
|
||||||
import { LEFT_MENU_SELECTORS } from "../../elements/account/left-menu/left-menu-selectors";
|
import { LEFT_MENU_SELECTORS } from "../../elements/account/left-menu/left-menu-selectors";
|
||||||
import { PRODUCTS_SELECTORS } from "../../elements/catalog/product-selectors";
|
import { PRODUCTS_SELECTORS } from "../../elements/catalog/product-selectors";
|
||||||
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
import { urlList } from "../../url/urlList";
|
||||||
import { URL_LIST } from "../../url/url-list";
|
|
||||||
import ChannelsUtils from "../../utils/channelsUtils";
|
|
||||||
import ProductsUtils from "../../utils/productsUtils";
|
|
||||||
|
|
||||||
// <reference types="cypress" />
|
|
||||||
describe("Products", () => {
|
describe("Products", () => {
|
||||||
const channels = new Channels();
|
|
||||||
const channelsUtils = new ChannelsUtils();
|
|
||||||
const productsUtils = new ProductsUtils();
|
|
||||||
|
|
||||||
const startsWith = "Cy-";
|
|
||||||
|
|
||||||
before(() => {
|
|
||||||
cy.clearSessionData().loginUserViaRequest();
|
|
||||||
productsUtils.deleteProducts(startsWith);
|
|
||||||
channelsUtils.deleteChannels(startsWith);
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.clearSessionData().loginUserViaRequest();
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
});
|
});
|
||||||
|
|
||||||
xit("should add new visible product", () => {
|
it("should navigate to channels page", () => {
|
||||||
cy.visit("/")
|
cy.visit(urlList.homePage)
|
||||||
.get(LEFT_MENU_SELECTORS.catalog)
|
.get(LEFT_MENU_SELECTORS.catalog)
|
||||||
.click()
|
.click()
|
||||||
.get(PRODUCTS_SELECTORS.products)
|
.get(LEFT_MENU_SELECTORS.products)
|
||||||
.click()
|
.click()
|
||||||
|
.location("pathname")
|
||||||
|
.should("contain", "/products");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should add new visible product", () => {
|
||||||
|
cy.visit(urlList.products)
|
||||||
.get(PRODUCTS_SELECTORS.createProductBtn)
|
.get(PRODUCTS_SELECTORS.createProductBtn)
|
||||||
.click()
|
.click()
|
||||||
.get(PRODUCTS_SELECTORS.productNameInput)
|
.get(PRODUCTS_SELECTORS.productNameInput)
|
||||||
|
@ -63,47 +51,4 @@ describe("Products", () => {
|
||||||
.get(PRODUCTS_SELECTORS.confirmationMsg)
|
.get(PRODUCTS_SELECTORS.confirmationMsg)
|
||||||
.contains("Product created");
|
.contains("Product created");
|
||||||
});
|
});
|
||||||
it("should display correct availibility for product in channel", () => {
|
|
||||||
const name = `${startsWith}${faker.random.number()}`;
|
|
||||||
cy.fixture("addresses").then(json => {
|
|
||||||
channels.createChannel(true, name, name, json.plAddress.currency);
|
|
||||||
productsUtils.createTypeAttributeAndCategoryForProduct(name).then(() => {
|
|
||||||
const productTypeId = productsUtils.getProductTypeId();
|
|
||||||
const attributeId = productsUtils.getAttributeId();
|
|
||||||
const categoryId = productsUtils.getCategoryId();
|
|
||||||
productsUtils.createProduct(
|
|
||||||
name,
|
|
||||||
attributeId,
|
|
||||||
productTypeId,
|
|
||||||
categoryId
|
|
||||||
);
|
|
||||||
cy.visit(URL_LIST.products)
|
|
||||||
.get(PRODUCTS_SELECTORS.searchProducts)
|
|
||||||
.type(name)
|
|
||||||
.get(PRODUCTS_SELECTORS.productsList)
|
|
||||||
.contains(name)
|
|
||||||
.click()
|
|
||||||
.get(PRODUCTS_SELECTORS.availableManageButton)
|
|
||||||
.click()
|
|
||||||
.get(PRODUCTS_SELECTORS.channelsAvailabilityForm)
|
|
||||||
.contains(name)
|
|
||||||
.click()
|
|
||||||
.get(BUTTON_SELECTORS.submit)
|
|
||||||
.click()
|
|
||||||
.get(PRODUCTS_SELECTORS.saveBtn)
|
|
||||||
.click()
|
|
||||||
.get(PRODUCTS_SELECTORS.goBackButton)
|
|
||||||
.click()
|
|
||||||
.get(PRODUCTS_SELECTORS.searchProducts)
|
|
||||||
.type(name)
|
|
||||||
.get(PRODUCTS_SELECTORS.productsList)
|
|
||||||
.contains(name)
|
|
||||||
.parentsUntil("tbody")
|
|
||||||
.find(PRODUCTS_SELECTORS.channelAvailabilityColumn)
|
|
||||||
.click()
|
|
||||||
.get(PRODUCTS_SELECTORS.channelAvailabilityList)
|
|
||||||
.contains(name);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,144 +0,0 @@
|
||||||
import faker from "faker";
|
|
||||||
|
|
||||||
import ShopInfo from "../../apiRequests/ShopInfo";
|
|
||||||
import { PRODUCTS_SELECTORS } from "../../elements/catalog/product-selectors";
|
|
||||||
import { SEARCH_SELECTORS } from "../../elements/frontend-elements/search-selectors";
|
|
||||||
import SearchSteps from "../../steps/frontendSteps/searchSteps";
|
|
||||||
import { URL_LIST } from "../../url/url-list";
|
|
||||||
import ChannelsUtils from "../../utils/channelsUtils";
|
|
||||||
import ProductsUtils from "../../utils/productsUtils";
|
|
||||||
|
|
||||||
// <reference types="cypress" />
|
|
||||||
describe("Products", () => {
|
|
||||||
const channelsUtils = new ChannelsUtils();
|
|
||||||
const productsUtils = new ProductsUtils();
|
|
||||||
const searchSteps = new SearchSteps();
|
|
||||||
|
|
||||||
const shopInfo = new ShopInfo();
|
|
||||||
|
|
||||||
const startsWith = "Cy-";
|
|
||||||
const name = `${startsWith}${faker.random.number()}`;
|
|
||||||
let productTypeId;
|
|
||||||
let attributeId;
|
|
||||||
let categoryId;
|
|
||||||
|
|
||||||
before(() => {
|
|
||||||
cy.clearSessionData().loginUserViaRequest();
|
|
||||||
productsUtils.deleteProducts(startsWith);
|
|
||||||
productsUtils.createTypeAttributeAndCategoryForProduct(name).then(() => {
|
|
||||||
productTypeId = productsUtils.getProductTypeId();
|
|
||||||
attributeId = productsUtils.getAttributeId();
|
|
||||||
categoryId = productsUtils.getCategoryId();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
cy.clearSessionData().loginUserViaRequest();
|
|
||||||
shopInfo
|
|
||||||
.getShopInfo()
|
|
||||||
.its("body.data.shop.domain.url")
|
|
||||||
.as("shopUrl");
|
|
||||||
});
|
|
||||||
it("should display on frontend only published products", () => {
|
|
||||||
const productName = `${startsWith}${faker.random.number()}`;
|
|
||||||
channelsUtils.getDefaultChannel().then(defaultChannel => {
|
|
||||||
productsUtils
|
|
||||||
.createProductInChannel(
|
|
||||||
productName,
|
|
||||||
productTypeId,
|
|
||||||
attributeId,
|
|
||||||
categoryId,
|
|
||||||
defaultChannel.id,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
.then(() => {
|
|
||||||
cy.visit(`${URL_LIST.products}${productsUtils.getCreatedProductId()}`)
|
|
||||||
.get(PRODUCTS_SELECTORS.assignedChannels)
|
|
||||||
.click()
|
|
||||||
.get(PRODUCTS_SELECTORS.publishedRadioButton)
|
|
||||||
.contains("Opublikowany")
|
|
||||||
.click()
|
|
||||||
.get(PRODUCTS_SELECTORS.saveBtn)
|
|
||||||
.click()
|
|
||||||
.waitForGraph("ProductChannelListingUpdate")
|
|
||||||
.get("@shopUrl")
|
|
||||||
.then(shopUrl => {
|
|
||||||
cy.visit(shopUrl);
|
|
||||||
searchSteps.searchFor(productName);
|
|
||||||
cy.get(SEARCH_SELECTORS.productItem).contains(productName);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it("shouldn't display not published product for unlogged user", () => {
|
|
||||||
const productName = `${startsWith}${faker.random.number()}`;
|
|
||||||
channelsUtils.getDefaultChannel().then(defaultChannel => {
|
|
||||||
productsUtils
|
|
||||||
.createProductInChannel(
|
|
||||||
productName,
|
|
||||||
productTypeId,
|
|
||||||
attributeId,
|
|
||||||
categoryId,
|
|
||||||
defaultChannel.id,
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
.then(() => {
|
|
||||||
cy.visit(`${URL_LIST.products}${productsUtils.getCreatedProductId()}`)
|
|
||||||
.get(PRODUCTS_SELECTORS.assignedChannels)
|
|
||||||
.click()
|
|
||||||
.get(PRODUCTS_SELECTORS.publishedRadioButton)
|
|
||||||
.contains("Nie opublikowano")
|
|
||||||
.click()
|
|
||||||
.get(PRODUCTS_SELECTORS.saveBtn)
|
|
||||||
.click()
|
|
||||||
.waitForGraph("ProductChannelListingUpdate")
|
|
||||||
.get("@shopUrl")
|
|
||||||
.then(shopUrl => {
|
|
||||||
cy.visit(shopUrl);
|
|
||||||
searchSteps.searchFor(productName);
|
|
||||||
cy.get(SEARCH_SELECTORS.productItem).should("not.exist");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it("should display not published product for staff member", () => {
|
|
||||||
const productName = `${startsWith}${faker.random.number()}`;
|
|
||||||
channelsUtils.getDefaultChannel().then(defaultChannel => {
|
|
||||||
productsUtils
|
|
||||||
.createProductInChannel(
|
|
||||||
productName,
|
|
||||||
productTypeId,
|
|
||||||
attributeId,
|
|
||||||
categoryId,
|
|
||||||
defaultChannel.id,
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
.then(() => {
|
|
||||||
cy.visit(`${URL_LIST.products}${productsUtils.getCreatedProductId()}`)
|
|
||||||
.get(PRODUCTS_SELECTORS.assignedChannels)
|
|
||||||
.click()
|
|
||||||
.get(PRODUCTS_SELECTORS.publishedRadioButton)
|
|
||||||
.contains("Nie opublikowano")
|
|
||||||
.click()
|
|
||||||
.get(PRODUCTS_SELECTORS.saveBtn)
|
|
||||||
.click()
|
|
||||||
.waitForGraph("ProductChannelListingUpdate")
|
|
||||||
.get("@shopUrl")
|
|
||||||
.then(shopUrl => {
|
|
||||||
cy.visit(shopUrl)
|
|
||||||
.loginInShop()
|
|
||||||
.then(() => {
|
|
||||||
searchSteps.searchFor(productName);
|
|
||||||
cy.get(SEARCH_SELECTORS.productItem).contains(productName);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
94
cypress/integration/products/publishedProducts.js
Normal file
94
cypress/integration/products/publishedProducts.js
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
import faker from "faker";
|
||||||
|
|
||||||
|
import ProductSteps from "../../steps/productSteps";
|
||||||
|
import { URL_LIST } from "../../url/url-list";
|
||||||
|
import ChannelsUtils from "../../utils/channelsUtils";
|
||||||
|
import FrontShopProductUtils from "../../utils/frontShop/frontShopProductUtils";
|
||||||
|
import ProductsUtils from "../../utils/productsUtils";
|
||||||
|
|
||||||
|
// <reference types="cypress" />
|
||||||
|
describe("Publish products", () => {
|
||||||
|
const channelsUtils = new ChannelsUtils();
|
||||||
|
const productsUtils = new ProductsUtils();
|
||||||
|
const productSteps = new ProductSteps();
|
||||||
|
const frontShopProductUtils = new FrontShopProductUtils();
|
||||||
|
|
||||||
|
const startsWith = "Cy-";
|
||||||
|
const name = `${startsWith}${faker.random.number()}`;
|
||||||
|
let productTypeId;
|
||||||
|
let attributeId;
|
||||||
|
let categoryId;
|
||||||
|
|
||||||
|
before(() => {
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
productsUtils.deleteProducts(startsWith);
|
||||||
|
productsUtils.createTypeAttributeAndCategoryForProduct(name).then(() => {
|
||||||
|
productTypeId = productsUtils.getProductTypeId();
|
||||||
|
attributeId = productsUtils.getAttributeId();
|
||||||
|
categoryId = productsUtils.getCategoryId();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
});
|
||||||
|
it("should update product to published", () => {
|
||||||
|
const productName = `${startsWith}${faker.random.number()}`;
|
||||||
|
channelsUtils.getDefaultChannel().then(defaultChannel => {
|
||||||
|
productsUtils
|
||||||
|
.createProductInChannel(
|
||||||
|
productName,
|
||||||
|
productTypeId,
|
||||||
|
attributeId,
|
||||||
|
categoryId,
|
||||||
|
defaultChannel.id,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
.then(() => {
|
||||||
|
const productId = productsUtils.getCreatedProductId();
|
||||||
|
const productUrl = `${URL_LIST.products}${productId}`;
|
||||||
|
productSteps.updateProductPublish(productUrl, true);
|
||||||
|
frontShopProductUtils
|
||||||
|
.isProductVisible(productId, defaultChannel.slug, productName)
|
||||||
|
.then(isVisible => {
|
||||||
|
expect(isVisible).to.be.eq(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it("should update product to not published", () => {
|
||||||
|
const productName = `${startsWith}${faker.random.number()}`;
|
||||||
|
channelsUtils.getDefaultChannel().then(defaultChannel => {
|
||||||
|
productsUtils
|
||||||
|
.createProductInChannel(
|
||||||
|
productName,
|
||||||
|
productTypeId,
|
||||||
|
attributeId,
|
||||||
|
categoryId,
|
||||||
|
defaultChannel.id,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
.then(() => {
|
||||||
|
const productId = productsUtils.getCreatedProductId();
|
||||||
|
const productUrl = `${URL_LIST.products}${productId}`;
|
||||||
|
productSteps.updateProductPublish(productUrl, false);
|
||||||
|
frontShopProductUtils
|
||||||
|
.isProductVisible(productId, defaultChannel.slug, productName)
|
||||||
|
.then(isVisible => {
|
||||||
|
expect(isVisible).to.be.eq(false);
|
||||||
|
});
|
||||||
|
cy.loginInShop().then(() => {
|
||||||
|
frontShopProductUtils
|
||||||
|
.isProductVisible(productId, defaultChannel.slug, productName)
|
||||||
|
.then(isVisible => {
|
||||||
|
expect(isVisible).to.be.eq(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -1,144 +0,0 @@
|
||||||
import faker from "faker";
|
|
||||||
|
|
||||||
import ShopInfo from "../../apiRequests/ShopInfo";
|
|
||||||
import { PRODUCTS_SELECTORS } from "../../elements/catalog/product-selectors";
|
|
||||||
import { SEARCH_SELECTORS } from "../../elements/frontend-elements/search-selectors";
|
|
||||||
import SearchSteps from "../../steps/frontendSteps/searchSteps";
|
|
||||||
import { URL_LIST } from "../../url/url-list";
|
|
||||||
import ChannelsUtils from "../../utils/channelsUtils";
|
|
||||||
import ProductsUtils from "../../utils/productsUtils";
|
|
||||||
|
|
||||||
// <reference types="cypress" />
|
|
||||||
describe("Products", () => {
|
|
||||||
const channelsUtils = new ChannelsUtils();
|
|
||||||
const productsUtils = new ProductsUtils();
|
|
||||||
const searchSteps = new SearchSteps();
|
|
||||||
|
|
||||||
const shopInfo = new ShopInfo();
|
|
||||||
|
|
||||||
const startsWith = "Cy-";
|
|
||||||
const name = `${startsWith}${faker.random.number()}`;
|
|
||||||
let productTypeId;
|
|
||||||
let attributeId;
|
|
||||||
let categoryId;
|
|
||||||
|
|
||||||
before(() => {
|
|
||||||
cy.clearSessionData().loginUserViaRequest();
|
|
||||||
productsUtils.deleteProducts(startsWith);
|
|
||||||
productsUtils.createTypeAttributeAndCategoryForProduct(name).then(() => {
|
|
||||||
productTypeId = productsUtils.getProductTypeId();
|
|
||||||
attributeId = productsUtils.getAttributeId();
|
|
||||||
categoryId = productsUtils.getCategoryId();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
cy.clearSessionData().loginUserViaRequest();
|
|
||||||
shopInfo
|
|
||||||
.getShopInfo()
|
|
||||||
.its("body.data.shop.domain.url")
|
|
||||||
.as("shopUrl");
|
|
||||||
});
|
|
||||||
it("should display on frontend only visible in listings products", () => {
|
|
||||||
const productName = `${startsWith}${faker.random.number()}`;
|
|
||||||
channelsUtils.getDefaultChannel().then(defaultChannel => {
|
|
||||||
productsUtils
|
|
||||||
.createProductInChannel(
|
|
||||||
productName,
|
|
||||||
productTypeId,
|
|
||||||
attributeId,
|
|
||||||
categoryId,
|
|
||||||
defaultChannel.id,
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
false
|
|
||||||
)
|
|
||||||
.then(() => {
|
|
||||||
cy.visit(`${URL_LIST.products}${productsUtils.getCreatedProductId()}`)
|
|
||||||
.get(PRODUCTS_SELECTORS.assignedChannels)
|
|
||||||
.click()
|
|
||||||
.get(PRODUCTS_SELECTORS.visibleInListingsButton)
|
|
||||||
.contains("Wyświetlaj na liście produktów")
|
|
||||||
.click()
|
|
||||||
.get(PRODUCTS_SELECTORS.saveBtn)
|
|
||||||
.click()
|
|
||||||
.waitForGraph("ProductChannelListingUpdate")
|
|
||||||
.get("@shopUrl")
|
|
||||||
.then(shopUrl => {
|
|
||||||
cy.visit(shopUrl);
|
|
||||||
searchSteps.searchFor(productName);
|
|
||||||
cy.get(SEARCH_SELECTORS.productItem).contains(productName);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it("shouldn't display not visible in listing product for unlogged user", () => {
|
|
||||||
const productName = `${startsWith}${faker.random.number()}`;
|
|
||||||
channelsUtils.getDefaultChannel().then(defaultChannel => {
|
|
||||||
productsUtils
|
|
||||||
.createProductInChannel(
|
|
||||||
productName,
|
|
||||||
productTypeId,
|
|
||||||
attributeId,
|
|
||||||
categoryId,
|
|
||||||
defaultChannel.id,
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
.then(() => {
|
|
||||||
cy.visit(`${URL_LIST.products}${productsUtils.getCreatedProductId()}`)
|
|
||||||
.get(PRODUCTS_SELECTORS.assignedChannels)
|
|
||||||
.click()
|
|
||||||
.get(PRODUCTS_SELECTORS.visibleInListingsButton)
|
|
||||||
.contains("Wyświetlaj na liście produktów")
|
|
||||||
.click()
|
|
||||||
.get(PRODUCTS_SELECTORS.saveBtn)
|
|
||||||
.click()
|
|
||||||
.waitForGraph("ProductChannelListingUpdate")
|
|
||||||
.get("@shopUrl")
|
|
||||||
.then(shopUrl => {
|
|
||||||
cy.visit(shopUrl);
|
|
||||||
searchSteps.searchFor(productName);
|
|
||||||
cy.get(SEARCH_SELECTORS.productItem).should("not.exist");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it("should display not visible in listing product for staff member", () => {
|
|
||||||
const productName = `${startsWith}${faker.random.number()}`;
|
|
||||||
channelsUtils.getDefaultChannel().then(defaultChannel => {
|
|
||||||
productsUtils
|
|
||||||
.createProductInChannel(
|
|
||||||
productName,
|
|
||||||
productTypeId,
|
|
||||||
attributeId,
|
|
||||||
categoryId,
|
|
||||||
defaultChannel.id,
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
.then(() => {
|
|
||||||
cy.visit(`${URL_LIST.products}${productsUtils.getCreatedProductId()}`)
|
|
||||||
.get(PRODUCTS_SELECTORS.assignedChannels)
|
|
||||||
.click()
|
|
||||||
.get(PRODUCTS_SELECTORS.visibleInListingsButton)
|
|
||||||
.contains("Wyświetlaj na liście produktów")
|
|
||||||
.click()
|
|
||||||
.get(PRODUCTS_SELECTORS.saveBtn)
|
|
||||||
.click()
|
|
||||||
.waitForGraph("ProductChannelListingUpdate")
|
|
||||||
.get("@shopUrl")
|
|
||||||
.then(shopUrl => {
|
|
||||||
cy.visit(shopUrl)
|
|
||||||
.loginInShop()
|
|
||||||
.then(() => {
|
|
||||||
searchSteps.searchFor(productName);
|
|
||||||
cy.get(SEARCH_SELECTORS.productItem).contains(productName);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
94
cypress/integration/products/visibleInListingsProducts.js
Normal file
94
cypress/integration/products/visibleInListingsProducts.js
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
import faker from "faker";
|
||||||
|
|
||||||
|
import ProductSteps from "../../steps/productSteps";
|
||||||
|
import { URL_LIST } from "../../url/url-list";
|
||||||
|
import ChannelsUtils from "../../utils/channelsUtils";
|
||||||
|
import FrontShopProductUtils from "../../utils/frontShop/frontShopProductUtils";
|
||||||
|
import ProductsUtils from "../../utils/productsUtils";
|
||||||
|
|
||||||
|
// <reference types="cypress" />
|
||||||
|
describe("Products displayed in listings", () => {
|
||||||
|
const channelsUtils = new ChannelsUtils();
|
||||||
|
const productsUtils = new ProductsUtils();
|
||||||
|
const productSteps = new ProductSteps();
|
||||||
|
const frontShopProductUtils = new FrontShopProductUtils();
|
||||||
|
|
||||||
|
const startsWith = "Cy-";
|
||||||
|
const name = `${startsWith}${faker.random.number()}`;
|
||||||
|
let productTypeId;
|
||||||
|
let attributeId;
|
||||||
|
let categoryId;
|
||||||
|
|
||||||
|
before(() => {
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
productsUtils.deleteProducts(startsWith);
|
||||||
|
productsUtils.createTypeAttributeAndCategoryForProduct(name).then(() => {
|
||||||
|
productTypeId = productsUtils.getProductTypeId();
|
||||||
|
attributeId = productsUtils.getAttributeId();
|
||||||
|
categoryId = productsUtils.getCategoryId();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
});
|
||||||
|
it("should update product to visible in listings", () => {
|
||||||
|
const productName = `${startsWith}${faker.random.number()}`;
|
||||||
|
channelsUtils.getDefaultChannel().then(defaultChannel => {
|
||||||
|
productsUtils
|
||||||
|
.createProductInChannel(
|
||||||
|
productName,
|
||||||
|
productTypeId,
|
||||||
|
attributeId,
|
||||||
|
categoryId,
|
||||||
|
defaultChannel.id,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
)
|
||||||
|
.then(() => {
|
||||||
|
const productId = productsUtils.getCreatedProductId();
|
||||||
|
const productUrl = `${URL_LIST.products}${productId}`;
|
||||||
|
productSteps.updateProductVisibleInListings(productUrl);
|
||||||
|
frontShopProductUtils
|
||||||
|
.isProductVisibleInSearchResult(productName, defaultChannel.slug)
|
||||||
|
.then(isProductVisible => {
|
||||||
|
expect(isProductVisible).to.be.eq(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it("should update product to not visible in listings", () => {
|
||||||
|
const productName = `${startsWith}${faker.random.number()}`;
|
||||||
|
channelsUtils.getDefaultChannel().then(defaultChannel => {
|
||||||
|
productsUtils
|
||||||
|
.createProductInChannel(
|
||||||
|
productName,
|
||||||
|
productTypeId,
|
||||||
|
attributeId,
|
||||||
|
categoryId,
|
||||||
|
defaultChannel.id,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
.then(() => {
|
||||||
|
const productId = productsUtils.getCreatedProductId();
|
||||||
|
const productUrl = `${URL_LIST.products}${productId}`;
|
||||||
|
productSteps.updateProductVisibleInListings(productUrl);
|
||||||
|
frontShopProductUtils
|
||||||
|
.isProductVisibleInSearchResult(productName, defaultChannel.slug)
|
||||||
|
.then(isProductVisible => {
|
||||||
|
expect(isProductVisible).to.be.eq(false);
|
||||||
|
});
|
||||||
|
cy.loginInShop().then(() => {
|
||||||
|
frontShopProductUtils
|
||||||
|
.isProductVisibleInSearchResult(productName, defaultChannel.slug)
|
||||||
|
.then(isProductVisible => {
|
||||||
|
expect(isProductVisible).to.be.eq(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
46
cypress/steps/productSteps.js
Normal file
46
cypress/steps/productSteps.js
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
import { PRODUCTS_SELECTORS } from "../elements/catalog/product-selectors";
|
||||||
|
|
||||||
|
class ProductSteps {
|
||||||
|
updateProductIsAvailableForPurchase(productUrl, isAvailableForPurchase) {
|
||||||
|
let isAvailableForPurchaseSelector;
|
||||||
|
if (isAvailableForPurchase) {
|
||||||
|
isAvailableForPurchaseSelector = PRODUCTS_SELECTORS.radioButtonsValueTrue;
|
||||||
|
} else {
|
||||||
|
isAvailableForPurchaseSelector =
|
||||||
|
PRODUCTS_SELECTORS.radioButtonsValueFalse;
|
||||||
|
}
|
||||||
|
this.updateProductMenageInChannel(
|
||||||
|
productUrl,
|
||||||
|
`${PRODUCTS_SELECTORS.availableForPurchaseRadioButtons}${isAvailableForPurchaseSelector}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
updateProductPublish(productUrl, isPublished) {
|
||||||
|
let isPublishedSelector;
|
||||||
|
if (isPublished) {
|
||||||
|
isPublishedSelector = PRODUCTS_SELECTORS.radioButtonsValueTrue;
|
||||||
|
} else {
|
||||||
|
isPublishedSelector = PRODUCTS_SELECTORS.radioButtonsValueFalse;
|
||||||
|
}
|
||||||
|
this.updateProductMenageInChannel(
|
||||||
|
productUrl,
|
||||||
|
`${PRODUCTS_SELECTORS.publishedRadioButtons}${isPublishedSelector}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
updateProductVisibleInListings(productUrl) {
|
||||||
|
this.updateProductMenageInChannel(
|
||||||
|
productUrl,
|
||||||
|
PRODUCTS_SELECTORS.visibleInListingsButton
|
||||||
|
);
|
||||||
|
}
|
||||||
|
updateProductMenageInChannel(productUrl, menageSelector) {
|
||||||
|
cy.visit(productUrl)
|
||||||
|
.get(PRODUCTS_SELECTORS.assignedChannels)
|
||||||
|
.click()
|
||||||
|
.get(menageSelector)
|
||||||
|
.click()
|
||||||
|
.get(PRODUCTS_SELECTORS.saveBtn)
|
||||||
|
.click()
|
||||||
|
.waitForGraph("ProductChannelListingUpdate");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default ProductSteps;
|
|
@ -1,41 +0,0 @@
|
||||||
/* eslint-disable sort-keys */
|
|
||||||
|
|
||||||
Cypress.Commands.add("searchInShop", searchQuery =>
|
|
||||||
cy.request({
|
|
||||||
method: "POST",
|
|
||||||
url: Cypress.env("API_URI"),
|
|
||||||
body: [
|
|
||||||
{
|
|
||||||
operationName: "SearchProducts",
|
|
||||||
variables: {
|
|
||||||
attributes: {},
|
|
||||||
channel: "default-channel",
|
|
||||||
pageSize: 6,
|
|
||||||
priceGte: null,
|
|
||||||
priceLte: null,
|
|
||||||
query: searchQuery,
|
|
||||||
sortBy: null
|
|
||||||
},
|
|
||||||
query:
|
|
||||||
"fragment Price on TaxedMoney {\n gross {\n amount\n currency\n __typename\n }\n net {\n amount\n currency\n __typename\n }\n __typename\n}\n\nfragment ProductPricingField on Product {\n pricing {\n onSale\n priceRangeUndiscounted {\n start {\n ...Price\n __typename\n }\n stop {\n ...Price\n __typename\n }\n __typename\n }\n priceRange {\n start {\n ...Price\n __typename\n }\n stop {\n ...Price\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n}\n\nquery SearchProducts($query: String!, $channel: String!, $attributes: [AttributeInput], $pageSize: Int, $sortBy: ProductOrder, $after: String) {\n products(channel: $channel, filter: {search: $query, attributes: $attributes}, first: $pageSize, sortBy: $sortBy, after: $after) {\n totalCount\n edges {\n node {\n ...ProductPricingField\n id\n name\n thumbnail {\n url\n alt\n __typename\n }\n thumbnail2x: thumbnail(size: 510) {\n url\n __typename\n }\n category {\n id\n name\n __typename\n }\n __typename\n }\n __typename\n }\n pageInfo {\n endCursor\n hasNextPage\n __typename\n }\n __typename\n }\n attributes(filter: {filterableInStorefront: true}, first: 100) {\n edges {\n node {\n id\n name\n slug\n values {\n id\n name\n slug\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n}\n"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
);
|
|
||||||
Cypress.Commands.add("getProductDetails", (productId, channelId) =>
|
|
||||||
cy.request({
|
|
||||||
method: "POST",
|
|
||||||
url: Cypress.env("API_URI"),
|
|
||||||
body: [
|
|
||||||
{
|
|
||||||
operationName: "ProductDetails",
|
|
||||||
variables: {
|
|
||||||
channel: channelId,
|
|
||||||
id: productId
|
|
||||||
},
|
|
||||||
query:
|
|
||||||
"fragment BasicProductFields on Product {\n id\n name\n thumbnail {\n url\n alt\n __typename\n }\n thumbnail2x: thumbnail(size: 510) {\n url\n __typename\n }\n __typename\n}\n\nfragment SelectedAttributeFields on SelectedAttribute {\n attribute {\n id\n name\n __typename\n }\n values {\n id\n name\n __typename\n }\n __typename\n}\n\nfragment Price on TaxedMoney {\n gross {\n amount\n currency\n __typename\n }\n net {\n amount\n currency\n __typename\n }\n __typename\n}\n\nfragment ProductVariantFields on ProductVariant {\n id\n sku\n name\n quantityAvailable(countryCode: $countryCode)\n images {\n id\n url\n alt\n __typename\n }\n pricing {\n onSale\n priceUndiscounted {\n ...Price\n __typename\n }\n price {\n ...Price\n __typename\n }\n __typename\n }\n attributes(variantSelection: VARIANT_SELECTION) {\n attribute {\n id\n name\n slug\n __typename\n }\n values {\n id\n name\n value: name\n __typename\n }\n __typename\n }\n __typename\n}\n\nfragment ProductPricingField on Product {\n pricing {\n onSale\n priceRangeUndiscounted {\n start {\n ...Price\n __typename\n }\n stop {\n ...Price\n __typename\n }\n __typename\n }\n priceRange {\n start {\n ...Price\n __typename\n }\n stop {\n ...Price\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n}\n\nquery ProductDetails($id: ID!, $channel: String, $countryCode: CountryCode) {\n product(id: $id, channel: $channel) {\n ...BasicProductFields\n ...ProductPricingField\n description\n category {\n id\n name\n products(first: 3, channel: $channel) {\n edges {\n node {\n ...BasicProductFields\n ...ProductPricingField\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n images {\n id\n alt\n url\n __typename\n }\n attributes {\n ...SelectedAttributeFields\n __typename\n }\n variants {\n ...ProductVariantFields\n __typename\n }\n seoDescription\n seoTitle\n isAvailable\n isAvailableForPurchase\n availableForPurchase\n __typename\n }\n}\n"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
);
|
|
|
@ -1,5 +1,4 @@
|
||||||
import "./user";
|
import "./user";
|
||||||
import "./frontShop";
|
|
||||||
|
|
||||||
import { urlList } from "../url/urlList";
|
import { urlList } from "../url/urlList";
|
||||||
|
|
||||||
|
|
28
cypress/utils/frontShop/frontShopProductUtils.js
Normal file
28
cypress/utils/frontShop/frontShopProductUtils.js
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
import ProductDetails from "../../apiRequests/frontShop/ProductDetails";
|
||||||
|
import Search from "../../apiRequests/frontShop/Search";
|
||||||
|
|
||||||
|
class FrontShopProductUtils {
|
||||||
|
isProductVisible(productId, channelSlug, name) {
|
||||||
|
const productDetails = new ProductDetails();
|
||||||
|
return productDetails
|
||||||
|
.getProductDetails(productId, channelSlug)
|
||||||
|
.then(productDetailsResp =>
|
||||||
|
productDetails.isProductExist(productDetailsResp, name)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
isProductAvailableForPurchase(productId, channelSlug) {
|
||||||
|
const productDetails = new ProductDetails();
|
||||||
|
return productDetails
|
||||||
|
.getProductDetails(productId, channelSlug)
|
||||||
|
.then(productDetailsResp =>
|
||||||
|
productDetails.isAvailableForPurchaseFromResp(productDetailsResp)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
isProductVisibleInSearchResult(productName, channelSlug) {
|
||||||
|
const search = new Search();
|
||||||
|
return search
|
||||||
|
.searchInShop(productName, channelSlug)
|
||||||
|
.then(resp => search.isProductExist(resp, productName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default FrontShopProductUtils;
|
Loading…
Reference in a new issue