From 62c36238e340d0f9ec39862fbb1e5f09bc601b26 Mon Sep 17 00:00:00 2001 From: Mitch-Budibase Date: Wed, 29 Jun 2022 18:28:32 +0100 Subject: [PATCH] Cypress Tests Refactoring Refactoring a large portion of tests - necessary updates to have them working (may still be timing issues on the smoke build) --- .../builder/cypress/integration/appOverview.spec.js | 3 +-- .../cypress/integration/appPublishWorkflow.spec.js | 13 +++++++++---- .../{createScreen.js => createScreen.spec.js} | 0 .../builder/cypress/integration/createTable.spec.js | 5 +++-- .../builder/cypress/integration/createView.spec.js | 3 ++- .../cypress/integration/renameAnApplication.spec.js | 1 - .../builder/cypress/integration/revertApp.spec.js | 3 ++- packages/builder/cypress/support/commands.js | 9 ++++++--- packages/builder/cypress/support/interact.js | 1 + 9 files changed, 24 insertions(+), 14 deletions(-) rename packages/builder/cypress/integration/{createScreen.js => createScreen.spec.js} (100%) diff --git a/packages/builder/cypress/integration/appOverview.spec.js b/packages/builder/cypress/integration/appOverview.spec.js index 244c0c89d4..d718f95b9f 100644 --- a/packages/builder/cypress/integration/appOverview.spec.js +++ b/packages/builder/cypress/integration/appOverview.spec.js @@ -136,7 +136,6 @@ filterTests(["all"], () => { .within(() => { cy.get(".confirm-wrap button").click({ force: true }) }) - cy.wait(1000) cy.visit(`${Cypress.config().baseUrl}/builder`) cy.get(".appTable .app-row-actions button") @@ -376,7 +375,7 @@ filterTests(["all"], () => { .should("be.visible") }) - it("Should allow unpublishing of the application", () => { + it("Should allow unpublishing of the application via the Unpublish link", () => { cy.visit(`${Cypress.config().baseUrl}/builder`) cy.get(".appTable .app-row-actions button") .contains("Manage") diff --git a/packages/builder/cypress/integration/appPublishWorkflow.spec.js b/packages/builder/cypress/integration/appPublishWorkflow.spec.js index 661d79d04b..a431051075 100644 --- a/packages/builder/cypress/integration/appPublishWorkflow.spec.js +++ b/packages/builder/cypress/integration/appPublishWorkflow.spec.js @@ -12,7 +12,7 @@ filterTests(['all'], () => { it("Should reflect the unpublished status correctly", () => { cy.visit(`${Cypress.config().baseUrl}/builder`) - cy.get(interact.APP_TABLE_STATUS, { timeout: 1000 }).eq(0) + cy.get(interact.APP_TABLE_STATUS, { timeout: 3000 }).eq(0) .within(() => { cy.contains("Unpublished") cy.get(interact.GLOBESTRIKE).should("exist") @@ -47,7 +47,7 @@ filterTests(['all'], () => { cy.visit(`${Cypress.config().baseUrl}/builder`) - cy.get(interact.APP_TABLE_STATUS, { timeout: 1000 }).eq(0) + cy.get(interact.APP_TABLE_STATUS, { timeout: 3000 }).eq(0) .within(() => { cy.contains("Published") cy.get(interact.GLOBE).should("exist") @@ -55,7 +55,7 @@ filterTests(['all'], () => { cy.get(interact.APP_TABLE_ROW_ACTION).eq(0) .within(() => { - cy.get(interact.SPECTRUM_BUTTON).contains("View") + cy.get(interact.SPECTRUM_BUTTON).contains("Manage") cy.get(interact.SPECTRUM_BUTTON).contains("Edit").click({ force: true }) }) @@ -85,7 +85,12 @@ filterTests(['all'], () => { cy.get(interact.APP_TABLE_APP_NAME).click({ force: true }) }) - cy.get(interact.SPECTRUM_LINK).contains('Unpublish').click(); + cy.get(interact.DEPLOYMENT_TOP_NAV).click() + cy.get(interact.PUBLISH_POPOVER_ACTION).click({ force: true }) + cy.get(interact.UNPUBLISH_MODAL) + .within(() => { + cy.get(interact.CONFIRM_WRAP_BUTTON).click({ force: true }) + }) cy.get(interact.UNPUBLISH_MODAL).should("be.visible") .within(() => { diff --git a/packages/builder/cypress/integration/createScreen.js b/packages/builder/cypress/integration/createScreen.spec.js similarity index 100% rename from packages/builder/cypress/integration/createScreen.js rename to packages/builder/cypress/integration/createScreen.spec.js diff --git a/packages/builder/cypress/integration/createTable.spec.js b/packages/builder/cypress/integration/createTable.spec.js index 4be693ee8f..da73c19fa6 100644 --- a/packages/builder/cypress/integration/createTable.spec.js +++ b/packages/builder/cypress/integration/createTable.spec.js @@ -39,8 +39,9 @@ filterTests(["smoke", "all"], () => { it("edits a row", () => { cy.contains("button", "Edit").click({ force: true }) - cy.get(interact.SPECTRUM_MODAL_INPUT, { timeout: 1000 }).clear() - cy.get(interact.SPECTRUM_MODAL_INPUT, { timeout: 1000 }).type("Updated") + cy.wait(500) + cy.get(interact.SPECTRUM_MODAL_INPUT).clear() + cy.get(interact.SPECTRUM_MODAL_INPUT).type("Updated") cy.contains("Save").click() cy.contains("Updated").should("have.text", "Updated") }) diff --git a/packages/builder/cypress/integration/createView.spec.js b/packages/builder/cypress/integration/createView.spec.js index fc89e61a5e..a2d09d97bf 100644 --- a/packages/builder/cypress/integration/createView.spec.js +++ b/packages/builder/cypress/integration/createView.spec.js @@ -70,7 +70,8 @@ filterTests(['smoke', 'all'], () => { cy.get(interact.SPECTRUM_BUTTON).contains("Save").click({ force: true }) }) - cy.get(interact.TITLE, { timeout: 1000 }).then($headers => { + cy.wait(1000) + cy.get(interact.TITLE).then($headers => { expect($headers).to.have.length(7) const headers = Array.from($headers).map(header => header.textContent.trim() diff --git a/packages/builder/cypress/integration/renameAnApplication.spec.js b/packages/builder/cypress/integration/renameAnApplication.spec.js index 8c92935481..370efadff2 100644 --- a/packages/builder/cypress/integration/renameAnApplication.spec.js +++ b/packages/builder/cypress/integration/renameAnApplication.spec.js @@ -51,7 +51,6 @@ filterTests(["all"], () => { renameApp(appName, " ", false, true) // Close modal and confirm name has not been changed cy.get(interact.SPECTRUM_DIALOG_GRID, { timeout: 1000 }).contains("Cancel").click() - cy.reload() cy.applicationInAppTable(appName) }) diff --git a/packages/builder/cypress/integration/revertApp.spec.js b/packages/builder/cypress/integration/revertApp.spec.js index ce59a4624a..4c6f245b76 100644 --- a/packages/builder/cypress/integration/revertApp.spec.js +++ b/packages/builder/cypress/integration/revertApp.spec.js @@ -36,6 +36,7 @@ filterTests(['smoke', 'all'], () => { cy.get(interact.SPECTRUM_BUTTON_GROUP).within(() => { cy.get(interact.SPECTRUM_BUTTON).contains("Publish").click({ force: true }) }) + cy.wait(1000) // Wait for next modal to finish loading cy.get(interact.SPECTRUM_BUTTON_GROUP, { timeout: 1000 }).within(() => { cy.get(interact.SPECTRUM_BUTTON).contains("Done").click({ force: true }) }) @@ -49,7 +50,7 @@ filterTests(['smoke', 'all'], () => { cy.get(interact.SPECTRUM_DIALOG_GRID).within(() => { // Click Revert cy.get(interact.SPECTRUM_BUTTON).contains("Revert").click({ force: true }) - + cy.wait(2000) // Wait for app to finish reverting }) // Confirm Paragraph component is still visible cy.get(interact.ROOT, { timeout: 1000 }).contains("New Paragraph") diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js index 6bd6074eda..c5baec3f4e 100644 --- a/packages/builder/cypress/support/commands.js +++ b/packages/builder/cypress/support/commands.js @@ -372,7 +372,8 @@ Cypress.Commands.add("searchForApplication", appName => { // Assumes there are no others Cypress.Commands.add("applicationInAppTable", appName => { - cy.get(".appTable", { timeout: 1000 }).within(() => { + cy.visit(`${Cypress.config().baseUrl}/builder`) + cy.get(".appTable", { timeout: 2000 }).within(() => { cy.get(".title").contains(appName).should("exist") }) }) @@ -400,7 +401,7 @@ Cypress.Commands.add("createTable", (tableName, initialTable) => { cy.navigateToDataSection() cy.get(`[data-cy="new-table"]`).click() } - cy.wait(500) + cy.wait(2000) cy.get(".item") .contains("Budibase DB") .click({ force: true }) @@ -539,9 +540,10 @@ Cypress.Commands.add("createScreen", (route, accessLevelLabel) => { cy.get("[data-cy='blank-screen']").click() cy.get(".spectrum-Button").contains("Continue").click({ force: true }) }) + cy.wait(500) cy.get(".spectrum-Dialog-grid", { timeout: 500 }).within(() => { cy.get(".spectrum-Form-itemField").eq(0).type(route) - cy.get(".spectrum-Button").contains("Continue").click({ force: true }) + cy.get(".confirm-wrap").contains("Continue").click({ force: true }) }) cy.get(".spectrum-Modal", { timeout: 1000 }).within(() => { @@ -567,6 +569,7 @@ Cypress.Commands.add( timeout: 500, }).within(() => { for (let i = 0; i < datasourceNames.length; i++) { + cy.wait(500) cy.get(".data-source-entry").contains(datasourceNames[i]).click() //Ensure the check mark is visible cy.get(".data-source-entry") diff --git a/packages/builder/cypress/support/interact.js b/packages/builder/cypress/support/interact.js index 7cf786625a..0b31d8a8c5 100644 --- a/packages/builder/cypress/support/interact.js +++ b/packages/builder/cypress/support/interact.js @@ -62,6 +62,7 @@ export const GLOBESTRIKE = "svg[aria-label=GlobeStrike]" export const GLOBE = "svg[aria-label=Globe]" export const UNPUBLISH_MODAL = "[data-cy=unpublish-modal]" export const CONFIRM_WRAP_BUTTON = ".confirm-wrap button" +export const DEPLOYMENT_TOP_NAV = ".deployment-top-nav" //changeAppiconAndColour export const APP_ROW_ACTION = ".app-row-actions-icon"