
* 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
84 lines
1.7 KiB
JavaScript
84 lines
1.7 KiB
JavaScript
import { getDefaultAddress, getValueWithDefault } from "./utils/Utils";
|
|
|
|
export function createWarehouse({ name, shippingZone, address, slug = name }) {
|
|
const shippingZoneLine = getValueWithDefault(
|
|
shippingZone,
|
|
`shippingZones:"${shippingZone}"`
|
|
);
|
|
const mutation = `mutation{
|
|
createWarehouse(input:{
|
|
name:"${name}"
|
|
slug:"${slug}"
|
|
${shippingZoneLine}
|
|
${getDefaultAddress(address, "address", false)}
|
|
}){
|
|
warehouseErrors{
|
|
field
|
|
message
|
|
}
|
|
warehouse{
|
|
id
|
|
name
|
|
}
|
|
}
|
|
}`;
|
|
return cy
|
|
.sendRequestWithQuery(mutation)
|
|
.its("body.data.createWarehouse.warehouse");
|
|
}
|
|
|
|
export function getWarehouses(first, search) {
|
|
const query = `query{
|
|
warehouses(first:${first}, filter:{
|
|
search:"${search}"
|
|
}){
|
|
edges{
|
|
node{
|
|
id
|
|
name
|
|
}
|
|
}
|
|
}
|
|
}`;
|
|
return cy
|
|
.sendRequestWithQuery(query)
|
|
.then(resp => resp.body.data.warehouses.edges);
|
|
}
|
|
|
|
export function deleteWarehouse(warehouseId) {
|
|
const mutation = `mutation{
|
|
deleteWarehouse(id:"${warehouseId}"){
|
|
warehouseErrors{
|
|
field
|
|
message
|
|
}
|
|
}
|
|
}`;
|
|
return cy.sendRequestWithQuery(mutation);
|
|
}
|
|
|
|
export function getWarehouse(warehouseId) {
|
|
const query = `query{
|
|
warehouse(id:"${warehouseId}"){
|
|
id
|
|
name
|
|
address{
|
|
companyName
|
|
streetAddress1
|
|
streetAddress2
|
|
city
|
|
postalCode
|
|
countryArea
|
|
phone
|
|
}
|
|
shippingZones(first:100){
|
|
edges{
|
|
node{
|
|
id
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}`;
|
|
return cy.sendRequestWithQuery(query).its("body.data.warehouse");
|
|
}
|