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
|
|
|
);
|
|
|
|
|
|
|
|
Cypress.Commands.add("clearAndType", { prevSubject: true }, (subject, text) => {
|
|
|
|
cy.wrap(subject)
|
|
|
|
.clear()
|
|
|
|
.type(text);
|
|
|
|
});
|
|
|
|
|
|
|
|
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-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
|
|
|
});
|