saleor-dashboard/cypress/apiRequests/Category.js
Karolina fc597a7a7f
Saleor 2590 remove classes from cypress tests (#1003)
* remove classes in shipping & products utils

* remove classes

* add const

* remove getters in ProductsUtils

* remove getters in Utils

* remove getters in Utils
2021-03-12 13:14:18 +01:00

42 lines
1.2 KiB
JavaScript

export function createCategory(name, slug = name) {
const mutation = `mutation{
categoryCreate(input:{name:"${name}", slug: "${slug}"}){
productErrors{
field
message
}
category{
id
}
}
}`;
return cy.sendRequestWithQuery(mutation);
}
export function getCategories(first, search) {
const mutation = `query{
categories(first:${first}, filter:{
search:"${search}"
}){
edges{
node{
id
name
}
}
}
}`;
return cy
.sendRequestWithQuery(mutation)
.then(resp => resp.body.data.categories.edges);
}
export function deleteCategory(categoryId) {
const mutation = `mutation{
categoryDelete(id:"${categoryId}"){
productErrors{
field
message
}
}
}`;
return cy.sendRequestWithQuery(mutation);
}