tests for collections
This commit is contained in:
parent
ca5df50640
commit
170a9b8b44
6 changed files with 158 additions and 75 deletions
|
@ -88,19 +88,26 @@ class Product {
|
||||||
price = 1,
|
price = 1,
|
||||||
costPrice = 1
|
costPrice = 1
|
||||||
) {
|
) {
|
||||||
|
const channelListings = channelId
|
||||||
|
? `channelListings:{
|
||||||
|
channelId:"${channelId}"
|
||||||
|
price:"${price}"
|
||||||
|
costPrice:"${costPrice}"
|
||||||
|
}`
|
||||||
|
: "";
|
||||||
|
const stocks = warehouseId
|
||||||
|
? `stocks:{
|
||||||
|
warehouse:"${warehouseId}"
|
||||||
|
quantity:${quantity}
|
||||||
|
}`
|
||||||
|
: "";
|
||||||
|
|
||||||
const mutation = `mutation{
|
const mutation = `mutation{
|
||||||
productVariantBulkCreate(product:"${productId}", variants:{
|
productVariantBulkCreate(product:"${productId}", variants:{
|
||||||
attributes:[]
|
attributes:[]
|
||||||
sku:"${sku}"
|
sku:"${sku}"
|
||||||
channelListings:{
|
${channelListings}
|
||||||
channelId:"${channelId}"
|
${stocks}
|
||||||
price:"${price}"
|
|
||||||
costPrice:"${costPrice}"
|
|
||||||
}
|
|
||||||
stocks:{
|
|
||||||
warehouse:"${warehouseId}"
|
|
||||||
quantity:${quantity}
|
|
||||||
}
|
|
||||||
}){
|
}){
|
||||||
productVariants{
|
productVariants{
|
||||||
id
|
id
|
||||||
|
|
|
@ -44,10 +44,13 @@ 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.visit(urlList.channels).waitForGraph("Channels");
|
cy.waitForGraph("Channels");
|
||||||
|
cy.visit(urlList.channels);
|
||||||
|
cy.wait("Channels");
|
||||||
|
cy.waitForGraph("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.waitForGraph("Channel")
|
cy.wait("@Channel")
|
||||||
.get(ADD_CHANNEL_FORM_SELECTORS.backToChannelsList)
|
.get(ADD_CHANNEL_FORM_SELECTORS.backToChannelsList)
|
||||||
.click()
|
.click()
|
||||||
.get(CHANNELS_SELECTORS.channelsTable)
|
.get(CHANNELS_SELECTORS.channelsTable)
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
// <reference types="cypress" />
|
// <reference types="cypress" />
|
||||||
import faker from "faker";
|
import faker from "faker";
|
||||||
|
|
||||||
import { COLLECTION_SELECTORS } from "../elements/catalog/collection-selectors";
|
import Product from "../apiRequests/Product";
|
||||||
import { ASSIGN_PRODUCTS_SELECTORS } from "../elements/catalog/products/assign-products-selectors";
|
import CollectionsSteps from "../steps/collectionsSteps";
|
||||||
import { MENAGE_CHANNEL_AVAILABILITY_FORM } from "../elements/channels/menage-channel-availability-form";
|
|
||||||
import { BUTTON_SELECTORS } from "../elements/shared/button-selectors";
|
|
||||||
import { urlList } from "../url/urlList";
|
import { urlList } from "../url/urlList";
|
||||||
import ChannelsUtils from "../utils/channelsUtils";
|
import ChannelsUtils from "../utils/channelsUtils";
|
||||||
import CollectionsUtils from "../utils/collectionsUtils";
|
import CollectionsUtils from "../utils/collectionsUtils";
|
||||||
|
@ -12,10 +10,12 @@ import ProductsUtils from "../utils/productsUtils";
|
||||||
import ShippingUtils from "../utils/shippingUtils";
|
import ShippingUtils from "../utils/shippingUtils";
|
||||||
|
|
||||||
describe("Collections", () => {
|
describe("Collections", () => {
|
||||||
|
const productRequest = new Product();
|
||||||
const channelsUtils = new ChannelsUtils();
|
const channelsUtils = new ChannelsUtils();
|
||||||
const productsUtils = new ProductsUtils();
|
const productsUtils = new ProductsUtils();
|
||||||
const collectionsUtils = new CollectionsUtils();
|
const collectionsUtils = new CollectionsUtils();
|
||||||
const shippingUtils = new ShippingUtils();
|
const shippingUtils = new ShippingUtils();
|
||||||
|
const collectionsSteps = new CollectionsSteps();
|
||||||
|
|
||||||
const startsWith = "Cy-";
|
const startsWith = "Cy-";
|
||||||
const name = `${startsWith}${faker.random.number()}`;
|
const name = `${startsWith}${faker.random.number()}`;
|
||||||
|
@ -34,7 +34,6 @@ describe("Collections", () => {
|
||||||
defaultChannel = channel;
|
defaultChannel = channel;
|
||||||
productsUtils.createTypeAttributeAndCategoryForProduct(name);
|
productsUtils.createTypeAttributeAndCategoryForProduct(name);
|
||||||
})
|
})
|
||||||
// .then(() => shippingUtils.createShipping(defaultChannel.id, name, ))
|
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const attribute = productsUtils.getAttribute();
|
const attribute = productsUtils.getAttribute();
|
||||||
const productType = productsUtils.getProductType();
|
const productType = productsUtils.getProductType();
|
||||||
|
@ -54,67 +53,81 @@ describe("Collections", () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.clearSessionData().loginUserViaRequest();
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
cy.visit(urlList.collections);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not display hidden collections", () => {
|
it("should not display hidden collections", () => {
|
||||||
const collectionName = `${startsWith}${faker.random.number()}`;
|
const collectionName = `${startsWith}${faker.random.number()}`;
|
||||||
|
cy.visit(urlList.collections);
|
||||||
|
|
||||||
cy.get(COLLECTION_SELECTORS.createCollectionButton)
|
collectionsSteps
|
||||||
.click()
|
.createCollection(collectionName, false, defaultChannel)
|
||||||
.get(COLLECTION_SELECTORS.nameInput)
|
.then(collection => {
|
||||||
.type(collectionName)
|
collectionsSteps.assignProductsToCollection(name);
|
||||||
.get(MENAGE_CHANNEL_AVAILABILITY_FORM.channelsMenageButton)
|
collectionsUtils.isCollectionVisible(
|
||||||
.click()
|
collection.id,
|
||||||
.get(MENAGE_CHANNEL_AVAILABILITY_FORM.allChannelsCheckbox)
|
defaultChannel.slug
|
||||||
.click();
|
);
|
||||||
cy.contains(
|
})
|
||||||
MENAGE_CHANNEL_AVAILABILITY_FORM.channelRow,
|
.then(isVisible => expect(isVisible).to.equal(false));
|
||||||
defaultChannel.name
|
});
|
||||||
)
|
|
||||||
.find(MENAGE_CHANNEL_AVAILABILITY_FORM.channelCheckbox)
|
it("should display collections", () => {
|
||||||
.click()
|
const collectionName = `${startsWith}${faker.random.number()}`;
|
||||||
.get(BUTTON_SELECTORS.submit)
|
cy.visit(urlList.collections);
|
||||||
.click()
|
|
||||||
.get(MENAGE_CHANNEL_AVAILABILITY_FORM.channelsAvailabilityItem)
|
collectionsSteps
|
||||||
.click()
|
.createCollection(collectionName, true, defaultChannel)
|
||||||
.get(
|
.then(collection => {
|
||||||
`${MENAGE_CHANNEL_AVAILABILITY_FORM.publishedCheckbox}${MENAGE_CHANNEL_AVAILABILITY_FORM.radioButtonsValueFalse}`
|
collectionsSteps.assignProductsToCollection(name);
|
||||||
)
|
collectionsUtils.isCollectionVisible(
|
||||||
.click()
|
collection.id,
|
||||||
.waitForGraph("CreateCollection")
|
defaultChannel.slug
|
||||||
.get(COLLECTION_SELECTORS.saveButton)
|
);
|
||||||
.click();
|
})
|
||||||
collectionsUtils.getCreatedCollection().then(collection => {
|
.then(isVisible => expect(isVisible).to.equal(true));
|
||||||
cy.get(COLLECTION_SELECTORS.addProductButton)
|
});
|
||||||
.click()
|
xit("should not display unavailable in channel collections", () => {
|
||||||
.get(ASSIGN_PRODUCTS_SELECTORS.searchInput)
|
channelsUtils.createChannel(true, name, name, "PLN").then(() => {
|
||||||
.type(name);
|
productRequest.updateChannelInProduct(
|
||||||
cy.contains(ASSIGN_PRODUCTS_SELECTORS.tableRow, name)
|
productsUtils.getCreatedProduct().id,
|
||||||
.find(ASSIGN_PRODUCTS_SELECTORS.checkbox)
|
channelsUtils.getCreatedChannel().id
|
||||||
.click()
|
);
|
||||||
.get(ASSIGN_PRODUCTS_SELECTORS.submitButton)
|
});
|
||||||
.click()
|
cy.visit(urlList.collections);
|
||||||
.loginInShop();
|
collectionsSteps
|
||||||
collectionsUtils
|
.createCollection(collectionName, true, channelsUtils.getCreatedChannel())
|
||||||
.isCollectionVisible(collection.id, defaultChannel.slug)
|
.then(collection => {
|
||||||
.then(isVisible => expect(isVisible).to.equal(true));
|
collectionsSteps.assignProductsToCollection(name);
|
||||||
});
|
collectionsUtils.isCollectionVisible(
|
||||||
|
collection.id,
|
||||||
|
defaultChannel.slug
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.then(isVisible => expect(isVisible).to.equal(true));
|
||||||
|
});
|
||||||
|
xit("should display products hidden in listing, only in collection", () => {
|
||||||
|
productsUtils.createProductInChannel(
|
||||||
|
name,
|
||||||
|
defaultChannel.id,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
productsUtils.getProductType().id,
|
||||||
|
productsUtils.getAttribute().id,
|
||||||
|
productsUtils.getCategory().id,
|
||||||
|
1
|
||||||
|
);
|
||||||
|
collectionsSteps
|
||||||
|
.createCollection(collectionName, true, defaultChannel)
|
||||||
|
.then(collection => {
|
||||||
|
collectionsSteps.assignProductsToCollection(name);
|
||||||
|
collectionsUtils.isProductInCollectionVisible(
|
||||||
|
collection.id,
|
||||||
|
defaultChannel.slug
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.then(isVisible => {
|
||||||
|
expect(isVisible).to.equal(true);
|
||||||
|
// productsUtils.searchForProduct
|
||||||
|
});
|
||||||
});
|
});
|
||||||
// xit("should display collections", () => {
|
|
||||||
// createVisibleCollection
|
|
||||||
// addProductToCollection
|
|
||||||
// checkIfCollectionIsNotDisplayed
|
|
||||||
// });
|
|
||||||
// xit("should not display unavailable collections", () => {
|
|
||||||
// createunavailableCollection
|
|
||||||
// addProductToCollection
|
|
||||||
// checkIfCollectionIsNotDisplayed
|
|
||||||
// });
|
|
||||||
// xit("should display products hidden in listing only in collection", () => {
|
|
||||||
// createHiddenInListingsProduct
|
|
||||||
// createVisibleCollection
|
|
||||||
// addProductToCollection
|
|
||||||
// checkIfCollectionIsNotDisplayed
|
|
||||||
// });
|
|
||||||
});
|
});
|
||||||
|
|
49
cypress/steps/collectionsSteps.js
Normal file
49
cypress/steps/collectionsSteps.js
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
import { COLLECTION_SELECTORS } from "../elements/catalog/collection-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 { BUTTON_SELECTORS } from "../elements/shared/button-selectors";
|
||||||
|
import CollectionsUtils from "../utils/collectionsUtils";
|
||||||
|
class CollectionsSteps {
|
||||||
|
createCollection(collectionName, isPublished, channel) {
|
||||||
|
const publishedSelector = isPublished
|
||||||
|
? MENAGE_CHANNEL_AVAILABILITY_FORM.radioButtonsValueTrue
|
||||||
|
: MENAGE_CHANNEL_AVAILABILITY_FORM.radioButtonsValueFalse;
|
||||||
|
const collectionsUtils = new CollectionsUtils();
|
||||||
|
|
||||||
|
cy.get(COLLECTION_SELECTORS.createCollectionButton)
|
||||||
|
.click()
|
||||||
|
.get(COLLECTION_SELECTORS.nameInput)
|
||||||
|
.type(collectionName)
|
||||||
|
.get(MENAGE_CHANNEL_AVAILABILITY_FORM.channelsMenageButton)
|
||||||
|
.click()
|
||||||
|
.get(MENAGE_CHANNEL_AVAILABILITY_FORM.allChannelsCheckbox)
|
||||||
|
.click();
|
||||||
|
cy.contains(MENAGE_CHANNEL_AVAILABILITY_FORM.channelRow, channel.name)
|
||||||
|
.find(MENAGE_CHANNEL_AVAILABILITY_FORM.channelCheckbox)
|
||||||
|
.click()
|
||||||
|
.get(BUTTON_SELECTORS.submit)
|
||||||
|
.click()
|
||||||
|
.get(MENAGE_CHANNEL_AVAILABILITY_FORM.channelsAvailabilityItem)
|
||||||
|
.click()
|
||||||
|
.get(
|
||||||
|
`${MENAGE_CHANNEL_AVAILABILITY_FORM.publishedCheckbox}${publishedSelector}`
|
||||||
|
)
|
||||||
|
.click()
|
||||||
|
.waitForGraph("CreateCollection")
|
||||||
|
.get(COLLECTION_SELECTORS.saveButton)
|
||||||
|
.click();
|
||||||
|
return collectionsUtils.waitForCreateCollectionRequest();
|
||||||
|
}
|
||||||
|
assignProductsToCollection(productName) {
|
||||||
|
cy.get(COLLECTION_SELECTORS.addProductButton)
|
||||||
|
.click()
|
||||||
|
.get(ASSIGN_PRODUCTS_SELECTORS.searchInput)
|
||||||
|
.type(productName);
|
||||||
|
cy.contains(ASSIGN_PRODUCTS_SELECTORS.tableRow, productName)
|
||||||
|
.find(ASSIGN_PRODUCTS_SELECTORS.checkbox)
|
||||||
|
.click()
|
||||||
|
.get(ASSIGN_PRODUCTS_SELECTORS.submitButton)
|
||||||
|
.click();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default CollectionsSteps;
|
|
@ -2,6 +2,7 @@ import Channels from "../apiRequests/Channels";
|
||||||
|
|
||||||
class ChannelsUtils {
|
class ChannelsUtils {
|
||||||
channels = new Channels();
|
channels = new Channels();
|
||||||
|
createdChannel;
|
||||||
|
|
||||||
deleteChannels(nameStartsWith) {
|
deleteChannels(nameStartsWith) {
|
||||||
this.channels.getChannels().then(resp => {
|
this.channels.getChannels().then(resp => {
|
||||||
|
@ -37,5 +38,15 @@ class ChannelsUtils {
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
createChannel(isActive, name, slug, currencyCode) {
|
||||||
|
return this.channels
|
||||||
|
.createChannel(isActive, name, slug, currencyCode)
|
||||||
|
.then(
|
||||||
|
resp => (this.createdChannel = resp.body.data.channelCreate.channel)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
getCreatedChannel() {
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
export default ChannelsUtils;
|
export default ChannelsUtils;
|
||||||
|
|
|
@ -8,10 +8,10 @@ class CollectionsUtils {
|
||||||
.getCollection(collectionId, channelSlug)
|
.getCollection(collectionId, channelSlug)
|
||||||
.then(resp => {
|
.then(resp => {
|
||||||
const collection = resp.body[0].data.collection;
|
const collection = resp.body[0].data.collection;
|
||||||
return collection && collection.id === collectionId;
|
return collection !== null && collection.id === collectionId;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getCreatedCollection() {
|
waitForCreateCollectionRequest() {
|
||||||
return cy
|
return cy
|
||||||
.wait(`@CreateCollection`)
|
.wait(`@CreateCollection`)
|
||||||
.its("response.body.data.collectionCreate.collection");
|
.its("response.body.data.collectionCreate.collection");
|
||||||
|
|
Loading…
Reference in a new issue