saleor-dashboard/cypress/steps/discounts/vouchersSteps.js
Karolina Rakoczy 5e7dc8e2a5
fixed all tests (#1253)
* fixed all tests

* fix shipping weight tests

* fix create product

* delete users created in previous tests

* merge
2021-07-26 11:58:47 +02:00

29 lines
1 KiB
JavaScript

import { VOUCHERS_SELECTORS } from "../../elements/discounts/vouchers";
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
import { selectChannelInDetailsPages } from "../channelsSteps";
import { confirmationMessageShouldDisappear } from "../shared/confirmationMessages";
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();
confirmationMessageShouldDisappear();
}