
* 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
54 lines
1 KiB
JavaScript
54 lines
1 KiB
JavaScript
export function createCollection(name, slug = name) {
|
|
const mutation = `mutation {
|
|
collectionCreate(input:{
|
|
name:"${name}",
|
|
slug:"${name}"
|
|
}){
|
|
collectionErrors{
|
|
field
|
|
message
|
|
}
|
|
collection{
|
|
name
|
|
id
|
|
}
|
|
}
|
|
}`;
|
|
return cy
|
|
.sendRequestWithQuery(mutation)
|
|
.its("body.data.collectionCreate.collection");
|
|
}
|
|
export function getCollections(search) {
|
|
const filter = search
|
|
? `, filter:{
|
|
search:""
|
|
}`
|
|
: "";
|
|
const query = `query{
|
|
collections(first:100 ${filter}){
|
|
edges{
|
|
node{
|
|
id
|
|
name
|
|
}
|
|
}
|
|
}
|
|
}`;
|
|
return cy
|
|
.sendRequestWithQuery(query)
|
|
.then(resp => resp.body.data.collections.edges);
|
|
}
|
|
export function deleteCollection(collectionId) {
|
|
const mutation = `mutation{
|
|
collectionDelete(id:"${collectionId}"){
|
|
collection{
|
|
id
|
|
}
|
|
collectionErrors{
|
|
field
|
|
message
|
|
}
|
|
}
|
|
}`;
|
|
return cy.sendRequestWithQuery(mutation);
|
|
}
|