Fixing internal table issues and updating createTable cypress test case.

This commit is contained in:
mike12345567 2021-06-02 12:32:07 +01:00
parent 1da4b31890
commit 781bd7bab6
5 changed files with 10 additions and 9 deletions

View File

@ -61,10 +61,10 @@ context("Create a Table", () => {
}) })
it("deletes a table", () => { it("deletes a table", () => {
cy.get(".ri-more-line") cy.get(".actions > :nth-child(1) > .icon > .spectrum-Icon > use")
.first() .first()
.click({ force: true }) .click({ force: true })
cy.get("[data-cy=delete-table]").click() cy.get(".spectrum-Menu > :nth-child(2)").click()
cy.contains("Delete Table").click() cy.contains("Delete Table").click()
cy.contains("dog").should("not.exist") cy.contains("dog").should("not.exist")
}) })

View File

@ -9,10 +9,7 @@ export function checkIfElementExists(el) {
return new Promise(resolve => { return new Promise(resolve => {
/// here if ele exists or not /// here if ele exists or not
cy.get("body").then(body => { cy.get("body").then(body => {
const found = body.find(el) if (body.find(el).length > 0) {
console.log(found)
console.log(found.length)
if (found.length > 0) {
resolve(true) resolve(true)
} else { } else {
resolve(false) resolve(false)
@ -51,7 +48,6 @@ Cypress.Commands.add("createApp", name => {
cy.visit(`localhost:${Cypress.env("PORT")}/builder`) cy.visit(`localhost:${Cypress.env("PORT")}/builder`)
cy.wait(500) cy.wait(500)
isFirstApp().then(isFirst => { isFirstApp().then(isFirst => {
console.log(isFirst)
const buttonText = isFirst ? "Create app" : "Create new app" const buttonText = isFirst ? "Create app" : "Create new app"
cy.contains(buttonText).click() cy.contains(buttonText).click()
cy.get("body").then(() => { cy.get("body").then(() => {

View File

@ -99,6 +99,7 @@
tables.deleteField(field) tables.deleteField(field)
notifications.success(`Column ${field.name} deleted.`) notifications.success(`Column ${field.name} deleted.`)
confirmDeleteDialog.hide() confirmDeleteDialog.hide()
hide()
deletion = false deletion = false
} }
} }

View File

@ -101,6 +101,12 @@ export function createTablesStore() {
// Optionally set display column // Optionally set display column
if (primaryDisplay) { if (primaryDisplay) {
state.draft.primaryDisplay = field.name state.draft.primaryDisplay = field.name
} else if (state.draft.primaryDisplay === originalName) {
const fields = Object.keys(state.draft.schema)
// pick another display column randomly if unselecting
state.draft.primaryDisplay = fields.filter(
name => name !== originalName || name !== field
)[0]
} }
if (indexes) { if (indexes) {

View File

@ -75,8 +75,6 @@ exports.save = async function (ctx) {
/* istanbul ignore next */ /* istanbul ignore next */
if (_rename && tableToSave.schema[_rename.updated].type === FieldTypes.LINK) { if (_rename && tableToSave.schema[_rename.updated].type === FieldTypes.LINK) {
ctx.throw(400, "Cannot rename a linked column.") ctx.throw(400, "Cannot rename a linked column.")
} else if (_rename && tableToSave.primaryDisplay === _rename.old) {
ctx.throw(400, "Cannot rename the display column.")
} }
tableToSave = await tableSaveFunctions.mid(tableToSave) tableToSave = await tableSaveFunctions.mid(tableToSave)