collections tests
This commit is contained in:
commit
6e6b9956ef
28 changed files with 790 additions and 289 deletions
37
cypress/apiRequests/Collections.js
Normal file
37
cypress/apiRequests/Collections.js
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
class Collections {
|
||||||
|
getCollections(search) {
|
||||||
|
const filter = search
|
||||||
|
? `, filter:{
|
||||||
|
search:""
|
||||||
|
}`
|
||||||
|
: "";
|
||||||
|
const query = `query{
|
||||||
|
collections(first:100 ${filter}){
|
||||||
|
edges{
|
||||||
|
node{
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
return cy
|
||||||
|
.sendRequestWithQuery(query)
|
||||||
|
.then(resp => resp.body.data.collections.edges);
|
||||||
|
}
|
||||||
|
deleteCollection(collectionId) {
|
||||||
|
const mutation = `mutation{
|
||||||
|
collectionDelete(id:"${collectionId}"){
|
||||||
|
collection{
|
||||||
|
id
|
||||||
|
}
|
||||||
|
collectionErrors{
|
||||||
|
field
|
||||||
|
message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
return cy.sendRequestWithQuery(mutation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default Collections;
|
|
@ -1,4 +1,7 @@
|
||||||
|
import Utils from "./utils/Utils";
|
||||||
|
|
||||||
class Product {
|
class Product {
|
||||||
|
utils = new Utils();
|
||||||
getFirstProducts(first, search) {
|
getFirstProducts(first, search) {
|
||||||
const filter = search
|
const filter = search
|
||||||
? `, filter:{
|
? `, filter:{
|
||||||
|
@ -17,21 +20,27 @@ class Product {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
`;
|
`;
|
||||||
return cy
|
return cy
|
||||||
.sendRequestWithQuery(query)
|
.sendRequestWithQuery(query)
|
||||||
.then(resp => resp.body.data.products.edges);
|
.then(resp => resp.body.data.products.edges);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateChannelInProduct(productId, channelId) {
|
updateChannelInProduct({
|
||||||
|
productId,
|
||||||
|
channelId,
|
||||||
|
isPublished = true,
|
||||||
|
isAvailableForPurchase = true,
|
||||||
|
visibleInListings = true
|
||||||
|
}) {
|
||||||
const mutation = `mutation{
|
const mutation = `mutation{
|
||||||
productChannelListingUpdate(id:"${productId}",
|
productChannelListingUpdate(id:"${productId}",
|
||||||
input:{
|
input:{
|
||||||
addChannels:{
|
addChannels:{
|
||||||
channelId:"${channelId}"
|
channelId:"${channelId}"
|
||||||
isPublished:true
|
isPublished:${isPublished}
|
||||||
isAvailableForPurchase:true
|
isAvailableForPurchase:${isAvailableForPurchase}
|
||||||
|
visibleInListings:${visibleInListings}
|
||||||
}
|
}
|
||||||
}){
|
}){
|
||||||
product{
|
product{
|
||||||
|
@ -40,7 +49,7 @@ class Product {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`;
|
}`;
|
||||||
return cy.sendRequestWithQuery(mutation);
|
cy.sendRequestWithQuery(mutation);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateChannelPriceInVariant(variantId, channelId) {
|
updateChannelPriceInVariant(variantId, channelId) {
|
||||||
|
@ -88,19 +97,22 @@ class Product {
|
||||||
price = 1,
|
price = 1,
|
||||||
costPrice = 1
|
costPrice = 1
|
||||||
) {
|
) {
|
||||||
const channelListings = channelId
|
const channelListings = this.utils.getValueWithDefault(
|
||||||
? `channelListings:{
|
channelId,
|
||||||
|
`channelListings:{
|
||||||
channelId:"${channelId}"
|
channelId:"${channelId}"
|
||||||
price:"${price}"
|
price:"${price}"
|
||||||
costPrice:"${costPrice}"
|
costPrice:"${costPrice}"
|
||||||
}`
|
}`
|
||||||
: "";
|
);
|
||||||
const stocks = warehouseId
|
|
||||||
? `stocks:{
|
const stocks = this.utils.getValueWithDefault(
|
||||||
|
warehouseId,
|
||||||
|
`stocks:{
|
||||||
warehouse:"${warehouseId}"
|
warehouse:"${warehouseId}"
|
||||||
quantity:${quantity}
|
quantity:${quantity}
|
||||||
}`
|
}`
|
||||||
: "";
|
);
|
||||||
|
|
||||||
const mutation = `mutation{
|
const mutation = `mutation{
|
||||||
productVariantBulkCreate(product: "${productId}", variants: {
|
productVariantBulkCreate(product: "${productId}", variants: {
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
class Collections {
|
|
||||||
getCollection(collectionId, channelSlug) {
|
|
||||||
const operationName = "Collection";
|
|
||||||
const variables = {
|
|
||||||
attributes: {},
|
|
||||||
priceGte: null,
|
|
||||||
priceLte: null,
|
|
||||||
sortBy: null,
|
|
||||||
channel: channelSlug,
|
|
||||||
id: collectionId,
|
|
||||||
pageSize: 6
|
|
||||||
};
|
|
||||||
const query =
|
|
||||||
"query Collection($id: ID!, $channel: String!) {\n collection(id: $id, channel: $channel) {\n id\n slug\n name\n seoDescription\n seoTitle\n backgroundImage {\n url\n __typename\n }\n __typename\n }\n attributes(filter: {channel: $channel, inCollection: $id, 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";
|
|
||||||
return cy.sendFrontShopRequest(operationName, query, variables);
|
|
||||||
}
|
|
||||||
getCollections(search) {
|
|
||||||
const filter = search
|
|
||||||
? `, filter:{
|
|
||||||
search:""
|
|
||||||
}`
|
|
||||||
: "";
|
|
||||||
const query = `query{
|
|
||||||
collections(first:100 ${filter}){
|
|
||||||
edges{
|
|
||||||
node{
|
|
||||||
id
|
|
||||||
name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}`;
|
|
||||||
return cy
|
|
||||||
.sendRequestWithQuery(query)
|
|
||||||
.then(resp => resp.body.data.collections.edges);
|
|
||||||
}
|
|
||||||
deleteCollection(collectionId) {
|
|
||||||
const mutation = `mutation{
|
|
||||||
collectionDelete(id:"${collectionId}"){
|
|
||||||
collection{
|
|
||||||
id
|
|
||||||
}
|
|
||||||
collectionErrors{
|
|
||||||
field
|
|
||||||
message
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}`;
|
|
||||||
return cy.sendRequestWithQuery(mutation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export default Collections;
|
|
21
cypress/apiRequests/storeFront/Collections.js
Normal file
21
cypress/apiRequests/storeFront/Collections.js
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
class Collections {
|
||||||
|
getCollection(collectionId, channelSlug) {
|
||||||
|
const query = `query Collection{
|
||||||
|
collection(id: "${collectionId}", channel: "${channelSlug}") {
|
||||||
|
id
|
||||||
|
slug
|
||||||
|
name
|
||||||
|
products(first:100){
|
||||||
|
edges{
|
||||||
|
node{
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
return cy.sendFrontShopRequestWithQuery(query);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default Collections;
|
18
cypress/apiRequests/storeFront/ProductDetails.js
Normal file
18
cypress/apiRequests/storeFront/ProductDetails.js
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
class ProductDetails {
|
||||||
|
getProductDetails(productId, channelId) {
|
||||||
|
const query = `fragment BasicProductFields on Product {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
query ProductDetails{
|
||||||
|
product(id: "${productId}", channel: "${channelId}") {
|
||||||
|
...BasicProductFields
|
||||||
|
isAvailable
|
||||||
|
isAvailableForPurchase
|
||||||
|
availableForPurchase
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
return cy.sendFrontShopRequestWithQuery(query);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default ProductDetails;
|
20
cypress/apiRequests/storeFront/Search.js
Normal file
20
cypress/apiRequests/storeFront/Search.js
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
class Search {
|
||||||
|
searchInShop(searchQuery) {
|
||||||
|
const query = `query SearchProducts {
|
||||||
|
products(channel: "default-channel", filter:{
|
||||||
|
search: "${searchQuery}"
|
||||||
|
}, first:10){
|
||||||
|
totalCount
|
||||||
|
edges{
|
||||||
|
node{
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
|
||||||
|
return cy.sendFrontShopRequestWithQuery(query);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default Search;
|
6
cypress/apiRequests/utils/Utils.js
Normal file
6
cypress/apiRequests/utils/Utils.js
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
class Utils {
|
||||||
|
getValueWithDefault(condition, value, defaultValue = "") {
|
||||||
|
return condition ? value : defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default Utils;
|
|
@ -13,9 +13,20 @@ export const PRODUCTS_SELECTORS = {
|
||||||
saveBtn: "[data-test='button-bar-confirm']",
|
saveBtn: "[data-test='button-bar-confirm']",
|
||||||
confirmationMsg: "[data-test='notification-success']",
|
confirmationMsg: "[data-test='notification-success']",
|
||||||
channelAvailabilityItem: "[data-test='channel-availability-item']",
|
channelAvailabilityItem: "[data-test='channel-availability-item']",
|
||||||
|
searchProducts: "[placeholder='Search Products...']",
|
||||||
availableManageButton:
|
availableManageButton:
|
||||||
"[data-test-id='channels-availiability-manage-button']",
|
"[data-test-id='channels-availiability-manage-button']",
|
||||||
channelsAvailabilityForm:
|
channelsAvailabilityForm:
|
||||||
"[data-test-id='manage-products-channels-availiability-list']",
|
"[data-test-id='manage-products-channels-availiability-list']",
|
||||||
|
channelAvailabilityColumn:
|
||||||
|
"[data-test='availability'][data-test-availability='true']",
|
||||||
|
channelAvailabilityList: "ul[role='menu']",
|
||||||
|
goBackButton: "[data-test-id='app-header-back-button']",
|
||||||
|
assignedChannels: "[data-test='channel-availability-item']",
|
||||||
|
publishedRadioButtons: "[name*='isPublished']",
|
||||||
|
availableForPurchaseRadioButtons: "[name*='isAvailableForPurchase']",
|
||||||
|
radioButtonsValueTrue: "[value='true']",
|
||||||
|
radioButtonsValueFalse: "[value='false']",
|
||||||
|
visibleInListingsButton: "[name*='visibleInListings']",
|
||||||
emptyProductRow: "[class*='Skeleton']"
|
emptyProductRow: "[class*='Skeleton']"
|
||||||
};
|
};
|
||||||
|
|
|
@ -44,10 +44,10 @@ describe("Channels", () => {
|
||||||
|
|
||||||
it("should create new channel", () => {
|
it("should create new channel", () => {
|
||||||
const randomChannel = `${channelStartsWith} ${faker.random.number()}`;
|
const randomChannel = `${channelStartsWith} ${faker.random.number()}`;
|
||||||
cy.waitForGraph("Channels");
|
cy.addAliasToGraphRequest("Channels");
|
||||||
cy.visit(urlList.channels);
|
cy.visit(urlList.channels);
|
||||||
cy.wait("Channels");
|
cy.wait("@Channels");
|
||||||
cy.waitForGraph("Channel");
|
cy.addAliasToGraphRequest("Channel");
|
||||||
channelsSteps.createChannelByView(randomChannel, currency);
|
channelsSteps.createChannelByView(randomChannel, currency);
|
||||||
// New channel should be visible in channels list
|
// New channel should be visible in channels list
|
||||||
cy.wait("@Channel")
|
cy.wait("@Channel")
|
||||||
|
@ -65,7 +65,9 @@ describe("Channels", () => {
|
||||||
.click();
|
.click();
|
||||||
|
|
||||||
// new channel should be visible at product availability form
|
// new channel should be visible at product availability form
|
||||||
cy.visit(urlList.products).waitForGraph("InitialProductFilterData");
|
cy.addAliasToGraphRequest("InitialProductFilterData");
|
||||||
|
cy.visit(urlList.products);
|
||||||
|
cy.wait("@InitialProductFilterData");
|
||||||
cy.get(PRODUCTS_SELECTORS.productsList)
|
cy.get(PRODUCTS_SELECTORS.productsList)
|
||||||
.first()
|
.first()
|
||||||
.click()
|
.click()
|
||||||
|
@ -106,15 +108,18 @@ describe("Channels", () => {
|
||||||
randomChannelToDelete,
|
randomChannelToDelete,
|
||||||
currency
|
currency
|
||||||
);
|
);
|
||||||
cy.visit(urlList.channels).waitForGraph("Channels");
|
cy.addAliasToGraphRequest("Channels");
|
||||||
|
cy.visit(urlList.channels);
|
||||||
|
cy.wait("@Channels");
|
||||||
cy.get(CHANNELS_SELECTORS.channelName)
|
cy.get(CHANNELS_SELECTORS.channelName)
|
||||||
.contains(randomChannelToDelete)
|
.contains(randomChannelToDelete)
|
||||||
.parentsUntil(CHANNELS_SELECTORS.channelsTable)
|
.parentsUntil(CHANNELS_SELECTORS.channelsTable)
|
||||||
.find("button")
|
.find("button")
|
||||||
.click()
|
.click();
|
||||||
.get(BUTTON_SELECTORS.submit)
|
cy.addAliasToGraphRequest("Channels");
|
||||||
.click()
|
cy.get(BUTTON_SELECTORS.submit).click();
|
||||||
.waitForGraph("Channels");
|
cy.wait("@Channels");
|
||||||
|
|
||||||
cy.get(CHANNELS_SELECTORS.channelName)
|
cy.get(CHANNELS_SELECTORS.channelName)
|
||||||
.contains(randomChannelToDelete)
|
.contains(randomChannelToDelete)
|
||||||
.should("not.exist");
|
.should("not.exist");
|
||||||
|
|
|
@ -8,18 +8,26 @@ import ChannelsUtils from "../utils/channelsUtils";
|
||||||
import CollectionsUtils from "../utils/collectionsUtils";
|
import CollectionsUtils from "../utils/collectionsUtils";
|
||||||
import ProductsUtils from "../utils/productsUtils";
|
import ProductsUtils from "../utils/productsUtils";
|
||||||
import ShippingUtils from "../utils/shippingUtils";
|
import ShippingUtils from "../utils/shippingUtils";
|
||||||
|
import StoreFrontCollectionUtils from "../utils/storeFront/collectionsUtils";
|
||||||
|
import StoreFrontProductUtils from "../utils/storeFront/storeFrontProductUtils";
|
||||||
|
|
||||||
describe("Collections", () => {
|
describe("Collections", () => {
|
||||||
const productRequest = new Product();
|
const productRequest = new Product();
|
||||||
const channelsUtils = new ChannelsUtils();
|
const channelsUtils = new ChannelsUtils();
|
||||||
const productsUtils = new ProductsUtils();
|
const productsUtils = new ProductsUtils();
|
||||||
|
const storeFrontProductUtils = new StoreFrontProductUtils();
|
||||||
const collectionsUtils = new CollectionsUtils();
|
const collectionsUtils = new CollectionsUtils();
|
||||||
|
const storeFrontCollectionUtils = new StoreFrontCollectionUtils();
|
||||||
const shippingUtils = new ShippingUtils();
|
const shippingUtils = new ShippingUtils();
|
||||||
const collectionsSteps = new CollectionsSteps();
|
const collectionsSteps = new CollectionsSteps();
|
||||||
|
|
||||||
const startsWith = "Cy-";
|
const startsWith = "Cy-";
|
||||||
const name = `${startsWith}${faker.random.number()}`;
|
const name = `${startsWith}${faker.random.number()}`;
|
||||||
|
|
||||||
|
let attribute;
|
||||||
|
let productType;
|
||||||
|
let category;
|
||||||
|
|
||||||
let defaultChannel;
|
let defaultChannel;
|
||||||
|
|
||||||
before(() => {
|
before(() => {
|
||||||
|
@ -35,19 +43,16 @@ describe("Collections", () => {
|
||||||
productsUtils.createTypeAttributeAndCategoryForProduct(name);
|
productsUtils.createTypeAttributeAndCategoryForProduct(name);
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const attribute = productsUtils.getAttribute();
|
attribute = productsUtils.getAttribute();
|
||||||
const productType = productsUtils.getProductType();
|
productType = productsUtils.getProductType();
|
||||||
const category = productsUtils.getCategory();
|
category = productsUtils.getCategory();
|
||||||
productsUtils.createProductInChannel(
|
productsUtils.createProductInChannel({
|
||||||
name,
|
name,
|
||||||
defaultChannel.id,
|
channelId: defaultChannel.id,
|
||||||
null,
|
productTypeId: productType.id,
|
||||||
null,
|
attributeId: attribute.id,
|
||||||
productType.id,
|
categoryId: category.id
|
||||||
attribute.id,
|
});
|
||||||
category.id,
|
|
||||||
1
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -63,7 +68,7 @@ describe("Collections", () => {
|
||||||
.createCollection(collectionName, false, defaultChannel)
|
.createCollection(collectionName, false, defaultChannel)
|
||||||
.then(collection => {
|
.then(collection => {
|
||||||
collectionsSteps.assignProductsToCollection(name);
|
collectionsSteps.assignProductsToCollection(name);
|
||||||
collectionsUtils.isCollectionVisible(
|
storeFrontCollectionUtils.isCollectionVisible(
|
||||||
collection.id,
|
collection.id,
|
||||||
defaultChannel.slug
|
defaultChannel.slug
|
||||||
);
|
);
|
||||||
|
@ -79,55 +84,71 @@ describe("Collections", () => {
|
||||||
.createCollection(collectionName, true, defaultChannel)
|
.createCollection(collectionName, true, defaultChannel)
|
||||||
.then(collection => {
|
.then(collection => {
|
||||||
collectionsSteps.assignProductsToCollection(name);
|
collectionsSteps.assignProductsToCollection(name);
|
||||||
collectionsUtils.isCollectionVisible(
|
storeFrontCollectionUtils.isCollectionVisible(
|
||||||
collection.id,
|
collection.id,
|
||||||
defaultChannel.slug
|
defaultChannel.slug
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.then(isVisible => expect(isVisible).to.equal(true));
|
.then(isVisible => expect(isVisible).to.equal(true));
|
||||||
});
|
});
|
||||||
xit("should not display unavailable in channel collections", () => {
|
it("should not display unavailable in channel collections", () => {
|
||||||
channelsUtils.createChannel(true, name, name, "PLN").then(() => {
|
const collectionName = `${startsWith}${faker.random.number()}`;
|
||||||
|
channelsUtils
|
||||||
|
.createChannel({ name: collectionName })
|
||||||
|
.then(() => {
|
||||||
productRequest.updateChannelInProduct(
|
productRequest.updateChannelInProduct(
|
||||||
productsUtils.getCreatedProduct().id,
|
productsUtils.getCreatedProduct().id,
|
||||||
channelsUtils.getCreatedChannel().id
|
channelsUtils.getCreatedChannel().id
|
||||||
);
|
);
|
||||||
});
|
})
|
||||||
|
.then(() => {
|
||||||
cy.visit(urlList.collections);
|
cy.visit(urlList.collections);
|
||||||
collectionsSteps
|
collectionsSteps.createCollection(
|
||||||
.createCollection(collectionName, true, channelsUtils.getCreatedChannel())
|
collectionName,
|
||||||
|
true,
|
||||||
|
channelsUtils.getCreatedChannel()
|
||||||
|
);
|
||||||
|
})
|
||||||
.then(collection => {
|
.then(collection => {
|
||||||
collectionsSteps.assignProductsToCollection(name);
|
collectionsSteps.assignProductsToCollection(name);
|
||||||
collectionsUtils.isCollectionVisible(
|
storeFrontCollectionUtils.isCollectionVisible(
|
||||||
collection.id,
|
collection.id,
|
||||||
defaultChannel.slug
|
defaultChannel.slug
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.then(isVisible => expect(isVisible).to.equal(true));
|
.then(isVisible => expect(isVisible).to.equal(false));
|
||||||
});
|
});
|
||||||
xit("should display products hidden in listing, only in collection", () => {
|
it("should display products hidden in listing, only in collection", () => {
|
||||||
productsUtils.createProductInChannel(
|
const randomName = `${startsWith}${faker.random.number()}`;
|
||||||
name,
|
const hiddenProductUtils = new ProductsUtils();
|
||||||
defaultChannel.id,
|
hiddenProductUtils.createProductInChannel({
|
||||||
null,
|
name: randomName,
|
||||||
null,
|
channelId: defaultChannel.id,
|
||||||
productsUtils.getProductType().id,
|
productTypeId: productType.id,
|
||||||
productsUtils.getAttribute().id,
|
attributeId: attribute.id,
|
||||||
productsUtils.getCategory().id,
|
categoryId: category.id,
|
||||||
1
|
visibleInListings: false
|
||||||
);
|
});
|
||||||
|
cy.visit(urlList.collections);
|
||||||
collectionsSteps
|
collectionsSteps
|
||||||
.createCollection(collectionName, true, defaultChannel)
|
.createCollection(randomName, true, defaultChannel)
|
||||||
.then(collection => {
|
.then(collection => {
|
||||||
collectionsSteps.assignProductsToCollection(name);
|
collectionsSteps.assignProductsToCollection(randomName);
|
||||||
collectionsUtils.isProductInCollectionVisible(
|
storeFrontCollectionUtils.isProductInCollectionVisible(
|
||||||
collection.id,
|
collection.id,
|
||||||
defaultChannel.slug
|
defaultChannel.slug,
|
||||||
|
hiddenProductUtils.getCreatedProduct().id
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.then(isVisible => {
|
.then(isVisible => {
|
||||||
expect(isVisible).to.equal(true);
|
expect(isVisible).to.equal(true);
|
||||||
// productsUtils.searchForProduct
|
storeFrontProductUtils.isProductVisibleInSearchResult(
|
||||||
|
hiddenProductUtils.getCreatedProduct().name,
|
||||||
|
defaultChannel.slug
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.then(isVisible => {
|
||||||
|
expect(isVisible).to.equal(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,7 +11,7 @@ import ProductsUtils from "../utils/productsUtils";
|
||||||
import ShippingUtils from "../utils/shippingUtils";
|
import ShippingUtils from "../utils/shippingUtils";
|
||||||
|
|
||||||
// <reference types="cypress" />
|
// <reference types="cypress" />
|
||||||
describe("User authorization", () => {
|
describe("Homepage analytics", () => {
|
||||||
const startsWith = "Cy-";
|
const startsWith = "Cy-";
|
||||||
|
|
||||||
const customer = new Customer();
|
const customer = new Customer();
|
||||||
|
@ -48,12 +48,12 @@ describe("User authorization", () => {
|
||||||
)
|
)
|
||||||
.then(resp => {
|
.then(resp => {
|
||||||
customerId = resp.body.data.customerCreate.user.id;
|
customerId = resp.body.data.customerCreate.user.id;
|
||||||
shippingUtils.createShipping(
|
shippingUtils.createShipping({
|
||||||
defaultChannel.id,
|
channelId: defaultChannel.id,
|
||||||
randomName,
|
name: randomName,
|
||||||
addresses.plAddress,
|
address: addresses.plAddress,
|
||||||
shippingPrice
|
price: shippingPrice
|
||||||
);
|
});
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
productsUtils.createTypeAttributeAndCategoryForProduct(randomName);
|
productsUtils.createTypeAttributeAndCategoryForProduct(randomName);
|
||||||
|
@ -63,16 +63,16 @@ describe("User authorization", () => {
|
||||||
const productType = productsUtils.getProductType();
|
const productType = productsUtils.getProductType();
|
||||||
const attribute = productsUtils.getAttribute();
|
const attribute = productsUtils.getAttribute();
|
||||||
const category = productsUtils.getCategory();
|
const category = productsUtils.getCategory();
|
||||||
productsUtils.createProductInChannel(
|
productsUtils.createProductInChannel({
|
||||||
randomName,
|
name: randomName,
|
||||||
defaultChannel.id,
|
channelId: defaultChannel.id,
|
||||||
warehouse.id,
|
warehouseId: warehouse.id,
|
||||||
20,
|
quantityInWarehouse: 20,
|
||||||
productType.id,
|
productTypeId: productType.id,
|
||||||
attribute.id,
|
attributeId: attribute.id,
|
||||||
category.id,
|
categoryId: category.id,
|
||||||
productPrice
|
price: productPrice
|
||||||
);
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -154,16 +154,16 @@ describe("User authorization", () => {
|
||||||
const attribute = productsUtils.getAttribute();
|
const attribute = productsUtils.getAttribute();
|
||||||
const category = productsUtils.getCategory();
|
const category = productsUtils.getCategory();
|
||||||
|
|
||||||
productsOutOfStockUtils.createProductInChannel(
|
productsOutOfStockUtils.createProductInChannel({
|
||||||
productOutOfStockRandomName,
|
name: productOutOfStockRandomName,
|
||||||
defaultChannel.id,
|
channelId: defaultChannel.id,
|
||||||
warehouse.id,
|
warehouseId: warehouse.id,
|
||||||
0,
|
quantityInWarehouse: 0,
|
||||||
productType.id,
|
productTypeId: productType.id,
|
||||||
attribute.id,
|
attributeId: attribute.id,
|
||||||
category.id,
|
categoryId: category.id,
|
||||||
productPrice
|
price: productPrice
|
||||||
);
|
});
|
||||||
|
|
||||||
cy.get("@productsOutOfStock").then(productsOutOfStockBefore => {
|
cy.get("@productsOutOfStock").then(productsOutOfStockBefore => {
|
||||||
const allProductsOutOfStock = productsOutOfStockBefore + 1;
|
const allProductsOutOfStock = productsOutOfStockBefore + 1;
|
||||||
|
|
|
@ -0,0 +1,115 @@
|
||||||
|
import faker from "faker";
|
||||||
|
|
||||||
|
import ProductSteps from "../../../steps/productSteps";
|
||||||
|
import { productDetailsUrl } from "../../../url/urlList";
|
||||||
|
import ChannelsUtils from "../../../utils/channelsUtils";
|
||||||
|
import ProductsUtils from "../../../utils/productsUtils";
|
||||||
|
import ShippingUtils from "../../../utils/shippingUtils";
|
||||||
|
import StoreFrontProductUtils from "../../../utils/storeFront/storeFrontProductUtils";
|
||||||
|
|
||||||
|
// <reference types="cypress" />
|
||||||
|
describe("Products available in listings", () => {
|
||||||
|
const shippingUtils = new ShippingUtils();
|
||||||
|
const channelsUtils = new ChannelsUtils();
|
||||||
|
const productsUtils = new ProductsUtils();
|
||||||
|
const productSteps = new ProductSteps();
|
||||||
|
const frontShopProductUtils = new StoreFrontProductUtils();
|
||||||
|
const startsWith = "Cy-";
|
||||||
|
const name = `${startsWith}${faker.random.number()}`;
|
||||||
|
let productType;
|
||||||
|
let attribute;
|
||||||
|
let category;
|
||||||
|
let defaultChannel;
|
||||||
|
let warehouse;
|
||||||
|
|
||||||
|
before(() => {
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
shippingUtils.deleteShipping(startsWith);
|
||||||
|
productsUtils.deleteProperProducts(startsWith);
|
||||||
|
|
||||||
|
channelsUtils
|
||||||
|
.getDefaultChannel()
|
||||||
|
.then(channel => {
|
||||||
|
defaultChannel = channel;
|
||||||
|
cy.fixture("addresses");
|
||||||
|
})
|
||||||
|
.then(addressesFixture => {
|
||||||
|
shippingUtils.createShipping({
|
||||||
|
channelId: defaultChannel.id,
|
||||||
|
name,
|
||||||
|
address: addressesFixture.plAddress
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
warehouse = shippingUtils.getWarehouse();
|
||||||
|
});
|
||||||
|
|
||||||
|
productsUtils.createTypeAttributeAndCategoryForProduct(name).then(() => {
|
||||||
|
productType = productsUtils.getProductType();
|
||||||
|
attribute = productsUtils.getAttribute();
|
||||||
|
category = productsUtils.getCategory();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should update product to available for purchase", () => {
|
||||||
|
const productName = `${startsWith}${faker.random.number()}`;
|
||||||
|
productsUtils
|
||||||
|
.createProductInChannel({
|
||||||
|
name: productName,
|
||||||
|
channelId: defaultChannel.id,
|
||||||
|
warehouseId: warehouse.id,
|
||||||
|
productTypeId: productType.id,
|
||||||
|
attributeId: attribute.id,
|
||||||
|
categoryId: category.id,
|
||||||
|
isAvailableForPurchase: false
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
const productUrl = productDetailsUrl(
|
||||||
|
productsUtils.getCreatedProduct().id
|
||||||
|
);
|
||||||
|
productSteps.updateProductIsAvailableForPurchase(productUrl, true);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
frontShopProductUtils.isProductAvailableForPurchase(
|
||||||
|
productsUtils.getCreatedProduct().id,
|
||||||
|
defaultChannel.slug,
|
||||||
|
productName
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.then(isProductVisible => {
|
||||||
|
expect(isProductVisible).to.be.eq(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it("should update product to not available for purchase", () => {
|
||||||
|
const productName = `${startsWith}${faker.random.number()}`;
|
||||||
|
productsUtils
|
||||||
|
.createProductInChannel({
|
||||||
|
name: productName,
|
||||||
|
channelId: defaultChannel.id,
|
||||||
|
warehouseId: warehouse.id,
|
||||||
|
productTypeId: productType.id,
|
||||||
|
attributeId: attribute.id,
|
||||||
|
categoryId: category.id
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
const productUrl = productDetailsUrl(
|
||||||
|
productsUtils.getCreatedProduct().id
|
||||||
|
);
|
||||||
|
productSteps.updateProductIsAvailableForPurchase(productUrl, false);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
frontShopProductUtils.isProductAvailableForPurchase(
|
||||||
|
productsUtils.getCreatedProduct().id,
|
||||||
|
defaultChannel.slug,
|
||||||
|
productName
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.then(isProductVisible => {
|
||||||
|
expect(isProductVisible).to.be.eq(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
108
cypress/integration/products/menageProducts/publishedProducts.js
Normal file
108
cypress/integration/products/menageProducts/publishedProducts.js
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
import faker from "faker";
|
||||||
|
|
||||||
|
import ProductSteps from "../../../steps/productSteps";
|
||||||
|
import { productDetailsUrl } from "../../../url/urlList";
|
||||||
|
import ChannelsUtils from "../../../utils/channelsUtils";
|
||||||
|
import ProductsUtils from "../../../utils/productsUtils";
|
||||||
|
import StoreFrontProductUtils from "../../../utils/storeFront/storeFrontProductUtils";
|
||||||
|
|
||||||
|
// <reference types="cypress" />
|
||||||
|
describe("Published products", () => {
|
||||||
|
const channelsUtils = new ChannelsUtils();
|
||||||
|
const productsUtils = new ProductsUtils();
|
||||||
|
const productSteps = new ProductSteps();
|
||||||
|
const frontShopProductUtils = new StoreFrontProductUtils();
|
||||||
|
|
||||||
|
const startsWith = "Cy-";
|
||||||
|
const name = `${startsWith}${faker.random.number()}`;
|
||||||
|
let productType;
|
||||||
|
let attribute;
|
||||||
|
let category;
|
||||||
|
|
||||||
|
before(() => {
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
productsUtils.deleteProperProducts(startsWith);
|
||||||
|
productsUtils.createTypeAttributeAndCategoryForProduct(name).then(() => {
|
||||||
|
productType = productsUtils.getProductType();
|
||||||
|
attribute = productsUtils.getAttribute();
|
||||||
|
category = productsUtils.getCategory();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
});
|
||||||
|
it("should update product to published", () => {
|
||||||
|
const productName = `${startsWith}${faker.random.number()}`;
|
||||||
|
let defaultChannel;
|
||||||
|
channelsUtils
|
||||||
|
.getDefaultChannel()
|
||||||
|
.then(channel => {
|
||||||
|
defaultChannel = channel;
|
||||||
|
productsUtils.createProductInChannel({
|
||||||
|
name: productName,
|
||||||
|
channelId: defaultChannel.id,
|
||||||
|
productTypeId: productType.id,
|
||||||
|
attributeId: attribute.id,
|
||||||
|
categoryId: category.id,
|
||||||
|
isPublished: false,
|
||||||
|
isAvailableForPurchase: false
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
const product = productsUtils.getCreatedProduct();
|
||||||
|
const productUrl = productDetailsUrl(product.id);
|
||||||
|
productSteps.updateProductPublish(productUrl, true);
|
||||||
|
frontShopProductUtils.isProductVisible(
|
||||||
|
product.id,
|
||||||
|
defaultChannel.slug,
|
||||||
|
productName
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.then(isVisible => {
|
||||||
|
expect(isVisible).to.be.eq(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it("should update product to not published", () => {
|
||||||
|
const productName = `${startsWith}${faker.random.number()}`;
|
||||||
|
let defaultChannel;
|
||||||
|
let product;
|
||||||
|
|
||||||
|
channelsUtils
|
||||||
|
.getDefaultChannel()
|
||||||
|
.then(channel => {
|
||||||
|
defaultChannel = channel;
|
||||||
|
productsUtils.createProductInChannel({
|
||||||
|
name: productName,
|
||||||
|
channelId: defaultChannel.id,
|
||||||
|
productTypeId: productType.id,
|
||||||
|
attributeId: attribute.id,
|
||||||
|
categoryId: category.id
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
product = productsUtils.getCreatedProduct();
|
||||||
|
const productUrl = productDetailsUrl(product.id);
|
||||||
|
productSteps.updateProductPublish(productUrl, false);
|
||||||
|
frontShopProductUtils.isProductVisible(
|
||||||
|
product.id,
|
||||||
|
defaultChannel.slug,
|
||||||
|
productName
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.then(isVisible => {
|
||||||
|
expect(isVisible).to.be.eq(false);
|
||||||
|
cy.loginInShop();
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
frontShopProductUtils.isProductVisible(
|
||||||
|
product.id,
|
||||||
|
defaultChannel.slug,
|
||||||
|
productName
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.then(isVisible => {
|
||||||
|
expect(isVisible).to.be.eq(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,102 @@
|
||||||
|
import faker from "faker";
|
||||||
|
|
||||||
|
import ProductSteps from "../../../steps/productSteps";
|
||||||
|
import { productDetailsUrl } from "../../../url/urlList";
|
||||||
|
import ChannelsUtils from "../../../utils/channelsUtils";
|
||||||
|
import ProductsUtils from "../../../utils/productsUtils";
|
||||||
|
import StoreFrontProductUtils from "../../../utils/storeFront/storeFrontProductUtils";
|
||||||
|
|
||||||
|
// <reference types="cypress" />
|
||||||
|
describe("Products displayed in listings", () => {
|
||||||
|
const channelsUtils = new ChannelsUtils();
|
||||||
|
const productsUtils = new ProductsUtils();
|
||||||
|
const productSteps = new ProductSteps();
|
||||||
|
const frontShopProductUtils = new StoreFrontProductUtils();
|
||||||
|
|
||||||
|
const startsWith = "Cy-";
|
||||||
|
const name = `${startsWith}${faker.random.number()}`;
|
||||||
|
let productType;
|
||||||
|
let attribute;
|
||||||
|
let category;
|
||||||
|
|
||||||
|
before(() => {
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
productsUtils.deleteProperProducts(startsWith);
|
||||||
|
productsUtils.createTypeAttributeAndCategoryForProduct(name).then(() => {
|
||||||
|
productType = productsUtils.getProductType();
|
||||||
|
attribute = productsUtils.getAttribute();
|
||||||
|
category = productsUtils.getCategory();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
});
|
||||||
|
it("should update product to visible in listings", () => {
|
||||||
|
const productName = `${startsWith}${faker.random.number()}`;
|
||||||
|
let defaultChannel;
|
||||||
|
channelsUtils
|
||||||
|
.getDefaultChannel()
|
||||||
|
.then(channel => {
|
||||||
|
defaultChannel = channel;
|
||||||
|
productsUtils.createProductInChannel({
|
||||||
|
name: productName,
|
||||||
|
channelId: defaultChannel.id,
|
||||||
|
productTypeId: productType.id,
|
||||||
|
attributeId: attribute.id,
|
||||||
|
categoryId: category.id,
|
||||||
|
visibleInListings: false,
|
||||||
|
isAvailableForPurchase: false
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
const product = productsUtils.getCreatedProduct();
|
||||||
|
const productUrl = productDetailsUrl(product.id);
|
||||||
|
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()}`;
|
||||||
|
let defaultChannel;
|
||||||
|
channelsUtils
|
||||||
|
.getDefaultChannel()
|
||||||
|
.then(channel => {
|
||||||
|
defaultChannel = channel;
|
||||||
|
productsUtils.createProductInChannel({
|
||||||
|
name: productName,
|
||||||
|
channelId: defaultChannel.id,
|
||||||
|
productTypeId: productType.id,
|
||||||
|
attributeId: attribute.id,
|
||||||
|
categoryId: category.id,
|
||||||
|
visibleInListings: true
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
const product = productsUtils.getCreatedProduct();
|
||||||
|
const productUrl = productDetailsUrl(product.id);
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -1,7 +1,7 @@
|
||||||
// <reference types="cypress" />
|
// <reference types="cypress" />
|
||||||
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 { urlList } from "../url/urlList";
|
import { urlList } from "../../url/urlList";
|
||||||
|
|
||||||
describe("Products", () => {
|
describe("Products", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
|
@ -2,13 +2,11 @@ import { COLLECTION_SELECTORS } from "../elements/catalog/collection-selectors";
|
||||||
import { ASSIGN_PRODUCTS_SELECTORS } from "../elements/catalog/products/assign-products-selectors";
|
import { ASSIGN_PRODUCTS_SELECTORS } from "../elements/catalog/products/assign-products-selectors";
|
||||||
import { MENAGE_CHANNEL_AVAILABILITY_FORM } from "../elements/channels/menage-channel-availability-form";
|
import { MENAGE_CHANNEL_AVAILABILITY_FORM } from "../elements/channels/menage-channel-availability-form";
|
||||||
import { BUTTON_SELECTORS } from "../elements/shared/button-selectors";
|
import { BUTTON_SELECTORS } from "../elements/shared/button-selectors";
|
||||||
import CollectionsUtils from "../utils/collectionsUtils";
|
|
||||||
class CollectionsSteps {
|
class CollectionsSteps {
|
||||||
createCollection(collectionName, isPublished, channel) {
|
createCollection(collectionName, isPublished, channel) {
|
||||||
const publishedSelector = isPublished
|
const publishedSelector = isPublished
|
||||||
? MENAGE_CHANNEL_AVAILABILITY_FORM.radioButtonsValueTrue
|
? MENAGE_CHANNEL_AVAILABILITY_FORM.radioButtonsValueTrue
|
||||||
: MENAGE_CHANNEL_AVAILABILITY_FORM.radioButtonsValueFalse;
|
: MENAGE_CHANNEL_AVAILABILITY_FORM.radioButtonsValueFalse;
|
||||||
const collectionsUtils = new CollectionsUtils();
|
|
||||||
|
|
||||||
cy.get(COLLECTION_SELECTORS.createCollectionButton)
|
cy.get(COLLECTION_SELECTORS.createCollectionButton)
|
||||||
.click()
|
.click()
|
||||||
|
@ -28,11 +26,12 @@ class CollectionsSteps {
|
||||||
.get(
|
.get(
|
||||||
`${MENAGE_CHANNEL_AVAILABILITY_FORM.publishedCheckbox}${publishedSelector}`
|
`${MENAGE_CHANNEL_AVAILABILITY_FORM.publishedCheckbox}${publishedSelector}`
|
||||||
)
|
)
|
||||||
.click()
|
|
||||||
.waitForGraph("CreateCollection")
|
|
||||||
.get(COLLECTION_SELECTORS.saveButton)
|
|
||||||
.click();
|
.click();
|
||||||
return collectionsUtils.waitForCreateCollectionRequest();
|
cy.addAliasToGraphRequest("CreateCollection");
|
||||||
|
cy.get(COLLECTION_SELECTORS.saveButton).click();
|
||||||
|
return cy
|
||||||
|
.wait("@CreateCollection")
|
||||||
|
.its("response.body.data.collectionCreate.collection");
|
||||||
}
|
}
|
||||||
assignProductsToCollection(productName) {
|
assignProductsToCollection(productName) {
|
||||||
cy.get(COLLECTION_SELECTORS.addProductButton)
|
cy.get(COLLECTION_SELECTORS.addProductButton)
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import { HEADER_SELECTORS } from "../elements/header/header-selectors";
|
import { HEADER_SELECTORS } from "../elements/header/header-selectors";
|
||||||
class HomePageSteps {
|
class HomePageSteps {
|
||||||
changeChannel(channelName) {
|
changeChannel(channelName) {
|
||||||
cy.get(HEADER_SELECTORS.channelSelect)
|
cy.get(HEADER_SELECTORS.channelSelect).click();
|
||||||
.click()
|
cy.addAliasToGraphRequest("Home");
|
||||||
.get(HEADER_SELECTORS.channelSelectList)
|
cy.get(HEADER_SELECTORS.channelSelectList)
|
||||||
.contains(channelName)
|
.contains(channelName)
|
||||||
.click()
|
.click();
|
||||||
.waitForGraph("Home");
|
cy.wait("@Home");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export default HomePageSteps;
|
export default HomePageSteps;
|
||||||
|
|
37
cypress/steps/productSteps.js
Normal file
37
cypress/steps/productSteps.js
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
import { PRODUCTS_SELECTORS } from "../elements/catalog/product-selectors";
|
||||||
|
|
||||||
|
class ProductSteps {
|
||||||
|
valueTrue = PRODUCTS_SELECTORS.radioButtonsValueTrue;
|
||||||
|
valueFalse = PRODUCTS_SELECTORS.radioButtonsValueFalse;
|
||||||
|
|
||||||
|
updateProductIsAvailableForPurchase(productUrl, isAvailableForPurchase) {
|
||||||
|
const isAvailableForPurchaseSelector = isAvailableForPurchase
|
||||||
|
? this.valueTrue
|
||||||
|
: this.valueFalse;
|
||||||
|
const availableForPurchaseSelector = `${PRODUCTS_SELECTORS.availableForPurchaseRadioButtons}${isAvailableForPurchaseSelector}`;
|
||||||
|
this.updateProductMenageInChannel(productUrl, availableForPurchaseSelector);
|
||||||
|
}
|
||||||
|
updateProductPublish(productUrl, isPublished) {
|
||||||
|
const isPublishedSelector = isPublished ? this.valueTrue : this.valueFalse;
|
||||||
|
const publishedSelector = `${PRODUCTS_SELECTORS.publishedRadioButtons}${isPublishedSelector}`;
|
||||||
|
this.updateProductMenageInChannel(productUrl, publishedSelector);
|
||||||
|
}
|
||||||
|
updateProductVisibleInListings(productUrl) {
|
||||||
|
this.updateProductMenageInChannel(
|
||||||
|
productUrl,
|
||||||
|
PRODUCTS_SELECTORS.visibleInListingsButton
|
||||||
|
);
|
||||||
|
}
|
||||||
|
updateProductMenageInChannel(productUrl, menageSelector) {
|
||||||
|
cy.visit(productUrl)
|
||||||
|
.get(PRODUCTS_SELECTORS.assignedChannels)
|
||||||
|
.click()
|
||||||
|
.get(menageSelector)
|
||||||
|
.click();
|
||||||
|
cy.addAliasToGraphRequest("ProductChannelListingUpdate");
|
||||||
|
cy.get(PRODUCTS_SELECTORS.saveBtn)
|
||||||
|
.click()
|
||||||
|
.wait("@ProductChannelListingUpdate");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default ProductSteps;
|
|
@ -21,7 +21,7 @@ Cypress.Commands.add("clearSessionData", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Cypress.Commands.add("waitForGraph", operationName => {
|
Cypress.Commands.add("addAliasToGraphRequest", operationName => {
|
||||||
cy.intercept("POST", urlList.apiUri, req => {
|
cy.intercept("POST", urlList.apiUri, req => {
|
||||||
req.statusCode = 200;
|
req.statusCode = 200;
|
||||||
const requestBody = req.body;
|
const requestBody = req.body;
|
||||||
|
@ -39,7 +39,10 @@ Cypress.Commands.add("waitForGraph", operationName => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Cypress.Commands.add("sendRequestWithQuery", query =>
|
Cypress.Commands.add("sendFrontShopRequestWithQuery", query =>
|
||||||
|
cy.sendRequestWithQuery(query, "token")
|
||||||
|
);
|
||||||
|
Cypress.Commands.add("sendRequestWithQuery", (query, authorization = "auth") =>
|
||||||
cy.request({
|
cy.request({
|
||||||
body: {
|
body: {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
@ -47,27 +50,9 @@ Cypress.Commands.add("sendRequestWithQuery", query =>
|
||||||
url: urlList.apiUri
|
url: urlList.apiUri
|
||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `JWT ${window.sessionStorage.getItem("auth")}`
|
Authorization: `JWT ${window.sessionStorage.getItem(authorization)}`
|
||||||
},
|
},
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: urlList.apiUri
|
url: urlList.apiUri
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
Cypress.Commands.add(
|
|
||||||
"sendFrontShopRequest",
|
|
||||||
(operationName, query, variables) =>
|
|
||||||
cy.request({
|
|
||||||
method: "POST",
|
|
||||||
url: urlList.apiUri,
|
|
||||||
headers: {
|
|
||||||
authorization: `JWT ${window.localStorage.getItem("token")}`
|
|
||||||
},
|
|
||||||
body: [
|
|
||||||
{
|
|
||||||
operationName,
|
|
||||||
variables,
|
|
||||||
query
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { LOGIN_SELECTORS } from "../../elements/account/login-selectors";
|
import { LOGIN_SELECTORS } from "../../elements/account/login-selectors";
|
||||||
import { urlList } from "../../url/urlList";
|
|
||||||
|
|
||||||
Cypress.Commands.add("loginUser", () =>
|
Cypress.Commands.add("loginUser", () =>
|
||||||
cy
|
cy
|
||||||
|
@ -11,39 +10,31 @@ Cypress.Commands.add("loginUser", () =>
|
||||||
.click()
|
.click()
|
||||||
);
|
);
|
||||||
|
|
||||||
Cypress.Commands.add("loginUserViaRequest", () => {
|
Cypress.Commands.add("loginInShop", () => {
|
||||||
const logInMutationQuery = `mutation TokenAuth($email: String!, $password: String!) {
|
cy.loginUserViaRequest("token");
|
||||||
tokenCreate(email: $email, password: $password) {
|
});
|
||||||
|
|
||||||
|
Cypress.Commands.add("loginUserViaRequest", (authorization = "auth") => {
|
||||||
|
const mutation = `mutation TokenAuth{
|
||||||
|
tokenCreate(email: "${Cypress.env("USER_NAME")}", password: "${Cypress.env(
|
||||||
|
"USER_PASSWORD"
|
||||||
|
)}") {
|
||||||
token
|
token
|
||||||
errors: accountErrors {
|
errors: accountErrors {
|
||||||
code
|
code
|
||||||
field
|
field
|
||||||
message
|
message
|
||||||
__typename
|
|
||||||
}
|
}
|
||||||
user {
|
user {
|
||||||
id
|
id
|
||||||
__typename
|
|
||||||
}
|
}
|
||||||
__typename
|
|
||||||
}
|
}
|
||||||
}`;
|
}`;
|
||||||
|
return cy.sendRequestWithQuery(mutation, authorization).then(resp => {
|
||||||
return cy
|
window.sessionStorage.setItem(
|
||||||
.request({
|
authorization,
|
||||||
body: {
|
resp.body.data.tokenCreate.token
|
||||||
operationName: "TokenAuth",
|
);
|
||||||
query: logInMutationQuery,
|
|
||||||
variables: {
|
|
||||||
email: Cypress.env("USER_NAME"),
|
|
||||||
password: Cypress.env("USER_PASSWORD")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
method: "POST",
|
|
||||||
url: urlList.apiUri
|
|
||||||
})
|
|
||||||
.then(resp => {
|
|
||||||
window.sessionStorage.setItem("auth", resp.body.data.tokenCreate.token);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
Cypress.Commands.add("loginInShop", () => {
|
Cypress.Commands.add("loginInShop", () => {
|
||||||
|
|
|
@ -8,3 +8,4 @@ export const urlList = {
|
||||||
warehouses: "warehouses/",
|
warehouses: "warehouses/",
|
||||||
collections: "collections/"
|
collections: "collections/"
|
||||||
};
|
};
|
||||||
|
export const productDetailsUrl = productId => `${urlList.products}${productId}`;
|
||||||
|
|
|
@ -38,7 +38,7 @@ class ChannelsUtils {
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
createChannel(isActive, name, slug, currencyCode) {
|
createChannel({ isActive = true, name, slug = name, currencyCode = "PLN" }) {
|
||||||
return this.channels
|
return this.channels
|
||||||
.createChannel(isActive, name, slug, currencyCode)
|
.createChannel(isActive, name, slug, currencyCode)
|
||||||
.then(
|
.then(
|
||||||
|
@ -46,7 +46,7 @@ class ChannelsUtils {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
getCreatedChannel() {
|
getCreatedChannel() {
|
||||||
return channel;
|
return this.createdChannel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export default ChannelsUtils;
|
export default ChannelsUtils;
|
||||||
|
|
|
@ -1,21 +1,8 @@
|
||||||
import Collections from "../apiRequests/frontShop/Collections";
|
import Collections from "../apiRequests/Collections";
|
||||||
|
|
||||||
class CollectionsUtils {
|
class CollectionsUtils {
|
||||||
collectionsRequest = new Collections();
|
collectionsRequest = new Collections();
|
||||||
|
|
||||||
isCollectionVisible(collectionId, channelSlug) {
|
|
||||||
return this.collectionsRequest
|
|
||||||
.getCollection(collectionId, channelSlug)
|
|
||||||
.then(resp => {
|
|
||||||
const collection = resp.body[0].data.collection;
|
|
||||||
return collection !== null && collection.id === collectionId;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
waitForCreateCollectionRequest() {
|
|
||||||
return cy
|
|
||||||
.wait(`@CreateCollection`)
|
|
||||||
.its("response.body.data.collectionCreate.collection");
|
|
||||||
}
|
|
||||||
deleteProperCollections(startsWith) {
|
deleteProperCollections(startsWith) {
|
||||||
cy.deleteProperElements(
|
cy.deleteProperElements(
|
||||||
this.collectionsRequest.deleteCollection,
|
this.collectionsRequest.deleteCollection,
|
||||||
|
|
|
@ -13,19 +13,37 @@ class ProductsUtils {
|
||||||
attribute;
|
attribute;
|
||||||
category;
|
category;
|
||||||
|
|
||||||
createProductInChannel(
|
createProductWithVariant(name, attributeId, productTypeId, categoryId) {
|
||||||
|
return this.createProduct(
|
||||||
|
attributeId,
|
||||||
|
name,
|
||||||
|
productTypeId,
|
||||||
|
categoryId
|
||||||
|
).then(() => this.createVariant(this.product.id, name));
|
||||||
|
}
|
||||||
|
|
||||||
|
createProductInChannel({
|
||||||
name,
|
name,
|
||||||
channelId,
|
channelId,
|
||||||
warehouseId,
|
warehouseId = null,
|
||||||
quantityInWarehouse,
|
quantityInWarehouse = 10,
|
||||||
productTypeId,
|
productTypeId,
|
||||||
attributeId,
|
attributeId,
|
||||||
categoryId,
|
categoryId,
|
||||||
price
|
price = 1,
|
||||||
) {
|
isPublished = true,
|
||||||
|
isAvailableForPurchase = true,
|
||||||
|
visibleInListings = true
|
||||||
|
}) {
|
||||||
return this.createProduct(attributeId, name, productTypeId, categoryId)
|
return this.createProduct(attributeId, name, productTypeId, categoryId)
|
||||||
.then(() =>
|
.then(() =>
|
||||||
this.productRequest.updateChannelInProduct(this.product.id, channelId)
|
this.productRequest.updateChannelInProduct({
|
||||||
|
productId: this.product.id,
|
||||||
|
channelId,
|
||||||
|
isPublished,
|
||||||
|
isAvailableForPurchase,
|
||||||
|
visibleInListings
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.createVariant(
|
this.createVariant(
|
||||||
|
@ -92,7 +110,9 @@ class ProductsUtils {
|
||||||
resp.body.data.productVariantBulkCreate.productVariants)
|
resp.body.data.productVariantBulkCreate.productVariants)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
getCreatedProduct() {
|
||||||
|
return this.product;
|
||||||
|
}
|
||||||
getCreatedVariants() {
|
getCreatedVariants() {
|
||||||
return this.variants;
|
return this.variants;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ class ShippingUtils {
|
||||||
shippingZone;
|
shippingZone;
|
||||||
warehouse;
|
warehouse;
|
||||||
|
|
||||||
createShipping(channelId, name, address, price) {
|
createShipping({ channelId, name, address, price = 1 }) {
|
||||||
return this.createShippingZone(name, address.country)
|
return this.createShippingZone(name, address.country)
|
||||||
.then(() => this.createWarehouse(name, this.shippingZone.id, address))
|
.then(() => this.createWarehouse(name, this.shippingZone.id, address))
|
||||||
.then(() => this.createShippingRate(name, this.shippingZone.id))
|
.then(() => this.createShippingRate(name, this.shippingZone.id))
|
||||||
|
|
23
cypress/utils/storeFront/collectionsUtils.js
Normal file
23
cypress/utils/storeFront/collectionsUtils.js
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import Collections from "../../apiRequests/storeFront/Collections";
|
||||||
|
|
||||||
|
class CollectionsUtils {
|
||||||
|
collectionsRequest = new Collections();
|
||||||
|
|
||||||
|
isCollectionVisible(collectionId, channelSlug) {
|
||||||
|
return this.collectionsRequest
|
||||||
|
.getCollection(collectionId, channelSlug)
|
||||||
|
.then(resp => {
|
||||||
|
const collection = resp.body.data.collection;
|
||||||
|
return collection !== null && collection.id === collectionId;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
isProductInCollectionVisible(collectionId, channelSlug, productId) {
|
||||||
|
return this.collectionsRequest
|
||||||
|
.getCollection(collectionId, channelSlug)
|
||||||
|
.then(resp => {
|
||||||
|
const product = resp.body.data.collection.products.edges[0].node;
|
||||||
|
return product !== null && product.id === productId;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default CollectionsUtils;
|
34
cypress/utils/storeFront/storeFrontProductUtils.js
Normal file
34
cypress/utils/storeFront/storeFrontProductUtils.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
import ProductDetails from "../../apiRequests/storeFront/ProductDetails";
|
||||||
|
import Search from "../../apiRequests/storeFront/Search";
|
||||||
|
|
||||||
|
class StoreFrontProductUtils {
|
||||||
|
isProductVisible(productId, channelSlug, name) {
|
||||||
|
const productDetails = new ProductDetails();
|
||||||
|
return productDetails
|
||||||
|
.getProductDetails(productId, channelSlug)
|
||||||
|
.then(productDetailsResp => {
|
||||||
|
const product = productDetailsResp.body.data.product;
|
||||||
|
return product !== null && product.name === name;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
isProductAvailableForPurchase(productId, channelSlug) {
|
||||||
|
const productDetails = new ProductDetails();
|
||||||
|
return productDetails
|
||||||
|
.getProductDetails(productId, channelSlug)
|
||||||
|
.then(
|
||||||
|
productDetailsResp =>
|
||||||
|
productDetailsResp.body.data.product.isAvailableForPurchase
|
||||||
|
);
|
||||||
|
}
|
||||||
|
isProductVisibleInSearchResult(productName, channelSlug) {
|
||||||
|
const search = new Search();
|
||||||
|
return search
|
||||||
|
.searchInShop(productName, channelSlug)
|
||||||
|
.then(
|
||||||
|
resp =>
|
||||||
|
resp.body.data.products.totalCount !== 0 &&
|
||||||
|
resp.body.data.products.edges[0].node.name === productName
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default StoreFrontProductUtils;
|
Loading…
Reference in a new issue