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

107 lines
4.1 KiB
JavaScript
Raw Normal View History

import filterTests from "../support/filterTests"
filterTests(['smoke', 'all'], () => {
2022-04-07 13:22:16 +02:00
context("Auto Screens UI", () => {
before(() => {
cy.login()
})
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()
cy.get("[aria-label=AddCircle]").click()
cy.get(".spectrum-Modal").within(() => {
cy.get(".item.disabled").contains("Autogenerated Screens")
cy.get(".confirm-wrap .spectrum-Button").should('be.disabled')
})
cy.deleteAllApps()
});
it("should not display incompatible sources", () => {
cy.createApp("Test App")
cy.selectExternalDatasource("REST")
cy.selectExternalDatasource("S3")
cy.get(".spectrum-Modal").within(() => {
cy.get(".spectrum-Button").contains("Save and continue to query").click({ force : true })
})
cy.navigateToAutogeneratedModal()
cy.get('.data-source-entry').should('have.length', 1)
cy.get('.data-source-entry')
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-07 13:22:16 +02:00
// Create autogenerated screens from the internal table
cy.createAutogeneratedScreens(["Cypress Tests"])
// Confirm screens have been auto generated
cy.get(".nav-items-container").contains("cypress-tests").click({ force: true })
cy.get(".nav-items-container").should('contain', 'cypress-tests/:id')
.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)
// Create autogenerated screens from the internal tables
cy.createAutogeneratedScreens([initialTable, secondTable])
// Confirm screens have been auto generated
cy.get(".nav-items-container").contains("cypress-tests").click({ force: true })
// Previously generated tables are suffixed with numbers - as expected
cy.get(".nav-items-container").should('contain', 'cypress-tests-2/:id')
.and('contain', 'cypress-tests-2/new/row')
cy.get(".nav-items-container").contains("table-two").click()
cy.get(".nav-items-container").should('contain', 'table-two/:id')
.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")
cy.createAutogeneratedScreens(["Table Three", "Table Four"], "Admin")
cy.get(".nav-items-container").within(() => {
cy.get(".nav-item").contains("/table-three").click()
cy.get(".nav-item").should('contain', 'table-three/:id')
.and('contain', 'table-three/new/row')
cy.get(".nav-item").contains("/table-four").click()
cy.get(".nav-item").should('contain', 'table-four/:id')
.and('contain', 'table-four/new/row')
//The access level should now be set to admin. Previous screens should be filtered.
cy.get(".nav-item").contains("/table-two").should('not.exist')
cy.get(".nav-item").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)
// Create autogenerated screens from a MySQL table - MySQL contains books table
cy.createAutogeneratedScreens(["books"])
cy.get(".nav-items-container").contains("books").click()
cy.get(".nav-items-container").should('contain', 'books/:id')
.and('contain', 'books/new/row')
})
}
})
})