
* Adding missing test to collections tests * Adding missing test to collections tests * fixing merge issues * fixing merge issues * update to test-env-deploy * update to test-env-deploy * changing test-env-deploy * adding sugestions * fixing what Karolina suggested * pulling from main
70 lines
1.4 KiB
JavaScript
70 lines
1.4 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(first, search) {
|
|
const filter = search
|
|
? `, filter:{
|
|
search:"${search}"
|
|
}`
|
|
: "";
|
|
const query = `query{
|
|
collections(first:${first} ${filter}){
|
|
edges{
|
|
node{
|
|
id
|
|
name
|
|
slug
|
|
}
|
|
}
|
|
}
|
|
}`;
|
|
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);
|
|
}
|
|
|
|
export function addProductToCollection({ collectionId, productId }) {
|
|
const mutation = `mutation addProduct {
|
|
collectionAddProducts(
|
|
collectionId: "${collectionId}"
|
|
products: ["${productId}"]
|
|
) {
|
|
errors {
|
|
message
|
|
}
|
|
}
|
|
}`;
|
|
return cy.sendRequestWithQuery(mutation);
|
|
}
|