From 70b70252ec8165626d4d475995d7529f0e08914a Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 5 Oct 2020 11:13:09 +0100 Subject: [PATCH] Fix cypress texts and update use of modal --- .../integration/createAutomation.spec.js | 10 +- .../cypress/integration/createTable.spec.js | 13 +- .../cypress/integration/createView.spec.js | 20 +-- packages/builder/cypress/support/commands.js | 42 ++++--- .../AutomationList/AutomationList.svelte | 10 +- .../CreateAutomationModal.svelte | 27 ++-- .../DataTable/buttons/CreateRowButton.svelte | 10 +- .../modals/CreateEditRecordModal.svelte | 32 ++--- .../DataTable/popovers/RowPopover.svelte | 10 +- .../ModelNavigator/ModelNavigator.svelte | 6 +- .../CreateTablePopover.svelte} | 9 +- .../EditTablePopover.svelte} | 0 .../EditViewPopover.svelte} | 0 .../components/common/ConfirmDialog.svelte | 20 +-- .../src/components/common/Modal/Modal.svelte | 105 ++++++++++++++-- .../common/Modal/ModalFooter.svelte | 63 ---------- .../components/common/Modal/ModalTitle.svelte | 10 -- .../src/components/common/Modal/index.js | 2 - .../src/components/settings/Link.svelte | 10 +- .../components/settings/SettingsModal.svelte | 28 +++-- .../settings/tabs/DangerZone.svelte | 23 ++-- .../components/start/CreateAppModal.svelte | 116 ++++++++++-------- .../EventsEditor/EventEditorModal.svelte | 57 +++------ .../EventsEditor/EventPropertyControl.svelte | 18 ++- .../userInterface/FrontendNavigatePane.svelte | 14 +-- .../components/userInterface/NewScreen.svelte | 82 ++++--------- .../userInterface/UserInterfaceRoot.svelte | 13 +- packages/builder/src/pages/index.svelte | 14 ++- 28 files changed, 378 insertions(+), 386 deletions(-) rename packages/builder/src/components/backend/ModelNavigator/{CreateTable.svelte => popovers/CreateTablePopover.svelte} (86%) rename packages/builder/src/components/backend/ModelNavigator/{EditTable.svelte => popovers/EditTablePopover.svelte} (100%) rename packages/builder/src/components/backend/ModelNavigator/{EditView.svelte => popovers/EditViewPopover.svelte} (100%) delete mode 100644 packages/builder/src/components/common/Modal/ModalFooter.svelte delete mode 100644 packages/builder/src/components/common/Modal/ModalTitle.svelte diff --git a/packages/builder/cypress/integration/createAutomation.spec.js b/packages/builder/cypress/integration/createAutomation.spec.js index 3acd5a7f7a..ca17e3b7f3 100644 --- a/packages/builder/cypress/integration/createAutomation.spec.js +++ b/packages/builder/cypress/integration/createAutomation.spec.js @@ -15,8 +15,12 @@ context("Create a automation", () => { cy.contains("automate").click() cy.contains("Create New Automation").click() - cy.get("input").type("Add Record") - cy.contains("Save").click() + cy.get(".modal").within(() => { + cy.get("input").type("Add Record") + cy.get(".buttons") + .contains("Create") + .click() + }) // Add trigger cy.get("[data-cy=add-automation-component]").click() @@ -28,7 +32,7 @@ context("Create a automation", () => { }) // Create action - cy.get("[data-cy=SAVE_RECORD]").click() + cy.get("[data-cy=CREATE_RECORD]").click() cy.get("[data-cy=automation-block-setup]").within(() => { cy.get("select") .first() diff --git a/packages/builder/cypress/integration/createTable.spec.js b/packages/builder/cypress/integration/createTable.spec.js index d2c5f2d6a6..a30ecb5ad8 100644 --- a/packages/builder/cypress/integration/createTable.spec.js +++ b/packages/builder/cypress/integration/createTable.spec.js @@ -12,7 +12,7 @@ context("Create a Table", () => { }) it("adds a new column to the table", () => { - cy.addColumn("dog", "name", "Plain Text") + cy.addColumn("dog", "name", "Text") cy.contains("name").should("be.visible") }) @@ -24,16 +24,18 @@ context("Create a Table", () => { it("updates a column on the table", () => { cy.contains("name").click() cy.get("[data-cy='edit-column-header']").click() - cy.get("[placeholder=Name]").type("updated") - cy.get("select").select("Plain Text") + cy.get(".actions input") + .first() + .type("updated") + cy.get("select").select("Text") cy.contains("Save Column").click() - cy.contains("nameupdated").should("have.text", "nameupdated ") + cy.contains("nameupdated").should("have.text", "nameupdated") }) it("edits a record", () => { cy.get("tbody .ri-more-line").click() cy.get("[data-cy=edit-row]").click() - cy.get(".actions input").type("Updated") + cy.get(".modal input").type("Updated") cy.contains("Save").click() cy.contains("RoverUpdated").should("have.text", "RoverUpdated") }) @@ -48,6 +50,7 @@ context("Create a Table", () => { it("deletes a column", () => { cy.contains("name").click() cy.get("[data-cy='delete-column-header']").click() + cy.contains("Delete Column").click() cy.contains("nameupdated").should("not.exist") }) diff --git a/packages/builder/cypress/integration/createView.spec.js b/packages/builder/cypress/integration/createView.spec.js index c817d98237..95cabc887f 100644 --- a/packages/builder/cypress/integration/createView.spec.js +++ b/packages/builder/cypress/integration/createView.spec.js @@ -3,7 +3,7 @@ context("Create a View", () => { cy.visit("localhost:4001/_builder") cy.createApp("View App", "View App Description") cy.createTable("data") - cy.addColumn("data", "group", "Plain Text") + cy.addColumn("data", "group", "Text") cy.addColumn("data", "age", "Number") cy.addColumn("data", "rating", "Number") @@ -18,10 +18,12 @@ context("Create a View", () => { it("creates a view", () => { cy.contains("Create New View").click() - cy.get("[placeholder='View Name']").type("Test View") - cy.contains("Save View").click() + cy.get(".menu-container").within(() => { + cy.get("input").type("Test View") + cy.contains("Save View").click() + }) cy.get(".title").contains("Test View") - cy.get("thead th").should($headers => { + cy.get("thead th div").should($headers => { expect($headers).to.have.length(3) const headers = $headers.map((i, header) => Cypress.$(header).text()) expect(headers.get()).to.deep.eq(["group", "age", "rating"]) @@ -39,7 +41,7 @@ context("Create a View", () => { .find("select") .eq(1) .select("More Than") - cy.get("input[placeholder='age']").type(18) + cy.get("input").type(18) cy.contains("Save").click() cy.get("tbody tr").should($values => { expect($values).to.have.length(5) @@ -57,7 +59,7 @@ context("Create a View", () => { .eq(1) .select("age") cy.contains("Save").click() - cy.get("thead th").should($headers => { + cy.get("thead th div").should($headers => { expect($headers).to.have.length(7) const headers = $headers.map((i, header) => Cypress.$(header).text()) expect(headers.get()).to.deep.eq([ @@ -113,8 +115,10 @@ context("Create a View", () => { .find(".ri-more-line") .click() cy.contains("Edit").click() - cy.get("[placeholder='View Name']").type(" Updated") - cy.contains("Save").click() + cy.get(".menu-container").within(() => { + cy.get("input").type(" Updated") + cy.contains("Save").click() + }) cy.contains("Test View Updated").should("be.visible") }) diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js index 82f87032fa..33761bcb99 100644 --- a/packages/builder/cypress/support/commands.js +++ b/packages/builder/cypress/support/commands.js @@ -59,14 +59,16 @@ Cypress.Commands.add("createApp", name => { Cypress.Commands.add("createTestTableWithData", () => { cy.createTable("dog") - cy.addColumn("dog", "name", "Plain Text") + cy.addColumn("dog", "name", "Text") cy.addColumn("dog", "age", "Number") }) Cypress.Commands.add("createTable", tableName => { // Enter model name cy.contains("Create New Table").click() - cy.get("[placeholder='Table Name']").type(tableName) + cy.get(".menu-container") + .get("input") + .type(tableName) cy.contains("Save").click() cy.contains(tableName).should("be.visible") @@ -77,25 +79,31 @@ Cypress.Commands.add("addColumn", (tableName, columnName, type) => { cy.contains(tableName).click() cy.contains("Create New Column").click() - cy.get("[placeholder=Name]").type(columnName) - cy.get("select").select(type) - - cy.contains("Save Column") - - cy.contains("Save").click() + // Configure column + cy.get(".menu-container").within(() => { + cy.get("input") + .first() + .type(columnName) + cy.get("select").select(type) + cy.contains("Save").click() + }) }) Cypress.Commands.add("addRecord", values => { cy.contains("Create New Row").click() - for (let i = 0; i < values.length; i++) { - cy.get(".actions input") - .eq(i) - .type(values[i]) - } + cy.get(".modal").within(() => { + for (let i = 0; i < values.length; i++) { + cy.get("input") + .eq(i) + .type(values[i]) + } - // Save - cy.contains("Save").click() + // Save + cy.get(".buttons") + .contains("Create") + .click() + }) }) Cypress.Commands.add("createUser", (username, password, accessLevel) => { @@ -114,7 +122,9 @@ Cypress.Commands.add("createUser", (username, password, accessLevel) => { .select(accessLevel) // Save - cy.get(".create-button > button").click() + cy.get(".inputs") + .contains("Create") + .click() }) Cypress.Commands.add("addHeadlineComponent", text => { diff --git a/packages/builder/src/components/automation/AutomationPanel/AutomationList/AutomationList.svelte b/packages/builder/src/components/automation/AutomationPanel/AutomationList/AutomationList.svelte index eb1b424cb5..15c42de1fa 100644 --- a/packages/builder/src/components/automation/AutomationPanel/AutomationList/AutomationList.svelte +++ b/packages/builder/src/components/automation/AutomationPanel/AutomationList/AutomationList.svelte @@ -5,7 +5,7 @@ import { Button } from "@budibase/bbui" import { Modal } from "components/common/Modal" - let modal + let modalVisible = false $: selectedAutomationId = $automationStore.selectedAutomation?.automation?._id @@ -15,7 +15,7 @@
-
- - - +{#if modalVisible} + +{/if} diff --git a/packages/builder/src/components/common/Modal/ModalFooter.svelte b/packages/builder/src/components/common/Modal/ModalFooter.svelte deleted file mode 100644 index fb85a1cbb2..0000000000 --- a/packages/builder/src/components/common/Modal/ModalFooter.svelte +++ /dev/null @@ -1,63 +0,0 @@ - - -
-
- -
-
- {#if showCancelButton} - - {/if} - {#if showConfirmButton} - - {/if} -
-
- - diff --git a/packages/builder/src/components/common/Modal/ModalTitle.svelte b/packages/builder/src/components/common/Modal/ModalTitle.svelte deleted file mode 100644 index 0f6a4f5207..0000000000 --- a/packages/builder/src/components/common/Modal/ModalTitle.svelte +++ /dev/null @@ -1,10 +0,0 @@ -
- -
- - diff --git a/packages/builder/src/components/common/Modal/index.js b/packages/builder/src/components/common/Modal/index.js index 8420f8416a..9f2767d3f7 100644 --- a/packages/builder/src/components/common/Modal/index.js +++ b/packages/builder/src/components/common/Modal/index.js @@ -1,5 +1,3 @@ export { default as Modal } from "./Modal.svelte" export { default as ModalContainer } from "./ModalContainer.svelte" -export { default as ModalTitle } from "./ModalTitle.svelte" -export { default as ModalFooter } from "./ModalFooter.svelte" export { ContextKey } from "./context" diff --git a/packages/builder/src/components/settings/Link.svelte b/packages/builder/src/components/settings/Link.svelte index 1550815c33..22d47676bc 100644 --- a/packages/builder/src/components/settings/Link.svelte +++ b/packages/builder/src/components/settings/Link.svelte @@ -3,15 +3,15 @@ import { SettingsIcon } from "components/common/Icons/" import { Modal } from "components/common/Modal" - let modal + let modalVisible - + (modalVisible = true)}> - - - +{#if modalVisible} + +{/if} diff --git a/packages/builder/src/components/start/CreateAppModal.svelte b/packages/builder/src/components/start/CreateAppModal.svelte index b38fdcaa14..2bb5d4874c 100644 --- a/packages/builder/src/components/start/CreateAppModal.svelte +++ b/packages/builder/src/components/start/CreateAppModal.svelte @@ -1,6 +1,6 @@ -
- + + on:change /> +{/if} diff --git a/packages/builder/src/components/userInterface/FrontendNavigatePane.svelte b/packages/builder/src/components/userInterface/FrontendNavigatePane.svelte index 60835d542c..724f351112 100644 --- a/packages/builder/src/components/userInterface/FrontendNavigatePane.svelte +++ b/packages/builder/src/components/userInterface/FrontendNavigatePane.svelte @@ -7,17 +7,15 @@ import { Button } from "@budibase/bbui" import { Spacer } from "@budibase/bbui" - const newScreen = () => { - newScreenPicker.show() - } - - let newScreenPicker + let modalVisible = false - + @@ -25,7 +23,9 @@
- +{#if modalVisible} + +{/if} diff --git a/packages/builder/src/components/userInterface/UserInterfaceRoot.svelte b/packages/builder/src/components/userInterface/UserInterfaceRoot.svelte index 85c8030216..f668660543 100644 --- a/packages/builder/src/components/userInterface/UserInterfaceRoot.svelte +++ b/packages/builder/src/components/userInterface/UserInterfaceRoot.svelte @@ -15,12 +15,9 @@ let newScreenPicker let confirmDeleteDialog let componentToDelete = "" - - const newScreen = () => { - newScreenPicker.show() - } - let settingsView + let modalVisible = false + const settings = () => { settingsView.show() } @@ -52,7 +49,7 @@ Screens
-
@@ -76,7 +73,9 @@ - +{#if modalVisible} + +{/if}