diff --git a/cypress/e2e/configuration/channels/channels.js b/cypress/e2e/configuration/channels/channels.js index fb92fe608..942e6539b 100644 --- a/cypress/e2e/configuration/channels/channels.js +++ b/cypress/e2e/configuration/channels/channels.js @@ -13,25 +13,39 @@ import { urlList } from "../../../fixtures/urlList"; import { ONE_PERMISSION_USERS } from "../../../fixtures/users"; import { createChannel } from "../../../support/api/requests/Channels"; import { - createShippingZone, + createShippingZoneWithoutWarehouse, getShippingZone, } from "../../../support/api/requests/ShippingMethod"; +import { createWarehouse as createWarehouseViaApi } from "../../../support/api/requests/Warehouse"; import { deleteChannelsStartsWith } from "../../../support/api/utils/channelsUtils"; import { deleteShippingStartsWith } from "../../../support/api/utils/shippingUtils"; +import { deleteWarehouseStartsWith } from "../../../support/api/utils/warehouseUtils"; +import { returnValueDependsOnShopVersion } from "../../../support/formatData/dataDependingOnVersion"; import { createChannelByView } from "../../../support/pages/channelsPage"; describe("Channels", () => { const channelStartsWith = `CyChannels`; - const randomName = `${channelStartsWith} ${faker.datatype.number()}`; + const randomName = `${channelStartsWith}${faker.datatype.number()}`; const currency = "PLN"; let shippingZone; + let usAddress; before(() => { cy.clearSessionData().loginUserViaRequest(); deleteChannelsStartsWith(channelStartsWith); deleteShippingStartsWith(channelStartsWith); - createShippingZone(randomName, "US").then(shippingZoneResp => { - shippingZone = shippingZoneResp; + deleteWarehouseStartsWith(channelStartsWith); + createShippingZoneWithoutWarehouse(randomName, "US").then( + shippingZoneResp => { + shippingZone = shippingZoneResp; + }, + ); + cy.fixture("addresses").then(addresses => { + usAddress = addresses.usAddress; + createWarehouseViaApi({ + name: randomName, + address: usAddress, + }); }); }); @@ -85,9 +99,8 @@ describe("Channels", () => { .contains(randomChannel); }, ); - it( - "should create channel with shippingZone. TC: SALEOR_0702", + "should create channel with shippingZone and warehouse TC: SALEOR_0712", { tags: ["@channel", "@allEnv"] }, () => { // remove login after fixing SALEOR-3162 @@ -102,6 +115,7 @@ describe("Channels", () => { name: randomChannel, currency, shippingZone: shippingZone.name, + warehouse: randomName, }); cy.waitForRequestAndCheckIfNoErrors("@Channel"); getShippingZone(shippingZone.id).then(shippingZoneResp => { diff --git a/cypress/support/api/utils/warehouseUtils.js b/cypress/support/api/utils/warehouseUtils.js new file mode 100644 index 000000000..e4fd2435d --- /dev/null +++ b/cypress/support/api/utils/warehouseUtils.js @@ -0,0 +1,9 @@ +import * as warehouseRequest from "../requests/Warehouse"; + +export function deleteWarehouseStartsWith(startsWith) { + cy.deleteElementsStartsWith( + warehouseRequest.deleteWarehouse, + warehouseRequest.getWarehouses, + startsWith, + ); +} diff --git a/cypress/support/pages/channelsPage.js b/cypress/support/pages/channelsPage.js index 5347f552a..fc430bb08 100644 --- a/cypress/support/pages/channelsPage.js +++ b/cypress/support/pages/channelsPage.js @@ -13,7 +13,8 @@ export function createChannelByView({ currency, slug = name, shippingZone, - defaultCountry = "Poland" + defaultCountry = "Poland", + warehouse, }) { cy.addAliasToGraphRequest("Channel") .get(CHANNELS_SELECTORS.createChannelButton) @@ -34,22 +35,38 @@ export function createChannelByView({ }); cy.fillAutocompleteSelect( ADD_CHANNEL_FORM_SELECTORS.countryAutocompleteInput, - defaultCountry + defaultCountry, ); if (shippingZone) { addShippingZone(shippingZone); } + if (warehouse) { + addWarehouse(warehouse); + } cy.get(ADD_CHANNEL_FORM_SELECTORS.saveButton).click(); } export function addShippingZone(shippingZone) { cy.get(BUTTON_SELECTORS.expandIcon) + .first() .click() .get(ADD_CHANNEL_FORM_SELECTORS.addShippingZoneButton) .click() .fillAutocompleteSelect( ADD_CHANNEL_FORM_SELECTORS.shippingAutocompleteSelect, - shippingZone + shippingZone, + ); +} + +export function addWarehouse(warehouse) { + cy.get(BUTTON_SELECTORS.expandIcon) + .last() + .click() + .get(ADD_CHANNEL_FORM_SELECTORS.addWarehouseButton) + .click() + .fillAutocompleteSelect( + ADD_CHANNEL_FORM_SELECTORS.warehouseAutocompleteSelect, + warehouse, ); }