saleor-dashboard/cypress/support/api/utils/discounts/vouchersUtils.js

29 lines
629 B
JavaScript
Raw Normal View History

import {
addChannelToVoucher,
createVoucher,
deleteVouchers,
getVouchers
} from "../../requests/Discounts/Vouchers";
export function deleteVouchersStartsWith(startsWith) {
cy.deleteElementsStartsWith(deleteVouchers, getVouchers, startsWith, "code");
}
export function createVoucherInChannel({
name,
productId,
channelId,
value,
code = name,
type,
country
}) {
let voucher;
return createVoucher({ name, productId, code, type, country })
.then(({ voucher: voucherResp }) => {
voucher = voucherResp;
addChannelToVoucher(voucher.id, channelId, value);
})
.then(() => voucher);
}