full cypress suite for new backend
This commit is contained in:
parent
4acb792278
commit
a8251cdb22
|
@ -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')
|
||||
})
|
||||
|
||||
})
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
})
|
||||
},
|
||||
|
|
|
@ -45,17 +45,14 @@
|
|||
<DropdownMenu bind:this={dropdown} {anchor} align="left">
|
||||
{#if editing}
|
||||
<h4>Edit Column</h4>
|
||||
<CreateEditColumn
|
||||
onClosed={hideEditor}
|
||||
field={field}
|
||||
/>
|
||||
<CreateEditColumn onClosed={hideEditor} {field} />
|
||||
{:else}
|
||||
<ul>
|
||||
<li on:click={showEditor}>
|
||||
<li data-cy="edit-column-header" on:click={showEditor}>
|
||||
<Icon name="edit" />
|
||||
Edit
|
||||
</li>
|
||||
<li on:click={deleteField}>
|
||||
<li data-cy="delete-column-header" on:click={deleteField}>
|
||||
<Icon name="delete" />
|
||||
Delete
|
||||
</li>
|
||||
|
|
|
@ -48,11 +48,11 @@
|
|||
<CreateEditRecord onClosed={hideEditor} record={row} />
|
||||
{:else}
|
||||
<ul>
|
||||
<li on:click={showEditor}>
|
||||
<li data-cy="edit-row" on:click={showEditor}>
|
||||
<Icon name="edit" />
|
||||
Edit
|
||||
</li>
|
||||
<li on:click={deleteRow}>
|
||||
<li data-cy="delete-row" on:click={deleteRow}>
|
||||
<Icon name="delete" />
|
||||
Delete
|
||||
</li>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<script>
|
||||
import { goto } from "@sveltech/routify"
|
||||
import { backendUiStore } from "builderStore"
|
||||
import { notifier } from "builderStore/store/notifications"
|
||||
import { DropdownMenu, Button, Icon, Input, Select } from "@budibase/bbui"
|
||||
|
@ -10,11 +11,12 @@
|
|||
let name
|
||||
|
||||
async function saveTable() {
|
||||
await backendUiStore.actions.models.save({
|
||||
const model = await backendUiStore.actions.models.save({
|
||||
name,
|
||||
schema: {},
|
||||
})
|
||||
notifier.success(`Table ${name} created successfully.`)
|
||||
$goto(`./model/${model._id}`)
|
||||
dropdown.hide()
|
||||
}
|
||||
</script>
|
||||
|
@ -26,6 +28,7 @@
|
|||
<div class="container">
|
||||
<h4>Create Table</h4>
|
||||
<Input
|
||||
data-cy="table-name-input"
|
||||
placeholder="Table Name"
|
||||
thin
|
||||
bind:value={name} />
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
<Icon name="edit" />
|
||||
Edit
|
||||
</li>
|
||||
<li on:click={deleteTable}>
|
||||
<li data-cy="delete-table" on:click={deleteTable}>
|
||||
<Icon name="delete" />
|
||||
Delete
|
||||
</li>
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue