2022-01-14 10:08:25 +00:00
|
|
|
// / <reference types="cypress"/>
|
|
|
|
// / <reference types="../../../support"/>
|
|
|
|
|
|
|
|
import faker from "faker";
|
|
|
|
|
2022-02-11 15:08:45 +00:00
|
|
|
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
|
2022-01-14 10:08:25 +00:00
|
|
|
import { shippingZoneDetailsUrl } from "../../../fixtures/urlList";
|
|
|
|
import {
|
|
|
|
createShippingZone,
|
2022-06-27 16:49:35 +00:00
|
|
|
getShippingZone,
|
2022-01-14 10:08:25 +00:00
|
|
|
} 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 { fillUpShippingZoneData } from "../../../support/pages/shippingMethodPage";
|
2022-02-11 15:08:45 +00:00
|
|
|
import { enterAndSelectShippings } from "../../../support/pages/shippingZones";
|
2022-01-14 10:08:25 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
describe("As a user I should be able to update and delete shipping zone", () => {
|
|
|
|
const startsWith = "EditShipping-";
|
|
|
|
const name = `${startsWith}${faker.datatype.number()}`;
|
2022-01-14 10:08:25 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
let defaultChannel;
|
|
|
|
let shippingZone;
|
|
|
|
let plAddress;
|
2022-01-14 10:08:25 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
before(() => {
|
|
|
|
cy.clearSessionData().loginUserViaRequest();
|
|
|
|
deleteShippingStartsWith(startsWith);
|
2022-01-14 10:08:25 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
getDefaultChannel()
|
|
|
|
.then(channel => {
|
|
|
|
defaultChannel = channel;
|
|
|
|
cy.fixture("addresses");
|
|
|
|
})
|
|
|
|
.then(addresses => {
|
|
|
|
plAddress = addresses.plAddress;
|
|
|
|
createWarehouse({ name, address: plAddress });
|
|
|
|
});
|
|
|
|
});
|
2022-01-14 10:08:25 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
const rateName = `${startsWith}${faker.datatype.number()}`;
|
2022-01-14 10:08:25 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
cy.clearSessionData().loginUserViaRequest();
|
|
|
|
createShippingZone(name, "US", defaultChannel.id).then(shippingZoneResp => {
|
|
|
|
shippingZone = shippingZoneResp;
|
2022-01-14 10:08:25 +00:00
|
|
|
});
|
2022-06-27 09:30:51 +00:00
|
|
|
});
|
2022-01-14 10:08:25 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
it(
|
|
|
|
"should be able to update shipping zone. TC: SALEOR_0808",
|
|
|
|
{ tags: ["@shipping", "@allEnv"] },
|
|
|
|
() => {
|
2022-01-14 10:08:25 +00:00
|
|
|
const updatedName = `${startsWith}Updated`;
|
|
|
|
|
|
|
|
cy.visit(shippingZoneDetailsUrl(shippingZone.id));
|
|
|
|
fillUpShippingZoneData({
|
|
|
|
channelName: defaultChannel.name,
|
|
|
|
country: "Poland",
|
|
|
|
shippingName: updatedName,
|
2022-06-27 16:49:35 +00:00
|
|
|
warehouseName: name,
|
2022-01-14 10:08:25 +00:00
|
|
|
});
|
|
|
|
getShippingZone(shippingZone.id).then(shippingZone => {
|
2022-06-27 09:30:51 +00:00
|
|
|
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);
|
2022-01-14 10:08:25 +00:00
|
|
|
expect(shippingZone.countries.find(el => el.code === "PL")).to.be.ok;
|
|
|
|
});
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
2022-01-14 10:08:25 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
it(
|
|
|
|
"should be able to delete shipping zone. TC: SALEOR_0809",
|
|
|
|
{ tags: ["@shipping", "@allEnv"] },
|
|
|
|
() => {
|
2022-01-14 10:08:25 +00:00
|
|
|
cy.visit(
|
2022-06-27 16:49:35 +00:00
|
|
|
shippingZoneDetailsUrl(shippingZone.id),
|
2022-01-14 10:08:25 +00:00
|
|
|
).deleteElementWithReqAlias("DeleteShippingZone");
|
|
|
|
getShippingZone(shippingZone.id).should("be.null");
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
2022-02-11 15:08:45 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
it(
|
|
|
|
"should be able to delete several shipping zones on shipping zones list page. TC: SALEOR_0810",
|
|
|
|
{ tags: ["@shipping", "@allEnv"] },
|
|
|
|
() => {
|
2022-02-11 15:08:45 +00:00
|
|
|
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");
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-02-11 15:08:45 +00:00
|
|
|
);
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
2022-01-14 10:08:25 +00:00
|
|
|
});
|