From b2b5fde7ba1e9abe5e45013b71c1d29e6d34b294 Mon Sep 17 00:00:00 2001 From: Dean Date: Wed, 20 Apr 2022 09:17:01 +0100 Subject: [PATCH] Cypress test fixes and refactoring. Removed debugging elements --- packages/bbui/src/Icon/Icon.svelte | 2 + .../changeAppIconAndColour.spec.js | 3 +- .../integration/renameAnApplication.spec.js | 50 ++++++++++--------- .../cypress/integration/revertApp.spec.js | 10 ++-- .../src/components/deploy/RevertModal.svelte | 7 ++- .../src/components/start/AppRow.svelte | 8 +-- .../builder/app/[application]/_layout.svelte | 3 -- .../server/src/api/controllers/application.js | 2 +- 8 files changed, 48 insertions(+), 37 deletions(-) diff --git a/packages/bbui/src/Icon/Icon.svelte b/packages/bbui/src/Icon/Icon.svelte index fbaac7098c..ac0ddb1249 100644 --- a/packages/bbui/src/Icon/Icon.svelte +++ b/packages/bbui/src/Icon/Icon.svelte @@ -10,6 +10,7 @@ export let hoverable = false export let disabled = false export let color + export let dataCy = null $: rotation = getRotation(direction) @@ -20,6 +21,7 @@ { cy.applicationInAppTable("Cypress Tests") cy.get(".appTable") .within(() => { - cy.get(".spectrum-Icon").eq(1).click() + cy.get("[data-cy='app-row-actions-menu']").eq(0).click() }) cy.get(".spectrum-Menu").contains("Edit icon").click() // Select random icon @@ -38,6 +38,7 @@ filterTests(['all'], () => { cy.get(".title").children().children() .should('have.attr', 'style').and('contains', 'color') }) + cy.deleteAllApps() }) }) }) diff --git a/packages/builder/cypress/integration/renameAnApplication.spec.js b/packages/builder/cypress/integration/renameAnApplication.spec.js index f4899f98a0..ef50bdc454 100644 --- a/packages/builder/cypress/integration/renameAnApplication.spec.js +++ b/packages/builder/cypress/integration/renameAnApplication.spec.js @@ -99,30 +99,32 @@ filterTests(['all'], () => { cy.searchForApplication(originalName) 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.get("[data-cy='app-row-actions-menu']").eq(0).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(".app-row-actions").within(() => { + cy.get(".spectrum-Button").contains("Edit").click({ force: true }) + }) + cy.get(".spectrum-Modal") + .within(() => { + if (noName == true) { 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(".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) + }) + } }) }) diff --git a/packages/builder/cypress/integration/revertApp.spec.js b/packages/builder/cypress/integration/revertApp.spec.js index c64d19f230..aeb1847b46 100644 --- a/packages/builder/cypress/integration/revertApp.spec.js +++ b/packages/builder/cypress/integration/revertApp.spec.js @@ -10,7 +10,7 @@ filterTests(['smoke', 'all'], () => { it("should try to revert an unpublished app", () => { // Click revert icon cy.get(".toprightnav").within(() => { - cy.get(".spectrum-Icon").eq(1).click() + cy.get("[data-cy='revert-application-topnav']").click({ force: true }) }) cy.get(".spectrum-Dialog-grid").within(() => { // Enter app name before revert @@ -33,11 +33,15 @@ filterTests(['smoke', 'all'], () => { cy.get(".spectrum-ButtonGroup").within(() => { cy.get(".spectrum-Button").contains("Publish").click({ force: true }) }) + cy.wait(1000) + cy.get(".spectrum-ButtonGroup").within(() => { + cy.get(".spectrum-Button").contains("Done").click({ force: true }) + }) // Add second component - Button cy.addComponent("Elements", "Button") // Click Revert cy.get(".toprightnav").within(() => { - cy.get(".spectrum-Icon").eq(1).click() + cy.get("[data-cy='revert-application-topnav']").click({ force: true }) }) cy.get(".spectrum-Dialog-grid").within(() => { // Click Revert @@ -54,7 +58,7 @@ filterTests(['smoke', 'all'], () => { it("should enter incorrect app name when reverting", () => { // Click Revert cy.get(".toprightnav").within(() => { - cy.get(".spectrum-Icon").eq(1).click({ force: true }) + cy.get("[data-cy='revert-application-topnav']").click({ force: true }) }) // Enter incorrect app name cy.get(".spectrum-Dialog-grid").within(() => { diff --git a/packages/builder/src/components/deploy/RevertModal.svelte b/packages/builder/src/components/deploy/RevertModal.svelte index 717c55f05e..fabd97fbca 100644 --- a/packages/builder/src/components/deploy/RevertModal.svelte +++ b/packages/builder/src/components/deploy/RevertModal.svelte @@ -28,7 +28,12 @@ } - +
-
+
editApp(app)}> @@ -69,7 +69,7 @@
-
+
{#if app.deployed}
- + {#if app.deployed} viewApp(app)} icon="GlobeOutline"> View published app @@ -115,7 +115,7 @@