all tests for products
This commit is contained in:
parent
584e66b9f9
commit
2a9e420420
8 changed files with 224 additions and 26 deletions
|
@ -27,7 +27,8 @@ class Product {
|
|||
productId,
|
||||
channelId,
|
||||
isPublished,
|
||||
isAvailableForPurchase
|
||||
isAvailableForPurchase,
|
||||
visibleInListings
|
||||
) {
|
||||
const mutation = `mutation{
|
||||
productChannelListingUpdate(id:"${productId}",
|
||||
|
@ -36,7 +37,7 @@ class Product {
|
|||
channelId:"${channelId}"
|
||||
isPublished:${isPublished}
|
||||
isAvailableForPurchase:${isAvailableForPurchase}
|
||||
visibleInListings:true
|
||||
visibleInListings:${visibleInListings}
|
||||
}
|
||||
}){
|
||||
product{
|
||||
|
|
|
@ -23,5 +23,6 @@ export const PRODUCTS_SELECTORS = {
|
|||
channelAvailabilityList: "ul[role='menu']",
|
||||
goBackButton: "[data-test-id='app-header-back-button']",
|
||||
assignedChannels: "[data-test='channel-availability-item']",
|
||||
publishedRadioButton: "[role=radiogroup]"
|
||||
publishedRadioButton: "[role=radiogroup]",
|
||||
visibleInListingsButton: "[class*='MuiFormControlLabel']"
|
||||
};
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
{
|
||||
"plAddress":{
|
||||
"plAddress": {
|
||||
"companyName": "Test3",
|
||||
"streetAddress1": "Smolna",
|
||||
"streetAddress2": "13/1",
|
||||
"city": "Wrocław",
|
||||
"postalCode": "53-346",
|
||||
"country": "PL",
|
||||
"countryArea": "Dolny Śląsk",
|
||||
"phone": "123456787",
|
||||
"currency": "PLN"
|
||||
}
|
||||
}
|
|
@ -33,8 +33,8 @@ describe("Products", () => {
|
|||
shippingUtils.deleteShipping(startsWith);
|
||||
productsUtils.deleteProducts(startsWith);
|
||||
|
||||
channelsUtils.findDefaultChannel().then(() => {
|
||||
defaultChannel = channelsUtils.getDefaultChannel();
|
||||
channelsUtils.getDefaultChannel().then(channel => {
|
||||
defaultChannel = channel;
|
||||
cy.fixture("addresses").then(json => {
|
||||
shippingUtils
|
||||
.createShipping(defaultChannel, name, json.plAddress, 10)
|
||||
|
@ -66,15 +66,18 @@ describe("Products", () => {
|
|||
productTypeId,
|
||||
attributeId,
|
||||
categoryId,
|
||||
defaultChannel,
|
||||
defaultChannel.id,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
warehouseId,
|
||||
10,
|
||||
10
|
||||
)
|
||||
.then(() => {
|
||||
const productUrl = `${URL_LIST.products}${productsUtils.getCreatedProductId}`;
|
||||
const productUrl = `${
|
||||
URL_LIST.products
|
||||
}${productsUtils.getCreatedProductId()}`;
|
||||
cy.visit(productUrl)
|
||||
.get(PRODUCTS_SELECTORS.assignedChannels)
|
||||
.click()
|
||||
|
@ -87,7 +90,7 @@ describe("Products", () => {
|
|||
.get("@shopUrl")
|
||||
.then(shopUrl => {
|
||||
cy.visit(shopUrl);
|
||||
searchSteps.searchFor(name);
|
||||
searchSteps.searchFor(productName);
|
||||
cy.get(SEARCH_SELECTORS.productItem)
|
||||
.contains(productName)
|
||||
.click()
|
||||
|
@ -98,4 +101,45 @@ describe("Products", () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
it("shouldn't be possible to add to cart not available for purchase product", () => {
|
||||
const productName = `${startsWith}${faker.random.number()}`;
|
||||
productsUtils
|
||||
.createProductInChannel(
|
||||
productName,
|
||||
productTypeId,
|
||||
attributeId,
|
||||
categoryId,
|
||||
defaultChannel.id,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
warehouseId,
|
||||
10,
|
||||
10
|
||||
)
|
||||
.then(() => {
|
||||
const productUrl = `${
|
||||
URL_LIST.products
|
||||
}${productsUtils.getCreatedProductId()}`;
|
||||
cy.visit(productUrl)
|
||||
.get(PRODUCTS_SELECTORS.assignedChannels)
|
||||
.click()
|
||||
.get(PRODUCTS_SELECTORS.publishedRadioButton)
|
||||
.contains("Niedostępne do zakupu")
|
||||
.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)
|
||||
.click()
|
||||
.get(PRODUCTS_DETAILS_SELECTORS.addToCartButton)
|
||||
.should("be.disabled");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -39,7 +39,7 @@ describe("Products", () => {
|
|||
.its("body.data.shop.domain.url")
|
||||
.as("shopUrl");
|
||||
});
|
||||
xit("should display on frontend only published products", () => {
|
||||
it("should display on frontend only published products", () => {
|
||||
const productName = `${startsWith}${faker.random.number()}`;
|
||||
channelsUtils.getDefaultChannel().then(defaultChannel => {
|
||||
productsUtils
|
||||
|
@ -50,7 +50,8 @@ describe("Products", () => {
|
|||
categoryId,
|
||||
defaultChannel.id,
|
||||
false,
|
||||
false
|
||||
false,
|
||||
true
|
||||
)
|
||||
.then(() => {
|
||||
cy.visit(`${URL_LIST.products}${productsUtils.getCreatedProductId()}`)
|
||||
|
@ -65,8 +66,8 @@ describe("Products", () => {
|
|||
.get("@shopUrl")
|
||||
.then(shopUrl => {
|
||||
cy.visit(shopUrl);
|
||||
searchSteps.searchFor(name);
|
||||
cy.get(SEARCH_SELECTORS.productItem).contains(name);
|
||||
searchSteps.searchFor(productName);
|
||||
cy.get(SEARCH_SELECTORS.productItem).contains(productName);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -82,7 +83,8 @@ describe("Products", () => {
|
|||
categoryId,
|
||||
defaultChannel.id,
|
||||
true,
|
||||
false
|
||||
false,
|
||||
true
|
||||
)
|
||||
.then(() => {
|
||||
cy.visit(`${URL_LIST.products}${productsUtils.getCreatedProductId()}`)
|
||||
|
@ -97,13 +99,13 @@ describe("Products", () => {
|
|||
.get("@shopUrl")
|
||||
.then(shopUrl => {
|
||||
cy.visit(shopUrl);
|
||||
searchSteps.searchFor(name);
|
||||
searchSteps.searchFor(productName);
|
||||
cy.get(SEARCH_SELECTORS.productItem).should("not.exist");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
xit("should display not published product for staff member", () => {
|
||||
it("should display not published product for staff member", () => {
|
||||
const productName = `${startsWith}${faker.random.number()}`;
|
||||
channelsUtils.getDefaultChannel().then(defaultChannel => {
|
||||
productsUtils
|
||||
|
@ -114,7 +116,8 @@ describe("Products", () => {
|
|||
categoryId,
|
||||
defaultChannel.id,
|
||||
true,
|
||||
false
|
||||
false,
|
||||
true
|
||||
)
|
||||
.then(() => {
|
||||
cy.visit(`${URL_LIST.products}${productsUtils.getCreatedProductId()}`)
|
||||
|
@ -131,8 +134,8 @@ describe("Products", () => {
|
|||
cy.visit(shopUrl)
|
||||
.loginInShop()
|
||||
.then(() => {
|
||||
searchSteps.searchFor(name);
|
||||
cy.get(SEARCH_SELECTORS.productItem).contains(name);
|
||||
searchSteps.searchFor(productName);
|
||||
cy.get(SEARCH_SELECTORS.productItem).contains(productName);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
144
cypress/integration/products/showInListings.js
Normal file
144
cypress/integration/products/showInListings.js
Normal file
|
@ -0,0 +1,144 @@
|
|||
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);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -3,8 +3,6 @@ import Channels from "../apiRequests/Channels";
|
|||
class ChannelsUtils {
|
||||
channels = new Channels();
|
||||
|
||||
defaultChannel;
|
||||
|
||||
deleteChannels(nameStartsWith) {
|
||||
this.channels.getChannels().then(resp => {
|
||||
const channelsArray = new Set(resp.body.data.channels);
|
||||
|
@ -28,7 +26,7 @@ class ChannelsUtils {
|
|||
}
|
||||
});
|
||||
}
|
||||
findDefaultChannel() {
|
||||
getDefaultChannel() {
|
||||
return this.channels.getChannels().then(resp => {
|
||||
const channelsArray = resp.body.data.channels;
|
||||
return (this.defaultChannel = channelsArray.find(function(
|
||||
|
@ -38,8 +36,5 @@ class ChannelsUtils {
|
|||
}));
|
||||
});
|
||||
}
|
||||
getDefaultChannel() {
|
||||
return this.defaultChannel;
|
||||
}
|
||||
}
|
||||
export default ChannelsUtils;
|
||||
|
|
|
@ -42,6 +42,7 @@ class ProductsUtils {
|
|||
channelId,
|
||||
isPublished,
|
||||
isAvailableForPurchase,
|
||||
visibleInListings,
|
||||
warehouseId,
|
||||
quantityInWarehouse,
|
||||
price
|
||||
|
@ -57,7 +58,8 @@ class ProductsUtils {
|
|||
this.createdProductId,
|
||||
channelId,
|
||||
isPublished,
|
||||
isAvailableForPurchase
|
||||
isAvailableForPurchase,
|
||||
visibleInListings
|
||||
)
|
||||
.then(() =>
|
||||
product
|
||||
|
|
Loading…
Reference in a new issue