From b64b5edaa7516b676b32362759d4b5bbf0a9238c Mon Sep 17 00:00:00 2001 From: Mitch-Budibase Date: Fri, 1 Apr 2022 14:37:11 +0100 Subject: [PATCH] Changing test structure when searching for applications Search functionality is not available when only 1 app exists - Updating to reflect this --- .../integration/renameAnApplication.spec.js | 65 +++++++++---------- packages/builder/cypress/support/commands.js | 23 +++++-- 2 files changed, 46 insertions(+), 42 deletions(-) diff --git a/packages/builder/cypress/integration/renameAnApplication.spec.js b/packages/builder/cypress/integration/renameAnApplication.spec.js index 204d18972e..f4899f98a0 100644 --- a/packages/builder/cypress/integration/renameAnApplication.spec.js +++ b/packages/builder/cypress/integration/renameAnApplication.spec.js @@ -79,7 +79,8 @@ filterTests(['all'], () => { const appName = "Cypress Tests" const numberName = 12345 const specialCharName = "£$%^" - cy.get(".home-logo").click() + cy.visit(`${Cypress.config().baseUrl}/builder`) + cy.wait(500) renameApp(appName, numberName) cy.reload() cy.wait(1000) @@ -95,41 +96,33 @@ filterTests(['all'], () => { }) const renameApp = (originalName, changedName, published, noName) => { - cy.wait(2000) cy.searchForApplication(originalName) - cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`) - .its("body") - .then(val => { - if (val.length > 0) { - cy.get(".appTable") - .within(() => { - cy.get(".spectrum-Icon").eq(1).click() - }) - // Check for when an app is published - if (published == true) { - // Should not have Edit as option, will unpublish app - cy.should("not.have.value", "Edit") - cy.get(".spectrum-Menu").contains("Unpublish").click() - cy.get(".spectrum-Dialog-grid").contains("Unpublish app").click() - cy.get(".appTable > :nth-child(5) > :nth-child(2) > .spectrum-Icon").click() + cy.get(".appTable") + .within(() => { + cy.get(".spectrum-Icon").eq(1).click() + }) + // Check for when an app is published + if (published == true) { + // Should not have Edit as option, will unpublish app + cy.should("not.have.value", "Edit") + cy.get(".spectrum-Menu").contains("Unpublish").click() + cy.get(".spectrum-Dialog-grid").contains("Unpublish app").click() + cy.get(".appTable > :nth-child(5) > :nth-child(2) > .spectrum-Icon").click() + } + cy.contains("Edit").click() + cy.get(".spectrum-Modal") + .within(() => { + if (noName == true) { + cy.get("input").clear() + cy.get(".spectrum-Dialog-grid").click() + .contains("App name must be letters, numbers and spaces only") + return cy } - cy.contains("Edit").click() - cy.get(".spectrum-Modal") - .within(() => { - if (noName == true) { - cy.get("input").clear() - cy.get(".spectrum-Dialog-grid").click() - .contains("App name must be letters, numbers and spaces only") - return cy - } - cy.get("input").clear() - cy.get("input").eq(0).type(changedName).should("have.value", changedName).blur() - cy.get(".spectrum-ButtonGroup").contains("Save").click({ force: true }) - cy.wait(500) - }) - } - }) - - } - }) + cy.get("input").clear() + cy.get("input").eq(0).type(changedName).should("have.value", changedName).blur() + cy.get(".spectrum-ButtonGroup").contains("Save").click({ force: true }) + cy.wait(500) + }) + } + }) }) diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js index afedeaba49..751449fb07 100644 --- a/packages/builder/cypress/support/commands.js +++ b/packages/builder/cypress/support/commands.js @@ -344,14 +344,25 @@ Cypress.Commands.add("addCustomSourceOptions", totalOptions => { Cypress.Commands.add("searchForApplication", appName => { cy.visit(`${Cypress.config().baseUrl}/builder`) cy.wait(2000) - // Searches for the app - cy.get(".filter").then(() => { - cy.get(".spectrum-Textfield").within(() => { - cy.get("input").eq(0).clear() - cy.get("input").eq(0).type(appName) + + // No app filter functionality if only 1 app exists + cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`) + .its("body") + .then(val => { + if (val.length < 2) { + return + } + else { + // Searches for the app + cy.get(".filter").then(() => { + cy.get(".spectrum-Textfield").within(() => { + cy.get("input").eq(0).clear() + cy.get("input").eq(0).type(appName) + }) + }) + } }) }) -}) //Assumes there are no others Cypress.Commands.add("applicationInAppTable", appName => {