Skip to content

Commit

Permalink
fix(cypress): improve test assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel910 committed Oct 27, 2021
1 parent 1fc36dc commit 3efaf3b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
Expand Up @@ -30,10 +30,7 @@ context("Export & Import Pages", () => {
cy.get(`[type="checkbox"]`).check();
});
});
/**
* Save image snapshot of the page preview before export so that we can compare it with importing the page.
*/
cy.get(".webiny-pb-page-document").matchImageSnapshot();

// Initiate page export
cy.findByTestId("export-page-button").click();

Expand Down Expand Up @@ -106,8 +103,6 @@ context("Export & Import Pages", () => {
cy.findByTestId("pages-default-data-list.select-page").click({ force: true });
});
});
// Check the image snapshot of the imported page
cy.get(".webiny-pb-page-document").matchImageSnapshot();

// Delete the imported page
cy.findByTestId("default-data-list").within(() => {
Expand Down
Expand Up @@ -3,8 +3,8 @@ import uniqid from "uniqid";
const sort = {
NEWEST_TO_OLDEST: "createdOn:desc",
OLDEST_TO_NEWEST: "createdOn:asc",
LOGIN_A_TO_Z: "email:asc",
LOGIN_Z_TO_A: "email:desc"
EMAIL_A_TO_Z: "email:asc",
EMAIL_Z_TO_A: "email:desc"
};

context("Search and sort security users", () => {
Expand Down Expand Up @@ -90,7 +90,7 @@ context("Search and sort security users", () => {
// Sort users from "email A -> Z"
cy.findByTestId("default-data-list.filter").click();
cy.findByTestId("ui.list.data-list").within(() => {
cy.get("select").select(sort.LOGIN_A_TO_Z);
cy.get("select").select(sort.EMAIL_A_TO_Z);
cy.findByTestId("default-data-list.filter").click();
});

Expand All @@ -105,7 +105,7 @@ context("Search and sort security users", () => {
// Sort users from "email Z -> A"
cy.findByTestId("default-data-list.filter").click();
cy.findByTestId("ui.list.data-list").within(() => {
cy.get("select").select(sort.LOGIN_Z_TO_A);
cy.get("select").select(sort.EMAIL_Z_TO_A);
cy.findByTestId("default-data-list.filter").click();
});
// We're testing it against the second element because the first one will be "Admin" user
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/reloadUntil/index.js
Expand Up @@ -15,6 +15,7 @@ Cypress.Commands.add("reloadUntil", (callback, options = {}) => {
function check() {
retries++;
return cy.then(async response => {
await sleep(REPEAT_WAIT_BETWEEN_RETRIES);
const result = await callback(response);
try {
if (!result) {
Expand All @@ -33,7 +34,6 @@ Cypress.Commands.add("reloadUntil", (callback, options = {}) => {
);
}
cy.log(`Assertion repeat ${repeat} / ${options.repeat}.`);
await sleep(REPEAT_WAIT_BETWEEN_RETRIES);
return cy
.log(`Reloading (attempt #${retries + 1})...`)
.reload()
Expand Down
4 changes: 2 additions & 2 deletions packages/api-page-builder/__tests__/graphql/utils/waitPage.ts
Expand Up @@ -19,8 +19,8 @@ export const waitPage = async (handler: Handler, page: Page) => {
},
{
name: `waiting for page ${pageIdentifier}`,
wait: 500,
tries: 30
wait: 3000,
tries: 10
}
);
};

0 comments on commit 3efaf3b

Please sign in to comment.