test for variants

This commit is contained in:
Karolina Rakoczy 2021-02-26 15:32:01 +01:00
parent ded6cdd5c4
commit 089a2c428d
4 changed files with 28 additions and 15 deletions

View file

@ -1,5 +1,6 @@
export const VARIANTS_SELECTORS = {
attributeCheckbox: "[name*='value:']",
valueContainer: "[class*='valueContainer']",
nextButton: "[class*='MuiButton-containedPrimary']",
priceInput: "[name*='channel-price']",
costPriceInput: "[name*='channel-costPrice']",

View file

@ -92,7 +92,7 @@ describe("creating variants", () => {
})
.then(variants => {
// expect(productDetailsResp.body[0].data.product.name).to.equal(name);
expect(variants[0].name).to.equal(attribute.values[0]);
expect(variants[0].name).to.equal(attribute.values[0].name);
expect(variants[0].pricing.price.gross.amount).to.equal(price);
// expect(
// productDetailsResp.body[0].data.product.variants[0].pricing.price
@ -109,6 +109,7 @@ describe("creating variants", () => {
productUtils
.createProductInChannel({
name,
attributeId: attribute.id,
channelId: defaultChannel.id,
warehouseId: warehouse.id,
productTypeId: productType.id,
@ -118,11 +119,12 @@ describe("creating variants", () => {
.then(() => {
createdProduct = productUtils.getCreatedProduct();
cy.visit(`${urlList.products}${createdProduct.id}`);
variantsSteps.createVariant(
secondVariantSku,
warehouse.name,
variantsPrice
);
variantsSteps.createVariant({
sku: secondVariantSku,
warehouseName: warehouse.name,
attributeName: attribute.values[1].name,
price: variantsPrice
});
})
.then(
() =>
@ -181,7 +183,12 @@ describe("creating variants", () => {
})
.then(() => {
cy.visit(`${urlList.products}${createdProduct.id}`);
variantsSteps.createFirstVariant(name, warehouse.id, variantsPrice);
variantsSteps.createFirstVariant(
name,
warehouse.id,
variantsPrice,
attribute.name
);
// productDetails.getProductDetails(product.id, defaultChannel.slug);
storeFrontProductUtils.getProductVariants(
product.id,
@ -192,10 +199,7 @@ describe("creating variants", () => {
expect(variants[0].pricing.price.gross.amount).to.equal(variantsPrice);
})
.then(() => {
storeFrontProductUtils.getProductVariants(
product.id,
defaultChannel.slug
);
storeFrontProductUtils.getProductVariants(product.id, newChannel.slug);
// productDetails.getProductDetails(product.id, newChannel.slug);
})
.then(variants => {

View file

@ -3,7 +3,9 @@ import { VARIANTS_SELECTORS } from "../../elements/catalog/variants-selectors";
class VariantsSteps {
createFirstVariant({ sku, warehouseId, price, attribute }) {
cy.get(PRODUCTS_SELECTORS.addVariantsButton).click();
cy.get(`${VARIANTS_SELECTORS.attributeCheckbox}`)
cy.get(VARIANTS_SELECTORS.valueContainer)
.contains(attribute)
.find(VARIANTS_SELECTORS.attributeCheckbox)
.click()
.get(VARIANTS_SELECTORS.nextButton)
.click();
@ -23,13 +25,19 @@ class VariantsSteps {
cy.get(VARIANTS_SELECTORS.nextButton).click();
cy.wait("@ProductVariantBulkCreate");
}
createVariant(sku, warehouseName, price, costPrice = price) {
createVariant({
sku,
warehouseName,
attributeName,
price,
costPrice = price
}) {
cy.get(PRODUCTS_SELECTORS.addVariantsButton)
.click()
.get(VARIANTS_SELECTORS.attributeSelector)
.click()
.get(VARIANTS_SELECTORS.attributeOption)
.first()
.contains(attributeName)
.click()
.get(VARIANTS_SELECTORS.priceInput)
.type(price)

View file

@ -1,4 +1,4 @@
import { PRODUCTS_SELECTORS } from "../elements/catalog/product-selectors";
import { PRODUCTS_SELECTORS } from "../../elements/catalog/product-selectors";
class ProductSteps {
valueTrue = PRODUCTS_SELECTORS.radioButtonsValueTrue;