2021-09-27 10:04:21 +00:00
|
|
|
Cypress.Commands.add("getTextFromElement", element =>
|
2023-01-16 13:55:38 +00:00
|
|
|
cy.get(element).invoke("text"),
|
2021-09-27 10:04:21 +00:00
|
|
|
);
|
2023-03-24 08:03:48 +00:00
|
|
|
Cypress.Commands.add("getRowSelectorWithNumber", rowNumber =>
|
|
|
|
cy.get(`[data-value=${rowNumber}]`),
|
|
|
|
);
|
2021-09-27 10:04:21 +00:00
|
|
|
|
|
|
|
Cypress.Commands.add("clearAndType", { prevSubject: true }, (subject, text) => {
|
2023-01-27 15:27:49 +00:00
|
|
|
cy.wrap(subject).then(subject => {
|
|
|
|
if (subject.find("[contenteditable]").length > 0) {
|
|
|
|
cy.wrap(subject).find("[contenteditable]").clear().type(text);
|
|
|
|
} else {
|
2023-05-04 08:57:18 +00:00
|
|
|
cy.wrap(subject).clear({ force: true }).type(text);
|
2023-01-27 15:27:49 +00:00
|
|
|
}
|
|
|
|
});
|
2021-09-27 10:04:21 +00:00
|
|
|
});
|
2023-03-09 08:18:07 +00:00
|
|
|
Cypress.Commands.add("clickOnElement", selector => {
|
|
|
|
cy.get(selector).click();
|
|
|
|
});
|
2021-09-27 10:04:21 +00:00
|
|
|
|
|
|
|
Cypress.Commands.add("waitForRequestAndCheckIfNoErrors", alias => {
|
|
|
|
cy.wait(alias).then(resp => {
|
2021-09-29 13:24:47 +00:00
|
|
|
expect(
|
|
|
|
resp.response.body.errors,
|
2023-01-16 13:55:38 +00:00
|
|
|
`No errors in ${alias} operation in graphql response`,
|
2021-09-29 13:24:47 +00:00
|
|
|
).to.be.undefined;
|
2021-09-27 10:04:21 +00:00
|
|
|
return resp;
|
|
|
|
});
|
|
|
|
});
|
2023-04-05 07:09:53 +00:00
|
|
|
Cypress.Commands.add("waitForRequestAndErrorMessage", (alias, error) => {
|
|
|
|
cy.wait(alias).then(resp => {
|
|
|
|
expect(resp.response.body.errors[0].message).to.contains(error);
|
|
|
|
return resp;
|
|
|
|
});
|
|
|
|
});
|
2023-01-16 09:43:13 +00:00
|
|
|
|
2023-01-16 13:55:38 +00:00
|
|
|
Cypress.Commands.add("checkIfDataAreNotNull", data => {
|
2023-01-16 09:43:13 +00:00
|
|
|
expect(data, "Created data should not be null").to.be.not.null;
|
2023-01-16 13:55:38 +00:00
|
|
|
if (typeof data === "object") {
|
2023-01-16 09:43:13 +00:00
|
|
|
Object.keys(data).forEach(key => {
|
2023-01-16 13:55:38 +00:00
|
|
|
cy.checkIfDataAreNotNull(data[key]);
|
|
|
|
});
|
|
|
|
} else if (Array.isArray(data)) {
|
2023-01-16 09:43:13 +00:00
|
|
|
expect(data).not.to.be.empty;
|
|
|
|
data.forEach(singleData => {
|
2023-01-16 13:55:38 +00:00
|
|
|
cy.checkIfDataAreNotNull(singleData);
|
|
|
|
});
|
2023-01-16 09:43:13 +00:00
|
|
|
}
|
2023-01-16 13:55:38 +00:00
|
|
|
});
|
2023-03-09 08:18:07 +00:00
|
|
|
Cypress.Commands.add("checkIfElementIsVisible", element => {
|
|
|
|
cy.get(element).should("be.visible");
|
|
|
|
});
|
2023-05-11 06:46:33 +00:00
|
|
|
Cypress.Commands.add("checkIfElementIsNotVisible", element => {
|
|
|
|
cy.get(element).should("not.be.visible");
|
|
|
|
});
|
|
|
|
Cypress.Commands.add("checkIfElementExist", element => {
|
|
|
|
cy.get(element).should("exist");
|
|
|
|
});
|
|
|
|
Cypress.Commands.add("checkIfElementNotExist", element => {
|
|
|
|
cy.get(element).should("not.exist");
|
|
|
|
});
|
2023-03-20 12:06:33 +00:00
|
|
|
Cypress.Commands.add("assertCanvasRowsNumber", (canvas, rowNumber) => {
|
|
|
|
cy.get(canvas).find("tr").should("have.length", rowNumber);
|
|
|
|
});
|