diff --git a/cypress/elements/catalog/variants-selectors.js b/cypress/elements/catalog/variants-selectors.js index 719aa3e7e..9763757b2 100644 --- a/cypress/elements/catalog/variants-selectors.js +++ b/cypress/elements/catalog/variants-selectors.js @@ -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']", diff --git a/cypress/integration/products/productsVariants.js b/cypress/integration/products/productsVariants.js index 743f07bf2..dcd58f185 100644 --- a/cypress/integration/products/productsVariants.js +++ b/cypress/integration/products/productsVariants.js @@ -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 => { diff --git a/cypress/steps/products/VariantsSteps.js b/cypress/steps/products/VariantsSteps.js index dde450b2a..d446b33d9 100644 --- a/cypress/steps/products/VariantsSteps.js +++ b/cypress/steps/products/VariantsSteps.js @@ -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) diff --git a/cypress/steps/productSteps.js b/cypress/steps/products/productSteps.js similarity index 94% rename from cypress/steps/productSteps.js rename to cypress/steps/products/productSteps.js index eec8c3736..57fb4e90c 100644 --- a/cypress/steps/productSteps.js +++ b/cypress/steps/products/productSteps.js @@ -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;