budibase/packages/builder/cypress/integration/autoScreensUI.spec.js

106 lines
4.2 KiB
JavaScript
Raw Normal View History

import filterTests from "../support/filterTests"
2022-05-31 17:39:05 +02:00
const interact = require('../support/interact')
filterTests(['smoke', 'all'], () => {
2022-04-07 13:22:16 +02:00
context("Auto Screens UI", () => {
before(() => {
cy.login()
cy.deleteAllApps()
})
2022-04-07 13:22:16 +02:00
2022-04-08 10:56:20 +02:00
it("should disable the autogenerated screen options if no sources are available", () => {
cy.createApp("First Test App", false)
cy.closeModal();
cy.contains("Design").click()
2022-05-31 17:39:05 +02:00
cy.get(interact.LABEL_ADD_CIRCLE).click()
cy.get(interact.SPECTRUM_MODAL).within(() => {
cy.get(interact.ITEM_DISABLED).contains("Autogenerated screens")
cy.get(interact.CONFIRM_WRAP_SPE_BUTTON).should('be.disabled')
2022-04-08 10:56:20 +02:00
})
cy.deleteAllApps()
});
it("should not display incompatible sources", () => {
cy.createApp("Test App")
cy.selectExternalDatasource("REST")
cy.selectExternalDatasource("S3")
2022-05-31 17:39:05 +02:00
cy.get(interact.SPECTRUM_MODAL).within(() => {
cy.get(interact.SPECTRUM_BUTTON).contains("Save and continue to query").click({ force : true })
2022-04-08 10:56:20 +02:00
})
cy.navigateToAutogeneratedModal()
2022-05-31 17:39:05 +02:00
cy.get(interact.DATA_SOURCE_ENTRY).should('have.length', 1)
cy.get(interact.DATA_SOURCE_ENTRY)
2022-04-08 10:56:20 +02:00
cy.deleteAllApps()
});
2022-04-07 13:22:16 +02:00
it("should generate internal table screens", () => {
2022-04-08 10:56:20 +02:00
cy.createTestApp()
2022-04-22 19:23:16 +02:00
// Create Autogenerated screens from the internal table
cy.createDatasourceScreen(["Cypress Tests"])
2022-04-07 13:22:16 +02:00
// Confirm screens have been auto generated
2022-05-31 17:39:05 +02:00
cy.get(interact.NAV_ITEMS_CONTAINER).contains("cypress-tests").click({ force: true })
cy.get(interact.NAV_ITEMS_CONTAINER).should('contain', 'cypress-tests/:id')
2022-04-07 13:22:16 +02:00
.and('contain', 'cypress-tests/new/row')
})
it("should generate multiple internal table screens at once", () => {
// Create a second internal table
const initialTable = "Cypress Tests"
const secondTable = "Table Two"
cy.createTable(secondTable)
2022-04-22 19:23:16 +02:00
// Create Autogenerated screens from the internal tables
cy.createDatasourceScreen([initialTable, secondTable])
2022-04-07 13:22:16 +02:00
// Confirm screens have been auto generated
2022-05-31 17:39:05 +02:00
cy.get(interact.NAV_ITEMS_CONTAINER).contains("cypress-tests").click({ force: true })
2022-04-07 13:22:16 +02:00
// Previously generated tables are suffixed with numbers - as expected
2022-05-31 17:39:05 +02:00
cy.get(interact.NAV_ITEMS_CONTAINER).should('contain', 'cypress-tests-2/:id')
2022-04-07 13:22:16 +02:00
.and('contain', 'cypress-tests-2/new/row')
2022-05-31 17:39:05 +02:00
cy.get(interact.NAV_ITEMS_CONTAINER).contains("table-two").click()
cy.get(interact.NAV_ITEMS_CONTAINER).should('contain', 'table-two/:id')
2022-04-07 13:22:16 +02:00
.and('contain', 'table-two/new/row')
})
2022-04-08 10:56:20 +02:00
it("should generate multiple internal table screens with the same screen access level", () => {
//The tables created in the previous step still exist
cy.createTable("Table Three")
cy.createTable("Table Four")
2022-04-22 19:23:16 +02:00
cy.createDatasourceScreen(["Table Three", "Table Four"], "Admin")
2022-04-08 10:56:20 +02:00
2022-05-31 17:39:05 +02:00
cy.get(interact.NAV_ITEMS_CONTAINER).contains("table-three").click()
cy.get(interact.NAV_ITEMS_CONTAINER).should('contain', 'table-three/:id')
2022-04-22 19:23:16 +02:00
.and('contain', 'table-three/new/row')
2022-05-31 17:39:05 +02:00
cy.get(interact.NAV_ITEMS_CONTAINER).contains("table-four").click()
cy.get(interact.NAV_ITEMS_CONTAINER).should('contain', 'table-four/:id')
2022-04-22 19:23:16 +02:00
.and('contain', 'table-four/new/row')
//The access level should now be set to admin. Previous screens should be filtered.
2022-05-31 17:39:05 +02:00
cy.get(interact.NAV_ITEMS_CONTAINER).contains("table-two").should('not.exist')
cy.get(interact.NAV_ITEMS_CONTAINER).contains("cypress-tests").should('not.exist')
2022-04-08 10:56:20 +02:00
})
2022-04-07 13:22:16 +02:00
if (Cypress.env("TEST_ENV")) {
it("should generate data source screens", () => {
// Using MySQL data source for testing this
const datasource = "MySQL"
// Select & configure MySQL data source
cy.selectExternalDatasource(datasource)
cy.addDatasourceConfig(datasource)
2022-04-22 19:23:16 +02:00
// Create Autogenerated screens from a MySQL table - MySQL contains books table
cy.createDatasourceScreen(["books"])
2022-05-31 17:39:05 +02:00
cy.get(interact.NAV_ITEMS_CONTAINER).contains("books").click()
cy.get(interact.NAV_ITEMS_CONTAINER).should('contain', 'books/:id')
2022-04-07 13:22:16 +02:00
.and('contain', 'books/new/row')
})
}
})
})