saleor-dashboard/cypress/support/pages/discounts/vouchersPage.js
Karolina Rakoczy 2c64a966cc
Saleor 4437 refactor tests (#1389)
* reference type cypress working

* refactor

* remove screenshots

* add reference

* add slash marker

* run tests based on shop version

* fix run tests based on shop version

* fix run tests based on shop version

* change base url to localhost

* fix plugins

* fix plugins

* fix plugins

* fix plugins

* fix plugins

* fix plugins

* fix yml

* fix yml

* chage file names

* fix files names

* fix broken imports add checking for errors in grpah responses

* fix broken imports add checking for errors in grpah responses

* update jest

* fix snapshot
2021-09-27 12:04:21 +02:00

29 lines
962 B
JavaScript

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