
* test plan for sales - discounts * create sale * passing tests for sales * tests for collections * remove eslint diable in sales tests * remove eslint-disable * move shared selectors * move shared selectors * fix indentation in requests * add formatDate function * remove moment * remove moment
52 lines
1 KiB
JavaScript
52 lines
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);
|
|
}
|
|
|
|
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);
|
|
}
|