2021-09-27 10:04:21 +00:00
|
|
|
// / <reference types="cypress" />
|
|
|
|
|
2022-11-16 15:01:34 +00:00
|
|
|
import "cypress-file-upload";
|
|
|
|
import "cypress-mailhog";
|
|
|
|
import "cypress-mochawesome-reporter/register";
|
2021-09-27 10:04:21 +00:00
|
|
|
import "./customCommands/basicOperations";
|
|
|
|
import "./customCommands/deleteElementsViaApi";
|
|
|
|
import "./customCommands/sharedElementsOperations/addressForm.js";
|
|
|
|
import "./customCommands/sharedElementsOperations/assignElementsForm.js";
|
|
|
|
import "./customCommands/sharedElementsOperations/confirmationMessages.js";
|
2022-11-16 15:01:34 +00:00
|
|
|
import "./customCommands/sharedElementsOperations/deleteElement";
|
2021-09-27 10:04:21 +00:00
|
|
|
import "./customCommands/sharedElementsOperations/progressBar.js";
|
|
|
|
import "./customCommands/sharedElementsOperations/selects.js";
|
|
|
|
import "./customCommands/sharedElementsOperations/tables";
|
2022-11-16 15:01:34 +00:00
|
|
|
import "./customCommands/softAssertions";
|
|
|
|
import "./customCommands/user";
|
2023-03-28 10:59:33 +00:00
|
|
|
import "@percy/cypress";
|
2022-03-03 10:25:27 +00:00
|
|
|
|
|
|
|
import { commandTimings } from "cypress-timings";
|
2022-06-27 09:30:51 +00:00
|
|
|
|
2023-03-30 07:59:35 +00:00
|
|
|
import { SHARED_ELEMENTS } from "../elements/shared/sharedElements";
|
2023-03-28 10:59:33 +00:00
|
|
|
import { urlList } from "../fixtures/urlList";
|
2022-06-27 09:30:51 +00:00
|
|
|
import cypressGrep from "../support/cypress-grep/support";
|
2020-07-20 09:42:44 +00:00
|
|
|
|
2023-03-28 10:59:33 +00:00
|
|
|
commandTimings();
|
2022-06-27 09:30:51 +00:00
|
|
|
cypressGrep();
|
|
|
|
|
2020-07-20 09:42:44 +00:00
|
|
|
Cypress.Commands.add("clearSessionData", () => {
|
|
|
|
cy.clearCookies();
|
|
|
|
cy.clearLocalStorage();
|
2022-11-28 11:36:53 +00:00
|
|
|
window.sessionStorage.clear();
|
2020-07-20 09:42:44 +00:00
|
|
|
});
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2023-04-05 07:09:53 +00:00
|
|
|
|
2023-03-28 10:59:33 +00:00
|
|
|
Cypress.Commands.add(
|
|
|
|
"addAliasToGraphRequestAndUseMockedResponseBody",
|
|
|
|
(operationName, bodyMock) => {
|
|
|
|
cy.intercept("POST", urlList.apiUri, req => {
|
|
|
|
req.statusCode = 200;
|
|
|
|
const requestBody = req.body;
|
|
|
|
if (Array.isArray(requestBody)) {
|
|
|
|
requestBody.forEach(element => {
|
|
|
|
if (element.operationName === operationName) {
|
|
|
|
req.alias = operationName;
|
|
|
|
req.reply({
|
|
|
|
body: bodyMock,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
if (requestBody.operationName === operationName) {
|
|
|
|
req.alias = operationName;
|
|
|
|
req.reply({
|
|
|
|
body: bodyMock,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
);
|
2021-02-11 13:58:05 +00:00
|
|
|
|
2023-03-30 07:59:35 +00:00
|
|
|
Cypress.Commands.add("getGridCellInfo", (col, row) =>
|
|
|
|
/*
|
|
|
|
It seeks for react fiber node to obtain Glide grid instance.
|
|
|
|
Within its ref, we have getBounds API which returns an info about given cell.
|
|
|
|
|
|
|
|
Browsing over the three starts from canvas. In case of changing that selector,
|
|
|
|
this function must be adjusted as well.
|
|
|
|
*/
|
|
|
|
cy
|
|
|
|
.get(SHARED_ELEMENTS.dataGridTable)
|
|
|
|
.should("be.visible")
|
|
|
|
.wait(3000)
|
|
|
|
.then(node => {
|
|
|
|
const fiberKey = Object.keys(node[0]).find(x =>
|
|
|
|
x.includes("__reactFiber"),
|
|
|
|
);
|
|
|
|
|
|
|
|
const bounds = node[0].parentNode[
|
|
|
|
fiberKey
|
|
|
|
].pendingProps.children.props.gridRef.current.getBounds(col, row);
|
|
|
|
|
|
|
|
return {
|
|
|
|
...bounds,
|
|
|
|
center: {
|
|
|
|
x: bounds.x + bounds.width / 2,
|
|
|
|
y: bounds.y + bounds.height / 2,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
|
|
|
|
Cypress.Commands.add("clickGridCell", (col, row) => {
|
|
|
|
cy.getGridCellInfo(col, row).then(bounds => {
|
|
|
|
cy.get("body").click(bounds.center.x, bounds.center.y);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
Cypress.Commands.add("clickGridHeader", col => {
|
|
|
|
cy.getGridCellInfo(col, 0).then(bounds => {
|
|
|
|
const headerXCenter = bounds.x + bounds.width / 2;
|
|
|
|
const headerYCenter = bounds.y - bounds.height / 2;
|
|
|
|
|
|
|
|
cy.get("body").click(headerXCenter, headerYCenter);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-05-16 11:38:53 +00:00
|
|
|
Cypress.on(
|
|
|
|
"uncaught:exception",
|
2022-11-16 15:01:34 +00:00
|
|
|
(_err, _runnable) =>
|
2021-05-16 11:38:53 +00:00
|
|
|
// returning false here prevents Cypress from
|
|
|
|
// failing the test
|
2022-06-27 16:49:35 +00:00
|
|
|
false,
|
2021-05-16 11:38:53 +00:00
|
|
|
);
|