saleor-dashboard/cypress/apiRequests/Checkout.js
Karolina 746ce8b95f
Saleor 1745 tests for discounts sales (#998)
* test plan for sales - discounts

* create sale

* passing tests for sales

* tests for collections

* remove eslint diable in sales tests

* remove eslint-disable

* move shared selectors

* move shared selectors

* fix indentation in requests

* add formatDate function

* remove moment

* remove moment
2021-03-12 15:57:02 +01:00

71 lines
1.5 KiB
JavaScript

export function createCheckout(
channelSlug,
email,
productQuantity,
variantsList
) {
const lines = variantsList.map(
variant => `{quantity:${productQuantity}
variantId:"${variant.id}"}`
);
const mutation = `mutation{
checkoutCreate(input:{
channel:"${channelSlug}"
email:"${email}"
lines: [${lines.join()}]
}){
checkoutErrors{
field
message
}
created
checkout{
id
}
}
}`;
return cy.sendRequestWithQuery(mutation);
}
export function addShippingMethod(checkoutId, shippingMethodId) {
const mutation = `mutation{
checkoutShippingMethodUpdate(checkoutId:"${checkoutId}",
shippingMethodId:"${shippingMethodId}"){
checkoutErrors{
message
field
}
}
}`;
return cy.sendRequestWithQuery(mutation);
}
export function addPayment(checkoutId, gateway, token) {
const mutation = `mutation{
checkoutPaymentCreate(checkoutId:"${checkoutId}",
input:{
gateway: "${gateway}"
token:"${token}"
}){
paymentErrors{
field
message
}
}
}`;
return cy.sendRequestWithQuery(mutation);
}
export function completeCheckout(checkoutId) {
const mutation = `mutation{
checkoutComplete(checkoutId:"${checkoutId}"){
order{
id
}
confirmationNeeded
confirmationData
checkoutErrors{
field
message
}
}
}`;
return cy.sendRequestWithQuery(mutation);
}