2021-09-27 10:04:21 +00:00
|
|
|
/// <reference types="cypress"/>
|
|
|
|
/// <reference types="../../../support"/>
|
|
|
|
|
2021-07-23 09:46:44 +00:00
|
|
|
import faker from "faker";
|
|
|
|
|
|
|
|
import { SHARED_ELEMENTS } from "../../../elements/shared/sharedElements";
|
|
|
|
import { SHIPPING_ZONE_DETAILS } from "../../../elements/shipping/shipping-zone-details";
|
2021-09-27 10:04:21 +00:00
|
|
|
import { ONE_PERMISSION_USERS } from "../../../fixtures/users";
|
|
|
|
import { createChannel } from "../../../support/api/requests/Channels";
|
2021-09-10 08:59:46 +00:00
|
|
|
import {
|
2021-09-27 10:04:21 +00:00
|
|
|
addChannelToShippingMethod,
|
|
|
|
addChannelToShippingZone
|
|
|
|
} from "../../../support/api/requests/ShippingMethod";
|
|
|
|
import * as channelsUtils from "../../../support/api/utils/channelsUtils";
|
|
|
|
import * as shippingUtils from "../../../support/api/utils/shippingUtils";
|
2021-07-23 09:46:44 +00:00
|
|
|
import filterTests from "../../../support/filterTests";
|
2022-04-11 08:20:26 +00:00
|
|
|
import { selectChannelInHeader } from "../../../support/pages/channelsPage";
|
2022-02-11 15:08:45 +00:00
|
|
|
import {
|
|
|
|
enterAndSelectShippings,
|
|
|
|
enterShippingZone
|
|
|
|
} from "../../../support/pages/shippingZones";
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2021-09-27 10:04:21 +00:00
|
|
|
filterTests({ definedTags: ["all"] }, () => {
|
2022-02-11 15:08:45 +00:00
|
|
|
describe("As a staff user I want have different shipping method prices for each channel", () => {
|
2021-07-23 09:46:44 +00:00
|
|
|
const startsWith = "ChannelShippingMethod";
|
|
|
|
let defaultChannel;
|
|
|
|
|
|
|
|
before(() => {
|
|
|
|
cy.clearSessionData().loginUserViaRequest();
|
|
|
|
shippingUtils.deleteShippingStartsWith(startsWith);
|
|
|
|
channelsUtils.deleteChannelsStartsWith(startsWith);
|
|
|
|
});
|
|
|
|
|
2022-02-11 15:08:45 +00:00
|
|
|
it("should be able to display different price for each channel. TC: SALEOR_0805", () => {
|
2021-07-23 09:46:44 +00:00
|
|
|
const shippingName = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
const defaultChannelPrice = 11;
|
|
|
|
const createdChannelPrice = 7;
|
|
|
|
const createdChannelCurrency = "PLN";
|
|
|
|
|
|
|
|
let shippingMethod;
|
|
|
|
let shippingZone;
|
|
|
|
let createdChannel;
|
|
|
|
|
|
|
|
cy.clearSessionData().loginUserViaRequest();
|
2022-04-11 08:20:26 +00:00
|
|
|
|
2021-07-23 09:46:44 +00:00
|
|
|
createChannel({
|
|
|
|
name: shippingName,
|
|
|
|
currencyCode: createdChannelCurrency
|
2022-04-11 08:20:26 +00:00
|
|
|
}).then(channel => {
|
|
|
|
createdChannel = channel;
|
|
|
|
});
|
|
|
|
|
|
|
|
shippingUtils
|
|
|
|
.createShippingWithDefaultChannel(shippingName, defaultChannelPrice)
|
2021-07-23 09:46:44 +00:00
|
|
|
.then(
|
|
|
|
({
|
|
|
|
shippingMethod: shippingMethodResp,
|
2022-04-11 08:20:26 +00:00
|
|
|
shippingZone: shippingZoneResp,
|
|
|
|
defaultChannel: defaultChannelResp
|
2021-07-23 09:46:44 +00:00
|
|
|
}) => {
|
|
|
|
shippingZone = shippingZoneResp;
|
|
|
|
shippingMethod = shippingMethodResp;
|
2022-04-11 08:20:26 +00:00
|
|
|
defaultChannel = defaultChannelResp;
|
|
|
|
|
2021-07-23 09:46:44 +00:00
|
|
|
addChannelToShippingZone(shippingZone.id, createdChannel.id).then(
|
|
|
|
() => {
|
|
|
|
addChannelToShippingMethod(
|
|
|
|
shippingMethod.id,
|
|
|
|
createdChannel.id,
|
|
|
|
createdChannelPrice
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
)
|
|
|
|
.then(() => {
|
2022-02-11 15:08:45 +00:00
|
|
|
cy.clearSessionData().loginUserViaRequest(
|
|
|
|
"auth",
|
|
|
|
ONE_PERMISSION_USERS.shipping
|
|
|
|
);
|
|
|
|
enterAndSelectShippings(shippingZone.id, enterShippingZone);
|
2022-04-11 08:20:26 +00:00
|
|
|
selectChannelInHeader(defaultChannel.name);
|
2021-09-27 10:04:21 +00:00
|
|
|
cy.waitForProgressBarToNotBeVisible()
|
|
|
|
.get(SHARED_ELEMENTS.skeleton)
|
|
|
|
.should("not.exist")
|
|
|
|
.getTextFromElement(
|
|
|
|
SHIPPING_ZONE_DETAILS.shippingRatePriceTableCell
|
|
|
|
)
|
2021-07-23 09:46:44 +00:00
|
|
|
.then(text => {
|
2022-04-11 08:20:26 +00:00
|
|
|
const value = defaultChannelPrice
|
|
|
|
.toFixed(2)
|
|
|
|
.toString()
|
|
|
|
.split(".");
|
|
|
|
const valueRegex = new RegExp(value.join("(.|,)"));
|
|
|
|
expect(text).to.match(valueRegex);
|
|
|
|
expect(text).to.includes(defaultChannel.currencyCode);
|
|
|
|
selectChannelInHeader(createdChannel.name);
|
2021-09-27 10:04:21 +00:00
|
|
|
cy.waitForProgressBarToNotBeVisible()
|
|
|
|
.get(SHARED_ELEMENTS.skeleton)
|
|
|
|
.should("not.exist");
|
2021-07-23 09:46:44 +00:00
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
cy.getTextFromElement(
|
|
|
|
SHIPPING_ZONE_DETAILS.shippingRatePriceTableCell
|
|
|
|
);
|
|
|
|
})
|
|
|
|
.then(text => {
|
2022-04-11 08:20:26 +00:00
|
|
|
const value = createdChannelPrice
|
|
|
|
.toFixed(2)
|
|
|
|
.toString()
|
|
|
|
.split(".");
|
|
|
|
const valueRegex = new RegExp(value.join("(.|,)"));
|
|
|
|
expect(text).to.match(valueRegex);
|
|
|
|
expect(text).to.includes(createdChannelCurrency);
|
2021-07-23 09:46:44 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|