mirror of https://github.com/Budibase/budibase.git
committed by
GitHub
26 changed files with 2370 additions and 1024 deletions
File diff suppressed because it is too large
@ -1,191 +1,222 @@ |
|||||
import filterTests from "../../support/filterTests" |
import filterTests from "../../support/filterTests" |
||||
|
|
||||
filterTests(['all'], () => { |
filterTests(["all"], () => { |
||||
context("MySQL Datasource Testing", () => { |
context("MySQL Datasource Testing", () => { |
||||
if (Cypress.env("TEST_ENV")) { |
if (Cypress.env("TEST_ENV")) { |
||||
|
before(() => { |
||||
before(() => { |
cy.login() |
||||
cy.login() |
cy.createTestApp() |
||||
cy.createTestApp() |
}) |
||||
}) |
const datasource = "MySQL" |
||||
const datasource = "MySQL" |
const queryName = "Cypress Test Query" |
||||
const queryName = "Cypress Test Query" |
const queryRename = "CT Query Rename" |
||||
const queryRename = "CT Query Rename" |
|
||||
|
it("Should add MySQL data source without configuration", () => { |
||||
it("Should add MySQL data source without configuration", () => { |
// Select MySQL data source
|
||||
// Select MySQL data source
|
cy.selectExternalDatasource(datasource) |
||||
cy.selectExternalDatasource(datasource) |
// Attempt to fetch tables without applying configuration
|
||||
// Attempt to fetch tables without applying configuration
|
cy.intercept("**/datasources").as("datasource") |
||||
cy.intercept('**/datasources').as('datasource') |
cy.get(".spectrum-Button") |
||||
cy.get(".spectrum-Button") |
.contains("Save and fetch tables") |
||||
.contains("Save and fetch tables") |
.click({ force: true }) |
||||
.click({ force: true }) |
// Intercept Request after button click & apply assertions
|
||||
// Intercept Request after button click & apply assertions
|
cy.wait("@datasource") |
||||
cy.wait("@datasource") |
cy.get("@datasource") |
||||
cy.get("@datasource").its('response.body') |
.its("response.body") |
||||
.should('have.property', 'message', 'connect ECONNREFUSED 127.0.0.1:3306') |
.should( |
||||
cy.get("@datasource").its('response.body') |
"have.property", |
||||
.should('have.property', 'status', 500) |
"message", |
||||
}) |
"connect ECONNREFUSED 127.0.0.1:3306" |
||||
|
) |
||||
it("should add MySQL data source and fetch tables", () => { |
cy.get("@datasource") |
||||
// Add & configure MySQL data source
|
.its("response.body") |
||||
cy.selectExternalDatasource(datasource) |
.should("have.property", "status", 500) |
||||
cy.intercept('**/datasources').as('datasource') |
}) |
||||
cy.addDatasourceConfig(datasource) |
|
||||
// Check response from datasource after adding configuration
|
it("should add MySQL data source and fetch tables", () => { |
||||
cy.wait("@datasource") |
// Add & configure MySQL data source
|
||||
cy.get("@datasource").its('response.statusCode') |
cy.selectExternalDatasource(datasource) |
||||
.should('eq', 200) |
cy.intercept("**/datasources").as("datasource") |
||||
// Confirm fetch tables was successful
|
cy.addDatasourceConfig(datasource) |
||||
cy.get(".spectrum-Table-body").eq(0) |
// Check response from datasource after adding configuration
|
||||
.find('tr') |
cy.wait("@datasource") |
||||
.its('length') |
cy.get("@datasource").its("response.statusCode").should("eq", 200) |
||||
.should('be.gt', 0) |
// Confirm fetch tables was successful
|
||||
}) |
cy.get(".spectrum-Table") |
||||
|
.eq(0) |
||||
it("should check table fetching error", () => { |
.find(".spectrum-Table-row") |
||||
// MySQL test data source contains tables without primary keys
|
.its("length") |
||||
cy.get(".spectrum-InLineAlert") |
.should("be.gt", 0) |
||||
.should('contain', 'Error fetching tables') |
}) |
||||
.and('contain', 'No primary key constraint found') |
|
||||
}) |
it("should check table fetching error", () => { |
||||
|
// MySQL test data source contains tables without primary keys
|
||||
it("should define a One relationship type", () => { |
cy.get(".spectrum-InLineAlert") |
||||
// Select relationship type & configure
|
.should("contain", "Error fetching tables") |
||||
cy.get(".spectrum-Button").contains("Define relationship").click({ force: true }) |
.and("contain", "No primary key constraint found") |
||||
cy.get(".spectrum-Dialog-grid").within(() => { |
}) |
||||
cy.get(".spectrum-Picker").eq(0).click() |
|
||||
cy.get(".spectrum-Popover").contains("One").click() |
it("should define a One relationship type", () => { |
||||
cy.get(".spectrum-Picker").eq(1).click() |
// Select relationship type & configure
|
||||
cy.get(".spectrum-Popover").contains("REGIONS").click() |
cy.get(".spectrum-Button") |
||||
cy.get(".spectrum-Picker").eq(2).click() |
.contains("Define relationship") |
||||
cy.get(".spectrum-Popover").contains("REGION_ID").click() |
.click({ force: true }) |
||||
cy.get(".spectrum-Picker").eq(3).click() |
cy.get(".spectrum-Dialog-grid").within(() => { |
||||
cy.get(".spectrum-Popover").contains("COUNTRIES").click() |
cy.get(".spectrum-Picker").eq(0).click() |
||||
cy.get(".spectrum-Picker").eq(4).click() |
cy.get(".spectrum-Popover").contains("One").click() |
||||
cy.get(".spectrum-Popover").contains("REGION_ID").click() |
cy.get(".spectrum-Picker").eq(1).click() |
||||
// Save relationship & reload page
|
cy.get(".spectrum-Popover").contains("REGIONS").click() |
||||
cy.get(".spectrum-Button").contains("Save").click({ force: true }) |
cy.get(".spectrum-Picker").eq(2).click() |
||||
cy.reload() |
cy.get(".spectrum-Popover").contains("REGION_ID").click() |
||||
}) |
cy.get(".spectrum-Picker").eq(3).click() |
||||
// Confirm table length & column name
|
cy.get(".spectrum-Popover").contains("COUNTRIES").click() |
||||
cy.get(".spectrum-Table-body").eq(1) |
cy.get(".spectrum-Picker").eq(4).click() |
||||
.find('tr') |
cy.get(".spectrum-Popover").contains("REGION_ID").click() |
||||
.its('length') |
// Save relationship & reload page
|
||||
.should('eq', 1) |
cy.get(".spectrum-Button").contains("Save").click({ force: true }) |
||||
cy.get(".spectrum-Table-cell").should('contain', "COUNTRIES to REGIONS") |
cy.reload() |
||||
}) |
}) |
||||
|
// Confirm table length & column name
|
||||
it("should define a Many relationship type", () => { |
cy.get(".spectrum-Table") |
||||
// Select relationship type & configure
|
.eq(1) |
||||
cy.get(".spectrum-Button").contains("Define relationship").click({ force: true }) |
.find(".spectrum-Table-row") |
||||
cy.get(".spectrum-Dialog-grid").within(() => { |
.its("length") |
||||
cy.get(".spectrum-Picker").eq(0).click() |
.should("eq", 1) |
||||
cy.get(".spectrum-Popover").contains("Many").click() |
cy.get(".spectrum-Table-cell").should("contain", "COUNTRIES to REGIONS") |
||||
cy.get(".spectrum-Picker").eq(1).click() |
}) |
||||
cy.get(".spectrum-Popover").contains("LOCATIONS").click() |
|
||||
cy.get(".spectrum-Picker").eq(2).click() |
it("should define a Many relationship type", () => { |
||||
cy.get(".spectrum-Popover").contains("REGIONS").click() |
// Select relationship type & configure
|
||||
cy.get(".spectrum-Picker").eq(3).click() |
cy.get(".spectrum-Button") |
||||
cy.get(".spectrum-Popover").contains("COUNTRIES").click() |
.contains("Define relationship") |
||||
cy.get(".spectrum-Picker").eq(4).click() |
.click({ force: true }) |
||||
cy.get(".spectrum-Popover").contains("COUNTRY_ID").click() |
cy.get(".spectrum-Dialog-grid").within(() => { |
||||
cy.get(".spectrum-Picker").eq(5).click() |
cy.get(".spectrum-Picker").eq(0).click() |
||||
cy.get(".spectrum-Popover").contains("REGION_ID").click() |
cy.get(".spectrum-Popover").contains("Many").click() |
||||
// Save relationship & reload page
|
cy.get(".spectrum-Picker").eq(1).click() |
||||
cy.get(".spectrum-Button").contains("Save").click({ force: true }) |
cy.get(".spectrum-Popover").contains("LOCATIONS").click() |
||||
cy.reload() |
cy.get(".spectrum-Picker").eq(2).click() |
||||
cy.wait(1000) |
cy.get(".spectrum-Popover").contains("REGIONS").click() |
||||
}) |
cy.get(".spectrum-Picker").eq(3).click() |
||||
// Confirm table length & relationship name
|
cy.get(".spectrum-Popover").contains("COUNTRIES").click() |
||||
cy.get(".spectrum-Table-body").eq(1) |
cy.get(".spectrum-Picker").eq(4).click() |
||||
.find('tr') |
cy.get(".spectrum-Popover").contains("COUNTRY_ID").click() |
||||
.its('length') |
cy.get(".spectrum-Picker").eq(5).click() |
||||
.should('eq', 2) |
cy.get(".spectrum-Popover").contains("REGION_ID").click() |
||||
cy.get(".spectrum-Table-cell") |
// Save relationship & reload page
|
||||
.should('contain', "LOCATIONS through COUNTRIES → REGIONS") |
cy.get(".spectrum-Button").contains("Save").click({ force: true }) |
||||
}) |
cy.reload() |
||||
|
cy.wait(1000) |
||||
it("should delete relationships", () => { |
}) |
||||
// Delete both relationships
|
// Confirm table length & relationship name
|
||||
cy.get(".spectrum-Table-body") |
cy.get(".spectrum-Table") |
||||
.eq(1).find('tr').its('length') |
.eq(1) |
||||
.then((len) => { |
.find(".spectrum-Table-row") |
||||
for (let i = 0; i < len; i++) { |
.its("length") |
||||
cy.get(".spectrum-Table-body").eq(1).within(() => { |
.should("eq", 2) |
||||
cy.get(".spectrum-Table-row").eq(0).click() |
cy.get(".spectrum-Table-cell").should( |
||||
cy.wait(500) |
"contain", |
||||
}) |
"LOCATIONS through COUNTRIES → REGIONS" |
||||
cy.get(".spectrum-Dialog-grid").within(() => { |
) |
||||
cy.get(".spectrum-Button").contains("Delete").click({ force: true }) |
}) |
||||
}) |
|
||||
cy.reload() |
it("should delete relationships", () => { |
||||
} |
// Delete both relationships
|
||||
// Confirm relationships no longer exist
|
cy.get(".spectrum-Table") |
||||
cy.get(".spectrum-Body").should('contain', 'No relationships configured') |
.eq(1) |
||||
}) |
.find(".spectrum-Table-row") |
||||
}) |
.its("length") |
||||
|
.then(len => { |
||||
it("should add a query", () => { |
for (let i = 0; i < len; i++) { |
||||
// Add query
|
cy.get(".spectrum-Table") |
||||
cy.get(".spectrum-Button").contains("Add query").click({ force: true }) |
.eq(1) |
||||
cy.get(".spectrum-Form-item").eq(0).within(() => { |
.within(() => { |
||||
cy.get("input").type(queryName) |
cy.get(".spectrum-Table-row").eq(0).click() |
||||
}) |
cy.wait(500) |
||||
// Insert Query within Fields section
|
|
||||
cy.get(".CodeMirror textarea").eq(0) |
|
||||
.type("SELECT * FROM books", { force: true }) |
|
||||
// Intercept query execution
|
|
||||
cy.intercept('**/queries/preview').as('query') |
|
||||
cy.get(".spectrum-Button").contains("Run Query").click({ force: true }) |
|
||||
cy.wait(500) |
|
||||
cy.wait("@query") |
|
||||
// Assert against Status Code & Body
|
|
||||
cy.get("@query").its('response.statusCode') |
|
||||
.should('eq', 200) |
|
||||
cy.get("@query").its('response.body') |
|
||||
.should('not.be.empty') |
|
||||
// Save query
|
|
||||
cy.get(".spectrum-Button").contains("Save Query").click({ force: true }) |
|
||||
cy.get(".nav-item").should('contain', queryName) |
|
||||
}) |
|
||||
|
|
||||
it("should duplicate a query", () => { |
|
||||
// Get last nav item - The query
|
|
||||
cy.get(".nav-item").last().within(() => { |
|
||||
cy.get(".icon").eq(1).click({ force: true }) |
|
||||
}) |
|
||||
// Select and confirm duplication
|
|
||||
cy.get(".spectrum-Menu").contains("Duplicate").click() |
|
||||
cy.get(".nav-item").should('contain', queryName + ' (1)') |
|
||||
}) |
|
||||
|
|
||||
it("should edit a query name", () => { |
|
||||
// Rename query
|
|
||||
cy.get(".spectrum-Form-item").eq(0).within(() => { |
|
||||
cy.get("input").clear().type(queryRename) |
|
||||
}) |
}) |
||||
// Save query
|
cy.get(".spectrum-Dialog-grid").within(() => { |
||||
cy.get(".spectrum-Button").contains("Save Query").click({ force: true }) |
cy.get(".spectrum-Button") |
||||
cy.get(".nav-item").should('contain', queryRename) |
.contains("Delete") |
||||
}) |
.click({ force: true }) |
||||
|
}) |
||||
it("should delete a query", () => { |
cy.reload() |
||||
// Get last nav item - The query
|
} |
||||
for (let i = 0; i < 2; i++) { |
// Confirm relationships no longer exist
|
||||
cy.get(".nav-item").last().within(() => { |
cy.get(".spectrum-Body").should( |
||||
cy.get(".icon").eq(1).click({ force: true }) |
"contain", |
||||
}) |
"No relationships configured" |
||||
// Select Delete
|
) |
||||
cy.get(".spectrum-Menu").contains("Delete").click() |
}) |
||||
cy.get(".spectrum-Button").contains("Delete Query").click({ force: true }) |
}) |
||||
cy.wait(1000) |
|
||||
} |
it("should add a query", () => { |
||||
// Confirm deletion
|
// Add query
|
||||
cy.get(".nav-item").should('not.contain', queryName) |
cy.get(".spectrum-Button").contains("Add query").click({ force: true }) |
||||
cy.get(".nav-item").should('not.contain', queryRename) |
cy.get(".spectrum-Form-item") |
||||
|
.eq(0) |
||||
|
.within(() => { |
||||
|
cy.get("input").type(queryName) |
||||
|
}) |
||||
|
// Insert Query within Fields section
|
||||
|
cy.get(".CodeMirror textarea") |
||||
|
.eq(0) |
||||
|
.type("SELECT * FROM books", { force: true }) |
||||
|
// Intercept query execution
|
||||
|
cy.intercept("**/queries/preview").as("query") |
||||
|
cy.get(".spectrum-Button").contains("Run Query").click({ force: true }) |
||||
|
cy.wait(500) |
||||
|
cy.wait("@query") |
||||
|
// Assert against Status Code & Body
|
||||
|
cy.get("@query").its("response.statusCode").should("eq", 200) |
||||
|
cy.get("@query").its("response.body").should("not.be.empty") |
||||
|
// Save query
|
||||
|
cy.get(".spectrum-Button").contains("Save Query").click({ force: true }) |
||||
|
cy.get(".nav-item").should("contain", queryName) |
||||
|
}) |
||||
|
|
||||
|
it("should duplicate a query", () => { |
||||
|
// Get last nav item - The query
|
||||
|
cy.get(".nav-item") |
||||
|
.last() |
||||
|
.within(() => { |
||||
|
cy.get(".icon").eq(1).click({ force: true }) |
||||
|
}) |
||||
|
// Select and confirm duplication
|
||||
|
cy.get(".spectrum-Menu").contains("Duplicate").click() |
||||
|
cy.get(".nav-item").should("contain", queryName + " (1)") |
||||
|
}) |
||||
|
|
||||
|
it("should edit a query name", () => { |
||||
|
// Rename query
|
||||
|
cy.get(".spectrum-Form-item") |
||||
|
.eq(0) |
||||
|
.within(() => { |
||||
|
cy.get("input").clear().type(queryRename) |
||||
|
}) |
||||
|
// Save query
|
||||
|
cy.get(".spectrum-Button").contains("Save Query").click({ force: true }) |
||||
|
cy.get(".nav-item").should("contain", queryRename) |
||||
|
}) |
||||
|
|
||||
|
it("should delete a query", () => { |
||||
|
// Get last nav item - The query
|
||||
|
for (let i = 0; i < 2; i++) { |
||||
|
cy.get(".nav-item") |
||||
|
.last() |
||||
|
.within(() => { |
||||
|
cy.get(".icon").eq(1).click({ force: true }) |
||||
}) |
}) |
||||
|
// Select Delete
|
||||
|
cy.get(".spectrum-Menu").contains("Delete").click() |
||||
|
cy.get(".spectrum-Button") |
||||
|
.contains("Delete Query") |
||||
|
.click({ force: true }) |
||||
|
cy.wait(1000) |
||||
} |
} |
||||
}) |
// Confirm deletion
|
||||
|
cy.get(".nav-item").should("not.contain", queryName) |
||||
|
cy.get(".nav-item").should("not.contain", queryRename) |
||||
|
}) |
||||
|
} |
||||
|
}) |
||||
}) |
}) |
||||
|
|||||
@ -1,196 +1,230 @@ |
|||||
import filterTests from "../../support/filterTests" |
import filterTests from "../../support/filterTests" |
||||
|
|
||||
filterTests(['all'], () => { |
filterTests(["all"], () => { |
||||
context("Oracle Datasource Testing", () => { |
context("Oracle Datasource Testing", () => { |
||||
if (Cypress.env("TEST_ENV")) { |
if (Cypress.env("TEST_ENV")) { |
||||
|
before(() => { |
||||
|
cy.login() |
||||
|
cy.createTestApp() |
||||
|
}) |
||||
|
const datasource = "Oracle" |
||||
|
const queryName = "Cypress Test Query" |
||||
|
const queryRename = "CT Query Rename" |
||||
|
|
||||
before(() => { |
it("Should add Oracle data source and skip table fetch", () => { |
||||
cy.login() |
// Select Oracle data source
|
||||
cy.createTestApp() |
cy.selectExternalDatasource(datasource) |
||||
}) |
// Skip table fetch - no config added
|
||||
const datasource = "Oracle" |
cy.get(".spectrum-Button") |
||||
const queryName = "Cypress Test Query" |
.contains("Skip table fetch") |
||||
const queryRename = "CT Query Rename" |
.click({ force: true }) |
||||
|
cy.wait(500) |
||||
it("Should add Oracle data source and skip table fetch", () => { |
// Confirm config contains localhost
|
||||
// Select Oracle data source
|
cy.get(".spectrum-Textfield-input") |
||||
cy.selectExternalDatasource(datasource) |
.eq(1) |
||||
// Skip table fetch - no config added
|
.should("have.value", "localhost") |
||||
cy.get(".spectrum-Button").contains("Skip table fetch").click({ force: true }) |
// Add another Oracle data source, configure & skip table fetch
|
||||
cy.wait(500) |
cy.selectExternalDatasource(datasource) |
||||
// Confirm config contains localhost
|
cy.addDatasourceConfig(datasource, true) |
||||
cy.get(".spectrum-Textfield-input").eq(1).should('have.value', 'localhost') |
// Confirm config and no tables
|
||||
// Add another Oracle data source, configure & skip table fetch
|
cy.get(".spectrum-Textfield-input") |
||||
cy.selectExternalDatasource(datasource) |
.eq(1) |
||||
cy.addDatasourceConfig(datasource, true) |
.should("have.value", Cypress.env("oracle").HOST) |
||||
// Confirm config and no tables
|
cy.get(".spectrum-Body").eq(2).should("contain", "No tables found.") |
||||
cy.get(".spectrum-Textfield-input").eq(1).should('have.value', Cypress.env("oracle").HOST) |
}) |
||||
cy.get(".spectrum-Body").eq(2).should('contain', 'No tables found.') |
|
||||
}) |
it("Should add Oracle data source and fetch tables without configuration", () => { |
||||
|
// Select Oracle data source
|
||||
it("Should add Oracle data source and fetch tables without configuration", () => { |
cy.selectExternalDatasource(datasource) |
||||
// Select Oracle data source
|
// Attempt to fetch tables without applying configuration
|
||||
cy.selectExternalDatasource(datasource) |
cy.intercept("**/datasources").as("datasource") |
||||
// Attempt to fetch tables without applying configuration
|
cy.get(".spectrum-Button") |
||||
cy.intercept('**/datasources').as('datasource') |
.contains("Save and fetch tables") |
||||
cy.get(".spectrum-Button") |
.click({ force: true }) |
||||
.contains("Save and fetch tables") |
// Intercept Request after button click & apply assertions
|
||||
.click({ force: true }) |
cy.wait("@datasource") |
||||
// Intercept Request after button click & apply assertions
|
cy.get("@datasource") |
||||
cy.wait("@datasource") |
.its("response.body") |
||||
cy.get("@datasource").its('response.body') |
.should("have.property", "status", 500) |
||||
.should('have.property', 'status', 500) |
}) |
||||
}) |
|
||||
|
it("should add Oracle data source and fetch tables", () => { |
||||
it("should add Oracle data source and fetch tables", () => { |
// Add & configure Oracle data source
|
||||
// Add & configure Oracle data source
|
cy.selectExternalDatasource(datasource) |
||||
cy.selectExternalDatasource(datasource) |
cy.intercept("**/datasources").as("datasource") |
||||
cy.intercept('**/datasources').as('datasource') |
cy.addDatasourceConfig(datasource) |
||||
cy.addDatasourceConfig(datasource) |
// Check response from datasource after adding configuration
|
||||
// Check response from datasource after adding configuration
|
cy.wait("@datasource") |
||||
cy.wait("@datasource") |
cy.get("@datasource").its("response.statusCode").should("eq", 200) |
||||
cy.get("@datasource").its('response.statusCode') |
// Confirm fetch tables was successful
|
||||
.should('eq', 200) |
cy.get(".spectrum-Table") |
||||
// Confirm fetch tables was successful
|
.eq(0) |
||||
cy.get(".spectrum-Table-body").eq(0) |
.find(".spectrum-Table-row") |
||||
.find('tr') |
.its("length") |
||||
.its('length') |
.should("be.gt", 0) |
||||
.should('be.gt', 0) |
}) |
||||
}) |
|
||||
|
it("should define a One relationship type", () => { |
||||
it("should define a One relationship type", () => { |
// Select relationship type & configure
|
||||
// Select relationship type & configure
|
cy.get(".spectrum-Button") |
||||
cy.get(".spectrum-Button").contains("Define relationship").click({ force: true }) |
.contains("Define relationship") |
||||
cy.get(".spectrum-Dialog-grid").within(() => { |
.click({ force: true }) |
||||
cy.get(".spectrum-Picker").eq(0).click() |
cy.get(".spectrum-Dialog-grid").within(() => { |
||||
cy.get(".spectrum-Popover").contains("One").click() |
cy.get(".spectrum-Picker").eq(0).click() |
||||
cy.get(".spectrum-Picker").eq(1).click() |
cy.get(".spectrum-Popover").contains("One").click() |
||||
cy.get(".spectrum-Popover").contains("REGIONS").click() |
cy.get(".spectrum-Picker").eq(1).click() |
||||
cy.get(".spectrum-Picker").eq(2).click() |
cy.get(".spectrum-Popover").contains("REGIONS").click() |
||||
cy.get(".spectrum-Popover").contains("REGION_ID").click() |
cy.get(".spectrum-Picker").eq(2).click() |
||||
cy.get(".spectrum-Picker").eq(3).click() |
cy.get(".spectrum-Popover").contains("REGION_ID").click() |
||||
cy.get(".spectrum-Popover").contains("COUNTRIES").click() |
cy.get(".spectrum-Picker").eq(3).click() |
||||
cy.get(".spectrum-Picker").eq(4).click() |
cy.get(".spectrum-Popover").contains("COUNTRIES").click() |
||||
cy.get(".spectrum-Popover").contains("REGION_ID").click() |
cy.get(".spectrum-Picker").eq(4).click() |
||||
// Save relationship & reload page
|
cy.get(".spectrum-Popover").contains("REGION_ID").click() |
||||
cy.get(".spectrum-Button").contains("Save").click({ force: true }) |
// Save relationship & reload page
|
||||
cy.reload() |
cy.get(".spectrum-Button").contains("Save").click({ force: true }) |
||||
}) |
cy.reload() |
||||
// Confirm table length & column name
|
}) |
||||
cy.get(".spectrum-Table-body").eq(1) |
// Confirm table length & column name
|
||||
.find('tr') |
cy.get(".spectrum-Table") |
||||
.its('length') |
.eq(1) |
||||
.should('eq', 1) |
.find(".spectrum-Table-row") |
||||
cy.get(".spectrum-Table-cell").should('contain', "COUNTRIES to REGIONS") |
.its("length") |
||||
}) |
.should("eq", 1) |
||||
|
cy.get(".spectrum-Table-cell").should("contain", "COUNTRIES to REGIONS") |
||||
it("should define a Many relationship type", () => { |
}) |
||||
// Select relationship type & configure
|
|
||||
cy.get(".spectrum-Button").contains("Define relationship").click({ force: true }) |
it("should define a Many relationship type", () => { |
||||
cy.get(".spectrum-Dialog-grid").within(() => { |
// Select relationship type & configure
|
||||
cy.get(".spectrum-Picker").eq(0).click() |
cy.get(".spectrum-Button") |
||||
cy.get(".spectrum-Popover").contains("Many").click() |
.contains("Define relationship") |
||||
cy.get(".spectrum-Picker").eq(1).click() |
.click({ force: true }) |
||||
cy.get(".spectrum-Popover").contains("LOCATIONS").click() |
cy.get(".spectrum-Dialog-grid").within(() => { |
||||
cy.get(".spectrum-Picker").eq(2).click() |
cy.get(".spectrum-Picker").eq(0).click() |
||||
cy.get(".spectrum-Popover").contains("REGIONS").click() |
cy.get(".spectrum-Popover").contains("Many").click() |
||||
cy.get(".spectrum-Picker").eq(3).click() |
cy.get(".spectrum-Picker").eq(1).click() |
||||
cy.get(".spectrum-Popover").contains("COUNTRIES").click() |
cy.get(".spectrum-Popover").contains("LOCATIONS").click() |
||||
cy.get(".spectrum-Picker").eq(4).click() |
cy.get(".spectrum-Picker").eq(2).click() |
||||
cy.get(".spectrum-Popover").contains("COUNTRY_ID").click() |
cy.get(".spectrum-Popover").contains("REGIONS").click() |
||||
cy.get(".spectrum-Picker").eq(5).click() |
cy.get(".spectrum-Picker").eq(3).click() |
||||
cy.get(".spectrum-Popover").contains("REGION_ID").click() |
cy.get(".spectrum-Popover").contains("COUNTRIES").click() |
||||
// Save relationship & reload page
|
cy.get(".spectrum-Picker").eq(4).click() |
||||
cy.get(".spectrum-Button").contains("Save").click({ force: true }) |
cy.get(".spectrum-Popover").contains("COUNTRY_ID").click() |
||||
cy.reload() |
cy.get(".spectrum-Picker").eq(5).click() |
||||
}) |
cy.get(".spectrum-Popover").contains("REGION_ID").click() |
||||
// Confirm table length & relationship name
|
// Save relationship & reload page
|
||||
cy.get(".spectrum-Table-body").eq(1) |
cy.get(".spectrum-Button").contains("Save").click({ force: true }) |
||||
.find('tr') |
cy.reload() |
||||
.its('length') |
}) |
||||
.should('eq', 2) |
// Confirm table length & relationship name
|
||||
cy.get(".spectrum-Table-cell") |
cy.get(".spectrum-Table") |
||||
.should('contain', "LOCATIONS through COUNTRIES → REGIONS") |
.eq(1) |
||||
}) |
.find(".spectrum-Table-row") |
||||
|
.its("length") |
||||
it("should delete relationships", () => { |
.should("eq", 2) |
||||
// Delete both relationships
|
cy.get(".spectrum-Table-cell").should( |
||||
cy.get(".spectrum-Table-body") |
"contain", |
||||
.eq(1).find('tr').its('length') |
"LOCATIONS through COUNTRIES → REGIONS" |
||||
.then((len) => { |
) |
||||
for (let i = 0; i < len; i++) { |
}) |
||||
cy.get(".spectrum-Table-body").eq(1).within(() => { |
|
||||
cy.get(".spectrum-Table-row").eq(0).click() |
it("should delete relationships", () => { |
||||
cy.wait(500) |
// Delete both relationships
|
||||
}) |
cy.get(".spectrum-Table") |
||||
cy.get(".spectrum-Dialog-grid").within(() => { |
.eq(1) |
||||
cy.get(".spectrum-Button").contains("Delete").click({ force: true }) |
.find(".spectrum-Table-row") |
||||
}) |
.its("length") |
||||
cy.reload() |
.then(len => { |
||||
} |
for (let i = 0; i < len; i++) { |
||||
// Confirm relationships no longer exist
|
cy.get(".spectrum-Table") |
||||
cy.get(".spectrum-Body").should('contain', 'No relationships configured') |
.eq(1) |
||||
}) |
.within(() => { |
||||
}) |
cy.get(".spectrum-Table-row").eq(0).click() |
||||
|
cy.wait(500) |
||||
it("should add a query", () => { |
|
||||
// Add query
|
|
||||
cy.get(".spectrum-Button").contains("Add query").click({ force: true }) |
|
||||
cy.get(".spectrum-Form-item").eq(0).within(() => { |
|
||||
cy.get("input").type(queryName) |
|
||||
}) |
|
||||
// Insert Query within Fields section
|
|
||||
cy.get(".CodeMirror textarea").eq(0) |
|
||||
.type("SELECT * FROM JOBS", { force: true }) |
|
||||
// Intercept query execution
|
|
||||
cy.intercept('**/queries/preview').as('query') |
|
||||
cy.get(".spectrum-Button").contains("Run Query").click({ force: true }) |
|
||||
cy.wait(500) |
|
||||
cy.wait("@query") |
|
||||
// Assert against Status Code & Body
|
|
||||
cy.get("@query").its('response.statusCode') |
|
||||
.should('eq', 200) |
|
||||
cy.get("@query").its('response.body') |
|
||||
.should('not.be.empty') |
|
||||
// Save query
|
|
||||
cy.get(".spectrum-Button").contains("Save Query").click({ force: true }) |
|
||||
cy.get(".nav-item").should('contain', queryName) |
|
||||
}) |
|
||||
|
|
||||
it("should duplicate a query", () => { |
|
||||
// Get query nav item
|
|
||||
cy.get(".nav-item").contains(queryName).parent().within(() => { |
|
||||
cy.get(".spectrum-Icon").eq(1).click({ force: true }) |
|
||||
}) |
|
||||
// Select and confirm duplication
|
|
||||
cy.get(".spectrum-Menu").contains("Duplicate").click() |
|
||||
cy.get(".nav-item").should('contain', queryName + ' (1)') |
|
||||
}) |
|
||||
|
|
||||
it("should edit a query name", () => { |
|
||||
// Rename query
|
|
||||
cy.get(".spectrum-Form-item").eq(0).within(() => { |
|
||||
cy.get("input").clear().type(queryRename) |
|
||||
}) |
|
||||
// Save query
|
|
||||
cy.get(".spectrum-Button").contains("Save Query").click({ force: true }) |
|
||||
cy.get(".nav-item").should('contain', queryRename) |
|
||||
}) |
|
||||
|
|
||||
it("should delete a query", () => { |
|
||||
// Get query nav item - QueryName
|
|
||||
cy.get(".nav-item").contains(queryName).parent().within(() => { |
|
||||
cy.get(".spectrum-Icon").eq(1).click({ force: true }) |
|
||||
}) |
}) |
||||
|
cy.get(".spectrum-Dialog-grid").within(() => { |
||||
// Select Delete
|
cy.get(".spectrum-Button") |
||||
cy.get(".spectrum-Menu").contains("Delete").click() |
.contains("Delete") |
||||
cy.get(".spectrum-Button").contains("Delete Query").click({ force: true }) |
.click({ force: true }) |
||||
cy.wait(1000) |
}) |
||||
|
cy.reload() |
||||
// Confirm deletion
|
} |
||||
cy.get(".nav-item").should('not.contain', queryName) |
// Confirm relationships no longer exist
|
||||
}) |
cy.get(".spectrum-Body").should( |
||||
} |
"contain", |
||||
}) |
"No relationships configured" |
||||
|
) |
||||
|
}) |
||||
|
}) |
||||
|
|
||||
|
it("should add a query", () => { |
||||
|
// Add query
|
||||
|
cy.get(".spectrum-Button").contains("Add query").click({ force: true }) |
||||
|
cy.get(".spectrum-Form-item") |
||||
|
.eq(0) |
||||
|
.within(() => { |
||||
|
cy.get("input").type(queryName) |
||||
|
}) |
||||
|
// Insert Query within Fields section
|
||||
|
cy.get(".CodeMirror textarea") |
||||
|
.eq(0) |
||||
|
.type("SELECT * FROM JOBS", { force: true }) |
||||
|
// Intercept query execution
|
||||
|
cy.intercept("**/queries/preview").as("query") |
||||
|
cy.get(".spectrum-Button").contains("Run Query").click({ force: true }) |
||||
|
cy.wait(500) |
||||
|
cy.wait("@query") |
||||
|
// Assert against Status Code & Body
|
||||
|
cy.get("@query").its("response.statusCode").should("eq", 200) |
||||
|
cy.get("@query").its("response.body").should("not.be.empty") |
||||
|
// Save query
|
||||
|
cy.get(".spectrum-Button").contains("Save Query").click({ force: true }) |
||||
|
cy.get(".nav-item").should("contain", queryName) |
||||
|
}) |
||||
|
|
||||
|
it("should duplicate a query", () => { |
||||
|
// Get query nav item
|
||||
|
cy.get(".nav-item") |
||||
|
.contains(queryName) |
||||
|
.parent() |
||||
|
.within(() => { |
||||
|
cy.get(".spectrum-Icon").eq(1).click({ force: true }) |
||||
|
}) |
||||
|
// Select and confirm duplication
|
||||
|
cy.get(".spectrum-Menu").contains("Duplicate").click() |
||||
|
cy.get(".nav-item").should("contain", queryName + " (1)") |
||||
|
}) |
||||
|
|
||||
|
it("should edit a query name", () => { |
||||
|
// Rename query
|
||||
|
cy.get(".spectrum-Form-item") |
||||
|
.eq(0) |
||||
|
.within(() => { |
||||
|
cy.get("input").clear().type(queryRename) |
||||
|
}) |
||||
|
// Save query
|
||||
|
cy.get(".spectrum-Button").contains("Save Query").click({ force: true }) |
||||
|
cy.get(".nav-item").should("contain", queryRename) |
||||
|
}) |
||||
|
|
||||
|
it("should delete a query", () => { |
||||
|
// Get query nav item - QueryName
|
||||
|
cy.get(".nav-item") |
||||
|
.contains(queryName) |
||||
|
.parent() |
||||
|
.within(() => { |
||||
|
cy.get(".spectrum-Icon").eq(1).click({ force: true }) |
||||
|
}) |
||||
|
|
||||
|
// Select Delete
|
||||
|
cy.get(".spectrum-Menu").contains("Delete").click() |
||||
|
cy.get(".spectrum-Button") |
||||
|
.contains("Delete Query") |
||||
|
.click({ force: true }) |
||||
|
cy.wait(1000) |
||||
|
|
||||
|
// Confirm deletion
|
||||
|
cy.get(".nav-item").should("not.contain", queryName) |
||||
|
}) |
||||
|
} |
||||
|
}) |
||||
}) |
}) |
||||
|
|||||
@ -1,241 +1,285 @@ |
|||||
import filterTests from "../../support/filterTests" |
import filterTests from "../../support/filterTests" |
||||
|
|
||||
filterTests(['all'], () => { |
filterTests(["all"], () => { |
||||
context("PostgreSQL Datasource Testing", () => { |
context("PostgreSQL Datasource Testing", () => { |
||||
if (Cypress.env("TEST_ENV")) { |
if (Cypress.env("TEST_ENV")) { |
||||
|
before(() => { |
||||
before(() => { |
cy.login() |
||||
cy.login() |
cy.createTestApp() |
||||
cy.createTestApp() |
}) |
||||
}) |
const datasource = "PostgreSQL" |
||||
const datasource = "PostgreSQL" |
const queryName = "Cypress Test Query" |
||||
const queryName = "Cypress Test Query" |
const queryRename = "CT Query Rename" |
||||
const queryRename = "CT Query Rename" |
|
||||
|
it("Should add PostgreSQL data source without configuration", () => { |
||||
it("Should add PostgreSQL data source without configuration", () => { |
// Select PostgreSQL data source
|
||||
// Select PostgreSQL data source
|
cy.selectExternalDatasource(datasource) |
||||
cy.selectExternalDatasource(datasource) |
// Attempt to fetch tables without applying configuration
|
||||
// Attempt to fetch tables without applying configuration
|
cy.intercept("**/datasources").as("datasource") |
||||
cy.intercept('**/datasources').as('datasource') |
cy.get(".spectrum-Button") |
||||
cy.get(".spectrum-Button") |
.contains("Save and fetch tables") |
||||
.contains("Save and fetch tables") |
.click({ force: true }) |
||||
.click({ force: true }) |
// Intercept Request after button click & apply assertions
|
||||
// Intercept Request after button click & apply assertions
|
cy.wait("@datasource") |
||||
cy.wait("@datasource") |
cy.get("@datasource") |
||||
cy.get("@datasource").its('response.body') |
.its("response.body") |
||||
.should('have.property', 'message', 'connect ECONNREFUSED 127.0.0.1:5432') |
.should( |
||||
cy.get("@datasource").its('response.body') |
"have.property", |
||||
.should('have.property', 'status', 500) |
"message", |
||||
}) |
"connect ECONNREFUSED 127.0.0.1:5432" |
||||
|
) |
||||
it("should add PostgreSQL data source and fetch tables", () => { |
cy.get("@datasource") |
||||
// Add & configure PostgreSQL data source
|
.its("response.body") |
||||
cy.selectExternalDatasource(datasource) |
.should("have.property", "status", 500) |
||||
cy.intercept('**/datasources').as('datasource') |
}) |
||||
cy.addDatasourceConfig(datasource) |
|
||||
// Check response from datasource after adding configuration
|
it("should add PostgreSQL data source and fetch tables", () => { |
||||
cy.wait("@datasource") |
// Add & configure PostgreSQL data source
|
||||
cy.get("@datasource").its('response.statusCode') |
cy.selectExternalDatasource(datasource) |
||||
.should('eq', 200) |
cy.intercept("**/datasources").as("datasource") |
||||
// Confirm fetch tables was successful
|
cy.addDatasourceConfig(datasource) |
||||
cy.get(".spectrum-Table-body").eq(0) |
// Check response from datasource after adding configuration
|
||||
.find('tr') |
cy.wait("@datasource") |
||||
.its('length') |
cy.get("@datasource").its("response.statusCode").should("eq", 200) |
||||
.should('be.gt', 0) |
// Confirm fetch tables was successful
|
||||
}) |
cy.get(".spectrum-Table") |
||||
|
.eq(0) |
||||
it("should define a One relationship type", () => { |
.find(".spectrum-Table-row") |
||||
// Select relationship type & configure
|
.its("length") |
||||
cy.get(".spectrum-Button").contains("Define relationship").click({ force: true }) |
.should("be.gt", 0) |
||||
cy.get(".spectrum-Dialog-grid").within(() => { |
}) |
||||
cy.get(".spectrum-Picker").eq(0).click() |
|
||||
cy.get(".spectrum-Popover").contains("One").click() |
it("should define a One relationship type", () => { |
||||
cy.get(".spectrum-Picker").eq(1).click() |
// Select relationship type & configure
|
||||
cy.get(".spectrum-Popover").contains("REGIONS").click() |
cy.get(".spectrum-Button") |
||||
cy.get(".spectrum-Picker").eq(2).click() |
.contains("Define relationship") |
||||
cy.get(".spectrum-Popover").contains("REGION_ID").click() |
.click({ force: true }) |
||||
cy.get(".spectrum-Picker").eq(3).click() |
cy.get(".spectrum-Dialog-grid").within(() => { |
||||
cy.get(".spectrum-Popover").contains("COUNTRIES").click() |
cy.get(".spectrum-Picker").eq(0).click() |
||||
cy.get(".spectrum-Picker").eq(4).click() |
cy.get(".spectrum-Popover").contains("One").click() |
||||
cy.get(".spectrum-Popover").contains("REGION_ID").click() |
cy.get(".spectrum-Picker").eq(1).click() |
||||
// Save relationship & reload page
|
cy.get(".spectrum-Popover").contains("REGIONS").click() |
||||
cy.get(".spectrum-Button").contains("Save").click({ force: true }) |
cy.get(".spectrum-Picker").eq(2).click() |
||||
cy.reload() |
cy.get(".spectrum-Popover").contains("REGION_ID").click() |
||||
}) |
cy.get(".spectrum-Picker").eq(3).click() |
||||
// Confirm table length & column name
|
cy.get(".spectrum-Popover").contains("COUNTRIES").click() |
||||
cy.get(".spectrum-Table-body").eq(1) |
cy.get(".spectrum-Picker").eq(4).click() |
||||
.find('tr') |
cy.get(".spectrum-Popover").contains("REGION_ID").click() |
||||
.its('length') |
// Save relationship & reload page
|
||||
.should('eq', 1) |
cy.get(".spectrum-Button").contains("Save").click({ force: true }) |
||||
cy.get(".spectrum-Table-cell").should('contain', "COUNTRIES to REGIONS") |
cy.reload() |
||||
}) |
}) |
||||
|
// Confirm table length & column name
|
||||
it("should define a Many relationship type", () => { |
cy.get(".spectrum-Table") |
||||
// Select relationship type & configure
|
.eq(1) |
||||
cy.get(".spectrum-Button").contains("Define relationship").click({ force: true }) |
.find(".spectrum-Table-row") |
||||
cy.get(".spectrum-Dialog-grid").within(() => { |
.its("length") |
||||
cy.get(".spectrum-Picker").eq(0).click() |
.should("eq", 1) |
||||
cy.get(".spectrum-Popover").contains("Many").click() |
cy.get(".spectrum-Table-cell").should("contain", "COUNTRIES to REGIONS") |
||||
cy.get(".spectrum-Picker").eq(1).click() |
}) |
||||
cy.get(".spectrum-Popover").contains("LOCATIONS").click() |
|
||||
cy.get(".spectrum-Picker").eq(2).click() |
it("should define a Many relationship type", () => { |
||||
cy.get(".spectrum-Popover").contains("REGIONS").click() |
// Select relationship type & configure
|
||||
cy.get(".spectrum-Picker").eq(3).click() |
cy.get(".spectrum-Button") |
||||
cy.get(".spectrum-Popover").contains("COUNTRIES").click() |
.contains("Define relationship") |
||||
cy.get(".spectrum-Picker").eq(4).click() |
.click({ force: true }) |
||||
cy.get(".spectrum-Popover").contains("COUNTRY_ID").click() |
cy.get(".spectrum-Dialog-grid").within(() => { |
||||
cy.get(".spectrum-Picker").eq(5).click() |
cy.get(".spectrum-Picker").eq(0).click() |
||||
cy.get(".spectrum-Popover").contains("REGION_ID").click() |
cy.get(".spectrum-Popover").contains("Many").click() |
||||
// Save relationship & reload page
|
cy.get(".spectrum-Picker").eq(1).click() |
||||
cy.get(".spectrum-Button").contains("Save").click({ force: true }) |
cy.get(".spectrum-Popover").contains("LOCATIONS").click() |
||||
cy.reload() |
cy.get(".spectrum-Picker").eq(2).click() |
||||
}) |
cy.get(".spectrum-Popover").contains("REGIONS").click() |
||||
// Confirm table length & relationship name
|
cy.get(".spectrum-Picker").eq(3).click() |
||||
cy.get(".spectrum-Table-body").eq(1) |
cy.get(".spectrum-Popover").contains("COUNTRIES").click() |
||||
.find('tr') |
cy.get(".spectrum-Picker").eq(4).click() |
||||
.its('length') |
cy.get(".spectrum-Popover").contains("COUNTRY_ID").click() |
||||
.should('eq', 2) |
cy.get(".spectrum-Picker").eq(5).click() |
||||
cy.get(".spectrum-Table-cell") |
cy.get(".spectrum-Popover").contains("REGION_ID").click() |
||||
.should('contain', "LOCATIONS through COUNTRIES → REGIONS") |
// Save relationship & reload page
|
||||
}) |
cy.get(".spectrum-Button").contains("Save").click({ force: true }) |
||||
|
cy.reload() |
||||
it("should delete a relationship", () => { |
}) |
||||
cy.get(".hierarchy-items-container").contains(datasource).click() |
// Confirm table length & relationship name
|
||||
cy.reload() |
cy.get(".spectrum-Table") |
||||
// Delete one relationship
|
.eq(1) |
||||
cy.get(".spectrum-Table-body").eq(1).within(() => { |
.find(".spectrum-Table-row") |
||||
cy.get(".spectrum-Table-row").eq(0).click() |
.its("length") |
||||
cy.wait(500) |
.should("eq", 2) |
||||
}) |
cy.get(".spectrum-Table-cell").should( |
||||
cy.get(".spectrum-Dialog-grid").within(() => { |
"contain", |
||||
cy.get(".spectrum-Button").contains("Delete").click({ force: true }) |
"LOCATIONS through COUNTRIES → REGIONS" |
||||
}) |
) |
||||
cy.reload() |
}) |
||||
// Confirm relationship was deleted
|
|
||||
cy.get(".spectrum-Table-body") |
it("should delete a relationship", () => { |
||||
.eq(1).find('tr').its('length').should('eq', 1) |
cy.get(".hierarchy-items-container").contains(datasource).click() |
||||
}) |
cy.reload() |
||||
|
// Delete one relationship
|
||||
it("should add a query", () => { |
cy.get(".spectrum-Table") |
||||
// Add query
|
.eq(1) |
||||
cy.get(".spectrum-Button").contains("Add query").click({ force: true }) |
.within(() => { |
||||
cy.get(".spectrum-Form-item").eq(0).within(() => { |
cy.get(".spectrum-Table-row").eq(0).click() |
||||
cy.get("input").type(queryName) |
cy.wait(500) |
||||
}) |
}) |
||||
// Insert Query within Fields section
|
cy.get(".spectrum-Dialog-grid").within(() => { |
||||
cy.get(".CodeMirror textarea").eq(0) |
cy.get(".spectrum-Button").contains("Delete").click({ force: true }) |
||||
.type("SELECT * FROM books", { force: true }) |
}) |
||||
// Intercept query execution
|
cy.reload() |
||||
cy.intercept('**/queries/preview').as('query') |
// Confirm relationship was deleted
|
||||
cy.get(".spectrum-Button").contains("Run Query").click({ force: true }) |
cy.get(".spectrum-Table") |
||||
cy.wait(500) |
.eq(1) |
||||
cy.wait("@query") |
.find(".spectrum-Table-row") |
||||
// Assert against Status Code & Body
|
.its("length") |
||||
cy.get("@query").its('response.statusCode') |
.should("eq", 1) |
||||
.should('eq', 200) |
}) |
||||
cy.get("@query").its('response.body') |
|
||||
.should('not.be.empty') |
it("should add a query", () => { |
||||
// Save query
|
// Add query
|
||||
cy.get(".spectrum-Button").contains("Save Query").click({ force: true }) |
cy.get(".spectrum-Button").contains("Add query").click({ force: true }) |
||||
cy.get(".hierarchy-items-container").should('contain', queryName) |
cy.get(".spectrum-Form-item") |
||||
}) |
.eq(0) |
||||
|
.within(() => { |
||||
it("should switch to schema with no tables", () => { |
cy.get("input").type(queryName) |
||||
// Switch Schema - To one without any tables
|
}) |
||||
cy.get(".hierarchy-items-container").contains(datasource).click() |
// Insert Query within Fields section
|
||||
switchSchema("randomText") |
cy.get(".CodeMirror textarea") |
||||
|
.eq(0) |
||||
// No tables displayed
|
.type("SELECT * FROM books", { force: true }) |
||||
cy.get(".spectrum-Body").eq(2).should('contain', 'No tables found') |
// Intercept query execution
|
||||
|
cy.intercept("**/queries/preview").as("query") |
||||
// Previously created query should be visible
|
cy.get(".spectrum-Button").contains("Run Query").click({ force: true }) |
||||
cy.get(".spectrum-Table-body").should('contain', queryName) |
cy.wait(500) |
||||
}) |
cy.wait("@query") |
||||
|
// Assert against Status Code & Body
|
||||
it("should switch schemas", () => { |
cy.get("@query").its("response.statusCode").should("eq", 200) |
||||
// Switch schema - To one with tables
|
cy.get("@query").its("response.body").should("not.be.empty") |
||||
switchSchema("1") |
// Save query
|
||||
|
cy.get(".spectrum-Button").contains("Save Query").click({ force: true }) |
||||
// Confirm tables exist - Check for specific one
|
cy.get(".hierarchy-items-container").should("contain", queryName) |
||||
cy.get(".spectrum-Table-body").eq(0).should('contain', 'test') |
}) |
||||
cy.get(".spectrum-Table-body").eq(0).find('tr').its('length').should('eq', 1) |
|
||||
|
it("should switch to schema with no tables", () => { |
||||
// Confirm specific table visible within left nav bar
|
// Switch Schema - To one without any tables
|
||||
cy.get(".hierarchy-items-container").should('contain', 'test') |
cy.get(".hierarchy-items-container").contains(datasource).click() |
||||
|
switchSchema("randomText") |
||||
// Switch back to public schema
|
|
||||
switchSchema("public") |
// No tables displayed
|
||||
|
cy.get(".spectrum-Body").eq(2).should("contain", "No tables found") |
||||
// Confirm tables exist - again
|
|
||||
cy.get(".spectrum-Table-body").eq(0).should('contain', 'REGIONS') |
// Previously created query should be visible
|
||||
cy.get(".spectrum-Table-body").eq(0) |
cy.get(".spectrum-Table").should("contain", queryName) |
||||
.find('tr').its('length').should('be.gt', 1) |
}) |
||||
|
|
||||
// Confirm specific table visible within left nav bar
|
it("should switch schemas", () => { |
||||
cy.get(".hierarchy-items-container").should('contain', 'REGIONS') |
// Switch schema - To one with tables
|
||||
|
switchSchema("1") |
||||
// No relationships and one query
|
|
||||
cy.get(".spectrum-Body").eq(3).should('contain', 'No relationships configured.') |
// Confirm tables exist - Check for specific one
|
||||
cy.get(".spectrum-Table-body").eq(1).should('contain', queryName) |
cy.get(".spectrum-Table").eq(0).should("contain", "test") |
||||
}) |
cy.get(".spectrum-Table") |
||||
|
.eq(0) |
||||
it("should duplicate a query", () => { |
.find(".spectrum-Table-row") |
||||
// Get last nav item - The query
|
.its("length") |
||||
cy.get(".nav-item").last().within(() => { |
.should("eq", 1) |
||||
cy.get(".icon").eq(1).click({ force: true }) |
|
||||
}) |
// Confirm specific table visible within left nav bar
|
||||
// Select and confirm duplication
|
cy.get(".hierarchy-items-container").should("contain", "test") |
||||
cy.get(".spectrum-Menu").contains("Duplicate").click() |
|
||||
cy.get(".nav-item").should('contain', queryName + ' (1)') |
// Switch back to public schema
|
||||
}) |
switchSchema("public") |
||||
|
|
||||
it("should edit a query name", () => { |
// Confirm tables exist - again
|
||||
// Access query
|
cy.get(".spectrum-Table").eq(0).should("contain", "REGIONS") |
||||
cy.get(".hierarchy-items-container").contains(queryName + ' (1)').click() |
cy.get(".spectrum-Table") |
||||
|
.eq(0) |
||||
// Rename query
|
.find(".spectrum-Table-row") |
||||
cy.get(".spectrum-Form-item").eq(0).within(() => { |
.its("length") |
||||
cy.get("input").clear().type(queryRename) |
.should("be.gt", 1) |
||||
}) |
|
||||
|
// Confirm specific table visible within left nav bar
|
||||
// Run and Save query
|
cy.get(".hierarchy-items-container").should("contain", "REGIONS") |
||||
cy.get(".spectrum-Button").contains("Run Query").click({ force: true }) |
|
||||
cy.wait(500) |
// No relationships and one query
|
||||
cy.get(".spectrum-Button").contains("Save Query").click({ force: true }) |
cy.get(".spectrum-Body") |
||||
cy.get(".nav-item").should('contain', queryRename) |
.eq(3) |
||||
}) |
.should("contain", "No relationships configured.") |
||||
|
cy.get(".spectrum-Table").eq(1).should("contain", queryName) |
||||
it("should delete a query", () => { |
}) |
||||
// Get last nav item - The query
|
|
||||
for (let i = 0; i < 2; i++) { |
it("should duplicate a query", () => { |
||||
cy.get(".nav-item").last().within(() => { |
// Get last nav item - The query
|
||||
cy.get(".icon").eq(1).click({ force: true }) |
cy.get(".nav-item") |
||||
}) |
.last() |
||||
// Select Delete
|
.within(() => { |
||||
cy.get(".spectrum-Menu").contains("Delete").click() |
cy.get(".icon").eq(1).click({ force: true }) |
||||
cy.get(".spectrum-Button").contains("Delete Query").click({ force: true }) |
}) |
||||
cy.wait(1000) |
// Select and confirm duplication
|
||||
} |
cy.get(".spectrum-Menu").contains("Duplicate").click() |
||||
// Confirm deletion
|
cy.get(".nav-item").should("contain", queryName + " (1)") |
||||
cy.get(".nav-item").should('not.contain', queryName) |
}) |
||||
cy.get(".nav-item").should('not.contain', queryRename) |
|
||||
|
it("should edit a query name", () => { |
||||
|
// Access query
|
||||
|
cy.get(".hierarchy-items-container") |
||||
|
.contains(queryName + " (1)") |
||||
|
.click() |
||||
|
|
||||
|
// Rename query
|
||||
|
cy.get(".spectrum-Form-item") |
||||
|
.eq(0) |
||||
|
.within(() => { |
||||
|
cy.get("input").clear().type(queryRename) |
||||
|
}) |
||||
|
|
||||
|
// Run and Save query
|
||||
|
cy.get(".spectrum-Button").contains("Run Query").click({ force: true }) |
||||
|
cy.wait(500) |
||||
|
cy.get(".spectrum-Button").contains("Save Query").click({ force: true }) |
||||
|
cy.get(".nav-item").should("contain", queryRename) |
||||
|
}) |
||||
|
|
||||
|
it("should delete a query", () => { |
||||
|
// Get last nav item - The query
|
||||
|
for (let i = 0; i < 2; i++) { |
||||
|
cy.get(".nav-item") |
||||
|
.last() |
||||
|
.within(() => { |
||||
|
cy.get(".icon").eq(1).click({ force: true }) |
||||
}) |
}) |
||||
|
// Select Delete
|
||||
const switchSchema = (schema) => { |
cy.get(".spectrum-Menu").contains("Delete").click() |
||||
// Edit configuration - Change Schema
|
cy.get(".spectrum-Button") |
||||
cy.get(".spectrum-Textfield").eq(6).within(() => { |
.contains("Delete Query") |
||||
cy.get('input').clear().type(schema) |
.click({ force: true }) |
||||
}) |
cy.wait(1000) |
||||
// Save configuration & fetch
|
|
||||
cy.get(".spectrum-Button").contains("Save").click({ force: true }) |
|
||||
cy.get(".spectrum-Button").contains("Fetch tables").click({ force: true }) |
|
||||
// Click fetch tables again within modal
|
|
||||
cy.get(".spectrum-Dialog-grid").within(() => { |
|
||||
cy.get(".spectrum-Button").contains("Fetch tables").click({ force: true }) |
|
||||
}) |
|
||||
cy.reload() |
|
||||
cy.wait(5000) |
|
||||
} |
|
||||
} |
} |
||||
}) |
// Confirm deletion
|
||||
|
cy.get(".nav-item").should("not.contain", queryName) |
||||
|
cy.get(".nav-item").should("not.contain", queryRename) |
||||
|
}) |
||||
|
|
||||
|
const switchSchema = schema => { |
||||
|
// Edit configuration - Change Schema
|
||||
|
cy.get(".spectrum-Textfield") |
||||
|
.eq(6) |
||||
|
.within(() => { |
||||
|
cy.get("input").clear().type(schema) |
||||
|
}) |
||||
|
// Save configuration & fetch
|
||||
|
cy.get(".spectrum-Button").contains("Save").click({ force: true }) |
||||
|
cy.get(".spectrum-Button") |
||||
|
.contains("Fetch tables") |
||||
|
.click({ force: true }) |
||||
|
// Click fetch tables again within modal
|
||||
|
cy.get(".spectrum-Dialog-grid").within(() => { |
||||
|
cy.get(".spectrum-Button") |
||||
|
.contains("Fetch tables") |
||||
|
.click({ force: true }) |
||||
|
}) |
||||
|
cy.reload() |
||||
|
cy.wait(5000) |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
}) |
}) |
||||
|
|||||
@ -0,0 +1,66 @@ |
|||||
|
<script> |
||||
|
import { |
||||
|
Input, |
||||
|
Select, |
||||
|
ColorPicker, |
||||
|
DrawerContent, |
||||
|
Layout, |
||||
|
Label, |
||||
|
} from "@budibase/bbui" |
||||
|
import { store } from "builderStore" |
||||
|
import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte" |
||||
|
|
||||
|
export let column |
||||
|
</script> |
||||
|
|
||||
|
<DrawerContent> |
||||
|
<div class="container"> |
||||
|
<Layout noPadding gap="S"> |
||||
|
<Input bind:value={column.width} label="Width" placeholder="Auto" /> |
||||
|
<Select |
||||
|
label="Alignment" |
||||
|
bind:value={column.align} |
||||
|
options={["Left", "Center", "Right"]} |
||||
|
placeholder="Default" |
||||
|
/> |
||||
|
<DrawerBindableInput |
||||
|
label="Value" |
||||
|
value={column.template} |
||||
|
on:change={e => (column.template = e.detail)} |
||||
|
placeholder={`{{ Value }}`} |
||||
|
bindings={[ |
||||
|
{ |
||||
|
readableBinding: "Value", |
||||
|
runtimeBinding: "[value]", |
||||
|
}, |
||||
|
]} |
||||
|
/> |
||||
|
<Layout noPadding gap="XS"> |
||||
|
<Label>Background color</Label> |
||||
|
<ColorPicker |
||||
|
value={column.background} |
||||
|
on:change={e => (column.background = e.detail)} |
||||
|
alignRight |
||||
|
spectrumTheme={$store.theme} |
||||
|
/> |
||||
|
</Layout> |
||||
|
<Layout noPadding gap="XS"> |
||||
|
<Label>Text color</Label> |
||||
|
<ColorPicker |
||||
|
value={column.color} |
||||
|
on:change={e => (column.color = e.detail)} |
||||
|
alignRight |
||||
|
spectrumTheme={$store.theme} |
||||
|
/> |
||||
|
</Layout> |
||||
|
</Layout> |
||||
|
</div> |
||||
|
</DrawerContent> |
||||
|
|
||||
|
<style> |
||||
|
.container { |
||||
|
width: 100%; |
||||
|
max-width: 240px; |
||||
|
margin: 0 auto; |
||||
|
} |
||||
|
</style> |
||||
@ -0,0 +1,34 @@ |
|||||
|
<script> |
||||
|
import { Drawer, Button, Icon } from "@budibase/bbui" |
||||
|
import CellDrawer from "./CellDrawer.svelte" |
||||
|
|
||||
|
export let column |
||||
|
|
||||
|
let boundValue |
||||
|
let drawer |
||||
|
|
||||
|
$: updateBoundValue(column) |
||||
|
|
||||
|
const updateBoundValue = value => { |
||||
|
boundValue = { ...value } |
||||
|
} |
||||
|
|
||||
|
const open = () => { |
||||
|
updateBoundValue(column) |
||||
|
drawer.show() |
||||
|
} |
||||
|
|
||||
|
const save = () => { |
||||
|
column = boundValue |
||||
|
drawer.hide() |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<Icon name="Settings" hoverable size="S" on:click={open} /> |
||||
|
<Drawer bind:this={drawer} title="Table Columns"> |
||||
|
<svelte:fragment slot="description"> |
||||
|
"{column.name}" column settings |
||||
|
</svelte:fragment> |
||||
|
<Button cta slot="buttons" on:click={save}>Save</Button> |
||||
|
<CellDrawer slot="body" bind:column={boundValue} /> |
||||
|
</Drawer> |
||||
Loading…
Reference in new issue