saleor-dashboard/cypress/apiRequests/ShippingMethod.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

77 lines
1.6 KiB
JavaScript

export function createShippingRate(name, shippingZone) {
const mutation = `mutation{
shippingPriceCreate(input:{
name: "${name}"
shippingZone: "${shippingZone}"
type: PRICE
}){
shippingMethod{
id
}
}
}`;
return cy.sendRequestWithQuery(mutation);
}
export function createShippingZone(name, country) {
const mutation = `mutation{
shippingZoneCreate(input:{
name: "${name}"
countries: "${country}"
}){
shippingZone{
id
}
}
}`;
return cy.sendRequestWithQuery(mutation);
}
export function addChannelToShippingMethod(shippingRateId, channelId, price) {
const mutation = `mutation{
shippingMethodChannelListingUpdate(id:"${shippingRateId}", input:{
addChannels: {
channelId:"${channelId}"
price: ${price}
}
}){
shippingMethod{
id
}
shippingErrors{
code
message
}
}
}`;
return cy.sendRequestWithQuery(mutation);
}
export function deleteShippingZone(shippingZoneId) {
const mutation = `mutation{
shippingZoneDelete(id:"${shippingZoneId}"){
shippingErrors{
message
}
}
}
`;
return cy.sendRequestWithQuery(mutation);
}
export function getShippingZones() {
const query = `query{
shippingZones(first:100){
edges{
node{
name
id
}
}
}
}
`;
return cy
.sendRequestWithQuery(query)
.then(resp => resp.body.data.shippingZones.edges);
}