
* update cypress * Fix clearAndtypeCommand * Fix selects * Fix attribute query, and logging errored responses * Fix mailhog commands * Fix mailhog * Fix for warehouses * fix tests for plugins and sku * Fix creating variants * Fix plugins * move cypress to optionalDependencies * move cypress to optionalDependencies
37 lines
905 B
JavaScript
37 lines
905 B
JavaScript
// / <reference types="cypress" />
|
|
|
|
import { urlList } from "../../../../fixtures/urlList";
|
|
|
|
Cypress.Commands.add(
|
|
"sendRequestWithQuery",
|
|
(query, authorization = "auth", variables = "") => {
|
|
let headers;
|
|
|
|
if (authorization && authorization.length !== 30) {
|
|
headers = {
|
|
Authorization: `JWT ${window.sessionStorage.getItem(authorization)}`,
|
|
};
|
|
} else if (authorization) {
|
|
headers = { Authorization: `Bearer ${authorization}` };
|
|
} else {
|
|
headers = {};
|
|
}
|
|
|
|
cy.request({
|
|
body: {
|
|
variables,
|
|
query,
|
|
},
|
|
headers,
|
|
method: "POST",
|
|
url: urlList.apiUri,
|
|
log: true,
|
|
}).then(response => {
|
|
const respInSting = JSON.stringify(response.body);
|
|
if (respInSting.includes(`"errors":[{`)) {
|
|
cy.log(query).log(JSON.stringify(response.body));
|
|
cy.wrap(response);
|
|
}
|
|
});
|
|
},
|
|
);
|