From 87ac25bcea2a5ac5f73df35ed90df9a13c6c526f Mon Sep 17 00:00:00 2001 From: Mitch-Budibase Date: Tue, 12 Apr 2022 15:59:12 +0100 Subject: [PATCH 1/4] Updated deleteApp function Added a check for app name, function returns if app does not exist, rather than trying to delete --- packages/builder/cypress/support/commands.js | 76 +++++++++++--------- 1 file changed, 41 insertions(+), 35 deletions(-) diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js index f4ccdcca24..2783d11ce6 100644 --- a/packages/builder/cypress/support/commands.js +++ b/packages/builder/cypress/support/commands.js @@ -60,44 +60,50 @@ Cypress.Commands.add("deleteApp", name => { cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`) .its("body") .then(val => { - if (val.length > 0) { - if (Cypress.env("TEST_ENV")) { - cy.searchForApplication(name) - cy.get(".appTable").within(() => { - cy.get(".spectrum-Icon").eq(1).click() + const findAppName = val.some(val => val.name == name) + if (findAppName) { + if (val.length > 0) { + if (Cypress.env("TEST_ENV")) { + cy.searchForApplication(name) + cy.get(".appTable").within(() => { + cy.get(".spectrum-Icon").eq(1).click() + }) + } else { + const appId = val.reduce((acc, app) => { + if (name === app.name) { + acc = app.appId + } + return acc + }, "") + + if (appId == "") { + return + } + + const appIdParsed = appId.split("_").pop() + const actionEleId = `[data-cy=row_actions_${appIdParsed}]` + cy.get(actionEleId).within(() => { + cy.get(".spectrum-Icon").eq(0).click() + }) + } + + cy.get(".spectrum-Menu").then($menu => { + if ($menu.text().includes("Unpublish")) { + cy.get(".spectrum-Menu").contains("Unpublish").click() + cy.get(".spectrum-Dialog-grid").contains("Unpublish app").click() + } else { + cy.get(".spectrum-Menu").contains("Delete").click() + cy.get(".spectrum-Dialog-grid").within(() => { + cy.get("input").type(name) + }) + cy.get(".spectrum-Button--warning").click() + } }) } else { - const appId = val.reduce((acc, app) => { - if (name === app.name) { - acc = app.appId - } - return acc - }, "") - - if (appId == "") { - return - } - - const appIdParsed = appId.split("_").pop() - const actionEleId = `[data-cy=row_actions_${appIdParsed}]` - cy.get(actionEleId).within(() => { - cy.get(".spectrum-Icon").eq(0).click() - }) + return } - - cy.get(".spectrum-Menu").then($menu => { - if ($menu.text().includes("Unpublish")) { - cy.get(".spectrum-Menu").contains("Unpublish").click() - cy.get(".spectrum-Dialog-grid").contains("Unpublish app").click() - } else { - cy.get(".spectrum-Menu").contains("Delete").click() - cy.get(".spectrum-Dialog-grid").within(() => { - cy.get("input").type(name) - }) - cy.get(".spectrum-Button--warning").click() - } - }) - } else { + } + else { return } }) From 29d7987768e4eec8c230dc5e0da7c4bca7d1004b Mon Sep 17 00:00:00 2001 From: Mitch-Budibase Date: Tue, 12 Apr 2022 16:20:15 +0100 Subject: [PATCH 2/4] Fixed Table Pagination Tests Previous issues with the second page loading - reloading the page solves it --- .../builder/cypress/integration/createTable.spec.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/builder/cypress/integration/createTable.spec.js b/packages/builder/cypress/integration/createTable.spec.js index 81b7c2f045..9f2bc3653f 100644 --- a/packages/builder/cypress/integration/createTable.spec.js +++ b/packages/builder/cypress/integration/createTable.spec.js @@ -61,7 +61,8 @@ filterTests(["smoke", "all"], () => { for (let i = 1; i < totalRows; i++) { cy.addRow([i]) } - cy.wait(1000) + cy.reload() + cy.wait(2000) cy.get(".spectrum-Pagination").within(() => { cy.get(".spectrum-ActionButton").eq(1).click() }) @@ -71,12 +72,12 @@ filterTests(["smoke", "all"], () => { }) it("Deletes rows and checks pagination", () => { - // Delete rows, removing second page of rows from table - const deleteRows = 5 + // Delete rows, removing second page from table cy.get(".spectrum-Checkbox-input").check({ force: true }) - cy.get(".spectrum-Table") - cy.contains("Delete 5 row(s)").click() - cy.get(".spectrum-Modal").contains("Delete").click() + cy.get(".popovers").within(() => { + cy.get(".spectrum-Button").click({ force: true }) + }) + cy.get(".spectrum-Dialog-grid").contains("Delete").click({ force: true }) cy.wait(1000) // Confirm table only has one page From f81aed711de86abc5f78fac7967aad098929f5f3 Mon Sep 17 00:00:00 2001 From: Mitch-Budibase Date: Tue, 12 Apr 2022 17:24:15 +0100 Subject: [PATCH 3/4] Updated createApp.spec.js The test 'should provide filterable templates' was failing on the smoke build. Updated to check existence of apps and act accordingly --- packages/builder/cypress/integration/createApp.spec.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/builder/cypress/integration/createApp.spec.js b/packages/builder/cypress/integration/createApp.spec.js index 4867534241..13c5979df9 100644 --- a/packages/builder/cypress/integration/createApp.spec.js +++ b/packages/builder/cypress/integration/createApp.spec.js @@ -25,9 +25,13 @@ filterTests(['smoke', 'all'], () => { cy.visit(`${Cypress.config().baseUrl}/builder`) cy.wait(500) - if (Cypress.env("TEST_ENV")) { - cy.get(".spectrum-Button").contains("Templates").click({force: true}) - } + cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`) + .its("body") + .then(val => { + if (val.length > 0) { + cy.get(".spectrum-Button").contains("Templates").click({force: true}) + } + }) cy.get(".template-category-filters").should("exist") cy.get(".template-categories").should("exist") From 0446c5f2e266be85ce093a3329de2b72bb2d752e Mon Sep 17 00:00:00 2001 From: Mitch-Budibase Date: Tue, 12 Apr 2022 17:33:17 +0100 Subject: [PATCH 4/4] lint --- packages/builder/cypress/support/commands.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js index 2783d11ce6..f79e96d6d5 100644 --- a/packages/builder/cypress/support/commands.js +++ b/packages/builder/cypress/support/commands.js @@ -75,18 +75,18 @@ Cypress.Commands.add("deleteApp", name => { } return acc }, "") - + if (appId == "") { return } - + const appIdParsed = appId.split("_").pop() const actionEleId = `[data-cy=row_actions_${appIdParsed}]` cy.get(actionEleId).within(() => { cy.get(".spectrum-Icon").eq(0).click() }) } - + cy.get(".spectrum-Menu").then($menu => { if ($menu.text().includes("Unpublish")) { cy.get(".spectrum-Menu").contains("Unpublish").click() @@ -102,8 +102,7 @@ Cypress.Commands.add("deleteApp", name => { } else { return } - } - else { + } else { return } })