saleor-dashboard/cypress/support/api/requests/utils/index.js
Karolina Rakoczy 2b3c566e09
Update cypress version (#3053)
* 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
2023-01-27 16:27:49 +01:00

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);
}
});
},
);