diff --git a/cypress/apiRequests/Checkout.js b/cypress/apiRequests/Checkout.js index 85c75347f..e7847fd68 100644 --- a/cypress/apiRequests/Checkout.js +++ b/cypress/apiRequests/Checkout.js @@ -33,6 +33,7 @@ export function createCheckout({ field message } + created checkout{ id @@ -56,6 +57,10 @@ export function addShippingMethod(checkoutId, shippingMethodId) { field } checkout{ + shippingMethod{ + id + name + } totalPrice{ gross{ amount diff --git a/cypress/apiRequests/ShippingMethod.js b/cypress/apiRequests/ShippingMethod.js index 8a4b78a6f..9792f67fa 100644 --- a/cypress/apiRequests/ShippingMethod.js +++ b/cypress/apiRequests/ShippingMethod.js @@ -61,6 +61,7 @@ export function createShippingZone(name, country, channelId) { .sendRequestWithQuery(mutation) .its("body.data.shippingZoneCreate.shippingZone"); } + export function addChannelToShippingZone(shippingZoneId, channelId) { const mutation = `mutation addCh{ shippingZoneUpdate(id:"${shippingZoneId}", input:{ @@ -74,6 +75,7 @@ export function addChannelToShippingZone(shippingZoneId, channelId) { }`; return cy.sendRequestWithQuery(mutation); } + export function addChannelToShippingMethod( shippingRateId, channelId, @@ -138,8 +140,12 @@ export function getShippingZone(shippingZoneId) { name id } + shippingMethods{ + id + name + } } - } `; + }`; return cy .sendRequestWithQuery(query) .then(resp => resp.body.data.shippingZone); diff --git a/cypress/apiRequests/shopSettings.js b/cypress/apiRequests/shopSettings.js index f38c10b2f..b7cc90c40 100644 --- a/cypress/apiRequests/shopSettings.js +++ b/cypress/apiRequests/shopSettings.js @@ -14,7 +14,10 @@ export function updateShopWeightUnit(weightUnit) { } } }`; - return cy.sendRequestWithQuery(mutation).its("body.data.shopSettingsUpdate"); + return cy + .sendRequestWithQuery(mutation) + .wait(1000) + .its("body.data.shopSettingsUpdate"); } export function updateShopAddress(address) { diff --git a/cypress/apiRequests/storeFront/ProductDetails.js b/cypress/apiRequests/storeFront/ProductDetails.js index 45df10b68..114bb4899 100644 --- a/cypress/apiRequests/storeFront/ProductDetails.js +++ b/cypress/apiRequests/storeFront/ProductDetails.js @@ -5,6 +5,7 @@ export function getProductDetails(productId, channelId, auth = "token") { auth === "auth", `privateMetadata{key value}` ); + const query = `fragment BasicProductFields on Product { id name @@ -49,6 +50,10 @@ export function getProductDetails(productId, channelId, auth = "token") { id sku name + weight{ + unit + value + } pricing { price { ...Price diff --git a/cypress/integration/apps.js b/cypress/integration/apps.js index 0bc1152db..fa9cd941d 100644 --- a/cypress/integration/apps.js +++ b/cypress/integration/apps.js @@ -6,7 +6,7 @@ import { APP_DETAILS } from "../elements/apps/appDetails"; import { APPS_LIST } from "../elements/apps/appsList"; import { WEBHOOK_DETAILS } from "../elements/apps/webhookDetails"; import { BUTTON_SELECTORS } from "../elements/shared/button-selectors"; -import { confirmationMessageShouldDisappear } from "../steps/shared/confirmationMessage"; +import { confirmationMessageShouldDisappear } from "../steps/shared/confirmationMessages"; import filterTests from "../support/filterTests"; import { appDetailsUrl, urlList } from "../url/urlList"; import { deleteAppsStartsWith } from "../utils/appUtils"; diff --git a/cypress/integration/configuration/customer.js b/cypress/integration/configuration/customer.js index 0076c191b..96fba9b7c 100644 --- a/cypress/integration/configuration/customer.js +++ b/cypress/integration/configuration/customer.js @@ -7,7 +7,7 @@ import { CUSTOMERS_LIST } from "../../elements/customer/customers-list"; import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors"; import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements"; import { fillUpAddressForm } from "../../steps/shared/addressForm"; -import { confirmationMessageShouldDisappear } from "../../steps/shared/confirmationMessage"; +import { confirmationMessageShouldDisappear } from "../../steps/shared/confirmationMessages"; import filterTests from "../../support/filterTests"; import { urlList } from "../../url/urlList"; diff --git a/cypress/integration/configuration/productTypes.js b/cypress/integration/configuration/productTypes.js index 556728bbb..767160fcc 100644 --- a/cypress/integration/configuration/productTypes.js +++ b/cypress/integration/configuration/productTypes.js @@ -8,7 +8,7 @@ import { import { PRODUCT_TYPE_DETAILS } from "../../elements/productTypes/productTypeDetails"; import { createProductType } from "../../steps/productTypeSteps"; import { assignElements } from "../../steps/shared/assignElements"; -import { confirmationMessageShouldDisappear } from "../../steps/shared/confirmationMessage"; +import { confirmationMessageShouldDisappear } from "../../steps/shared/confirmationMessages"; import { visitAndWaitForProgressBarToDisappear } from "../../steps/shared/progressBar"; import filterTests from "../../support/filterTests"; import { productTypeDetailsUrl, urlList } from "../../url/urlList"; diff --git a/cypress/integration/configuration/shippingMethods/shippingWeight.js b/cypress/integration/configuration/shippingMethods/shippingWeight.js deleted file mode 100644 index c38244d6e..000000000 --- a/cypress/integration/configuration/shippingMethods/shippingWeight.js +++ /dev/null @@ -1,190 +0,0 @@ -// -import faker from "faker"; - -import { createCheckout } from "../../../apiRequests/Checkout"; -import { - createShippingRate as createShippingRateViaApi, - createShippingZone -} from "../../../apiRequests/ShippingMethod"; -import { updateShopWeightUnit } from "../../../apiRequests/shopSettings"; -import { createWarehouse } from "../../../apiRequests/Warehouse"; -import { ONE_PERMISSION_USERS } from "../../../Data/users"; -import { SHARED_ELEMENTS } from "../../../elements/shared/sharedElements"; -import { SHIPPING_RATE_DETAILS } from "../../../elements/shipping/shipping-rate-details"; -import { - changeWeightUnit, - createShippingRate, - rateOptions -} from "../../../steps/shippingMethodSteps"; -import filterTests from "../../../support/filterTests"; -import { - shippingZoneDetailsUrl, - urlList, - weightRateUrl -} from "../../../url/urlList"; -import { getDefaultChannel } from "../../../utils/channelsUtils"; -import { - createProductInChannel, - createTypeAttributeAndCategoryForProduct, - deleteProductsStartsWith -} from "../../../utils/products/productsUtils"; -import { deleteShippingStartsWith } from "../../../utils/shippingUtils"; -import { isShippingAvailableInCheckout } from "../../../utils/storeFront/checkoutUtils"; - -filterTests(["all"], () => { - describe("Shipping weight limits", () => { - const startsWith = "CyWeightRates-"; - const name = `${startsWith}${faker.datatype.number()}`; - - const price = 10; - - let defaultChannel; - let usAddress; - let shippingZone; - let warehouse; - let variantsList; - - before(() => { - cy.clearSessionData().loginUserViaRequest(); - deleteShippingStartsWith(startsWith); - deleteProductsStartsWith(startsWith); - - updateShopWeightUnit("KG"); - getDefaultChannel() - .then(channel => { - defaultChannel = channel; - cy.fixture("addresses"); - }) - .then(({ usAddress: usAddressResp }) => { - usAddress = usAddressResp; - createShippingZone(name, "US", defaultChannel.id); - }) - .then(shippingZoneResp => { - shippingZone = shippingZoneResp; - createWarehouse({ - name, - shippingZone: shippingZone.id, - address: usAddress - }); - }) - .then(warehouseResp => { - warehouse = warehouseResp; - createTypeAttributeAndCategoryForProduct(name); - }) - .then(({ attribute, productType, category }) => { - createProductInChannel({ - name, - channelId: defaultChannel.id, - warehouseId: warehouse.id, - attributeId: attribute.id, - categoryId: category.id, - productTypeId: productType.id, - weight: 10 - }); - }) - .then(({ variantsList: variantsListResp }) => { - variantsList = variantsListResp; - }); - }); - - beforeEach(() => { - cy.clearSessionData() - .loginUserViaRequest("auth", ONE_PERMISSION_USERS.shipping) - .visit(shippingZoneDetailsUrl(shippingZone.id)); - }); - - it("should be possible to buy product in a shipping weight limits", () => { - const rateName = `${startsWith}${faker.datatype.number()}`; - createShippingRate({ - rateName, - price, - rateOption: rateOptions.WEIGHT_OPTION, - weightLimits: { - max: 11, - min: 10 - } - }); - createCheckout({ - address: usAddress, - channelSlug: defaultChannel.slug, - email: "example@example.com", - variantsList - }).then(({ checkout }) => { - expect(isShippingAvailableInCheckout(checkout, rateName)).to.be.true; - }); - }); - - it("should not be possible to buy product not in a shipping weight limits", () => { - const rateName = `${startsWith}${faker.datatype.number()}`; - createShippingRate({ - rateName, - price, - rateOption: rateOptions.WEIGHT_OPTION, - weightLimits: { - max: 101, - min: 100 - } - }); - createCheckout({ - address: usAddress, - channelSlug: defaultChannel.slug, - email: "example@example.com", - variantsList - }).then(({ checkout }) => { - expect(isShippingAvailableInCheckout(checkout, rateName)).to.be.false; - }); - }); - - // Log in as user with shipping permissions after resolving SALEOR-3407 bug - it("should recalculate weight after changing shipping weight unit", () => { - const rateName = `${startsWith}${faker.datatype.number()}`; - const minWeightInKg = 1; - const maxWeightInKg = 10; - const minWeightInG = minWeightInKg * 1000; - const maxWeightInG = maxWeightInKg * 1000; - let shippingMethod; - - cy.clearSessionData().loginUserViaRequest(); - - createShippingRateViaApi({ - name: rateName, - shippingZone: shippingZone.id, - type: "WEIGHT", - maxWeight: maxWeightInKg, - minWeight: minWeightInKg - }) - .then(({ shippingMethod: shippingMethodResp }) => { - shippingMethod = shippingMethodResp; - cy.visit(urlList.shippingMethods) - .get(SHARED_ELEMENTS.progressBar) - .should("not.exist"); - changeWeightUnit("G"); - - cy.addAliasToGraphRequest("ShippingZone"); - cy.visit(weightRateUrl(shippingZone.id, shippingMethod.id)) - .wait("@ShippingZone") - .its("response.body"); - }) - .then(responseArray => { - const shippingMethods = responseArray.find( - element => element.data.shippingZone - ).data.shippingZone.shippingMethods; - const rate = shippingMethods.find( - element => element.id === shippingMethod.id - ); - expect(rate.minimumOrderWeight.unit).to.eq("G"); - cy.get(SHARED_ELEMENTS.progressBar) - .should("not.be.visible") - .get(SHIPPING_RATE_DETAILS.minWeightInput) - .invoke("val"); - }) - .then(actualMinWeight => { - expect(parseInt(actualMinWeight, 10)).to.eq(minWeightInG); - cy.get(SHIPPING_RATE_DETAILS.maxWeightInput).invoke("val"); - }) - .then(actualMaxWeight => { - expect(parseInt(actualMaxWeight, 10)).to.eq(maxWeightInG); - }); - }); - }); -}); diff --git a/cypress/integration/configuration/shippingMethods/shippingWeights/shippingWeightsLimits.js b/cypress/integration/configuration/shippingMethods/shippingWeights/shippingWeightsLimits.js new file mode 100644 index 000000000..21052c8c6 --- /dev/null +++ b/cypress/integration/configuration/shippingMethods/shippingWeights/shippingWeightsLimits.js @@ -0,0 +1,134 @@ +// +import faker from "faker"; + +import { createCheckout } from "../../../../apiRequests/Checkout"; +import { createShippingZone } from "../../../../apiRequests/ShippingMethod"; +import { createWarehouse } from "../../../../apiRequests/Warehouse"; +import { ONE_PERMISSION_USERS } from "../../../../Data/users"; +import { + createShippingRate, + rateOptions +} from "../../../../steps/shippingMethodSteps"; +import filterTests from "../../../../support/filterTests"; +import { shippingZoneDetailsUrl } from "../../../../url/urlList"; +import { getDefaultChannel } from "../../../../utils/channelsUtils"; +import { + createProductInChannel, + createTypeAttributeAndCategoryForProduct, + deleteProductsStartsWith +} from "../../../../utils/products/productsUtils"; +import { deleteShippingStartsWith } from "../../../../utils/shippingUtils"; +import { isShippingAvailableInCheckout } from "../../../../utils/storeFront/checkoutUtils"; + +filterTests(["all"], () => { + describe("Shipping weight limits", () => { + const startsWith = "CyWeightRates-"; + const name = `${startsWith}${faker.datatype.number()}`; + + const price = 10; + + let defaultChannel; + let usAddress; + let shippingZone; + let warehouse; + let variantsList; + + before(() => { + cy.clearSessionData().loginUserViaRequest(); + deleteShippingStartsWith(startsWith); + deleteProductsStartsWith(startsWith); + + getDefaultChannel() + .then(channel => { + defaultChannel = channel; + cy.fixture("addresses"); + }) + .then(({ usAddress: usAddressResp }) => { + usAddress = usAddressResp; + createShippingZone(name, "US", defaultChannel.id); + }) + .then(shippingZoneResp => { + shippingZone = shippingZoneResp; + createWarehouse({ + name, + shippingZone: shippingZone.id, + address: usAddress + }); + }) + .then(warehouseResp => { + warehouse = warehouseResp; + createTypeAttributeAndCategoryForProduct(name); + }) + .then(({ attribute, productType, category }) => { + createProductInChannel({ + name, + channelId: defaultChannel.id, + warehouseId: warehouse.id, + attributeId: attribute.id, + categoryId: category.id, + productTypeId: productType.id, + weight: 10 + }); + }) + .then(({ variantsList: variantsListResp }) => { + variantsList = variantsListResp; + }); + }); + + beforeEach(() => { + cy.clearSessionData() + .loginUserViaRequest("auth", ONE_PERMISSION_USERS.shipping) + .visit(shippingZoneDetailsUrl(shippingZone.id)); + }); + + it("should be possible to buy product in a shipping weight limits", () => { + const rateName = `${startsWith}${faker.datatype.number()}`; + + createShippingRate({ + rateName, + price, + rateOption: rateOptions.WEIGHT_OPTION, + weightLimits: { + max: 11, + min: 10 + } + }) + .then(() => { + createCheckout({ + address: usAddress, + channelSlug: defaultChannel.slug, + email: "example@example.com", + variantsList + }); + }) + .then(({ checkout }) => { + expect(isShippingAvailableInCheckout(checkout, rateName)).to.be.true; + }); + }); + + it("should not be possible to buy product not in a shipping weight limits", () => { + const rateName = `${startsWith}${faker.datatype.number()}`; + + createShippingRate({ + rateName, + price, + rateOption: rateOptions.WEIGHT_OPTION, + weightLimits: { + max: 101, + min: 100 + } + }) + .then(() => { + createCheckout({ + address: usAddress, + channelSlug: defaultChannel.slug, + email: "example@example.com", + variantsList + }); + }) + .then(({ checkout }) => { + expect(isShippingAvailableInCheckout(checkout, rateName)).to.be.false; + }); + }); + }); +}); diff --git a/cypress/integration/configuration/shippingMethods/shippingWeights/weightRecalculate.js b/cypress/integration/configuration/shippingMethods/shippingWeights/weightRecalculate.js new file mode 100644 index 000000000..babc7d577 --- /dev/null +++ b/cypress/integration/configuration/shippingMethods/shippingWeights/weightRecalculate.js @@ -0,0 +1,99 @@ +// +import faker from "faker"; + +import { + createShippingRate as createShippingRateViaApi, + createShippingZone +} from "../../../../apiRequests/ShippingMethod"; +import { updateShopWeightUnit } from "../../../../apiRequests/shopSettings"; +import { SHARED_ELEMENTS } from "../../../../elements/shared/sharedElements"; +import { SHIPPING_RATE_DETAILS } from "../../../../elements/shipping/shipping-rate-details"; +import { waitForProgressBarToNotBeVisible } from "../../../../steps/shared/progressBar"; +import { changeWeightUnit } from "../../../../steps/shippingMethodSteps"; +import filterTests from "../../../../support/filterTests"; +import { urlList, weightRateUrl } from "../../../../url/urlList"; +import { getDefaultChannel } from "../../../../utils/channelsUtils"; +import { deleteProductsStartsWith } from "../../../../utils/products/productsUtils"; +import { deleteShippingStartsWith } from "../../../../utils/shippingUtils"; + +filterTests(["all"], () => { + describe("Recalculate weights", () => { + const startsWith = "RecalculateWeight"; + const name = `${startsWith}${faker.datatype.number()}`; + + let defaultChannel; + let usAddress; + let shippingZone; + + before(() => { + cy.clearSessionData().loginUserViaRequest(); + deleteShippingStartsWith(startsWith); + deleteProductsStartsWith(startsWith); + + updateShopWeightUnit("KG") + .then(() => { + getDefaultChannel().then(channel => { + defaultChannel = channel; + cy.fixture("addresses"); + }); + }) + .then(({ usAddress: usAddressResp }) => { + usAddress = usAddressResp; + createShippingZone(name, "US", defaultChannel.id); + }) + .then(shippingZoneResp => { + shippingZone = shippingZoneResp; + }); + }); + + // Log in as user with shipping permissions after resolving SALEOR-3407 bug + it("should recalculate weight after changing shipping weight unit", () => { + const rateName = `${startsWith}${faker.datatype.number()}`; + const minWeightInKg = 1; + const maxWeightInKg = 10; + const minWeightInG = minWeightInKg * 1000; + const maxWeightInG = maxWeightInKg * 1000; + let shippingMethod; + + cy.clearSessionData().loginUserViaRequest(); + + createShippingRateViaApi({ + name: rateName, + shippingZone: shippingZone.id, + type: "WEIGHT", + maxWeight: maxWeightInKg, + minWeight: minWeightInKg + }) + .then(({ shippingMethod: shippingMethodResp }) => { + shippingMethod = shippingMethodResp; + cy.visit(urlList.shippingMethods) + .get(SHARED_ELEMENTS.progressBar) + .should("not.exist"); + changeWeightUnit("G"); + + cy.addAliasToGraphRequest("ShippingZone"); + cy.visit(weightRateUrl(shippingZone.id, shippingMethod.id)) + .wait("@ShippingZone") + .its("response.body"); + }) + .then(responseArray => { + const shippingMethods = responseArray.find( + element => element.data.shippingZone + ).data.shippingZone.shippingMethods; + const rate = shippingMethods.find( + element => element.id === shippingMethod.id + ); + waitForProgressBarToNotBeVisible(); + expect(rate.minimumOrderWeight.unit).to.eq("G"); + cy.get(SHIPPING_RATE_DETAILS.minWeightInput).invoke("val"); + }) + .then(actualMinWeight => { + expect(parseInt(actualMinWeight, 10)).to.eq(minWeightInG); + cy.get(SHIPPING_RATE_DETAILS.maxWeightInput).invoke("val"); + }) + .then(actualMaxWeight => { + expect(parseInt(actualMaxWeight, 10)).to.eq(maxWeightInG); + }); + }); + }); +}); diff --git a/cypress/integration/configuration/siteSettings.js b/cypress/integration/configuration/siteSettings.js index 0ab1e6de3..dc2ffe435 100644 --- a/cypress/integration/configuration/siteSettings.js +++ b/cypress/integration/configuration/siteSettings.js @@ -4,7 +4,7 @@ import { getShopInfo, updateShopAddress } from "../../apiRequests/shopSettings"; import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors"; import { SITE_SETTINGS_DETAILS } from "../../elements/siteSettings/site-settings-details"; import { fillUpBasicAddress } from "../../steps/shared/addressForm"; -import { confirmationMessageShouldDisappear } from "../../steps/shared/confirmationMessage"; +import { confirmationMessageShouldDisappear } from "../../steps/shared/confirmationMessages"; import filterTests from "../../support/filterTests"; import { urlList } from "../../url/urlList"; diff --git a/cypress/integration/customerRegistration.js b/cypress/integration/customerRegistration.js index 5918f72d1..a310a33c8 100644 --- a/cypress/integration/customerRegistration.js +++ b/cypress/integration/customerRegistration.js @@ -1,9 +1,13 @@ import faker from "faker"; -import { confirmAccount, customerRegistration } from "../apiRequests/Customer"; +import { + confirmAccount, + customerRegistration, + deleteCustomersStartsWith +} from "../apiRequests/Customer"; import { CUSTOMER_DETAILS } from "../elements/customers/customer-details"; import { BUTTON_SELECTORS } from "../elements/shared/button-selectors"; -import { confirmationMessageShouldDisappear } from "../steps/shared/confirmationMessage"; +import { confirmationMessageShouldDisappear } from "../steps/shared/confirmationMessages"; import filterTests from "../support/filterTests"; import { customerDetailsUrl } from "../url/urlList"; import { getDefaultChannel } from "../utils/channelsUtils"; @@ -17,6 +21,7 @@ describe("Tests for customer registration", () => { before(() => { cy.clearSessionData().loginUserViaRequest(); + deleteCustomersStartsWith(startsWith); getDefaultChannel().then(channel => { defaultChannel = channel; }); diff --git a/cypress/integration/pages/pageTypes.js b/cypress/integration/pages/pageTypes.js index e260750fe..2ea5674d5 100644 --- a/cypress/integration/pages/pageTypes.js +++ b/cypress/integration/pages/pageTypes.js @@ -7,7 +7,7 @@ import { PAGE_TYPES_LIST } from "../../elements/pageTypes/pageTypesList"; import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors"; import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements"; import { assignElements } from "../../steps/shared/assignElements"; -import { confirmationMessageShouldDisappear } from "../../steps/shared/confirmationMessage"; +import { confirmationMessageShouldDisappear } from "../../steps/shared/confirmationMessages"; import filterTests from "../../support/filterTests"; import { pageTypeDetailsUrl, urlList } from "../../url/urlList"; diff --git a/cypress/integration/products/createProduct.js b/cypress/integration/products/createProduct.js index 26b4a05cb..82ba9f767 100644 --- a/cypress/integration/products/createProduct.js +++ b/cypress/integration/products/createProduct.js @@ -15,7 +15,7 @@ import { } from "../../steps/catalog/products/priceList"; import { fillUpCommonFieldsForAllProductTypes } from "../../steps/catalog/products/productSteps"; import { selectChannelInDetailsPages } from "../../steps/channelsSteps"; -import { confirmationMessageShouldDisappear } from "../../steps/shared/confirmationMessage"; +import { confirmationMessageShouldDisappear } from "../../steps/shared/confirmationMessages"; import filterTests from "../../support/filterTests"; import { urlList } from "../../url/urlList"; import { diff --git a/cypress/integration/products/updatingProducts.js b/cypress/integration/products/updatingProducts.js index d032110d6..5c83aa011 100644 --- a/cypress/integration/products/updatingProducts.js +++ b/cypress/integration/products/updatingProducts.js @@ -9,7 +9,7 @@ import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors"; import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements"; import { metadataForms } from "../../steps/catalog/metadataSteps"; import { fillUpCommonFieldsForAllProductTypes } from "../../steps/catalog/products/productSteps"; -import { confirmationMessageShouldDisappear } from "../../steps/shared/confirmationMessage"; +import { confirmationMessageShouldDisappear } from "../../steps/shared/confirmationMessages"; import filterTests from "../../support/filterTests"; import { productDetailsUrl } from "../../url/urlList"; import { getDefaultChannel } from "../../utils/channelsUtils"; diff --git a/cypress/steps/collectionsSteps.js b/cypress/steps/collectionsSteps.js index 8ae319164..d023343e0 100644 --- a/cypress/steps/collectionsSteps.js +++ b/cypress/steps/collectionsSteps.js @@ -3,8 +3,7 @@ import { AVAILABLE_CHANNELS_FORM } from "../elements/channels/available-channels import { SELECT_CHANNELS_TO_ASSIGN } from "../elements/channels/select-channels-to-assign"; import { ASSIGN_ELEMENTS_SELECTORS } from "../elements/shared/assign-elements-selectors"; import { BUTTON_SELECTORS } from "../elements/shared/button-selectors"; -import { SHARED_ELEMENTS } from "../elements/shared/sharedElements"; -import { confirmationMessageShouldDisappear } from "./shared/confirmationMessage"; +import { confirmationMessageShouldDisappear } from "./shared/confirmationMessages"; export function createCollection(collectionName, isPublished, channel) { const publishedSelector = isPublished diff --git a/cypress/steps/discounts/salesSteps.js b/cypress/steps/discounts/salesSteps.js index 8bc85dfbf..df1fb9c34 100644 --- a/cypress/steps/discounts/salesSteps.js +++ b/cypress/steps/discounts/salesSteps.js @@ -3,7 +3,7 @@ import { ASSIGN_ELEMENTS_SELECTORS } from "../../elements/shared/assign-elements import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors"; import { formatDate } from "../../support/format/formatDate"; import { selectChannelInDetailsPages } from "../channelsSteps"; -import { confirmationMessageShouldDisappear } from "../shared/confirmationMessage"; +import { confirmationMessageShouldDisappear } from "../shared/confirmationMessages"; import { waitForProgressBarToNotBeVisible } from "../shared/progressBar"; export const discountOptions = { diff --git a/cypress/steps/discounts/vouchersSteps.js b/cypress/steps/discounts/vouchersSteps.js index 3d94aea6d..58c1bd268 100644 --- a/cypress/steps/discounts/vouchersSteps.js +++ b/cypress/steps/discounts/vouchersSteps.js @@ -1,7 +1,7 @@ import { VOUCHERS_SELECTORS } from "../../elements/discounts/vouchers"; import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors"; import { selectChannelInDetailsPages } from "../channelsSteps"; -import { confirmationMessageShouldDisappear } from "../shared/confirmationMessage"; +import { confirmationMessageShouldDisappear } from "../shared/confirmationMessages"; export const discountOptions = { PERCENTAGE: VOUCHERS_SELECTORS.percentageDiscountRadioButton, diff --git a/cypress/steps/navigationSteps.js b/cypress/steps/navigationSteps.js index 55bd68d39..aa93aae83 100644 --- a/cypress/steps/navigationSteps.js +++ b/cypress/steps/navigationSteps.js @@ -3,7 +3,7 @@ import { MENU_LIST } from "../elements/navigation/menu-list"; import { BUTTON_SELECTORS } from "../elements/shared/button-selectors"; import { SHARED_ELEMENTS } from "../elements/shared/sharedElements"; import { menuDetailsUrl, urlList } from "../url/urlList"; -import { confirmationMessageShouldDisappear } from "./shared/confirmationMessage"; +import { confirmationMessageShouldDisappear } from "./shared/confirmationMessages"; export function createMenu(name) { cy.visit(urlList.navigation) diff --git a/cypress/steps/shared/confirmationMessage.js b/cypress/steps/shared/confirmationMessage.js deleted file mode 100644 index 67fafefaa..000000000 --- a/cypress/steps/shared/confirmationMessage.js +++ /dev/null @@ -1,8 +0,0 @@ -import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements"; - -export function confirmationMessageShouldDisappear() { - cy.get(SHARED_ELEMENTS.notificationSuccess) - .should("be.visible") - .get(SHARED_ELEMENTS.notificationSuccess) - .should("not.exist"); -} diff --git a/cypress/steps/shippingMethodSteps.js b/cypress/steps/shippingMethodSteps.js index 04c0490b2..9847edc9f 100644 --- a/cypress/steps/shippingMethodSteps.js +++ b/cypress/steps/shippingMethodSteps.js @@ -3,7 +3,7 @@ import { SHARED_ELEMENTS } from "../elements/shared/sharedElements"; import { SHIPPING_RATE_DETAILS } from "../elements/shipping/shipping-rate-details"; import { SHIPPING_ZONE_DETAILS } from "../elements/shipping/shipping-zone-details"; import { SHIPPING_ZONES_LIST } from "../elements/shipping/shipping-zones-list"; -import { confirmationMessageShouldDisappear } from "./shared/confirmationMessage"; +import { confirmationMessageShouldDisappear } from "./shared/confirmationMessages"; import { waitForProgressBarToNotBeVisible } from "./shared/progressBar"; import { fillBaseSelect } from "./shared/selects"; @@ -58,7 +58,7 @@ export function changeWeightUnit(weightUnit) { cy.addAliasToGraphRequest("UpdateDefaultWeightUnit"); cy.get(SHIPPING_ZONES_LIST.saveUnit).click(); confirmationMessageShouldDisappear(); - cy.wait("@UpdateDefaultWeightUnit"); + cy.wait("@UpdateDefaultWeightUnit").wait(1000); } export function createShippingRate({ @@ -75,7 +75,7 @@ export function createShippingRate({ weightLimits, deliveryTime }); - saveRate(); + return saveRate(); } export function enterAndFillUpShippingRate({ @@ -121,7 +121,7 @@ export function createRateWithPostalCode({ .type(maxPostalCode) .get(BUTTON_SELECTORS.submit) .click(); - saveRate(); + return saveRate(); } export function saveRate() { @@ -130,7 +130,10 @@ export function saveRate() { .get(BUTTON_SELECTORS.confirm) .click(); confirmationMessageShouldDisappear(); - cy.wait(`@ShippingMethodChannelListingUpdate`).wait(`@ShippingZone`); + return cy + .wait(`@ShippingMethodChannelListingUpdate`) + .wait(`@ShippingZone`) + .its("response.body.0.data.shippingZone"); } export function fillUpWeightLimits({ max, min }) { diff --git a/cypress/utils/users.js b/cypress/utils/users.js index a7052a8cf..a4b8cd999 100644 --- a/cypress/utils/users.js +++ b/cypress/utils/users.js @@ -28,6 +28,7 @@ export function getMailActivationLinkForUser(email, i = 0) { } return cy.mhGetMailsByRecipient(email).should(mails => { if (!mails.length) { + cy.wait(10000); getMailActivationLinkForUser(email, i + 1); } else { cy.wrap(mails)