2021-03-23 10:15:39 +00:00
|
|
|
import { VOUCHERS_SELECTORS } from "../../elements/discounts/vouchers";
|
|
|
|
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
|
|
|
import { selectChannelInDetailsPages } from "../channelsSteps";
|
2021-07-26 09:58:47 +00:00
|
|
|
import { confirmationMessageShouldDisappear } from "../shared/confirmationMessages";
|
2021-03-23 10:15:39 +00:00
|
|
|
|
|
|
|
export const discountOptions = {
|
|
|
|
PERCENTAGE: VOUCHERS_SELECTORS.percentageDiscountRadioButton,
|
|
|
|
FIXED: VOUCHERS_SELECTORS.fixedDiscountRadioButton,
|
|
|
|
SHIPPING: VOUCHERS_SELECTORS.shippingDiscountRadioButton
|
|
|
|
};
|
|
|
|
|
|
|
|
export function createVoucher({
|
|
|
|
voucherCode,
|
|
|
|
voucherValue,
|
|
|
|
discountOption,
|
|
|
|
channelName
|
|
|
|
}) {
|
|
|
|
cy.get(VOUCHERS_SELECTORS.createVoucherButton).click();
|
|
|
|
selectChannelInDetailsPages(channelName);
|
|
|
|
cy.get(VOUCHERS_SELECTORS.voucherCodeInput)
|
|
|
|
.type(voucherCode)
|
|
|
|
.get(discountOption)
|
|
|
|
.click();
|
|
|
|
if (discountOption !== discountOptions.SHIPPING) {
|
|
|
|
cy.get(VOUCHERS_SELECTORS.discountValueInputs).type(voucherValue);
|
|
|
|
}
|
|
|
|
cy.get(BUTTON_SELECTORS.confirm).click();
|
2021-07-15 09:20:59 +00:00
|
|
|
confirmationMessageShouldDisappear();
|
2021-03-23 10:15:39 +00:00
|
|
|
}
|