saleor-dashboard/cypress/apiRequests/ShippingMethod.js
Karolina 588175df30
Saleor 1737 tests for shipping methods (#1013)
* remove classes in shipping & products utils

* remove classes

* add tests plans

* add const

* tests for shipping methods

* test for shipping

* test for shipping

* tests for shipping

* install eslint-plugin-chai-friendly

* update stories

* add missing imports
2021-04-02 13:01:38 +02:00

78 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
name
}
}
}`;
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);
}