|
|
@ -10,7 +10,7 @@ Cypress.on("uncaught:exception", () => { |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
Cypress.Commands.add("login", () => { |
|
|
Cypress.Commands.add("login", () => { |
|
|
cy.visit(`${Cypress.config().baseUrl}/builder`) |
|
|
cy.visit(`localhost:${Cypress.env("PORT")}/builder`) |
|
|
cy.wait(2000) |
|
|
cy.wait(2000) |
|
|
cy.url().then(url => { |
|
|
cy.url().then(url => { |
|
|
if (url.includes("builder/admin")) { |
|
|
if (url.includes("builder/admin")) { |
|
|
@ -33,77 +33,31 @@ Cypress.Commands.add("login", () => { |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
Cypress.Commands.add("createApp", name => { |
|
|
Cypress.Commands.add("createApp", name => { |
|
|
cy.visit(`${Cypress.config().baseUrl}/builder`) |
|
|
cy.visit(`localhost:${Cypress.env("PORT")}/builder`) |
|
|
cy.wait(500) |
|
|
cy.wait(500) |
|
|
cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`) |
|
|
|
|
|
.its("body") |
|
|
|
|
|
.then(body => { |
|
|
|
|
|
if (body.length > 0) { |
|
|
|
|
|
cy.get(".spectrum-Button").contains("Create app").click({ force: true }) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
cy.contains(/Start from scratch/).dblclick() |
|
|
cy.contains(/Start from scratch/).dblclick() |
|
|
cy.wait(2000) |
|
|
|
|
|
cy.get(".spectrum-Modal").within(() => { |
|
|
cy.get(".spectrum-Modal").within(() => { |
|
|
cy.get("input").eq(0).type(name).should("have.value", name).blur() |
|
|
cy.get("input").eq(0).type(name).should("have.value", name).blur() |
|
|
cy.get(".spectrum-ButtonGroup").contains("Create app").click() |
|
|
cy.get(".spectrum-ButtonGroup").contains("Create app").click() |
|
|
cy.wait(5000) |
|
|
cy.wait(7000) |
|
|
}) |
|
|
}) |
|
|
cy.createTable("Cypress Tests", true) |
|
|
|
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
Cypress.Commands.add("deleteApp", name => { |
|
|
Cypress.Commands.add("deleteApp", appName => { |
|
|
cy.visit(`${Cypress.config().baseUrl}/builder`) |
|
|
cy.visit(`localhost:${Cypress.env("PORT")}/builder`) |
|
|
cy.wait(2000) |
|
|
cy.wait(1000) |
|
|
cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`) |
|
|
cy.request(`localhost:${Cypress.env("PORT")}/api/applications?status=all`) |
|
|
.its("body") |
|
|
.its("body") |
|
|
.then(val => { |
|
|
.then(val => { |
|
|
if (val.length > 0) { |
|
|
if (val.length > 0) { |
|
|
cy.searchForApplication(name) |
|
|
cy.get( |
|
|
cy.get(".appTable").within(() => { |
|
|
".appTable > :nth-child(5) > :nth-child(2) > .spectrum-Icon" |
|
|
cy.get(".spectrum-Icon").eq(1).click() |
|
|
).click() |
|
|
}) |
|
|
cy.contains("Delete").click() |
|
|
cy.get(".spectrum-Menu").then($menu => { |
|
|
cy.get(".spectrum-Modal").within(() => { |
|
|
if ($menu.text().includes("Unpublish")) { |
|
|
cy.get("input").type(appName) |
|
|
cy.get(".spectrum-Menu").contains("Unpublish").click() |
|
|
cy.get(".spectrum-Button--warning").click() |
|
|
cy.get(".spectrum-Dialog-grid").contains("Unpublish app").click() |
|
|
|
|
|
} else { |
|
|
|
|
|
cy.get(".spectrum-Menu").contains("Delete").click() |
|
|
|
|
|
cy.get(".spectrum-Dialog-grid").within(() => { |
|
|
|
|
|
cy.get("input").type(name) |
|
|
|
|
|
}) |
|
|
|
|
|
cy.get(".spectrum-Button--warning").click() |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
}) |
|
|
} else { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("deleteAllApps", () => { |
|
|
|
|
|
cy.visit(`${Cypress.config().baseUrl}/builder`) |
|
|
|
|
|
cy.wait(500) |
|
|
|
|
|
cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`) |
|
|
|
|
|
.its("body") |
|
|
|
|
|
.then(val => { |
|
|
|
|
|
for (let i = 0; i < val.length; i++) { |
|
|
|
|
|
cy.get(".spectrum-Heading") |
|
|
|
|
|
.eq(1) |
|
|
|
|
|
.then(app => { |
|
|
|
|
|
const name = app.text() |
|
|
|
|
|
cy.get(".title") |
|
|
|
|
|
.children() |
|
|
|
|
|
.within(() => { |
|
|
|
|
|
cy.get(".spectrum-Icon").eq(0).click() |
|
|
|
|
|
}) |
|
|
|
|
|
cy.get(".spectrum-Menu").contains("Delete").click() |
|
|
|
|
|
cy.get(".spectrum-Dialog-grid").within(() => { |
|
|
|
|
|
cy.get("input").type(name) |
|
|
|
|
|
cy.get(".spectrum-Button--warning").click() |
|
|
|
|
|
}) |
|
|
|
|
|
cy.reload() |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
@ -112,7 +66,6 @@ Cypress.Commands.add("createTestApp", () => { |
|
|
const appName = "Cypress Tests" |
|
|
const appName = "Cypress Tests" |
|
|
cy.deleteApp(appName) |
|
|
cy.deleteApp(appName) |
|
|
cy.createApp(appName, "This app is used for Cypress testing.") |
|
|
cy.createApp(appName, "This app is used for Cypress testing.") |
|
|
cy.createScreen("home", "home") |
|
|
|
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
Cypress.Commands.add("createTestTableWithData", () => { |
|
|
Cypress.Commands.add("createTestTableWithData", () => { |
|
|
@ -121,18 +74,10 @@ Cypress.Commands.add("createTestTableWithData", () => { |
|
|
cy.addColumn("dog", "age", "Number") |
|
|
cy.addColumn("dog", "age", "Number") |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
Cypress.Commands.add("createTable", (tableName, initialTable) => { |
|
|
Cypress.Commands.add("createTable", tableName => { |
|
|
if (!initialTable) { |
|
|
cy.contains("Budibase DB").click() |
|
|
cy.navigateToDataSection() |
|
|
cy.contains("Create new table").click() |
|
|
cy.get(".add-button").click() |
|
|
|
|
|
} |
|
|
|
|
|
cy.wait(7000) |
|
|
|
|
|
cy.get(".spectrum-Modal") |
|
|
|
|
|
.contains("Budibase DB") |
|
|
|
|
|
.click() |
|
|
|
|
|
.then(() => { |
|
|
|
|
|
cy.get(".spectrum-Button").contains("Continue").click({ force: true }) |
|
|
|
|
|
}) |
|
|
|
|
|
cy.get(".spectrum-Modal").within(() => { |
|
|
cy.get(".spectrum-Modal").within(() => { |
|
|
cy.wait(1000) |
|
|
cy.wait(1000) |
|
|
cy.get("input").first().type(tableName).blur() |
|
|
cy.get("input").first().type(tableName).blur() |
|
|
@ -239,49 +184,22 @@ Cypress.Commands.add("navigateToFrontend", () => { |
|
|
cy.wait(1000) |
|
|
cy.wait(1000) |
|
|
cy.contains("Design").click() |
|
|
cy.contains("Design").click() |
|
|
cy.get(".spectrum-Search").type("/") |
|
|
cy.get(".spectrum-Search").type("/") |
|
|
|
|
|
cy.createScreen("home", "home") |
|
|
|
|
|
cy.addComponent("Elements", "Headline") |
|
|
cy.get(".nav-item").contains("home").click() |
|
|
cy.get(".nav-item").contains("home").click() |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
Cypress.Commands.add("navigateToDataSection", () => { |
|
|
|
|
|
// Clicks on the Data tab
|
|
|
|
|
|
cy.wait(500) |
|
|
|
|
|
cy.contains("Data").click() |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("createScreen", (screenName, route) => { |
|
|
Cypress.Commands.add("createScreen", (screenName, route) => { |
|
|
cy.contains("Design").click() |
|
|
|
|
|
cy.get("[aria-label=AddCircle]").click() |
|
|
cy.get("[aria-label=AddCircle]").click() |
|
|
cy.get(".spectrum-Modal").within(() => { |
|
|
cy.get(".spectrum-Modal").within(() => { |
|
|
cy.get(".item").contains("Blank").click() |
|
|
cy.get(".item").first().click() |
|
|
cy.get(".spectrum-Button").contains("Add Screens").click({ force: true }) |
|
|
cy.get(".spectrum-Button--cta").click() |
|
|
cy.wait(500) |
|
|
|
|
|
}) |
|
|
|
|
|
cy.get(".spectrum-Dialog-grid").within(() => { |
|
|
|
|
|
cy.get(".spectrum-Form-itemField").eq(0).type(screenName) |
|
|
|
|
|
cy.get(".spectrum-Form-itemField").eq(1).type(route) |
|
|
|
|
|
cy.get(".spectrum-Button").contains("Continue").click({ force: true }) |
|
|
|
|
|
cy.wait(1000) |
|
|
|
|
|
}) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("createAutogeneratedScreens", screenNames => { |
|
|
|
|
|
// Screen name must already exist within data source
|
|
|
|
|
|
cy.contains("Design").click() |
|
|
|
|
|
cy.get("[aria-label=AddCircle]").click() |
|
|
|
|
|
for (let i = 0; i < screenNames.length; i++) { |
|
|
|
|
|
cy.get(".item").contains(screenNames[i]).click() |
|
|
|
|
|
} |
|
|
|
|
|
cy.get(".spectrum-Button").contains("Add Screens").click({ force: true }) |
|
|
|
|
|
cy.wait(2000) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("addRow", values => { |
|
|
|
|
|
cy.contains("Create row").click() |
|
|
|
|
|
cy.get(".spectrum-Modal").within(() => { |
|
|
cy.get(".spectrum-Modal").within(() => { |
|
|
for (let i = 0; i < values.length; i++) { |
|
|
cy.get("input").first().clear().type(screenName) |
|
|
cy.get("input").eq(i).type(values[i]).blur() |
|
|
cy.get("input").eq(1).clear().type(route) |
|
|
} |
|
|
cy.get(".spectrum-Button--cta").click() |
|
|
cy.get(".spectrum-ButtonGroup").contains("Create").click() |
|
|
cy.wait(2000) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
@ -319,144 +237,7 @@ Cypress.Commands.add("addCustomSourceOptions", totalOptions => { |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
Cypress.Commands.add("searchForApplication", appName => { |
|
|
Cypress.Commands.add("searchForApplication", appName => { |
|
|
cy.wait(1000) |
|
|
cy.get(".spectrum-Textfield").within(() => { |
|
|
// Searches for the app
|
|
|
cy.get("input").eq(0).type(appName) |
|
|
cy.get(".filter").then(() => { |
|
|
|
|
|
cy.get(".spectrum-Textfield").within(() => { |
|
|
|
|
|
cy.get("input").eq(0).type(appName) |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
// Confirms app exists after search
|
|
|
|
|
|
cy.get(".appTable").contains(appName) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("selectExternalDatasource", datasourceName => { |
|
|
|
|
|
// Navigates to Data Section
|
|
|
|
|
|
cy.navigateToDataSection() |
|
|
|
|
|
// Open Data Source modal
|
|
|
|
|
|
cy.get(".nav").within(() => { |
|
|
|
|
|
cy.get(".add-button").click() |
|
|
|
|
|
}) |
|
|
}) |
|
|
// Clicks specified datasource & continue
|
|
|
|
|
|
cy.get(".item-list").contains(datasourceName).click() |
|
|
|
|
|
cy.get(".spectrum-Dialog-grid").within(() => { |
|
|
|
|
|
cy.get(".spectrum-Button").contains("Continue").click({ force: true }) |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("addDatasourceConfig", (datasource, skipFetch) => { |
|
|
|
|
|
// selectExternalDatasource should be called prior to this
|
|
|
|
|
|
// Adds the config for specified datasource & fetches tables
|
|
|
|
|
|
// Currently supports MySQL, PostgreSQL, Oracle
|
|
|
|
|
|
// Host IP Address
|
|
|
|
|
|
cy.wait(500) |
|
|
|
|
|
cy.get(".spectrum-Dialog-grid").within(() => { |
|
|
|
|
|
cy.get(".form-row") |
|
|
|
|
|
.eq(0) |
|
|
|
|
|
.within(() => { |
|
|
|
|
|
cy.get(".spectrum-Textfield").within(() => { |
|
|
|
|
|
cy.log(datasource) |
|
|
|
|
|
if (datasource == "Oracle") { |
|
|
|
|
|
cy.get("input").clear().type(Cypress.env("oracle").HOST) |
|
|
|
|
|
} else { |
|
|
|
|
|
cy.get("input").clear().type(Cypress.env("HOST_IP")) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
// Database Name
|
|
|
|
|
|
cy.get(".spectrum-Dialog-grid").within(() => { |
|
|
|
|
|
if (datasource == "MySQL") { |
|
|
|
|
|
cy.get(".form-row") |
|
|
|
|
|
.eq(4) |
|
|
|
|
|
.within(() => { |
|
|
|
|
|
cy.get("input").clear().type(Cypress.env("mysql").DATABASE) |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
cy.get(".form-row") |
|
|
|
|
|
.eq(2) |
|
|
|
|
|
.within(() => { |
|
|
|
|
|
if (datasource == "PostgreSQL") { |
|
|
|
|
|
cy.get("input").clear().type(Cypress.env("postgresql").DATABASE) |
|
|
|
|
|
} |
|
|
|
|
|
if (datasource == "Oracle") { |
|
|
|
|
|
cy.get("input").clear().type(Cypress.env("oracle").DATABASE) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
// User
|
|
|
|
|
|
cy.get(".spectrum-Dialog-grid").within(() => { |
|
|
|
|
|
if (datasource == "MySQL") { |
|
|
|
|
|
cy.get(".form-row") |
|
|
|
|
|
.eq(2) |
|
|
|
|
|
.within(() => { |
|
|
|
|
|
cy.get("input").clear().type(Cypress.env("mysql").USER) |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
cy.get(".form-row") |
|
|
|
|
|
.eq(3) |
|
|
|
|
|
.within(() => { |
|
|
|
|
|
if (datasource == "PostgreSQL") { |
|
|
|
|
|
cy.get("input").clear().type(Cypress.env("postgresql").USER) |
|
|
|
|
|
} |
|
|
|
|
|
if (datasource == "Oracle") { |
|
|
|
|
|
cy.get("input").clear().type(Cypress.env("oracle").USER) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
// Password
|
|
|
|
|
|
cy.get(".spectrum-Dialog-grid").within(() => { |
|
|
|
|
|
if (datasource == "MySQL") { |
|
|
|
|
|
cy.get(".form-row") |
|
|
|
|
|
.eq(3) |
|
|
|
|
|
.within(() => { |
|
|
|
|
|
cy.get("input").clear().type(Cypress.env("mysql").PASSWORD) |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
cy.get(".form-row") |
|
|
|
|
|
.eq(4) |
|
|
|
|
|
.within(() => { |
|
|
|
|
|
if (datasource == "PostgreSQL") { |
|
|
|
|
|
cy.get("input").clear().type(Cypress.env("postgresql").PASSWORD) |
|
|
|
|
|
} |
|
|
|
|
|
if (datasource == "Oracle") { |
|
|
|
|
|
cy.get("input").clear().type(Cypress.env("oracle").PASSWORD) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
// Click to fetch tables
|
|
|
|
|
|
if (skipFetch) { |
|
|
|
|
|
cy.get(".spectrum-Dialog-grid").within(() => { |
|
|
|
|
|
cy.get(".spectrum-Button").contains("Skip table fetch") |
|
|
|
|
|
.click({ force: true }) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
cy.get(".spectrum-Dialog-grid").within(() => { |
|
|
|
|
|
cy.get(".spectrum-Button").contains("Save and fetch tables") |
|
|
|
|
|
.click({ force: true }) |
|
|
|
|
|
cy.wait(1000) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("createRestQuery", (method, restUrl) => { |
|
|
|
|
|
// addExternalDatasource should be called prior to this
|
|
|
|
|
|
// Configures REST datasource & sends query
|
|
|
|
|
|
cy.wait(500) |
|
|
|
|
|
cy.get(".spectrum-Button").contains("Add query").click({ force: true }) |
|
|
|
|
|
// Select Method & add Rest URL
|
|
|
|
|
|
cy.get(".spectrum-Picker-label").eq(1).click() |
|
|
|
|
|
cy.get(".spectrum-Menu").contains(method).click() |
|
|
|
|
|
cy.get("input").clear().type(restUrl) |
|
|
|
|
|
// Send query
|
|
|
|
|
|
cy.get(".spectrum-Button").contains("Send").click({ force: true }) |
|
|
|
|
|
cy.wait(500) |
|
|
|
|
|
cy.get(".spectrum-Button").contains("Save query").click({ force: true }) |
|
|
|
|
|
cy.get(".hierarchy-items-container") |
|
|
|
|
|
.should("contain", method) |
|
|
|
|
|
.and("contain", restUrl) |
|
|
|
|
|
}) |
|
|
}) |
|
|
|