saleor-dashboard/cypress/apiRequests/Attribute.js

56 lines
1.4 KiB
JavaScript
Raw Normal View History

2021-02-04 11:15:27 +00:00
class Attribute {
2021-02-26 15:39:42 +00:00
createAttribute(name, attributeValues = ["value"]) {
attributeValues = attributeValues.map(element => `{name:"${element}"}`);
2021-02-04 11:15:27 +00:00
const mutation = `mutation{
attributeCreate(input:{
name:"${name}"
valueRequired:false
type:PRODUCT_TYPE
2021-02-26 15:39:42 +00:00
values: [${attributeValues}]
2021-02-04 11:15:27 +00:00
}){
attribute{
id
2021-02-25 09:51:52 +00:00
name
values{name}
2021-02-04 11:15:27 +00:00
}
attributeErrors{
field
message
}
}
}`;
return cy.sendRequestWithQuery(mutation);
}
getAttributes(first, search) {
const mutation = `query{
attributes(first:${first}, filter:{
search:"${search}"
}){
edges{
node{
id
name
2021-02-04 11:15:27 +00:00
}
}
}
}`;
2021-02-16 14:19:46 +00:00
return cy
.sendRequestWithQuery(mutation)
.then(resp => resp.body.data.attributes.edges);
2021-02-04 11:15:27 +00:00
}
deleteAttribute(attributeId) {
const mutation = `mutation{
attributeDelete(id:"${attributeId}"){
attributeErrors{
field
message
2021-02-04 11:15:27 +00:00
}
}
}`;
2021-02-04 11:15:27 +00:00
return cy.sendRequestWithQuery(mutation);
}
}
export default Attribute;