2022-01-14 10:08:25 +00:00
|
|
|
// / <reference types="cypress"/>
|
|
|
|
// / <reference types="../../../support"/>
|
|
|
|
|
|
|
|
import faker from "faker";
|
|
|
|
|
2022-03-15 08:02:32 +00:00
|
|
|
import { shippingRateUrl } from "../../../fixtures/urlList";
|
2022-01-14 10:08:25 +00:00
|
|
|
import {
|
|
|
|
addChannelToShippingMethod,
|
|
|
|
createShippingRate,
|
|
|
|
createShippingZone,
|
2022-06-27 16:49:35 +00:00
|
|
|
getShippingZone,
|
2022-01-14 10:08:25 +00:00
|
|
|
} from "../../../support/api/requests/ShippingMethod";
|
|
|
|
import { getDefaultChannel } from "../../../support/api/utils/channelsUtils";
|
|
|
|
import { deleteShippingStartsWith } from "../../../support/api/utils/shippingUtils";
|
|
|
|
import {
|
|
|
|
fillUpShippingRate,
|
2022-06-27 16:49:35 +00:00
|
|
|
saveRateAfterUpdate,
|
2022-01-14 10:08:25 +00:00
|
|
|
} from "../../../support/pages/shippingMethodPage";
|
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
describe("As a user I should be able to update and delete shipping method", () => {
|
|
|
|
const startsWith = "EditShipping-";
|
|
|
|
const name = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
const price = 10;
|
2022-01-14 10:08:25 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
let defaultChannel;
|
|
|
|
let shippingZone;
|
|
|
|
let shippingMethod;
|
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;
|
|
|
|
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
|
|
|
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();
|
|
|
|
createShippingRate({
|
|
|
|
name: rateName,
|
2022-06-27 16:49:35 +00:00
|
|
|
shippingZone: shippingZone.id,
|
2022-06-27 09:30:51 +00:00
|
|
|
}).then(({ shippingMethod: shippingResp }) => {
|
|
|
|
shippingMethod = shippingResp;
|
|
|
|
addChannelToShippingMethod(shippingMethod.id, defaultChannel.id, 1);
|
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 rate. TC: SALEOR_0806",
|
|
|
|
{ tags: ["@shipping", "@allEnv", "@stable"] },
|
|
|
|
() => {
|
2022-01-14 10:08:25 +00:00
|
|
|
const updatedRateName = `${startsWith}Updated`;
|
|
|
|
const deliveryTime = { min: 1, max: 7 };
|
|
|
|
|
2022-03-15 08:02:32 +00:00
|
|
|
cy.visit(shippingRateUrl(shippingZone.id, shippingMethod.id));
|
2022-01-14 10:08:25 +00:00
|
|
|
fillUpShippingRate({
|
|
|
|
rateName: updatedRateName,
|
|
|
|
price,
|
2022-06-27 16:49:35 +00:00
|
|
|
deliveryTime,
|
2022-01-14 10:08:25 +00:00
|
|
|
});
|
|
|
|
saveRateAfterUpdate();
|
|
|
|
getShippingZone(shippingZone.id).then(({ shippingMethods }) => {
|
|
|
|
expect(shippingMethods).to.have.length(1);
|
2022-06-27 09:30:51 +00:00
|
|
|
expect(shippingMethods[0].minimumDeliveryDays).to.be.eq(
|
2022-06-27 16:49:35 +00:00
|
|
|
deliveryTime.min,
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
|
|
|
expect(shippingMethods[0].maximumDeliveryDays).to.be.eq(
|
2022-06-27 16:49:35 +00:00
|
|
|
deliveryTime.max,
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
|
|
|
expect(shippingMethods[0].channelListings[0].price.amount).to.be.eq(
|
2022-06-27 16:49:35 +00:00
|
|
|
price,
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
2022-01-14 10:08:25 +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
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
it(
|
|
|
|
"should be able to delete shipping rate. TC: SALEOR_0807",
|
|
|
|
{ tags: ["@shipping", "@allEnv", "@stable"] },
|
|
|
|
() => {
|
2022-01-14 10:08:25 +00:00
|
|
|
cy.visit(
|
2022-06-27 16:49:35 +00:00
|
|
|
shippingRateUrl(shippingZone.id, shippingMethod.id),
|
2022-01-14 10:08:25 +00:00
|
|
|
).deleteElementWithReqAlias("DeleteShippingRate");
|
|
|
|
getShippingZone(shippingZone.id).then(({ shippingMethods }) => {
|
|
|
|
const deletedShipping = shippingMethods.find(
|
2022-06-27 16:49:35 +00:00
|
|
|
element => element.id === shippingMethod.id,
|
2022-01-14 10:08:25 +00:00
|
|
|
);
|
|
|
|
expect(deletedShipping).to.be.not.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
|
|
|
});
|