create variants steps
This commit is contained in:
parent
e1bd4b28e9
commit
1a09ccefe0
6 changed files with 193 additions and 156 deletions
|
@ -1,3 +0,0 @@
|
|||
export const CART_SELECTORS = {
|
||||
productInCart: "[data-test='cartRow']"
|
||||
};
|
|
@ -1,3 +0,0 @@
|
|||
export const PRODUCTS_DETAILS_SELECTORS = {
|
||||
addToCartButton: "[data-test='addProductToCartButton']"
|
||||
};
|
|
@ -1,5 +0,0 @@
|
|||
export const SEARCH_SELECTORS = {
|
||||
searchButton: "[data-test='menuSearchOverlayLink']",
|
||||
searchInputField: "[placeholder='search']",
|
||||
productItem: ".search__products__item"
|
||||
};
|
|
@ -1,11 +1,11 @@
|
|||
import faker from "faker";
|
||||
|
||||
import Channels from "../apiRequests/Channels";
|
||||
import Product from "../apiRequests/Product";
|
||||
import ShopInfo from "../apiRequests/ShopInfo";
|
||||
import { PRODUCTS_SELECTORS } from "../elements/catalog/product-selectors";
|
||||
import { VARIANTS_SELECTORS } from "../elements/catalog/variants-selectors";
|
||||
import { SEARCH_SELECTORS } from "../elements/frontend-elements/search-selectors";
|
||||
import SearchSteps from "../steps/frontendSteps/searchSteps";
|
||||
import VariantsSteps from "../steps/products/VariantsSteps";
|
||||
import { urlList } from "../url/url-list";
|
||||
import ChannelsUtils from "../utils/channelsUtils";
|
||||
import ProductsUtils from "../utils/productsUtils";
|
||||
|
@ -20,12 +20,43 @@ describe("creating variants", () => {
|
|||
const shippingUtils = new ShippingUtils();
|
||||
const product = new Product();
|
||||
const shopInfo = new ShopInfo();
|
||||
const searchSteps = new SearchSteps();
|
||||
const channels = new Channels();
|
||||
|
||||
const variantsSteps = new VariantsSteps();
|
||||
|
||||
let defaultChannel;
|
||||
let warehouse;
|
||||
let attribute;
|
||||
let productType;
|
||||
let category;
|
||||
|
||||
before(() => {
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
shippingUtils.deleteShipping(startsWith);
|
||||
productUtils.deleteProducts(startsWith);
|
||||
|
||||
const name = `${startsWith}${faker.random.number()}`;
|
||||
channelsUtils
|
||||
.getDefaultChannel()
|
||||
.then(channel => {
|
||||
defaultChannel = channel;
|
||||
cy.fixture("addresses");
|
||||
})
|
||||
.then(fixtureAddresses =>
|
||||
shippingUtils.createShipping(
|
||||
channel.id,
|
||||
name,
|
||||
fixtureAddresses.plAddress,
|
||||
10
|
||||
)
|
||||
)
|
||||
.then(() => (warehouse = shippingUtils.getWarehouse()));
|
||||
|
||||
productUtils.createTypeAttributeAndCategoryForProduct(name).then(() => {
|
||||
attribute = productUtils.getAttribute();
|
||||
productType = productUtils.getProductType();
|
||||
category = productUtils.getCategory();
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -38,146 +69,130 @@ describe("creating variants", () => {
|
|||
|
||||
it("should create variant visible on frontend", () => {
|
||||
const name = `${startsWith}${faker.random.number()}`;
|
||||
let warehouseId;
|
||||
let defaultChannel;
|
||||
let productId;
|
||||
channelsUtils.getDefaultChannel().then(channel => {
|
||||
cy.fixture("addresses").then(json => {
|
||||
defaultChannel = channel;
|
||||
shippingUtils
|
||||
.createShipping(channel.id, name, json.plAddress, 10)
|
||||
.then(() => {
|
||||
warehouseId = shippingUtils.getWarehouseId();
|
||||
});
|
||||
});
|
||||
});
|
||||
productUtils.createTypeAttributeAndCategoryForProduct(name).then(() => {
|
||||
const attributeId = productUtils.getAttributeId();
|
||||
const productTypeId = productUtils.getProductTypeId();
|
||||
const categoryId = productUtils.getCategoryId();
|
||||
let createdProduct;
|
||||
|
||||
product
|
||||
.createProduct(attributeId, name, productTypeId, categoryId)
|
||||
.then(resp => {
|
||||
productId = resp.body.data.productCreate.product.id;
|
||||
product.updateChannelInProduct(
|
||||
productId,
|
||||
defaultChannel.id,
|
||||
true,
|
||||
true,
|
||||
true
|
||||
);
|
||||
cy.visit(`${urlList.products}${productId}`)
|
||||
.get(PRODUCTS_SELECTORS.addVariantsButton)
|
||||
.click()
|
||||
.get(VARIANTS_SELECTORS.attributeCheckbox)
|
||||
.first()
|
||||
.click()
|
||||
.get(VARIANTS_SELECTORS.nextButton)
|
||||
.click()
|
||||
.get(VARIANTS_SELECTORS.priceInput)
|
||||
.type(10)
|
||||
.get(`[name*='${warehouseId}']`)
|
||||
.click()
|
||||
.get(VARIANTS_SELECTORS.nextButton)
|
||||
.click()
|
||||
.get(VARIANTS_SELECTORS.skuInput)
|
||||
.type(name)
|
||||
.get(VARIANTS_SELECTORS.nextButton)
|
||||
.click()
|
||||
.waitForGraph("ProductVariantBulkCreate")
|
||||
// .searchInShop(name).then(searchResp => {
|
||||
// expect(searchResp.body[0].data.products.edges[0].node.name).to.equal(name)
|
||||
// })
|
||||
.getProductDetails(productId, defaultChannel.slug)
|
||||
.then(productDetailsResp => {
|
||||
expect(productDetailsResp.body[0].data.product.name).to.equal(
|
||||
name
|
||||
);
|
||||
expect(
|
||||
productDetailsResp.body[0].data.product.variants[0].pricing
|
||||
.price.gross.amount
|
||||
).to.equal(10);
|
||||
});
|
||||
});
|
||||
});
|
||||
product
|
||||
.createProduct(attribute.id, name, productType.id, category.id)
|
||||
.then(resp => {
|
||||
createdProduct = resp.body.data.productCreate.product;
|
||||
product.updateChannelInProduct(
|
||||
createdProduct.id,
|
||||
defaultChannel.id,
|
||||
true,
|
||||
true,
|
||||
true
|
||||
);
|
||||
cy.visit(`${urlList.products}${productId}`);
|
||||
variantsSteps.createFirstVariant(warehouse.id);
|
||||
// .get(PRODUCTS_SELECTORS.addVariantsButton)
|
||||
// .click()
|
||||
// .get(VARIANTS_SELECTORS.attributeCheckbox)
|
||||
// .first()
|
||||
// .click()
|
||||
// .get(VARIANTS_SELECTORS.nextButton)
|
||||
// .click()
|
||||
// .get(VARIANTS_SELECTORS.priceInput)
|
||||
// .type(10)
|
||||
// .get(`[name*='${warehouseId}']`)
|
||||
// .click()
|
||||
// .get(VARIANTS_SELECTORS.nextButton)
|
||||
// .click()
|
||||
// .get(VARIANTS_SELECTORS.skuInput)
|
||||
// .type(name)
|
||||
// .get(VARIANTS_SELECTORS.nextButton)
|
||||
// .click()
|
||||
// .waitForGraph("ProductVariantBulkCreate")
|
||||
cy.getProductDetails(product.id, defaultChannel.slug).then(
|
||||
productDetailsResp => {
|
||||
expect(productDetailsResp.body[0].data.product.name).to.equal(name);
|
||||
expect(
|
||||
productDetailsResp.body[0].data.product.variants[0].pricing.price
|
||||
.gross.amount
|
||||
).to.equal(10);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
it("should create several variants", () => {
|
||||
const name = `${startsWith}${faker.random.number()}`;
|
||||
const secondVariantSku = `${startsWith}${faker.random.number()}`;
|
||||
let defaultChannel;
|
||||
let warehouseId;
|
||||
let productId;
|
||||
channelsUtils.getDefaultChannel().then(channel => {
|
||||
cy.fixture("addresses").then(json => {
|
||||
defaultChannel = channel;
|
||||
shippingUtils
|
||||
.createShipping(channel.id, name, json.plAddress, 10)
|
||||
.then(() => {
|
||||
warehouseId = shippingUtils.getWarehouseId();
|
||||
});
|
||||
productUtils
|
||||
.createProductInChannel(
|
||||
name,
|
||||
productType.id,
|
||||
attribute.id,
|
||||
category.id,
|
||||
defaultChannel.id,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
warehouse.id,
|
||||
10,
|
||||
10
|
||||
)
|
||||
.then(() => {
|
||||
cy.visit(`${urlList.products}${productId}`);
|
||||
variantsSteps.createVariant(secondVariantSku, warehouse.name);
|
||||
// .get(PRODUCTS_SELECTORS.addVariantsButton)
|
||||
// .click()
|
||||
// .get(VARIANTS_SELECTORS.attributeSelector)
|
||||
// .click()
|
||||
// .get(VARIANTS_SELECTORS.attributeOption)
|
||||
// .first()
|
||||
// .click()
|
||||
// .get(VARIANTS_SELECTORS.priceInput)
|
||||
// .type(10)
|
||||
// .get(VARIANTS_SELECTORS.skuInputInAddVariant)
|
||||
// .type(secondVariantSku)
|
||||
// .get(VARIANTS_SELECTORS.addWarehouseButton)
|
||||
// .click()
|
||||
// .get(VARIANTS_SELECTORS.warehouseOption)
|
||||
// .contains(name)
|
||||
// .click()
|
||||
// .get(VARIANTS_SELECTORS.saveButton)
|
||||
// .click()
|
||||
})
|
||||
.then(() => cy.getProductDetails(productId, defaultChannel.slug))
|
||||
.then(productDetailsResp => {
|
||||
expect(productDetailsResp.body[0].data.product.name).to.equal(name);
|
||||
expect(productDetailsResp.body[0].data.product.variants).to.have.length(
|
||||
2
|
||||
);
|
||||
expect(
|
||||
productDetailsResp.body[0].data.product.variants[0].pricing.price
|
||||
.gross.amount
|
||||
).to.equal(10);
|
||||
expect(
|
||||
productDetailsResp.body[0].data.product.variants[1].pricing.price
|
||||
.gross.amount
|
||||
).to.equal(10);
|
||||
});
|
||||
});
|
||||
productUtils.createTypeAttributeAndCategoryForProduct(name).then(resp => {
|
||||
const productTypeId = productUtils.getProductTypeId();
|
||||
const attributeId = productUtils.getAttributeId();
|
||||
const categoryId = productUtils.getCategoryId();
|
||||
productUtils
|
||||
.createProductInChannel(
|
||||
name,
|
||||
productTypeId,
|
||||
attributeId,
|
||||
categoryId,
|
||||
});
|
||||
it("should create variant for many channels", () => {
|
||||
const name = `${startsWith}${faker.random.number()}`;
|
||||
let newChannel;
|
||||
channels
|
||||
.createChannel(true, name, name, "PLN")
|
||||
.then(resp => {
|
||||
newChannel = resp.body.data.createdChannel.channel;
|
||||
product.createProduct(attribute.id, name, productType.id, category.id);
|
||||
})
|
||||
.then(resp => {
|
||||
const createdProduct = resp.body.data.productCreate.product;
|
||||
product.updateChannelInProduct(
|
||||
createdProduct.id,
|
||||
defaultChannel.id,
|
||||
true,
|
||||
true,
|
||||
true
|
||||
);
|
||||
product.updateChannelInProduct(
|
||||
createdProduct.id,
|
||||
newChannel.id,
|
||||
true,
|
||||
warehouseId,
|
||||
10,
|
||||
10
|
||||
)
|
||||
.then(() => {
|
||||
productId = productUtils.getCreatedProductId();
|
||||
cy.visit(`${urlList.products}${productId}`)
|
||||
.get(PRODUCTS_SELECTORS.addVariantsButton)
|
||||
.click()
|
||||
.get(VARIANTS_SELECTORS.attributeSelector)
|
||||
.click()
|
||||
.get(VARIANTS_SELECTORS.attributeOption)
|
||||
.first()
|
||||
.click()
|
||||
.get(VARIANTS_SELECTORS.priceInput)
|
||||
.type(10)
|
||||
.get(VARIANTS_SELECTORS.skuInputInAddVariant)
|
||||
.type(secondVariantSku)
|
||||
.get(VARIANTS_SELECTORS.addWarehouseButton)
|
||||
.click()
|
||||
.get(VARIANTS_SELECTORS.warehouseOption)
|
||||
.contains(name)
|
||||
.click()
|
||||
.get(VARIANTS_SELECTORS.saveButton)
|
||||
.click()
|
||||
.then(() => {
|
||||
cy.getProductDetails(productId, defaultChannel.slug).then(
|
||||
productDetailsResp => {
|
||||
expect(productDetailsResp.body[0].data.product.name).to.equal(
|
||||
name
|
||||
);
|
||||
expect(
|
||||
productDetailsResp.body[0].data.product.variants
|
||||
).to.have.length(2);
|
||||
expect(
|
||||
productDetailsResp.body[0].data.product.variants[0].pricing
|
||||
.price.gross.amount
|
||||
).to.equal(10);
|
||||
expect(
|
||||
productDetailsResp.body[0].data.product.variants[1].pricing
|
||||
.price.gross.amount
|
||||
).to.equal(10);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
true,
|
||||
true
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
import { SEARCH_SELECTORS } from "../../elements/frontend-elements/search-selectors";
|
||||
|
||||
class SearchSteps {
|
||||
searchFor(query) {
|
||||
cy.get(SEARCH_SELECTORS.searchButton)
|
||||
.click()
|
||||
.get(SEARCH_SELECTORS.searchInputField)
|
||||
.type(query);
|
||||
}
|
||||
}
|
||||
export default SearchSteps;
|
44
cypress/steps/products/VariantsSteps.js
Normal file
44
cypress/steps/products/VariantsSteps.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
import { VARIANTS_SELECTORS } from "../../elements/catalog/variants-selectors";
|
||||
class VariantsSteps {
|
||||
createFirstVariant(sku, warehouseId) {
|
||||
cy.get(PRODUCTS_SELECTORS.addVariantsButton)
|
||||
.click()
|
||||
.get(VARIANTS_SELECTORS.attributeCheckbox)
|
||||
.first()
|
||||
.click()
|
||||
.get(VARIANTS_SELECTORS.nextButton)
|
||||
.click()
|
||||
.get(VARIANTS_SELECTORS.priceInput)
|
||||
.type(10)
|
||||
.get(`[name*='${warehouseId}']`)
|
||||
.click()
|
||||
.get(VARIANTS_SELECTORS.nextButton)
|
||||
.click()
|
||||
.get(VARIANTS_SELECTORS.skuInput)
|
||||
.type(sku)
|
||||
.get(VARIANTS_SELECTORS.nextButton)
|
||||
.click()
|
||||
.waitForGraph("ProductVariantBulkCreate");
|
||||
}
|
||||
createVariant(sku, warehouseName) {
|
||||
cy.get(PRODUCTS_SELECTORS.addVariantsButton)
|
||||
.click()
|
||||
.get(VARIANTS_SELECTORS.attributeSelector)
|
||||
.click()
|
||||
.get(VARIANTS_SELECTORS.attributeOption)
|
||||
.first()
|
||||
.click()
|
||||
.get(VARIANTS_SELECTORS.priceInput)
|
||||
.type(10)
|
||||
.get(VARIANTS_SELECTORS.skuInputInAddVariant)
|
||||
.type(sku)
|
||||
.get(VARIANTS_SELECTORS.addWarehouseButton)
|
||||
.click()
|
||||
.get(VARIANTS_SELECTORS.warehouseOption)
|
||||
.contains(warehouseName)
|
||||
.click()
|
||||
.get(VARIANTS_SELECTORS.saveButton)
|
||||
.click();
|
||||
}
|
||||
}
|
||||
export default VariantsSteps;
|
Loading…
Reference in a new issue