1
0
Fork 0
mirror of synced 2024-05-19 20:02:34 +12:00
budibase/packages/builder/cypress/integration/autoScreensUI.spec.js

101 lines
3.5 KiB
JavaScript
Raw Normal View History

import filterTests from "../support/filterTests"
2022-06-01 03:39:05 +12:00
const interact = require('../support/interact')
filterTests(['smoke', 'all'], () => {
2022-04-07 23:22:16 +12:00
context("Auto Screens UI", () => {
before(() => {
cy.login()
cy.deleteAllApps()
})
2022-04-07 23:22:16 +12:00
2022-04-08 20:56:20 +12:00
it("should disable the autogenerated screen options if no sources are available", () => {
cy.createApp("First Test App", false)
cy.closeModal();
cy.navigateToAutogeneratedModal()
cy.get(interact.CONFIRM_WRAP_SPE_BUTTON).should('be.disabled')
2022-04-08 20:56:20 +12:00
cy.deleteAllApps()
});
it("should not display incompatible sources", () => {
cy.createApp("Test App")
cy.selectExternalDatasource("REST")
cy.selectExternalDatasource("S3")
2022-06-01 03:39:05 +12:00
cy.get(interact.SPECTRUM_MODAL).within(() => {
cy.get(interact.SPECTRUM_BUTTON).contains("Save and continue to query").click({ force : true })
2022-04-08 20:56:20 +12:00
})
cy.navigateToAutogeneratedModal()
2022-06-01 03:39:05 +12:00
cy.get(interact.DATA_SOURCE_ENTRY).should('have.length', 1)
cy.get(interact.DATA_SOURCE_ENTRY)
2022-04-08 20:56:20 +12:00
cy.deleteAllApps()
});
2022-04-07 23:22:16 +12:00
it("should generate internal table screens", () => {
2022-04-08 20:56:20 +12:00
cy.createTestApp()
2022-04-23 05:23:16 +12:00
// Create Autogenerated screens from the internal table
cy.createDatasourceScreen(["Cypress Tests"])
2022-04-07 23:22:16 +12:00
// Confirm screens have been auto generated
cy.get(interact.BODY).should('contain', "cypress-tests")
.and('contain', 'cypress-tests/:id')
2022-04-07 23:22:16 +12:00
.and('contain', 'cypress-tests/new/row')
})
it("should generate multiple internal table screens at once", () => {
const initialTable = "Cypress Tests"
const secondTable = "Table Two"
// Create a second internal table
2022-04-07 23:22:16 +12:00
cy.createTable(secondTable)
2022-04-23 05:23:16 +12:00
// Create Autogenerated screens from the internal tables
cy.createDatasourceScreen([initialTable, secondTable])
2022-04-07 23:22:16 +12:00
// Confirm screens have been auto generated
// Previously generated tables are suffixed with numbers - as expected
cy.get(interact.BODY).should('contain', 'cypress-tests-2')
.and('contain', 'cypress-tests-2/:id')
2022-04-07 23:22:16 +12:00
.and('contain', 'cypress-tests-2/new/row')
.and('contain', 'table-two')
.and('contain', 'table-two/:id')
2022-04-07 23:22:16 +12:00
.and('contain', 'table-two/new/row')
})
2022-04-08 20:56:20 +12: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-23 05:23:16 +12:00
cy.createDatasourceScreen(["Table Three", "Table Four"], "Admin")
2022-04-08 20:56:20 +12:00
// Filter screens to Admin
cy.filterScreensAccessLevel('Admin')
cy.get(interact.BODY).should('contain', 'table-three')
.and('contain', 'table-three/:id')
.and('contain', 'table-three/new/row')
.and('contain', 'table-four')
.and('contain', 'table-four/:id')
2022-04-23 05:23:16 +12:00
.and('contain', 'table-four/new/row')
.and('not.contain', 'table-two')
.and('not.contain', 'cypress-tests')
2022-04-08 20:56:20 +12:00
})
2022-04-07 23:22:16 +12:00
if (Cypress.env("TEST_ENV")) {
it("should generate datasource screens", () => {
// Using MySQL datasource for testing this
2022-04-07 23:22:16 +12:00
const datasource = "MySQL"
// Select & configure MySQL datasource
2022-04-07 23:22:16 +12:00
cy.selectExternalDatasource(datasource)
cy.addDatasourceConfig(datasource)
2022-04-23 05:23:16 +12:00
// Create Autogenerated screens from a MySQL table - MySQL contains books table
cy.createDatasourceScreen(["books"])
cy.get(interact.BODY).should('contain', 'books')
.and('contain', 'books/:id')
2022-04-07 23:22:16 +12:00
.and('contain', 'books/new/row')
})
}
})
})