2020-08-20 13:36:00 +00:00
|
|
|
import "./user";
|
2021-02-11 15:55:30 +00:00
|
|
|
import "./softAssertions";
|
2021-02-16 14:19:46 +00:00
|
|
|
import "./deleteElement/index.js";
|
2021-03-15 13:16:02 +00:00
|
|
|
import "./elements/index";
|
2020-07-20 09:42:44 +00:00
|
|
|
|
2021-02-11 13:58:05 +00:00
|
|
|
import { urlList } from "../url/urlList";
|
|
|
|
|
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();
|
2021-02-11 13:58:05 +00:00
|
|
|
cy.visit(urlList.homePage, {
|
2020-07-20 09:42:44 +00:00
|
|
|
onBeforeLoad: win => {
|
|
|
|
win.sessionStorage.clear();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2021-01-27 09:41:55 +00:00
|
|
|
|
2021-02-23 12:09:58 +00:00
|
|
|
Cypress.Commands.add("addAliasToGraphRequest", operationName => {
|
2021-02-11 14:17:00 +00:00
|
|
|
cy.intercept("POST", urlList.apiUri, req => {
|
2021-02-11 13:58:05 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-02-23 14:30:52 +00:00
|
|
|
Cypress.Commands.add("sendRequestWithQuery", (query, authorization = "auth") =>
|
2021-02-19 09:57:25 +00:00
|
|
|
cy.request({
|
2021-02-23 14:30:52 +00:00
|
|
|
body: {
|
|
|
|
method: "POST",
|
|
|
|
query,
|
|
|
|
url: urlList.apiUri
|
|
|
|
},
|
2021-01-27 09:41:55 +00:00
|
|
|
headers: {
|
2021-02-19 09:57:25 +00:00
|
|
|
Authorization: `JWT ${window.sessionStorage.getItem(authorization)}`
|
2021-01-27 09:41:55 +00:00
|
|
|
},
|
2021-02-11 13:58:05 +00:00
|
|
|
method: "POST",
|
|
|
|
url: urlList.apiUri
|
2021-01-27 09:41:55 +00:00
|
|
|
})
|
|
|
|
);
|
2021-05-16 11:38:53 +00:00
|
|
|
Cypress.on(
|
|
|
|
"uncaught:exception",
|
|
|
|
(err, runnable) =>
|
|
|
|
// returning false here prevents Cypress from
|
|
|
|
// failing the test
|
|
|
|
false
|
|
|
|
);
|