2021-03-12 12:14:18 +00:00
|
|
|
export function createAttribute(name, attributeValues = ["value"]) {
|
|
|
|
const values = attributeValues.map(element => `{name:"${element}"}`);
|
|
|
|
const mutation = `mutation{
|
2021-03-12 14:57:02 +00:00
|
|
|
attributeCreate(input:{
|
|
|
|
name:"${name}"
|
|
|
|
valueRequired:false
|
|
|
|
type:PRODUCT_TYPE
|
|
|
|
values: [${values}]
|
|
|
|
}){
|
|
|
|
attribute{
|
|
|
|
id
|
|
|
|
name
|
2021-06-08 06:58:36 +00:00
|
|
|
choices(first: 100){
|
|
|
|
edges{
|
|
|
|
node{
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-03-12 14:57:02 +00:00
|
|
|
}
|
|
|
|
attributeErrors{
|
|
|
|
field
|
|
|
|
message
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}`;
|
2021-04-28 13:10:47 +00:00
|
|
|
return cy
|
|
|
|
.sendRequestWithQuery(mutation)
|
|
|
|
.its("body.data.attributeCreate.attribute");
|
2021-03-12 12:14:18 +00:00
|
|
|
}
|
2021-02-04 11:15:27 +00:00
|
|
|
|
2021-03-12 12:14:18 +00:00
|
|
|
export function getAttributes(first, search) {
|
|
|
|
const mutation = `query{
|
2021-03-12 14:57:02 +00:00
|
|
|
attributes(first:${first}, filter:{
|
|
|
|
search:"${search}"
|
|
|
|
}){
|
|
|
|
edges{
|
|
|
|
node{
|
|
|
|
id
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}`;
|
2021-03-12 12:14:18 +00:00
|
|
|
return cy
|
|
|
|
.sendRequestWithQuery(mutation)
|
|
|
|
.then(resp => resp.body.data.attributes.edges);
|
|
|
|
}
|
2021-02-04 11:15:27 +00:00
|
|
|
|
2021-03-12 12:14:18 +00:00
|
|
|
export function deleteAttribute(attributeId) {
|
|
|
|
const mutation = `mutation{
|
2021-03-12 14:57:02 +00:00
|
|
|
attributeDelete(id:"${attributeId}"){
|
|
|
|
attributeErrors{
|
|
|
|
field
|
|
|
|
message
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}`;
|
2021-03-12 12:14:18 +00:00
|
|
|
return cy.sendRequestWithQuery(mutation);
|
2021-02-04 11:15:27 +00:00
|
|
|
}
|