From 8a07f226e6cdd6b2df7c536788edddd0b16da458 Mon Sep 17 00:00:00 2001 From: Ewa Czerniak Date: Fri, 29 Jul 2022 08:35:55 +0200 Subject: [PATCH] Fix for tests connected with changes for relation between channel-warehouse-shippingzone (#2189) --- .../shippingMethods/channelsInShipping.js | 2 +- .../shippingMethods/createShippingMethod.js | 9 +- .../shippingMethods/editShippingMethod.js | 22 ++- .../shippingMethods/editShippingZone.js | 55 +++--- .../shippingMethods/postalCodes.js | 31 +-- .../shippingWeights/shippingWeightsLimits.js | 26 +-- .../shippingWeights/weightRecalculate.js | 19 +- .../e2e/configuration/warehouses/warehouse.js | 187 ++++++++++-------- .../support/api/requests/ShippingMethod.js | 39 +++- cypress/support/api/utils/shippingUtils.js | 28 +-- .../sharedElementsOperations/selects.js | 3 +- cypress/support/pages/shippingMethodPage.js | 22 +-- 12 files changed, 268 insertions(+), 175 deletions(-) diff --git a/cypress/e2e/configuration/shippingMethods/channelsInShipping.js b/cypress/e2e/configuration/shippingMethods/channelsInShipping.js index 5d99485a6..b09b21a9d 100644 --- a/cypress/e2e/configuration/shippingMethods/channelsInShipping.js +++ b/cypress/e2e/configuration/shippingMethods/channelsInShipping.js @@ -31,7 +31,7 @@ describe("As a staff user I want have different shipping method prices for each it( "should be able to display different price for each channel. TC: SALEOR_0805", - { tags: ["@shipping", "@allEnv"] }, + { tags: ["@shipping", "@allEnv", "@stable"] }, () => { const shippingName = `${startsWith}${faker.datatype.number()}`; const defaultChannelPrice = 11; diff --git a/cypress/e2e/configuration/shippingMethods/createShippingMethod.js b/cypress/e2e/configuration/shippingMethods/createShippingMethod.js index 5e367922f..86505620b 100644 --- a/cypress/e2e/configuration/shippingMethods/createShippingMethod.js +++ b/cypress/e2e/configuration/shippingMethods/createShippingMethod.js @@ -5,6 +5,7 @@ import faker from "faker"; import { urlList } from "../../../fixtures/urlList"; import { ONE_PERMISSION_USERS } from "../../../fixtures/users"; +import { updateChannelWarehouses } from "../../../support/api/requests/Channels"; import { createCheckout } from "../../../support/api/requests/Checkout"; import { createVariant } from "../../../support/api/requests/Product"; import { createWarehouse } from "../../../support/api/requests/Warehouse"; @@ -44,14 +45,18 @@ describe("As a staff user I want to create shipping zone and rate", () => { .getDefaultChannel() .then(channel => { defaultChannel = channel; + cy.fixture("addresses"); }) .then(addresses => { address = addresses.usAddress; + createWarehouse({ name, address }); }) .then(warehouseResp => { warehouse = warehouseResp; + + updateChannelWarehouses(defaultChannel.id, warehouse.id); productsUtils.createTypeAttributeAndCategoryForProduct({ name: startsWith, }); @@ -103,7 +108,7 @@ describe("As a staff user I want to create shipping zone and rate", () => { it( "should be able to create price based shipping method. TC: SALEOR_0803", - { tags: ["@shipping", "@allEnv"] }, + { tags: ["@shipping", "@allEnv", "@stable"] }, () => { const shippingName = `${startsWith}${faker.datatype.number()}`; cy.clearSessionData().loginUserViaRequest( @@ -153,7 +158,7 @@ describe("As a staff user I want to create shipping zone and rate", () => { it( "should be able to create weight based shipping method. TC: SALEOR_0804", - { tags: ["@shipping", "@allEnv"] }, + { tags: ["@shipping", "@allEnv", "@stable"] }, () => { const shippingName = `${startsWith}${faker.datatype.number()}`; cy.clearSessionData().loginUserViaRequest( diff --git a/cypress/e2e/configuration/shippingMethods/editShippingMethod.js b/cypress/e2e/configuration/shippingMethods/editShippingMethod.js index c13ca84e4..0e44fb0fe 100644 --- a/cypress/e2e/configuration/shippingMethods/editShippingMethod.js +++ b/cypress/e2e/configuration/shippingMethods/editShippingMethod.js @@ -4,12 +4,14 @@ import faker from "faker"; import { shippingRateUrl } from "../../../fixtures/urlList"; +import { updateChannelWarehouses } from "../../../support/api/requests/Channels"; import { addChannelToShippingMethod, createShippingRate, createShippingZone, getShippingZone, } from "../../../support/api/requests/ShippingMethod"; +import { createWarehouse } from "../../../support/api/requests/Warehouse"; import { getDefaultChannel } from "../../../support/api/utils/channelsUtils"; import { deleteShippingStartsWith } from "../../../support/api/utils/shippingUtils"; import { @@ -25,6 +27,8 @@ describe("As a user I should be able to update and delete shipping method", () = let defaultChannel; let shippingZone; let shippingMethod; + let usAddress; + let warehouse; before(() => { cy.clearSessionData().loginUserViaRequest(); @@ -33,10 +37,22 @@ describe("As a user I should be able to update and delete shipping method", () = getDefaultChannel() .then(channel => { defaultChannel = channel; - createShippingZone(name, "US", defaultChannel.id); + + cy.fixture("addresses"); }) - .then(shippingZoneResp => { - shippingZone = shippingZoneResp; + .then(({ usAddress: usAddressResp }) => { + usAddress = usAddressResp; + + createWarehouse({ name, address: usAddress }).then(warehouseResp => { + warehouse = warehouseResp; + + updateChannelWarehouses(defaultChannel.id, warehouse.id); + createShippingZone(name, "US", defaultChannel.id, warehouse.id).then( + shippingZoneResp => { + shippingZone = shippingZoneResp; + }, + ); + }); }); }); diff --git a/cypress/e2e/configuration/shippingMethods/editShippingZone.js b/cypress/e2e/configuration/shippingMethods/editShippingZone.js index 53b417615..2170d1d75 100644 --- a/cypress/e2e/configuration/shippingMethods/editShippingZone.js +++ b/cypress/e2e/configuration/shippingMethods/editShippingZone.js @@ -5,6 +5,7 @@ import faker from "faker"; import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors"; import { shippingZoneDetailsUrl } from "../../../fixtures/urlList"; +import { updateChannelWarehouses } from "../../../support/api/requests/Channels"; import { createShippingZone, getShippingZone, @@ -22,6 +23,7 @@ describe("As a user I should be able to update and delete shipping zone", () => let defaultChannel; let shippingZone; let plAddress; + let warehouse; before(() => { cy.clearSessionData().loginUserViaRequest(); @@ -34,7 +36,11 @@ describe("As a user I should be able to update and delete shipping zone", () => }) .then(addresses => { plAddress = addresses.plAddress; - createWarehouse({ name, address: plAddress }); + createWarehouse({ name, address: plAddress }).then(warehouseResp => { + warehouse = warehouseResp; + + updateChannelWarehouses(defaultChannel.id, warehouse.id); + }); }); }); @@ -42,14 +48,16 @@ describe("As a user I should be able to update and delete shipping zone", () => const rateName = `${startsWith}${faker.datatype.number()}`; cy.clearSessionData().loginUserViaRequest(); - createShippingZone(name, "US", defaultChannel.id).then(shippingZoneResp => { - shippingZone = shippingZoneResp; - }); + createShippingZone(name, "US", defaultChannel.id, warehouse.id).then( + shippingZoneResp => { + shippingZone = shippingZoneResp; + }, + ); }); it( "should be able to update shipping zone. TC: SALEOR_0808", - { tags: ["@shipping", "@allEnv"] }, + { tags: ["@shipping", "@allEnv", "@stable"] }, () => { const updatedName = `${startsWith}Updated`; @@ -64,7 +72,7 @@ describe("As a user I should be able to update and delete shipping zone", () => expect(shippingZone.channels).to.have.length(0); expect(shippingZone.name).to.eq(updatedName); expect(shippingZone.description).to.eq(updatedName); - expect(shippingZone.warehouses[0].name).to.eq(name); + expect(shippingZone.warehouses).to.have.length(0); expect(shippingZone.countries.find(el => el.code === "PL")).to.be.ok; }); }, @@ -72,7 +80,7 @@ describe("As a user I should be able to update and delete shipping zone", () => it( "should be able to delete shipping zone. TC: SALEOR_0809", - { tags: ["@shipping", "@allEnv"] }, + { tags: ["@shipping", "@allEnv", "@stable"] }, () => { cy.visit( shippingZoneDetailsUrl(shippingZone.id), @@ -83,24 +91,27 @@ describe("As a user I should be able to update and delete shipping zone", () => it( "should be able to delete several shipping zones on shipping zones list page. TC: SALEOR_0810", - { tags: ["@shipping", "@allEnv"] }, + { tags: ["@shipping", "@allEnv", "@stable"] }, () => { let secondShippingZone; - createShippingZone(`${startsWith}Second`, "US", defaultChannel.id).then( - shippingZoneResp => { - secondShippingZone = shippingZoneResp; - enterAndSelectShippings([shippingZone.id, secondShippingZone.id]); - cy.get(BUTTON_SELECTORS.deleteSelectedElementsButton) - .click() - .addAliasToGraphRequest("BulkDeleteShippingZone") - .get(BUTTON_SELECTORS.submit) - .click() - .wait("@BulkDeleteShippingZone"); - getShippingZone(shippingZone.id).should("be.null"); - getShippingZone(secondShippingZone.id).should("be.null"); - }, - ); + createShippingZone( + `${startsWith}Second`, + "US", + defaultChannel.id, + warehouse.id, + ).then(shippingZoneResp => { + secondShippingZone = shippingZoneResp; + enterAndSelectShippings([shippingZone.id, secondShippingZone.id]); + cy.get(BUTTON_SELECTORS.deleteSelectedElementsButton) + .click() + .addAliasToGraphRequest("BulkDeleteShippingZone") + .get(BUTTON_SELECTORS.submit) + .click() + .wait("@BulkDeleteShippingZone"); + getShippingZone(shippingZone.id).should("be.null"); + getShippingZone(secondShippingZone.id).should("be.null"); + }); }, ); }); diff --git a/cypress/e2e/configuration/shippingMethods/postalCodes.js b/cypress/e2e/configuration/shippingMethods/postalCodes.js index 7b5c79294..44dee52ea 100644 --- a/cypress/e2e/configuration/shippingMethods/postalCodes.js +++ b/cypress/e2e/configuration/shippingMethods/postalCodes.js @@ -43,6 +43,7 @@ describe("As a user I want to create shipping method with postal codes", () => { getDefaultChannel() .then(channel => { defaultChannel = channel; + cy.fixture("addresses"); }) .then( @@ -52,22 +53,24 @@ describe("As a user I want to create shipping method with postal codes", () => { }) => { usAddress = usAddressResp; secondUsAddress = secondUsAddressResp; - createShippingZone(name, "US", defaultChannel.id); + + createWarehouse({ name, address: usAddress }).then(warehouseResp => { + warehouse = warehouseResp; + + updateChannelWarehouses(defaultChannel.id, warehouse.id); + createShippingZone( + name, + "US", + defaultChannel.id, + warehouse.id, + ).then(shippingZoneResp => { + shippingZone = shippingZoneResp; + + createTypeAttributeAndCategoryForProduct({ name }); + }); + }); }, ) - .then(shippingZoneResp => { - shippingZone = shippingZoneResp; - createWarehouse({ - name, - shippingZone: shippingZone.id, - address: usAddress, - }); - }) - .then(warehouseResp => { - warehouse = warehouseResp; - updateChannelWarehouses(defaultChannel.id, warehouse.id); - createTypeAttributeAndCategoryForProduct({ name }); - }) .then(({ attribute, productType, category }) => { createProductInChannel({ name, diff --git a/cypress/e2e/configuration/shippingMethods/shippingWeights/shippingWeightsLimits.js b/cypress/e2e/configuration/shippingMethods/shippingWeights/shippingWeightsLimits.js index c17c795fe..cd50486af 100644 --- a/cypress/e2e/configuration/shippingMethods/shippingWeights/shippingWeightsLimits.js +++ b/cypress/e2e/configuration/shippingMethods/shippingWeights/shippingWeightsLimits.js @@ -42,25 +42,25 @@ describe("As a staff user I want to manage shipping weights", () => { 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, + + createWarehouse({ name, address: usAddress }).then(warehouseResp => { + warehouse = warehouseResp; + + updateChannelWarehouses(defaultChannel.id, warehouse.id); + createShippingZone(name, "US", defaultChannel.id, warehouse.id).then( + shippingZoneResp => { + shippingZone = shippingZoneResp; + + createTypeAttributeAndCategoryForProduct({ name }); + }, + ); }); }) - .then(warehouseResp => { - warehouse = warehouseResp; - updateChannelWarehouses(defaultChannel.id, warehouse.id); - createTypeAttributeAndCategoryForProduct({ name }); - }) .then(({ attribute, productType, category }) => { createProductInChannel({ name, diff --git a/cypress/e2e/configuration/shippingMethods/shippingWeights/weightRecalculate.js b/cypress/e2e/configuration/shippingMethods/shippingWeights/weightRecalculate.js index 5c38a9634..1357892ee 100644 --- a/cypress/e2e/configuration/shippingMethods/shippingWeights/weightRecalculate.js +++ b/cypress/e2e/configuration/shippingMethods/shippingWeights/weightRecalculate.js @@ -6,23 +6,26 @@ import faker from "faker"; import { SHARED_ELEMENTS } from "../../../../elements/shared/sharedElements"; import { SHIPPING_RATE_DETAILS } from "../../../../elements/shipping/shipping-rate-details"; import { shippingRateUrl, urlList } from "../../../../fixtures/urlList"; +import { updateChannelWarehouses } from "../../../../support/api/requests/Channels"; import { createShippingRate as createShippingRateViaApi, createShippingZone, } from "../../../../support/api/requests/ShippingMethod"; import { updateShopWeightUnit } from "../../../../support/api/requests/ShopSettings"; +import { createWarehouse } from "../../../../support/api/requests/Warehouse"; import { getDefaultChannel } from "../../../../support/api/utils/channelsUtils"; import { deleteProductsStartsWith } from "../../../../support/api/utils/products/productsUtils"; import { deleteShippingStartsWith } from "../../../../support/api/utils/shippingUtils"; import { changeWeightUnit } from "../../../../support/pages/shippingMethodPage"; -xdescribe("As a staff user I want to change shop default weight unit", () => { +describe("As a staff user I want to change shop default weight unit", () => { const startsWith = "RecalculateWeight"; const name = `${startsWith}${faker.datatype.number()}`; let defaultChannel; let usAddress; let shippingZone; + let warehouse; before(() => { cy.clearSessionData().loginUserViaRequest(); @@ -38,14 +41,19 @@ xdescribe("As a staff user I want to change shop default weight unit", () => { }) .then(({ usAddress: usAddressResp }) => { usAddress = usAddressResp; - createShippingZone(name, "US", defaultChannel.id); + + createWarehouse({ name, address: usAddress }).then(warehouseResp => { + warehouse = warehouseResp; + + updateChannelWarehouses(defaultChannel.id, warehouse.id); + createShippingZone(name, "US", defaultChannel.id, warehouse.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. TC: SALEOR_0901", { tags: ["@shipping", "@allEnv", "@stable"] }, @@ -79,9 +87,8 @@ xdescribe("As a staff user I want to change shop default weight unit", () => { .its("response.body"); }) .then(responseArray => { - const shippingMethods = responseArray.find( - element => element.data.shippingZone, - ).data.shippingZone.shippingMethods; + const shippingMethods = + responseArray.data.shippingZone.shippingMethods; const rate = shippingMethods.find( element => element.id === shippingMethod.id, ); diff --git a/cypress/e2e/configuration/warehouses/warehouse.js b/cypress/e2e/configuration/warehouses/warehouse.js index 958dd94ff..6707ddeed 100644 --- a/cypress/e2e/configuration/warehouses/warehouse.js +++ b/cypress/e2e/configuration/warehouses/warehouse.js @@ -12,7 +12,11 @@ import { urlList, warehouseDetailsUrl, } from "../../../fixtures/urlList"; -import { createShippingZone } from "../../../support/api/requests/ShippingMethod"; +import { updateChannelWarehouses } from "../../../support/api/requests/Channels"; +import { + createShippingZone, + createShippingZoneWithoutWarehouse, +} from "../../../support/api/requests/ShippingMethod"; import { createWarehouse as createWarehouseViaApi, getWarehouse, @@ -20,7 +24,7 @@ import { import { getDefaultChannel } from "../../../support/api/utils/channelsUtils"; import { deleteShippingStartsWith } from "../../../support/api/utils/shippingUtils"; -describe("Warehouse settings", () => { +describe("As an admin I want to manage warehouses", () => { const startsWith = "CyWarehouse"; let usAddress; let secondUsAddress; @@ -38,32 +42,36 @@ describe("Warehouse settings", () => { cy.clearSessionData().loginUserViaRequest(); }); - it("should create warehouse", { tags: ["@warehouse", "@allEnv"] }, () => { - const name = `${startsWith}${faker.datatype.number()}`; - cy.visit(urlList.warehouses) - .get(WAREHOUSES_LIST.createNewButton) - .click() - .get(WAREHOUSES_DETAILS.nameInput) - .type(name) - .fillUpBasicAddress(usAddress) - .addAliasToGraphRequest("WarehouseCreate") - .get(BUTTON_SELECTORS.confirm) - .click() - .waitForRequestAndCheckIfNoErrors("@WarehouseCreate") - .its("response.body.data.createWarehouse.warehouse") - .then(warehouse => { - getWarehouse(warehouse.id); - }) - .then(warehouse => { - const addressResp = warehouse.address; - expect(warehouse.name).to.be.eq(name); - cy.expectCorrectBasicAddress(addressResp, usAddress); - }); - }); + it( + "should be able to create warehouse. TC: SALEOR_1101", + { tags: ["@warehouse", "@allEnv", "@stable"] }, + () => { + const name = `${startsWith}${faker.datatype.number()}`; + cy.visit(urlList.warehouses) + .get(WAREHOUSES_LIST.createNewButton) + .click() + .get(WAREHOUSES_DETAILS.nameInput) + .type(name) + .fillUpBasicAddress(usAddress) + .addAliasToGraphRequest("WarehouseCreate") + .get(BUTTON_SELECTORS.confirm) + .click() + .waitForRequestAndCheckIfNoErrors("@WarehouseCreate") + .its("response.body.data.createWarehouse.warehouse") + .then(warehouse => { + getWarehouse(warehouse.id); + }) + .then(warehouse => { + const addressResp = warehouse.address; + expect(warehouse.name).to.be.eq(name); + cy.expectCorrectBasicAddress(addressResp, usAddress); + }); + }, + ); it( - "should add warehouse to shipping zone", - { tags: ["@warehouse", "@allEnv"] }, + "should be able to add warehouse to shipping zone. TC: SALEOR_1102", + { tags: ["@warehouse", "@allEnv", "@stable"] }, () => { const name = `${startsWith}${faker.datatype.number()}`; let defaultChannel; @@ -73,6 +81,7 @@ describe("Warehouse settings", () => { getDefaultChannel() .then(channelResp => { defaultChannel = channelResp; + createWarehouseViaApi({ name, address: usAddress, @@ -80,10 +89,13 @@ describe("Warehouse settings", () => { }) .then(warehouseResp => { warehouse = warehouseResp; - createShippingZone(name, "US", defaultChannel.id); + + updateChannelWarehouses(defaultChannel.id, warehouse.id); + createShippingZoneWithoutWarehouse(name, "US", defaultChannel.id); }) .then(shippingZoneResp => { shippingZone = shippingZoneResp; + cy.visit(shippingZoneDetailsUrl(shippingZone.id)) .fillAutocompleteSelect( SHIPPING_ZONE_DETAILS.warehouseSelector, @@ -103,26 +115,30 @@ describe("Warehouse settings", () => { }, ); - it("should delete warehouse", { tags: ["@warehouse", "@allEnv"] }, () => { - const name = `${startsWith}${faker.datatype.number()}`; - createWarehouseViaApi({ - name, - address: usAddress, - }).then(warehouse => { - cy.visit(warehouseDetailsUrl(warehouse.id)) - .get(BUTTON_SELECTORS.deleteButton) - .click() - .addAliasToGraphRequest("WarehouseDelete") - .get(BUTTON_SELECTORS.submit) - .click() - .waitForRequestAndCheckIfNoErrors("@WarehouseDelete"); - getWarehouse(warehouse.id).should("be.null"); - }); - }); + it( + "should be able to delete warehouse. TC: SALEOR_1103", + { tags: ["@warehouse", "@allEnv", "@stable"] }, + () => { + const name = `${startsWith}${faker.datatype.number()}`; + createWarehouseViaApi({ + name, + address: usAddress, + }).then(warehouse => { + cy.visit(warehouseDetailsUrl(warehouse.id)) + .get(BUTTON_SELECTORS.deleteButton) + .click() + .addAliasToGraphRequest("WarehouseDelete") + .get(BUTTON_SELECTORS.submit) + .click() + .waitForRequestAndCheckIfNoErrors("@WarehouseDelete"); + getWarehouse(warehouse.id).should("be.null"); + }); + }, + ); it( - "should remove warehouse from shipping zone", - { tags: ["@warehouse", "@allEnv"] }, + "should be able to remove warehouse from shipping zone. TC: SALEOR_1104", + { tags: ["@warehouse", "@allEnv", "@stable"] }, () => { const name = `${startsWith}${faker.datatype.number()}`; let defaultChannel; @@ -132,18 +148,20 @@ describe("Warehouse settings", () => { getDefaultChannel() .then(channelResp => { defaultChannel = channelResp; - createShippingZone(name, "US", defaultChannel.id); + + createWarehouseViaApi({ + name, + address: usAddress, + }).then(warehouseResp => { + warehouse = warehouseResp; + + updateChannelWarehouses(defaultChannel.id, warehouse.id); + createShippingZone(name, "US", defaultChannel.id, warehouse.id); + }); }) .then(shippingZoneResp => { shippingZone = shippingZoneResp; - createWarehouseViaApi({ - name, - shippingZone: shippingZone.id, - address: usAddress, - }); - }) - .then(warehouseResp => { - warehouse = warehouseResp; + cy.visit(shippingZoneDetailsUrl(shippingZone.id)) .get(SHIPPING_ZONE_DETAILS.removeWarehouseButton) .click() @@ -151,39 +169,42 @@ describe("Warehouse settings", () => { .get(BUTTON_SELECTORS.confirm) .click() .waitForRequestAndCheckIfNoErrors("@UpdateShippingZone"); - getWarehouse(warehouse.id); - }) - .then(warehouseResp => { - expect(warehouseResp.shippingZones.edges).to.be.empty; + getWarehouse(warehouse.id).then(warehouseResp => { + expect(warehouseResp.shippingZones.edges).to.be.empty; + }); }); }, ); - it("should update warehouse", { tags: ["@warehouse", "@allEnv"] }, () => { - const name = `${startsWith}${faker.datatype.number()}`; - const updatedName = `${startsWith}${faker.datatype.number()}`; - let warehouse; + it( + "should be able to update warehouse. TC: SALEOR_1105", + { tags: ["@warehouse", "@allEnv", "@stable"] }, + () => { + const name = `${startsWith}${faker.datatype.number()}`; + const updatedName = `${startsWith}${faker.datatype.number()}`; + let warehouse; - createWarehouseViaApi({ - name, - address: usAddress, - }) - .then(warehouseResp => { - warehouse = warehouseResp; - cy.visit(warehouseDetailsUrl(warehouse.id)) - .get(WAREHOUSES_DETAILS.nameInput) - .clearAndType(updatedName) - .fillUpBasicAddress(secondUsAddress) - .addAliasToGraphRequest("WarehouseUpdate") - .get(BUTTON_SELECTORS.confirm) - .click() - .waitForRequestAndCheckIfNoErrors("@WarehouseUpdate"); - getWarehouse(warehouse.id); + createWarehouseViaApi({ + name, + address: usAddress, }) - .then(warehouseResp => { - const addressResp = warehouseResp.address; - expect(warehouseResp.name).to.be.eq(updatedName); - cy.expectCorrectBasicAddress(addressResp, secondUsAddress); - }); - }); + .then(warehouseResp => { + warehouse = warehouseResp; + cy.visit(warehouseDetailsUrl(warehouse.id)) + .get(WAREHOUSES_DETAILS.nameInput) + .clearAndType(updatedName) + .fillUpBasicAddress(secondUsAddress) + .addAliasToGraphRequest("WarehouseUpdate") + .get(BUTTON_SELECTORS.confirm) + .click() + .waitForRequestAndCheckIfNoErrors("@WarehouseUpdate"); + getWarehouse(warehouse.id); + }) + .then(warehouseResp => { + const addressResp = warehouseResp.address; + expect(warehouseResp.name).to.be.eq(updatedName); + cy.expectCorrectBasicAddress(addressResp, secondUsAddress); + }); + }, + ); }); diff --git a/cypress/support/api/requests/ShippingMethod.js b/cypress/support/api/requests/ShippingMethod.js index ea672926c..edb6fc2f5 100644 --- a/cypress/support/api/requests/ShippingMethod.js +++ b/cypress/support/api/requests/ShippingMethod.js @@ -5,15 +5,15 @@ export function createShippingRate({ shippingZone, type = "PRICE", maxWeight, - minWeight + minWeight, }) { const maxOrderWeight = getValueWithDefault( maxWeight, - `maximumOrderWeight: ${maxWeight}` + `maximumOrderWeight: ${maxWeight}`, ); const minOrderWeight = getValueWithDefault( minWeight, - `minimumOrderWeight: ${minWeight}` + `minimumOrderWeight: ${minWeight}`, ); const mutation = `mutation{ @@ -37,10 +37,37 @@ export function createShippingRate({ return cy.sendRequestWithQuery(mutation).its("body.data.shippingPriceCreate"); } -export function createShippingZone(name, country, channelId) { +export function createShippingZone(name, country, channelId, warehouseId) { const channelsLines = getValueWithDefault( channelId, - `addChannels:["${channelId}"]` + `addChannels:["${channelId}"]`, + ); + const mutation = `mutation{ + shippingZoneCreate(input:{ + name: "${name}" + countries: "${country}" + ${channelsLines} + addWarehouses: ["${warehouseId}"] + }){ + shippingZone{ + id + name + } + errors{ + field + message + } + } + }`; + return cy + .sendRequestWithQuery(mutation) + .its("body.data.shippingZoneCreate.shippingZone"); +} + +export function createShippingZoneWithoutWarehouse(name, country, channelId) { + const channelsLines = getValueWithDefault( + channelId, + `addChannels:["${channelId}"]`, ); const mutation = `mutation{ shippingZoneCreate(input:{ @@ -81,7 +108,7 @@ export function addChannelToShippingMethod( shippingRateId, channelId, price, - minProductPrice = 0 + minProductPrice = 0, ) { const mutation = `mutation{ shippingMethodChannelListingUpdate(id:"${shippingRateId}", input:{ diff --git a/cypress/support/api/utils/shippingUtils.js b/cypress/support/api/utils/shippingUtils.js index 746156826..0793e2d83 100644 --- a/cypress/support/api/utils/shippingUtils.js +++ b/cypress/support/api/utils/shippingUtils.js @@ -14,23 +14,25 @@ export function createShipping({ let shippingZone; let warehouse; - return shippingMethodRequest - .createShippingZone(name, address.country, channelId) - .then(shippingZoneResp => { - shippingZone = shippingZoneResp; - warehouseRequest.createWarehouse({ - name, - shippingZone: shippingZone.id, - address, - }); + return warehouseRequest + .createWarehouse({ + name, + address, }) .then(warehouseResp => { warehouse = warehouseResp; + updateChannelWarehouses(channelId, warehouse.id); - shippingMethodRequest.createShippingRate({ - name, - shippingZone: shippingZone.id, - }); + shippingMethodRequest + .createShippingZone(name, address.country, channelId, warehouse.id) + .then(shippingZoneResp => { + shippingZone = shippingZoneResp; + + shippingMethodRequest.createShippingRate({ + name, + shippingZone: shippingZone.id, + }); + }); }) .then(({ shippingMethod: sippingMethodResp }) => { shippingMethod = sippingMethodResp; diff --git a/cypress/support/customCommands/sharedElementsOperations/selects.js b/cypress/support/customCommands/sharedElementsOperations/selects.js index e196cf6da..5e5a03763 100644 --- a/cypress/support/customCommands/sharedElementsOperations/selects.js +++ b/cypress/support/customCommands/sharedElementsOperations/selects.js @@ -1,7 +1,7 @@ import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors"; import { selectorWithDataValue, - SHARED_ELEMENTS + SHARED_ELEMENTS, } from "../../../elements/shared/sharedElements"; Cypress.Commands.add("createNewOption", (selectSelector, newOption) => { @@ -26,6 +26,7 @@ Cypress.Commands.add("fillMultiSelect", (selectSelector, option) => { Cypress.Commands.add("fillBaseSelect", (selectSelector, value) => { cy.get(selectSelector) + .should("not.have.attr", "aria-disabled", "true") .click() .get(selectorWithDataValue(value)) .click(); diff --git a/cypress/support/pages/shippingMethodPage.js b/cypress/support/pages/shippingMethodPage.js index c59caf9bb..006cbd3c8 100644 --- a/cypress/support/pages/shippingMethodPage.js +++ b/cypress/support/pages/shippingMethodPage.js @@ -9,14 +9,14 @@ export function createShippingZone( shippingName, warehouseName, country, - channelName + channelName, ) { cy.get(SHIPPING_ZONES_LIST.addShippingZone).click(); fillUpShippingZoneData({ shippingName, warehouseName, country, - channelName + channelName, }); } @@ -24,7 +24,7 @@ export function fillUpShippingZoneData({ shippingName, warehouseName, country, - channelName + channelName, }) { cy.get(SHIPPING_ZONE_DETAILS.nameInput) .clearAndType(shippingName) @@ -79,7 +79,7 @@ export function createShippingRate({ rateOption, weightLimits, deliveryTime, - priceLimits + priceLimits, }) { enterAndFillUpShippingRate({ rateName, @@ -87,7 +87,7 @@ export function createShippingRate({ rateOption, weightLimits, deliveryTime, - priceLimits + priceLimits, }); return saveRate(); } @@ -98,7 +98,7 @@ export function enterAndFillUpShippingRate({ rateOption, weightLimits, priceLimits, - deliveryTime + deliveryTime, }) { cy.get(rateOption).click(); fillUpShippingRate({ @@ -106,7 +106,7 @@ export function enterAndFillUpShippingRate({ price, weightLimits, priceLimits, - deliveryTime + deliveryTime, }); } @@ -115,7 +115,7 @@ export function fillUpShippingRate({ price, weightLimits, priceLimits, - deliveryTime + deliveryTime, }) { cy.waitForProgressBarToNotBeVisible() .get(SHARED_ELEMENTS.richTextEditor.empty) @@ -142,7 +142,7 @@ export function createRateWithPostalCode({ rateOption = rateOptions.PRICE_OPTION, minPostalCode, maxPostalCode, - postalCodeOption + postalCodeOption, }) { enterAndFillUpShippingRate({ rateName, price, rateOption }); cy.get(postalCodeOption) @@ -195,10 +195,10 @@ export function fillUpDeliveryTime({ min, max }) { export const rateOptions = { PRICE_OPTION: SHIPPING_ZONE_DETAILS.addPriceRateButton, - WEIGHT_OPTION: SHIPPING_ZONE_DETAILS.addWeightRateButton + WEIGHT_OPTION: SHIPPING_ZONE_DETAILS.addWeightRateButton, }; export const postalCodesOptions = { INCLUDE_OPTION: SHIPPING_RATE_DETAILS.includePostalCodesCheckbox, - EXCLUDE_OPTION: SHIPPING_RATE_DETAILS.excludePostalCodesCheckbox + EXCLUDE_OPTION: SHIPPING_RATE_DETAILS.excludePostalCodesCheckbox, };