saleor-dashboard/cypress/apiRequests/Collections.js
Karolina 2173e241b5
Saleor 2692 tests for filtering products (#1055)
* test for filtering products

* tests for filters

* change filter input selector

* change filter input selector

* change filter input selector

* add data-test-id
2021-04-12 17:22:12 +02:00

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);
}