diff --git a/packages/builder/cypress/integration/createTable.spec.js b/packages/builder/cypress/integration/createTable.spec.js index 7a567af426..c744eb7e4f 100644 --- a/packages/builder/cypress/integration/createTable.spec.js +++ b/packages/builder/cypress/integration/createTable.spec.js @@ -1,41 +1,70 @@ context('Create a Table', () => { - before(() => { cy.visit('localhost:4001/_builder') cy.createApp('Table App', 'Table App Description') }) - // https://on.cypress.io/interacting-with-elements it('should create a new Table', () => { - cy.createTable('dog') // Check if Table exists cy.get('.title').should('have.text', 'dog') }) - // it('adds a new column to the table', () => { - // cy.addRecord('bob', '15') + it('adds a new column to the table', () => { + cy.addColumn('dog', 'name', 'Plain Text') - // cy.contains('bob').should('have.text', 'bob') - // }) + cy.contains('name').should("be.visible") + }) - // it('updates a column on the table', () => { - // cy.addRecord('bob', '15') + it('creates a record in the table', () => { + cy.addRecord(["Rover"]) - // cy.contains('bob').should('have.text', 'bob') - // }) + cy.contains('Rover').should("be.visible") + }) - // it('edits a record', () => { - // cy.addRecord('bob', '15') + it('updates a column on the table', () => { + cy.contains("name").click() + cy.get("[data-cy='edit-column-header']").click() - // cy.contains('bob').should('have.text', 'bob') - // }) + cy.get("[placeholder=Name]").type("updated") + cy.get("select").select("Plain Text") - // it('deletes a record', () => { - // cy.addRecord('bob', '15') + cy.contains("Save Column").click() - // cy.contains('bob').should('have.text', 'bob') - // }) + 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("updatedRecord") + cy.contains("Save").click() + + cy.contains('updatedRecord').should('have.text', 'updatedRecord') + }) + + it('deletes a record', () => { + cy.get("tbody .ri-more-line").click() + cy.get("[data-cy=delete-row]").click() + cy.get(".modal-actions").contains("Delete").click() + + cy.contains('updatedRecord').should('not.exist') + }) + + it('deletes a column', () => { + cy.contains("name").click() + cy.get("[data-cy='delete-column-header']").click() + + cy.contains('nameupdated').should('not.exist') + }) + + it('deletes a table', () => { + cy.contains("div", "dog").get(".ri-more-line").click() + cy.get("[data-cy=delete-table]").click() + cy.get(".modal-actions").contains("Delete").click() + + cy.contains('dog').should('not.exist') + }) }) diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js index d6e2ce5ad5..b01d0797b3 100644 --- a/packages/builder/cypress/support/commands.js +++ b/packages/builder/cypress/support/commands.js @@ -70,22 +70,22 @@ Cypress.Commands.add("createTable", tableName => { Cypress.Commands.add("addColumn", (tableName, columnName, type) => { // Select Table cy.contains(tableName).click() + cy.contains("Create New Column").click() - // Click "Create New Column" - // Fill in dropdown - //hit save - // assertions + cy.get("[placeholder=Name]").type(columnName) + cy.get("select").select(type) + + cy.contains("Save Column") - // Add 'name' field cy.contains("Save").click() - cy.contains(modelName).should("be.visible").click() }) -Cypress.Commands.add("addRecord", (firstField, secondField) => { - cy.contains("Create New Record").click() +Cypress.Commands.add("addRecord", values => { + cy.contains("Create New Row").click() - cy.get("[data-cy='Plain Text-input']").type(firstField) - cy.get("[data-cy=Number-input]").type(secondField) + for (let i = 0; i < values.length; i++) { + cy.get("input").eq(i).type(values[i]) + } // Save cy.contains("Save").click() diff --git a/packages/builder/src/builderStore/store/backend.js b/packages/builder/src/builderStore/store/backend.js index 09227c09a7..f95360000e 100644 --- a/packages/builder/src/builderStore/store/backend.js +++ b/packages/builder/src/builderStore/store/backend.js @@ -82,12 +82,13 @@ export const getBackendUiStore = () => { const savedModel = await response.json() await store.actions.models.fetch() store.actions.models.select(savedModel) + return savedModel }, delete: async model => { await api.delete(`/api/models/${model._id}/${model._rev}`) store.update(state => { - state.selectedModel = state.models[0] || {} state.models = state.models.filter(existing => existing._id !== model._id) + state.selectedModel = state.models[0] || {} return state }) }, diff --git a/packages/builder/src/components/database/ModelDataTable/popovers/ColumnHeader.svelte b/packages/builder/src/components/database/ModelDataTable/popovers/ColumnHeader.svelte index edbb56569a..0aae87f299 100644 --- a/packages/builder/src/components/database/ModelDataTable/popovers/ColumnHeader.svelte +++ b/packages/builder/src/components/database/ModelDataTable/popovers/ColumnHeader.svelte @@ -45,17 +45,14 @@ {#if editing}

Edit Column

- + {:else}
    -
  • +
  • Edit
  • -
  • +
  • Delete
  • diff --git a/packages/builder/src/components/database/ModelDataTable/popovers/EditRow.svelte b/packages/builder/src/components/database/ModelDataTable/popovers/EditRow.svelte index 3a33b85d9f..ff700dcc49 100644 --- a/packages/builder/src/components/database/ModelDataTable/popovers/EditRow.svelte +++ b/packages/builder/src/components/database/ModelDataTable/popovers/EditRow.svelte @@ -48,11 +48,11 @@ {:else}
      -
    • +
    • Edit
    • -
    • +
    • Delete
    • diff --git a/packages/builder/src/components/nav/ModelNavigator/CreateTable.svelte b/packages/builder/src/components/nav/ModelNavigator/CreateTable.svelte index f22655f536..8f1d27d0ca 100644 --- a/packages/builder/src/components/nav/ModelNavigator/CreateTable.svelte +++ b/packages/builder/src/components/nav/ModelNavigator/CreateTable.svelte @@ -1,4 +1,5 @@ @@ -26,6 +28,7 @@

      Create Table

      diff --git a/packages/builder/src/components/nav/ModelNavigator/EditTable.svelte b/packages/builder/src/components/nav/ModelNavigator/EditTable.svelte index f5b425a4b2..887421f318 100644 --- a/packages/builder/src/components/nav/ModelNavigator/EditTable.svelte +++ b/packages/builder/src/components/nav/ModelNavigator/EditTable.svelte @@ -61,7 +61,7 @@ Edit -
    • +
    • Delete
    • diff --git a/packages/builder/src/pages/[application]/backend/model/index.svelte b/packages/builder/src/pages/[application]/backend/model/index.svelte index 101655ddb9..a4bcf1d50d 100644 --- a/packages/builder/src/pages/[application]/backend/model/index.svelte +++ b/packages/builder/src/pages/[application]/backend/model/index.svelte @@ -23,4 +23,6 @@ {#if $backendUiStore.models.length === 0} Please create a table -{:else}Please select a table{/if} +{:else} +Please select a table +{/if} diff --git a/packages/builder/yarn.lock b/packages/builder/yarn.lock index faa7073cf2..fa47012f63 100644 --- a/packages/builder/yarn.lock +++ b/packages/builder/yarn.lock @@ -775,7 +775,7 @@ lodash "^4.17.13" to-fast-properties "^2.0.0" -"@budibase/bbui@^1.18.0": +"@budibase/bbui@^1.23.0": version "1.23.0" resolved "https://registry.yarnpkg.com/@budibase/bbui/-/bbui-1.23.0.tgz#ffcc35a378dca2bdb0a72076d2aec530a11a8a42" integrity sha512-Ix3yFG4hRwmLjPcvCs+cU6hKtjIn+KMfEfzQjNM9RWKoSH08812606LDNf3r/povO6/sxpiUNWZJcGvvdW6gBQ== @@ -3587,6 +3587,11 @@ fast-levenshtein@~2.0.6: resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= +fast-sort@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/fast-sort/-/fast-sort-2.2.0.tgz#20903763531fbcbb41c9df5ab1bf5f2cefc8476a" + integrity sha512-W7zqnn2zsYoQA87FKmYtgOsbJohOrh7XrtZrCVHN5XZKqTBTv5UG+rSS3+iWbg/nepRQUOu+wnas8BwtK8kiCg== + fastq@^1.6.0: version "1.7.0" resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.7.0.tgz#fcd79a08c5bd7ec5b55cd3f5c4720db551929801" @@ -3940,6 +3945,11 @@ har-validator@~5.1.3: ajv "^6.5.5" har-schema "^2.0.0" +harmony-reflect@^1.4.6: + version "1.6.1" + resolved "https://registry.yarnpkg.com/harmony-reflect/-/harmony-reflect-1.6.1.tgz#c108d4f2bb451efef7a37861fdbdae72c9bdefa9" + integrity sha512-WJTeyp0JzGtHcuMsi7rw2VwtkvLa+JyfEKJCFyfcS0+CDkjQ5lHPu7zEhFZP+PDSRrEgXa5Ah0l1MbgbE41XjA== + has-ansi@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" @@ -4136,6 +4146,13 @@ idb-wrapper@^1.5.0: resolved "https://registry.yarnpkg.com/idb-wrapper/-/idb-wrapper-1.7.2.tgz#8251afd5e77fe95568b1c16152eb44b396767ea2" integrity sha512-zfNREywMuf0NzDo9mVsL0yegjsirJxHpKHvWcyRozIqQy89g0a3U+oBPOCN4cc0oCiOuYgZHimzaW/R46G1Mpg== +identity-obj-proxy@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/identity-obj-proxy/-/identity-obj-proxy-3.0.0.tgz#94d2bda96084453ef36fbc5aaec37e0f79f1fc14" + integrity sha1-lNK9qWCERT7zb7xarsN+D3nx/BQ= + dependencies: + harmony-reflect "^1.4.6" + ignore@^5.1.1: version "5.1.4" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.4.tgz#84b7b3dbe64552b6ef0eca99f6743dbec6d97adf"