Fix for tests connected with changes for relation between channel-warehouse-shippingzone (#2189)

This commit is contained in:
Ewa Czerniak 2022-07-29 08:35:55 +02:00 committed by GitHub
parent 6cd42b0ae8
commit 8a07f226e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 268 additions and 175 deletions

View file

@ -31,7 +31,7 @@ describe("As a staff user I want have different shipping method prices for each
it( it(
"should be able to display different price for each channel. TC: SALEOR_0805", "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 shippingName = `${startsWith}${faker.datatype.number()}`;
const defaultChannelPrice = 11; const defaultChannelPrice = 11;

View file

@ -5,6 +5,7 @@ import faker from "faker";
import { urlList } from "../../../fixtures/urlList"; import { urlList } from "../../../fixtures/urlList";
import { ONE_PERMISSION_USERS } from "../../../fixtures/users"; import { ONE_PERMISSION_USERS } from "../../../fixtures/users";
import { updateChannelWarehouses } from "../../../support/api/requests/Channels";
import { createCheckout } from "../../../support/api/requests/Checkout"; import { createCheckout } from "../../../support/api/requests/Checkout";
import { createVariant } from "../../../support/api/requests/Product"; import { createVariant } from "../../../support/api/requests/Product";
import { createWarehouse } from "../../../support/api/requests/Warehouse"; 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() .getDefaultChannel()
.then(channel => { .then(channel => {
defaultChannel = channel; defaultChannel = channel;
cy.fixture("addresses"); cy.fixture("addresses");
}) })
.then(addresses => { .then(addresses => {
address = addresses.usAddress; address = addresses.usAddress;
createWarehouse({ name, address }); createWarehouse({ name, address });
}) })
.then(warehouseResp => { .then(warehouseResp => {
warehouse = warehouseResp; warehouse = warehouseResp;
updateChannelWarehouses(defaultChannel.id, warehouse.id);
productsUtils.createTypeAttributeAndCategoryForProduct({ productsUtils.createTypeAttributeAndCategoryForProduct({
name: startsWith, name: startsWith,
}); });
@ -103,7 +108,7 @@ describe("As a staff user I want to create shipping zone and rate", () => {
it( it(
"should be able to create price based shipping method. TC: SALEOR_0803", "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()}`; const shippingName = `${startsWith}${faker.datatype.number()}`;
cy.clearSessionData().loginUserViaRequest( cy.clearSessionData().loginUserViaRequest(
@ -153,7 +158,7 @@ describe("As a staff user I want to create shipping zone and rate", () => {
it( it(
"should be able to create weight based shipping method. TC: SALEOR_0804", "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()}`; const shippingName = `${startsWith}${faker.datatype.number()}`;
cy.clearSessionData().loginUserViaRequest( cy.clearSessionData().loginUserViaRequest(

View file

@ -4,12 +4,14 @@
import faker from "faker"; import faker from "faker";
import { shippingRateUrl } from "../../../fixtures/urlList"; import { shippingRateUrl } from "../../../fixtures/urlList";
import { updateChannelWarehouses } from "../../../support/api/requests/Channels";
import { import {
addChannelToShippingMethod, addChannelToShippingMethod,
createShippingRate, createShippingRate,
createShippingZone, createShippingZone,
getShippingZone, getShippingZone,
} from "../../../support/api/requests/ShippingMethod"; } from "../../../support/api/requests/ShippingMethod";
import { createWarehouse } from "../../../support/api/requests/Warehouse";
import { getDefaultChannel } from "../../../support/api/utils/channelsUtils"; import { getDefaultChannel } from "../../../support/api/utils/channelsUtils";
import { deleteShippingStartsWith } from "../../../support/api/utils/shippingUtils"; import { deleteShippingStartsWith } from "../../../support/api/utils/shippingUtils";
import { import {
@ -25,6 +27,8 @@ describe("As a user I should be able to update and delete shipping method", () =
let defaultChannel; let defaultChannel;
let shippingZone; let shippingZone;
let shippingMethod; let shippingMethod;
let usAddress;
let warehouse;
before(() => { before(() => {
cy.clearSessionData().loginUserViaRequest(); cy.clearSessionData().loginUserViaRequest();
@ -33,10 +37,22 @@ describe("As a user I should be able to update and delete shipping method", () =
getDefaultChannel() getDefaultChannel()
.then(channel => { .then(channel => {
defaultChannel = channel; defaultChannel = channel;
createShippingZone(name, "US", defaultChannel.id);
cy.fixture("addresses");
}) })
.then(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; shippingZone = shippingZoneResp;
},
);
});
}); });
}); });

View file

@ -5,6 +5,7 @@ import faker from "faker";
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors"; import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
import { shippingZoneDetailsUrl } from "../../../fixtures/urlList"; import { shippingZoneDetailsUrl } from "../../../fixtures/urlList";
import { updateChannelWarehouses } from "../../../support/api/requests/Channels";
import { import {
createShippingZone, createShippingZone,
getShippingZone, getShippingZone,
@ -22,6 +23,7 @@ describe("As a user I should be able to update and delete shipping zone", () =>
let defaultChannel; let defaultChannel;
let shippingZone; let shippingZone;
let plAddress; let plAddress;
let warehouse;
before(() => { before(() => {
cy.clearSessionData().loginUserViaRequest(); cy.clearSessionData().loginUserViaRequest();
@ -34,7 +36,11 @@ describe("As a user I should be able to update and delete shipping zone", () =>
}) })
.then(addresses => { .then(addresses => {
plAddress = addresses.plAddress; 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()}`; const rateName = `${startsWith}${faker.datatype.number()}`;
cy.clearSessionData().loginUserViaRequest(); cy.clearSessionData().loginUserViaRequest();
createShippingZone(name, "US", defaultChannel.id).then(shippingZoneResp => { createShippingZone(name, "US", defaultChannel.id, warehouse.id).then(
shippingZoneResp => {
shippingZone = shippingZoneResp; shippingZone = shippingZoneResp;
}); },
);
}); });
it( it(
"should be able to update shipping zone. TC: SALEOR_0808", "should be able to update shipping zone. TC: SALEOR_0808",
{ tags: ["@shipping", "@allEnv"] }, { tags: ["@shipping", "@allEnv", "@stable"] },
() => { () => {
const updatedName = `${startsWith}Updated`; 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.channels).to.have.length(0);
expect(shippingZone.name).to.eq(updatedName); expect(shippingZone.name).to.eq(updatedName);
expect(shippingZone.description).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; 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( it(
"should be able to delete shipping zone. TC: SALEOR_0809", "should be able to delete shipping zone. TC: SALEOR_0809",
{ tags: ["@shipping", "@allEnv"] }, { tags: ["@shipping", "@allEnv", "@stable"] },
() => { () => {
cy.visit( cy.visit(
shippingZoneDetailsUrl(shippingZone.id), shippingZoneDetailsUrl(shippingZone.id),
@ -83,12 +91,16 @@ describe("As a user I should be able to update and delete shipping zone", () =>
it( it(
"should be able to delete several shipping zones on shipping zones list page. TC: SALEOR_0810", "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; let secondShippingZone;
createShippingZone(`${startsWith}Second`, "US", defaultChannel.id).then( createShippingZone(
shippingZoneResp => { `${startsWith}Second`,
"US",
defaultChannel.id,
warehouse.id,
).then(shippingZoneResp => {
secondShippingZone = shippingZoneResp; secondShippingZone = shippingZoneResp;
enterAndSelectShippings([shippingZone.id, secondShippingZone.id]); enterAndSelectShippings([shippingZone.id, secondShippingZone.id]);
cy.get(BUTTON_SELECTORS.deleteSelectedElementsButton) cy.get(BUTTON_SELECTORS.deleteSelectedElementsButton)
@ -99,8 +111,7 @@ describe("As a user I should be able to update and delete shipping zone", () =>
.wait("@BulkDeleteShippingZone"); .wait("@BulkDeleteShippingZone");
getShippingZone(shippingZone.id).should("be.null"); getShippingZone(shippingZone.id).should("be.null");
getShippingZone(secondShippingZone.id).should("be.null"); getShippingZone(secondShippingZone.id).should("be.null");
}, });
);
}, },
); );
}); });

View file

@ -43,6 +43,7 @@ describe("As a user I want to create shipping method with postal codes", () => {
getDefaultChannel() getDefaultChannel()
.then(channel => { .then(channel => {
defaultChannel = channel; defaultChannel = channel;
cy.fixture("addresses"); cy.fixture("addresses");
}) })
.then( .then(
@ -52,22 +53,24 @@ describe("As a user I want to create shipping method with postal codes", () => {
}) => { }) => {
usAddress = usAddressResp; usAddress = usAddressResp;
secondUsAddress = secondUsAddressResp; 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 }) => { .then(({ attribute, productType, category }) => {
createProductInChannel({ createProductInChannel({
name, name,

View file

@ -42,24 +42,24 @@ describe("As a staff user I want to manage shipping weights", () => {
getDefaultChannel() getDefaultChannel()
.then(channel => { .then(channel => {
defaultChannel = channel; defaultChannel = channel;
cy.fixture("addresses"); cy.fixture("addresses");
}) })
.then(({ usAddress: usAddressResp }) => { .then(({ usAddress: usAddressResp }) => {
usAddress = usAddressResp; usAddress = usAddressResp;
createShippingZone(name, "US", defaultChannel.id);
}) createWarehouse({ name, address: usAddress }).then(warehouseResp => {
.then(shippingZoneResp => {
shippingZone = shippingZoneResp;
createWarehouse({
name,
shippingZone: shippingZone.id,
address: usAddress,
});
})
.then(warehouseResp => {
warehouse = warehouseResp; warehouse = warehouseResp;
updateChannelWarehouses(defaultChannel.id, warehouse.id); updateChannelWarehouses(defaultChannel.id, warehouse.id);
createShippingZone(name, "US", defaultChannel.id, warehouse.id).then(
shippingZoneResp => {
shippingZone = shippingZoneResp;
createTypeAttributeAndCategoryForProduct({ name }); createTypeAttributeAndCategoryForProduct({ name });
},
);
});
}) })
.then(({ attribute, productType, category }) => { .then(({ attribute, productType, category }) => {
createProductInChannel({ createProductInChannel({

View file

@ -6,23 +6,26 @@ import faker from "faker";
import { SHARED_ELEMENTS } from "../../../../elements/shared/sharedElements"; import { SHARED_ELEMENTS } from "../../../../elements/shared/sharedElements";
import { SHIPPING_RATE_DETAILS } from "../../../../elements/shipping/shipping-rate-details"; import { SHIPPING_RATE_DETAILS } from "../../../../elements/shipping/shipping-rate-details";
import { shippingRateUrl, urlList } from "../../../../fixtures/urlList"; import { shippingRateUrl, urlList } from "../../../../fixtures/urlList";
import { updateChannelWarehouses } from "../../../../support/api/requests/Channels";
import { import {
createShippingRate as createShippingRateViaApi, createShippingRate as createShippingRateViaApi,
createShippingZone, createShippingZone,
} from "../../../../support/api/requests/ShippingMethod"; } from "../../../../support/api/requests/ShippingMethod";
import { updateShopWeightUnit } from "../../../../support/api/requests/ShopSettings"; import { updateShopWeightUnit } from "../../../../support/api/requests/ShopSettings";
import { createWarehouse } from "../../../../support/api/requests/Warehouse";
import { getDefaultChannel } from "../../../../support/api/utils/channelsUtils"; import { getDefaultChannel } from "../../../../support/api/utils/channelsUtils";
import { deleteProductsStartsWith } from "../../../../support/api/utils/products/productsUtils"; import { deleteProductsStartsWith } from "../../../../support/api/utils/products/productsUtils";
import { deleteShippingStartsWith } from "../../../../support/api/utils/shippingUtils"; import { deleteShippingStartsWith } from "../../../../support/api/utils/shippingUtils";
import { changeWeightUnit } from "../../../../support/pages/shippingMethodPage"; 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 startsWith = "RecalculateWeight";
const name = `${startsWith}${faker.datatype.number()}`; const name = `${startsWith}${faker.datatype.number()}`;
let defaultChannel; let defaultChannel;
let usAddress; let usAddress;
let shippingZone; let shippingZone;
let warehouse;
before(() => { before(() => {
cy.clearSessionData().loginUserViaRequest(); cy.clearSessionData().loginUserViaRequest();
@ -38,14 +41,19 @@ xdescribe("As a staff user I want to change shop default weight unit", () => {
}) })
.then(({ usAddress: usAddressResp }) => { .then(({ usAddress: usAddressResp }) => {
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 => { .then(shippingZoneResp => {
shippingZone = shippingZoneResp; shippingZone = shippingZoneResp;
}); });
}); });
// Log in as user with shipping permissions after resolving SALEOR-3407 bug
it( it(
"should recalculate weight after changing shipping weight unit. TC: SALEOR_0901", "should recalculate weight after changing shipping weight unit. TC: SALEOR_0901",
{ tags: ["@shipping", "@allEnv", "@stable"] }, { tags: ["@shipping", "@allEnv", "@stable"] },
@ -79,9 +87,8 @@ xdescribe("As a staff user I want to change shop default weight unit", () => {
.its("response.body"); .its("response.body");
}) })
.then(responseArray => { .then(responseArray => {
const shippingMethods = responseArray.find( const shippingMethods =
element => element.data.shippingZone, responseArray.data.shippingZone.shippingMethods;
).data.shippingZone.shippingMethods;
const rate = shippingMethods.find( const rate = shippingMethods.find(
element => element.id === shippingMethod.id, element => element.id === shippingMethod.id,
); );

View file

@ -12,7 +12,11 @@ import {
urlList, urlList,
warehouseDetailsUrl, warehouseDetailsUrl,
} from "../../../fixtures/urlList"; } 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 { import {
createWarehouse as createWarehouseViaApi, createWarehouse as createWarehouseViaApi,
getWarehouse, getWarehouse,
@ -20,7 +24,7 @@ import {
import { getDefaultChannel } from "../../../support/api/utils/channelsUtils"; import { getDefaultChannel } from "../../../support/api/utils/channelsUtils";
import { deleteShippingStartsWith } from "../../../support/api/utils/shippingUtils"; import { deleteShippingStartsWith } from "../../../support/api/utils/shippingUtils";
describe("Warehouse settings", () => { describe("As an admin I want to manage warehouses", () => {
const startsWith = "CyWarehouse"; const startsWith = "CyWarehouse";
let usAddress; let usAddress;
let secondUsAddress; let secondUsAddress;
@ -38,7 +42,10 @@ describe("Warehouse settings", () => {
cy.clearSessionData().loginUserViaRequest(); cy.clearSessionData().loginUserViaRequest();
}); });
it("should create warehouse", { tags: ["@warehouse", "@allEnv"] }, () => { it(
"should be able to create warehouse. TC: SALEOR_1101",
{ tags: ["@warehouse", "@allEnv", "@stable"] },
() => {
const name = `${startsWith}${faker.datatype.number()}`; const name = `${startsWith}${faker.datatype.number()}`;
cy.visit(urlList.warehouses) cy.visit(urlList.warehouses)
.get(WAREHOUSES_LIST.createNewButton) .get(WAREHOUSES_LIST.createNewButton)
@ -59,11 +66,12 @@ describe("Warehouse settings", () => {
expect(warehouse.name).to.be.eq(name); expect(warehouse.name).to.be.eq(name);
cy.expectCorrectBasicAddress(addressResp, usAddress); cy.expectCorrectBasicAddress(addressResp, usAddress);
}); });
}); },
);
it( it(
"should add warehouse to shipping zone", "should be able to add warehouse to shipping zone. TC: SALEOR_1102",
{ tags: ["@warehouse", "@allEnv"] }, { tags: ["@warehouse", "@allEnv", "@stable"] },
() => { () => {
const name = `${startsWith}${faker.datatype.number()}`; const name = `${startsWith}${faker.datatype.number()}`;
let defaultChannel; let defaultChannel;
@ -73,6 +81,7 @@ describe("Warehouse settings", () => {
getDefaultChannel() getDefaultChannel()
.then(channelResp => { .then(channelResp => {
defaultChannel = channelResp; defaultChannel = channelResp;
createWarehouseViaApi({ createWarehouseViaApi({
name, name,
address: usAddress, address: usAddress,
@ -80,10 +89,13 @@ describe("Warehouse settings", () => {
}) })
.then(warehouseResp => { .then(warehouseResp => {
warehouse = warehouseResp; warehouse = warehouseResp;
createShippingZone(name, "US", defaultChannel.id);
updateChannelWarehouses(defaultChannel.id, warehouse.id);
createShippingZoneWithoutWarehouse(name, "US", defaultChannel.id);
}) })
.then(shippingZoneResp => { .then(shippingZoneResp => {
shippingZone = shippingZoneResp; shippingZone = shippingZoneResp;
cy.visit(shippingZoneDetailsUrl(shippingZone.id)) cy.visit(shippingZoneDetailsUrl(shippingZone.id))
.fillAutocompleteSelect( .fillAutocompleteSelect(
SHIPPING_ZONE_DETAILS.warehouseSelector, SHIPPING_ZONE_DETAILS.warehouseSelector,
@ -103,7 +115,10 @@ describe("Warehouse settings", () => {
}, },
); );
it("should delete warehouse", { tags: ["@warehouse", "@allEnv"] }, () => { it(
"should be able to delete warehouse. TC: SALEOR_1103",
{ tags: ["@warehouse", "@allEnv", "@stable"] },
() => {
const name = `${startsWith}${faker.datatype.number()}`; const name = `${startsWith}${faker.datatype.number()}`;
createWarehouseViaApi({ createWarehouseViaApi({
name, name,
@ -118,11 +133,12 @@ describe("Warehouse settings", () => {
.waitForRequestAndCheckIfNoErrors("@WarehouseDelete"); .waitForRequestAndCheckIfNoErrors("@WarehouseDelete");
getWarehouse(warehouse.id).should("be.null"); getWarehouse(warehouse.id).should("be.null");
}); });
}); },
);
it( it(
"should remove warehouse from shipping zone", "should be able to remove warehouse from shipping zone. TC: SALEOR_1104",
{ tags: ["@warehouse", "@allEnv"] }, { tags: ["@warehouse", "@allEnv", "@stable"] },
() => { () => {
const name = `${startsWith}${faker.datatype.number()}`; const name = `${startsWith}${faker.datatype.number()}`;
let defaultChannel; let defaultChannel;
@ -132,18 +148,20 @@ describe("Warehouse settings", () => {
getDefaultChannel() getDefaultChannel()
.then(channelResp => { .then(channelResp => {
defaultChannel = 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 => { .then(shippingZoneResp => {
shippingZone = shippingZoneResp; shippingZone = shippingZoneResp;
createWarehouseViaApi({
name,
shippingZone: shippingZone.id,
address: usAddress,
});
})
.then(warehouseResp => {
warehouse = warehouseResp;
cy.visit(shippingZoneDetailsUrl(shippingZone.id)) cy.visit(shippingZoneDetailsUrl(shippingZone.id))
.get(SHIPPING_ZONE_DETAILS.removeWarehouseButton) .get(SHIPPING_ZONE_DETAILS.removeWarehouseButton)
.click() .click()
@ -151,15 +169,17 @@ describe("Warehouse settings", () => {
.get(BUTTON_SELECTORS.confirm) .get(BUTTON_SELECTORS.confirm)
.click() .click()
.waitForRequestAndCheckIfNoErrors("@UpdateShippingZone"); .waitForRequestAndCheckIfNoErrors("@UpdateShippingZone");
getWarehouse(warehouse.id); getWarehouse(warehouse.id).then(warehouseResp => {
})
.then(warehouseResp => {
expect(warehouseResp.shippingZones.edges).to.be.empty; expect(warehouseResp.shippingZones.edges).to.be.empty;
}); });
});
}, },
); );
it("should update warehouse", { tags: ["@warehouse", "@allEnv"] }, () => { it(
"should be able to update warehouse. TC: SALEOR_1105",
{ tags: ["@warehouse", "@allEnv", "@stable"] },
() => {
const name = `${startsWith}${faker.datatype.number()}`; const name = `${startsWith}${faker.datatype.number()}`;
const updatedName = `${startsWith}${faker.datatype.number()}`; const updatedName = `${startsWith}${faker.datatype.number()}`;
let warehouse; let warehouse;
@ -185,5 +205,6 @@ describe("Warehouse settings", () => {
expect(warehouseResp.name).to.be.eq(updatedName); expect(warehouseResp.name).to.be.eq(updatedName);
cy.expectCorrectBasicAddress(addressResp, secondUsAddress); cy.expectCorrectBasicAddress(addressResp, secondUsAddress);
}); });
}); },
);
}); });

View file

@ -5,15 +5,15 @@ export function createShippingRate({
shippingZone, shippingZone,
type = "PRICE", type = "PRICE",
maxWeight, maxWeight,
minWeight minWeight,
}) { }) {
const maxOrderWeight = getValueWithDefault( const maxOrderWeight = getValueWithDefault(
maxWeight, maxWeight,
`maximumOrderWeight: ${maxWeight}` `maximumOrderWeight: ${maxWeight}`,
); );
const minOrderWeight = getValueWithDefault( const minOrderWeight = getValueWithDefault(
minWeight, minWeight,
`minimumOrderWeight: ${minWeight}` `minimumOrderWeight: ${minWeight}`,
); );
const mutation = `mutation{ const mutation = `mutation{
@ -37,10 +37,37 @@ export function createShippingRate({
return cy.sendRequestWithQuery(mutation).its("body.data.shippingPriceCreate"); return cy.sendRequestWithQuery(mutation).its("body.data.shippingPriceCreate");
} }
export function createShippingZone(name, country, channelId) { export function createShippingZone(name, country, channelId, warehouseId) {
const channelsLines = getValueWithDefault( const channelsLines = getValueWithDefault(
channelId, 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{ const mutation = `mutation{
shippingZoneCreate(input:{ shippingZoneCreate(input:{
@ -81,7 +108,7 @@ export function addChannelToShippingMethod(
shippingRateId, shippingRateId,
channelId, channelId,
price, price,
minProductPrice = 0 minProductPrice = 0,
) { ) {
const mutation = `mutation{ const mutation = `mutation{
shippingMethodChannelListingUpdate(id:"${shippingRateId}", input:{ shippingMethodChannelListingUpdate(id:"${shippingRateId}", input:{

View file

@ -14,23 +14,25 @@ export function createShipping({
let shippingZone; let shippingZone;
let warehouse; let warehouse;
return shippingMethodRequest return warehouseRequest
.createShippingZone(name, address.country, channelId) .createWarehouse({
.then(shippingZoneResp => {
shippingZone = shippingZoneResp;
warehouseRequest.createWarehouse({
name, name,
shippingZone: shippingZone.id,
address, address,
});
}) })
.then(warehouseResp => { .then(warehouseResp => {
warehouse = warehouseResp; warehouse = warehouseResp;
updateChannelWarehouses(channelId, warehouse.id); updateChannelWarehouses(channelId, warehouse.id);
shippingMethodRequest
.createShippingZone(name, address.country, channelId, warehouse.id)
.then(shippingZoneResp => {
shippingZone = shippingZoneResp;
shippingMethodRequest.createShippingRate({ shippingMethodRequest.createShippingRate({
name, name,
shippingZone: shippingZone.id, shippingZone: shippingZone.id,
}); });
});
}) })
.then(({ shippingMethod: sippingMethodResp }) => { .then(({ shippingMethod: sippingMethodResp }) => {
shippingMethod = sippingMethodResp; shippingMethod = sippingMethodResp;

View file

@ -1,7 +1,7 @@
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors"; import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
import { import {
selectorWithDataValue, selectorWithDataValue,
SHARED_ELEMENTS SHARED_ELEMENTS,
} from "../../../elements/shared/sharedElements"; } from "../../../elements/shared/sharedElements";
Cypress.Commands.add("createNewOption", (selectSelector, newOption) => { Cypress.Commands.add("createNewOption", (selectSelector, newOption) => {
@ -26,6 +26,7 @@ Cypress.Commands.add("fillMultiSelect", (selectSelector, option) => {
Cypress.Commands.add("fillBaseSelect", (selectSelector, value) => { Cypress.Commands.add("fillBaseSelect", (selectSelector, value) => {
cy.get(selectSelector) cy.get(selectSelector)
.should("not.have.attr", "aria-disabled", "true")
.click() .click()
.get(selectorWithDataValue(value)) .get(selectorWithDataValue(value))
.click(); .click();

View file

@ -9,14 +9,14 @@ export function createShippingZone(
shippingName, shippingName,
warehouseName, warehouseName,
country, country,
channelName channelName,
) { ) {
cy.get(SHIPPING_ZONES_LIST.addShippingZone).click(); cy.get(SHIPPING_ZONES_LIST.addShippingZone).click();
fillUpShippingZoneData({ fillUpShippingZoneData({
shippingName, shippingName,
warehouseName, warehouseName,
country, country,
channelName channelName,
}); });
} }
@ -24,7 +24,7 @@ export function fillUpShippingZoneData({
shippingName, shippingName,
warehouseName, warehouseName,
country, country,
channelName channelName,
}) { }) {
cy.get(SHIPPING_ZONE_DETAILS.nameInput) cy.get(SHIPPING_ZONE_DETAILS.nameInput)
.clearAndType(shippingName) .clearAndType(shippingName)
@ -79,7 +79,7 @@ export function createShippingRate({
rateOption, rateOption,
weightLimits, weightLimits,
deliveryTime, deliveryTime,
priceLimits priceLimits,
}) { }) {
enterAndFillUpShippingRate({ enterAndFillUpShippingRate({
rateName, rateName,
@ -87,7 +87,7 @@ export function createShippingRate({
rateOption, rateOption,
weightLimits, weightLimits,
deliveryTime, deliveryTime,
priceLimits priceLimits,
}); });
return saveRate(); return saveRate();
} }
@ -98,7 +98,7 @@ export function enterAndFillUpShippingRate({
rateOption, rateOption,
weightLimits, weightLimits,
priceLimits, priceLimits,
deliveryTime deliveryTime,
}) { }) {
cy.get(rateOption).click(); cy.get(rateOption).click();
fillUpShippingRate({ fillUpShippingRate({
@ -106,7 +106,7 @@ export function enterAndFillUpShippingRate({
price, price,
weightLimits, weightLimits,
priceLimits, priceLimits,
deliveryTime deliveryTime,
}); });
} }
@ -115,7 +115,7 @@ export function fillUpShippingRate({
price, price,
weightLimits, weightLimits,
priceLimits, priceLimits,
deliveryTime deliveryTime,
}) { }) {
cy.waitForProgressBarToNotBeVisible() cy.waitForProgressBarToNotBeVisible()
.get(SHARED_ELEMENTS.richTextEditor.empty) .get(SHARED_ELEMENTS.richTextEditor.empty)
@ -142,7 +142,7 @@ export function createRateWithPostalCode({
rateOption = rateOptions.PRICE_OPTION, rateOption = rateOptions.PRICE_OPTION,
minPostalCode, minPostalCode,
maxPostalCode, maxPostalCode,
postalCodeOption postalCodeOption,
}) { }) {
enterAndFillUpShippingRate({ rateName, price, rateOption }); enterAndFillUpShippingRate({ rateName, price, rateOption });
cy.get(postalCodeOption) cy.get(postalCodeOption)
@ -195,10 +195,10 @@ export function fillUpDeliveryTime({ min, max }) {
export const rateOptions = { export const rateOptions = {
PRICE_OPTION: SHIPPING_ZONE_DETAILS.addPriceRateButton, PRICE_OPTION: SHIPPING_ZONE_DETAILS.addPriceRateButton,
WEIGHT_OPTION: SHIPPING_ZONE_DETAILS.addWeightRateButton WEIGHT_OPTION: SHIPPING_ZONE_DETAILS.addWeightRateButton,
}; };
export const postalCodesOptions = { export const postalCodesOptions = {
INCLUDE_OPTION: SHIPPING_RATE_DETAILS.includePostalCodesCheckbox, INCLUDE_OPTION: SHIPPING_RATE_DETAILS.includePostalCodesCheckbox,
EXCLUDE_OPTION: SHIPPING_RATE_DETAILS.excludePostalCodesCheckbox EXCLUDE_OPTION: SHIPPING_RATE_DETAILS.excludePostalCodesCheckbox,
}; };