saleor-dashboard/cypress/apiRequests/Attribute.js
Karolina Rakoczy 074c0f7a6c
Saleor 2960 checkout products without shipment (#1075)
* add tests for puchase by type

* add expect for isShippingRequired
2021-04-28 15:10:47 +02:00

54 lines
1.1 KiB
JavaScript

export function createAttribute(name, attributeValues = ["value"]) {
const values = attributeValues.map(element => `{name:"${element}"}`);
const mutation = `mutation{
attributeCreate(input:{
name:"${name}"
valueRequired:false
type:PRODUCT_TYPE
values: [${values}]
}){
attribute{
id
name
values{name}
}
attributeErrors{
field
message
}
}
}`;
return cy
.sendRequestWithQuery(mutation)
.its("body.data.attributeCreate.attribute");
}
export function getAttributes(first, search) {
const mutation = `query{
attributes(first:${first}, filter:{
search:"${search}"
}){
edges{
node{
id
name
}
}
}
}`;
return cy
.sendRequestWithQuery(mutation)
.then(resp => resp.body.data.attributes.edges);
}
export function deleteAttribute(attributeId) {
const mutation = `mutation{
attributeDelete(id:"${attributeId}"){
attributeErrors{
field
message
}
}
}`;
return cy.sendRequestWithQuery(mutation);
}