2020-08-20 13:36:00 +00:00
|
|
|
import "./user";
|
2021-02-12 08:54:52 +00:00
|
|
|
import "./frontShop";
|
2020-07-20 09:42:44 +00:00
|
|
|
|
|
|
|
Cypress.Commands.add("clearSessionData", () => {
|
|
|
|
// Because of known cypress bug, not all local storage data are cleared.
|
|
|
|
// Here is workaround to ensure tests have no side effects.
|
|
|
|
// Suggested usage:
|
|
|
|
|
|
|
|
// beforeEach(() => {
|
|
|
|
// cy.clearSessionData();
|
|
|
|
// });
|
|
|
|
|
|
|
|
cy.clearCookies();
|
|
|
|
cy.clearLocalStorage();
|
|
|
|
cy.visit("/", {
|
|
|
|
onBeforeLoad: win => {
|
|
|
|
win.sessionStorage.clear();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2021-02-04 11:15:27 +00:00
|
|
|
|
|
|
|
Cypress.Commands.add("sendRequestWithQuery", query =>
|
|
|
|
cy.request({
|
|
|
|
method: "POST",
|
|
|
|
body: {
|
|
|
|
method: "POST",
|
|
|
|
url: Cypress.env("API_URI"),
|
|
|
|
query
|
|
|
|
},
|
|
|
|
headers: {
|
|
|
|
Authorization: `JWT ${window.sessionStorage.getItem("auth")}`
|
|
|
|
},
|
|
|
|
url: Cypress.env("API_URI")
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
Cypress.Commands.add("waitForGraph", operationName => {
|
|
|
|
const GRAPH_URL = "/graphql";
|
|
|
|
cy.intercept("POST", GRAPH_URL, req => {
|
|
|
|
req.statusCode = 200;
|
|
|
|
const requestBody = req.body;
|
|
|
|
if (Array.isArray(requestBody)) {
|
|
|
|
requestBody.forEach(element => {
|
|
|
|
if (element.operationName === operationName) {
|
|
|
|
req.alias = operationName;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
if (requestBody.operationName === operationName) {
|
|
|
|
req.alias = operationName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
cy.wait(`@${operationName}`);
|
|
|
|
});
|