From 22e78bbd23525c1251f6b03a234207050794d68c Mon Sep 17 00:00:00 2001 From: Karolina Rakoczy Date: Thu, 1 Sep 2022 15:17:13 +0200 Subject: [PATCH] Fix tests for attributes in products types (#2269) --- .../attributesInProduductTypes.js | 5 +- .../assignElementsForm.js | 46 +++++++++---------- 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/cypress/e2e/configuration/productTypes/attributesInProduductTypes.js b/cypress/e2e/configuration/productTypes/attributesInProduductTypes.js index 2cfa87607..0c199cef3 100644 --- a/cypress/e2e/configuration/productTypes/attributesInProduductTypes.js +++ b/cypress/e2e/configuration/productTypes/attributesInProduductTypes.js @@ -48,7 +48,7 @@ describe("As an admin I want to manage attributes in product types", () => { .get(PRODUCT_TYPE_DETAILS.assignProductAttributeButton) .click() .addAliasToGraphRequest("AssignProductAttribute") - .assignElements(startsWith, false) + .assignElements(startsWith, false, true) .confirmationMessageShouldAppear() .waitForRequestAndCheckIfNoErrors("@AssignProductAttribute"); getProductType(productType.id); @@ -71,11 +71,12 @@ describe("As an admin I want to manage attributes in product types", () => { productTypeDetailsUrl(productType.id), ) .get(PRODUCT_TYPE_DETAILS.hasVariantsButton) + .should("be.enabled") .click({ force: true }) .get(PRODUCT_TYPE_DETAILS.assignVariantAttributeButton) .click() .addAliasToGraphRequest("AssignProductAttribute") - .assignElements(startsWith, false) + .assignElements(startsWith, false, true) .confirmationMessageShouldAppear() .wait("@AssignProductAttribute"); getProductType(productType.id); diff --git a/cypress/support/customCommands/sharedElementsOperations/assignElementsForm.js b/cypress/support/customCommands/sharedElementsOperations/assignElementsForm.js index 883162b19..b1193a727 100644 --- a/cypress/support/customCommands/sharedElementsOperations/assignElementsForm.js +++ b/cypress/support/customCommands/sharedElementsOperations/assignElementsForm.js @@ -1,27 +1,23 @@ import { ASSIGN_ELEMENTS_SELECTORS } from "../../../elements/shared/assign-elements-selectors"; +import { SHARED_ELEMENTS } from "../../../elements/shared/sharedElements"; -// export function assignElements(name, withLoader = true) { -// cy.get(ASSIGN_ELEMENTS_SELECTORS.searchInput).type(name); -// if (withLoader) { -// cy.get(ASSIGN_ELEMENTS_SELECTORS.dialogContent); -// waitForProgressBarToNotBeVisible(); -// } -// cy.contains(ASSIGN_ELEMENTS_SELECTORS.tableRow, name) -// .find(ASSIGN_ELEMENTS_SELECTORS.checkbox) -// .click() -// .get(ASSIGN_ELEMENTS_SELECTORS.submitButton) -// .click(); -// } - -Cypress.Commands.add("assignElements", (name, withLoader = true) => { - cy.get(ASSIGN_ELEMENTS_SELECTORS.searchInput).type(name); - if (withLoader) { - cy.get(ASSIGN_ELEMENTS_SELECTORS.dialogContent); - cy.waitForProgressBarToNotBeVisible(); - } - cy.contains(ASSIGN_ELEMENTS_SELECTORS.tableRow, name) - .find(ASSIGN_ELEMENTS_SELECTORS.checkbox) - .click() - .get(ASSIGN_ELEMENTS_SELECTORS.submitButton) - .click(); -}); +Cypress.Commands.add( + "assignElements", + (name, withLoader = true, waitWithoutLoader = false) => { + cy.get(ASSIGN_ELEMENTS_SELECTORS.searchInput).type(name); + if (withLoader) { + cy.get(ASSIGN_ELEMENTS_SELECTORS.dialogContent); + cy.waitForProgressBarToNotBeVisible(); + } + if (waitWithoutLoader) { + cy.get(SHARED_ELEMENTS.dialog) + .find(ASSIGN_ELEMENTS_SELECTORS.tableRow) + .should("have.length", 1); + } + cy.contains(ASSIGN_ELEMENTS_SELECTORS.tableRow, name) + .find(ASSIGN_ELEMENTS_SELECTORS.checkbox) + .click() + .get(ASSIGN_ELEMENTS_SELECTORS.submitButton) + .click(); + }, +);