2021-10-11 12:33:54 +02:00
|
|
|
Cypress.on("uncaught:exception", () => {
|
2021-10-08 12:45:54 +02:00
|
|
|
return false
|
|
|
|
})
|
|
|
|
|
2022-06-01 19:54:14 +02:00
|
|
|
// ACCOUNTS & USERS
|
2022-06-17 18:41:07 +02:00
|
|
|
Cypress.Commands.add("login", (email, password) => {
|
2022-07-22 17:33:00 +02:00
|
|
|
cy.visit(`${Cypress.config().baseUrl}/builder`, { timeout: 10000 })
|
2022-07-29 19:41:57 +02:00
|
|
|
cy.url()
|
|
|
|
.should("include", "/builder/")
|
|
|
|
.then(url => {
|
|
|
|
if (url.includes("builder/admin")) {
|
|
|
|
// create admin user
|
|
|
|
cy.get("input").first().type("test@test.com")
|
|
|
|
cy.get('input[type="password"]').first().type("test")
|
|
|
|
cy.get('input[type="password"]').eq(1).type("test")
|
|
|
|
cy.contains("Create super admin user").click({ force: true })
|
|
|
|
}
|
|
|
|
if (url.includes("builder/auth") || url.includes("builder/admin")) {
|
|
|
|
// login
|
|
|
|
cy.contains("Sign in to Budibase").then(() => {
|
|
|
|
if (email == null) {
|
|
|
|
cy.get("input").first().type("test@test.com")
|
|
|
|
cy.get('input[type="password"]').type("test")
|
|
|
|
} else {
|
|
|
|
cy.get("input").first().type(email)
|
|
|
|
cy.get('input[type="password"]').type(password)
|
|
|
|
}
|
|
|
|
cy.get("button").first().click({ force: true })
|
|
|
|
cy.wait(1000)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
2021-04-15 13:14:50 +02:00
|
|
|
})
|
2020-06-11 12:04:31 +02:00
|
|
|
|
2022-05-11 20:37:12 +02:00
|
|
|
Cypress.Commands.add("logOut", () => {
|
2022-06-22 19:55:43 +02:00
|
|
|
cy.visit(`${Cypress.config().baseUrl}/builder`, { timeout: 2000 })
|
2022-05-11 20:37:12 +02:00
|
|
|
cy.get(".user-dropdown .avatar > .icon").click({ force: true })
|
|
|
|
cy.get(".spectrum-Popover[data-cy='user-menu']").within(() => {
|
|
|
|
cy.get("li[data-cy='user-logout']").click({ force: true })
|
|
|
|
})
|
|
|
|
cy.wait(2000)
|
2022-05-10 17:58:55 +02:00
|
|
|
})
|
|
|
|
|
2022-06-20 19:38:44 +02:00
|
|
|
Cypress.Commands.add("logoutNoAppGrid", () => {
|
|
|
|
// Logs user out when app grid is not present
|
|
|
|
cy.visit(`${Cypress.config().baseUrl}/builder`)
|
|
|
|
cy.get(".avatar > .icon").click({ force: true })
|
|
|
|
cy.get(".spectrum-Popover[data-cy='user-menu']").within(() => {
|
|
|
|
cy.get(".spectrum-Menu-item").contains("Log out").click({ force: true })
|
|
|
|
})
|
|
|
|
cy.wait(2000)
|
|
|
|
})
|
|
|
|
|
2022-07-29 19:41:57 +02:00
|
|
|
Cypress.Commands.add("createUser", (email, permission) => {
|
2022-06-01 19:54:14 +02:00
|
|
|
cy.contains("Users").click()
|
|
|
|
cy.get(`[data-cy="add-user"]`).click()
|
2022-06-22 19:55:43 +02:00
|
|
|
cy.get(".spectrum-Dialog-grid").within(() => {
|
2022-07-29 19:41:57 +02:00
|
|
|
// Enter email
|
|
|
|
cy.get(".spectrum-Textfield-input").clear().click().type(email)
|
|
|
|
|
|
|
|
// Select permission, if applicable
|
|
|
|
// Default is App User
|
|
|
|
if (permission != null) {
|
|
|
|
cy.get(".spectrum-Picker-label").click()
|
|
|
|
cy.get(".spectrum-Menu").within(() => {
|
|
|
|
cy.get(".spectrum-Menu-item")
|
|
|
|
.contains(permission)
|
|
|
|
.click({ force: true })
|
|
|
|
})
|
|
|
|
}
|
|
|
|
// Add user and wait for modal to change
|
|
|
|
cy.get(".spectrum-Button").contains("Add user").click({ force: true })
|
|
|
|
cy.get(".spectrum-ActionButton").contains("Add email").should("not.exist")
|
|
|
|
})
|
|
|
|
// Onboarding modal
|
|
|
|
cy.get(".spectrum-Dialog-grid").within(() => {
|
|
|
|
cy.get(".onboarding-type").eq(1).click()
|
|
|
|
cy.get(".spectrum-Button").contains("Done").click({ force: true })
|
|
|
|
cy.get(".spectrum-Button").contains("Cancel").should("not.exist")
|
2022-06-22 19:55:43 +02:00
|
|
|
})
|
2022-07-29 19:41:57 +02:00
|
|
|
|
|
|
|
// Accounts created modal - Click Done button
|
|
|
|
cy.get(".spectrum-Button").contains("Done").click({ force: true })
|
2022-06-22 19:55:43 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
Cypress.Commands.add("deleteUser", email => {
|
|
|
|
// Assumes user has access to Users section
|
|
|
|
cy.contains("Users", { timeout: 2000 }).click()
|
|
|
|
cy.contains(email).click()
|
|
|
|
|
2022-07-29 19:41:57 +02:00
|
|
|
cy.get(".title").within(() => {
|
|
|
|
cy.get(".spectrum-Icon").click({ force: true })
|
|
|
|
})
|
|
|
|
cy.get(".spectrum-Menu").within(() => {
|
|
|
|
cy.get(".spectrum-Menu-item").contains("Delete").click({ force: true })
|
|
|
|
})
|
|
|
|
cy.get(".spectrum-Dialog-grid").contains("Delete user").click({ force: true })
|
2022-05-12 18:04:05 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
Cypress.Commands.add("updateUserInformation", (firstName, lastName) => {
|
2022-06-17 18:41:07 +02:00
|
|
|
cy.get(".user-dropdown .avatar > .icon", { timeout: 2000 }).click({
|
|
|
|
force: true,
|
|
|
|
})
|
2022-05-12 18:04:05 +02:00
|
|
|
|
|
|
|
cy.get(".spectrum-Popover[data-cy='user-menu']").within(() => {
|
|
|
|
cy.get("li[data-cy='user-info']").click({ force: true })
|
|
|
|
})
|
|
|
|
|
|
|
|
cy.get(".spectrum-Modal.is-open").within(() => {
|
2022-05-16 12:13:17 +02:00
|
|
|
cy.get("[data-cy='user-first-name']").clear()
|
|
|
|
|
2022-05-12 18:04:05 +02:00
|
|
|
if (!firstName || firstName == "") {
|
|
|
|
cy.get("[data-cy='user-first-name']").invoke("val").should("be.empty")
|
|
|
|
} else {
|
|
|
|
cy.get("[data-cy='user-first-name']")
|
|
|
|
.type(firstName)
|
|
|
|
.should("have.value", firstName)
|
|
|
|
.blur()
|
|
|
|
}
|
2022-05-16 12:13:17 +02:00
|
|
|
|
|
|
|
cy.get("[data-cy='user-last-name']").clear()
|
|
|
|
|
2022-05-12 18:04:05 +02:00
|
|
|
if (!lastName || lastName == "") {
|
|
|
|
cy.get("[data-cy='user-last-name']").invoke("val").should("be.empty")
|
|
|
|
} else {
|
|
|
|
cy.get("[data-cy='user-last-name']")
|
|
|
|
.type(lastName)
|
|
|
|
.should("have.value", lastName)
|
|
|
|
.blur()
|
|
|
|
}
|
|
|
|
cy.get("button").contains("Update information").click({ force: true })
|
2022-07-29 19:41:57 +02:00
|
|
|
cy.get(".spectrum-Dialog-grid").should("not.exist")
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
Cypress.Commands.add("setUserRole", (user, role) => {
|
|
|
|
cy.contains("Users").click()
|
|
|
|
cy.contains(user).click()
|
|
|
|
|
|
|
|
// Set Role
|
|
|
|
cy.wait(500)
|
|
|
|
cy.get(".spectrum-Form-itemField")
|
|
|
|
.eq(2)
|
|
|
|
.within(() => {
|
|
|
|
cy.get(".spectrum-Picker-label").click({ force: true })
|
|
|
|
})
|
|
|
|
cy.get(".spectrum-Menu").within(() => {
|
|
|
|
cy.get(".spectrum-Menu-itemLabel").contains(role).click({ force: true })
|
2022-05-12 18:04:05 +02:00
|
|
|
})
|
2022-07-29 19:41:57 +02:00
|
|
|
cy.get(".spectrum-Form-itemField").eq(2).should("contain", role)
|
2022-05-12 18:04:05 +02:00
|
|
|
})
|
|
|
|
|
2022-06-01 19:54:14 +02:00
|
|
|
// APPLICATIONS
|
|
|
|
Cypress.Commands.add("createTestApp", () => {
|
|
|
|
const appName = "Cypress Tests"
|
|
|
|
cy.deleteApp(appName)
|
|
|
|
cy.createApp(appName, "This app is used for Cypress testing.")
|
|
|
|
})
|
|
|
|
|
2022-04-08 10:56:20 +02:00
|
|
|
Cypress.Commands.add("createApp", (name, addDefaultTable) => {
|
|
|
|
const shouldCreateDefaultTable =
|
|
|
|
typeof addDefaultTable != "boolean" ? true : addDefaultTable
|
|
|
|
|
2022-07-07 16:13:15 +02:00
|
|
|
cy.visit(`${Cypress.config().baseUrl}/builder`, { timeout: 10000 })
|
2022-07-06 17:17:58 +02:00
|
|
|
cy.wait(1000)
|
2022-07-07 16:13:15 +02:00
|
|
|
cy.get(`[data-cy="create-app-btn"]`, { timeout: 5000 }).click({ force: true })
|
2022-03-29 00:21:38 +02:00
|
|
|
|
2022-04-01 12:31:18 +02:00
|
|
|
// If apps already exist
|
2022-07-18 15:28:27 +02:00
|
|
|
cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`, {
|
|
|
|
timeout: 5000,
|
|
|
|
})
|
2022-04-01 12:31:18 +02:00
|
|
|
.its("body")
|
|
|
|
.then(val => {
|
|
|
|
if (val.length > 0) {
|
2022-07-07 16:13:15 +02:00
|
|
|
cy.get(`[data-cy="create-app-btn"]`, { timeout: 5000 }).click({
|
|
|
|
force: true,
|
|
|
|
})
|
2022-04-01 12:31:18 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-10-14 17:45:27 +02:00
|
|
|
cy.get(".spectrum-Modal").within(() => {
|
2022-05-12 18:04:05 +02:00
|
|
|
cy.get("input").eq(0).should("have.focus")
|
|
|
|
if (name && name != "") {
|
|
|
|
cy.get("input").eq(0).clear()
|
|
|
|
cy.get("input").eq(0).type(name).should("have.value", name).blur()
|
|
|
|
}
|
2022-05-11 18:04:54 +02:00
|
|
|
cy.get(".spectrum-ButtonGroup")
|
|
|
|
.contains("Create app")
|
|
|
|
.click({ force: true })
|
2022-06-21 19:25:33 +02:00
|
|
|
cy.wait(2000)
|
2021-10-14 17:45:27 +02:00
|
|
|
})
|
2022-04-08 10:56:20 +02:00
|
|
|
if (shouldCreateDefaultTable) {
|
|
|
|
cy.createTable("Cypress Tests", true)
|
|
|
|
}
|
2020-06-11 12:04:31 +02:00
|
|
|
})
|
2020-08-05 16:18:28 +02:00
|
|
|
|
2022-01-21 15:41:53 +01:00
|
|
|
Cypress.Commands.add("deleteApp", name => {
|
2022-06-30 13:30:53 +02:00
|
|
|
cy.visit(`${Cypress.config().baseUrl}/builder`, { timeout: 5000 })
|
2022-01-21 15:41:53 +01:00
|
|
|
cy.wait(2000)
|
|
|
|
cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`)
|
2021-11-15 16:40:48 +01:00
|
|
|
.its("body")
|
|
|
|
.then(val => {
|
2022-04-12 16:59:12 +02:00
|
|
|
const findAppName = val.some(val => val.name == name)
|
|
|
|
if (findAppName) {
|
|
|
|
if (val.length > 0) {
|
2022-04-28 18:50:06 +02:00
|
|
|
const appId = val.reduce((acc, app) => {
|
|
|
|
if (name === app.name) {
|
|
|
|
acc = app.appId
|
2022-04-01 12:31:18 +02:00
|
|
|
}
|
2022-04-28 18:50:06 +02:00
|
|
|
return acc
|
|
|
|
}, "")
|
2022-04-01 12:31:18 +02:00
|
|
|
|
2022-04-28 18:50:06 +02:00
|
|
|
if (appId == "") {
|
|
|
|
return
|
2022-03-29 00:21:38 +02:00
|
|
|
}
|
|
|
|
|
2022-06-15 16:08:03 +02:00
|
|
|
// Go to app overview
|
2022-04-28 18:50:06 +02:00
|
|
|
const appIdParsed = appId.split("_").pop()
|
|
|
|
const actionEleId = `[data-cy=row_actions_${appIdParsed}]`
|
|
|
|
cy.get(actionEleId).within(() => {
|
2022-06-15 16:08:03 +02:00
|
|
|
cy.contains("Manage").click({ force: true })
|
2022-04-28 18:50:06 +02:00
|
|
|
})
|
2022-06-28 19:01:04 +02:00
|
|
|
cy.wait(500)
|
2022-06-15 16:08:03 +02:00
|
|
|
|
|
|
|
// Unpublish first if needed
|
|
|
|
cy.get(`[data-cy="app-status"]`).then($status => {
|
2022-06-28 19:01:04 +02:00
|
|
|
if ($status.text().includes("- Unpublish")) {
|
|
|
|
// Exact match for Unpublish
|
|
|
|
cy.contains("Unpublish").click({ force: true })
|
2022-06-15 16:08:03 +02:00
|
|
|
cy.get(".spectrum-Modal").within(() => {
|
2022-06-28 19:01:04 +02:00
|
|
|
cy.contains("Unpublish app").click({ force: true })
|
2022-06-15 16:08:03 +02:00
|
|
|
})
|
2022-04-12 16:59:12 +02:00
|
|
|
}
|
2022-04-01 12:31:18 +02:00
|
|
|
})
|
2022-05-04 18:06:27 +02:00
|
|
|
|
2022-06-15 16:08:03 +02:00
|
|
|
// Delete app
|
|
|
|
cy.get(".app-overview-actions-icon").within(() => {
|
|
|
|
cy.get(".spectrum-Icon").click({ force: true })
|
2022-05-04 18:06:27 +02:00
|
|
|
})
|
2022-07-22 17:33:00 +02:00
|
|
|
cy.get(".spectrum-Menu").contains("Delete").click({ force: true })
|
2022-05-04 18:06:27 +02:00
|
|
|
cy.get(".spectrum-Dialog-grid").within(() => {
|
|
|
|
cy.get("input").type(name)
|
|
|
|
})
|
|
|
|
cy.get(".spectrum-Button--warning").click()
|
2022-04-12 16:59:12 +02:00
|
|
|
} else {
|
|
|
|
return
|
2022-03-29 00:21:38 +02:00
|
|
|
}
|
2022-01-21 15:41:53 +01:00
|
|
|
} else {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
Cypress.Commands.add("deleteAllApps", () => {
|
2022-07-18 14:52:21 +02:00
|
|
|
cy.visit(`${Cypress.config().baseUrl}/builder`, { timeout: 5000 })
|
2022-01-21 15:41:53 +01:00
|
|
|
cy.wait(500)
|
2022-07-18 14:52:21 +02:00
|
|
|
cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`, {
|
|
|
|
timeout: 5000,
|
|
|
|
})
|
2022-01-21 15:41:53 +01:00
|
|
|
.its("body")
|
|
|
|
.then(val => {
|
|
|
|
for (let i = 0; i < val.length; i++) {
|
2022-06-15 16:08:03 +02:00
|
|
|
cy.deleteApp(val[i].name)
|
2022-03-29 00:21:38 +02:00
|
|
|
cy.reload()
|
2021-11-15 16:40:48 +01:00
|
|
|
}
|
|
|
|
})
|
2021-03-05 14:52:26 +01:00
|
|
|
})
|
|
|
|
|
2022-05-10 17:58:55 +02:00
|
|
|
Cypress.Commands.add("unlockApp", unlock_config => {
|
|
|
|
let config = { ...unlock_config }
|
|
|
|
|
|
|
|
cy.get(".spectrum-Modal .spectrum-Dialog[data-cy='app-lock-modal']")
|
|
|
|
.should("be.visible")
|
|
|
|
.within(() => {
|
|
|
|
if (config.owned) {
|
|
|
|
cy.get(".spectrum-Dialog-heading").contains("Locked by you")
|
|
|
|
cy.get(".lock-expiry-body").contains(
|
|
|
|
"This lock will expire in 10 minutes from now"
|
|
|
|
)
|
|
|
|
|
|
|
|
cy.intercept("**/lock").as("unlockApp")
|
|
|
|
cy.get(".spectrum-Button")
|
|
|
|
.contains("Release Lock")
|
|
|
|
.click({ force: true })
|
|
|
|
cy.wait("@unlockApp")
|
|
|
|
cy.get("@unlockApp").its("response.statusCode").should("eq", 200)
|
|
|
|
cy.get("@unlockApp").its("response.body").should("deep.equal", {
|
|
|
|
message: "Lock released successfully.",
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
//Show the name ?
|
|
|
|
cy.get(".lock-expiry-body").should("not.be.visible")
|
|
|
|
cy.get(".spectrum-Button").contains("Done")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2022-06-01 19:54:14 +02:00
|
|
|
Cypress.Commands.add("updateAppName", (changedName, noName) => {
|
|
|
|
cy.get(".spectrum-Modal").within(() => {
|
|
|
|
if (noName == true) {
|
|
|
|
cy.get("input").clear()
|
|
|
|
cy.get(".spectrum-Dialog-grid")
|
|
|
|
.click()
|
|
|
|
.contains("App name must be letters, numbers and spaces only")
|
|
|
|
return cy
|
|
|
|
}
|
|
|
|
cy.get("input").clear()
|
|
|
|
cy.get("input")
|
|
|
|
.eq(0)
|
|
|
|
.type(changedName)
|
|
|
|
.should("have.value", changedName)
|
|
|
|
.blur()
|
|
|
|
cy.get(".spectrum-ButtonGroup").contains("Save").click({ force: true })
|
|
|
|
cy.wait(500)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2022-05-19 14:32:05 +02:00
|
|
|
Cypress.Commands.add("publishApp", resolvedAppPath => {
|
2022-07-26 15:43:06 +02:00
|
|
|
// Assumes you have navigated to an application first
|
2022-05-19 14:32:05 +02:00
|
|
|
cy.get(".toprightnav button.spectrum-Button")
|
|
|
|
.contains("Publish")
|
|
|
|
.click({ force: true })
|
|
|
|
|
|
|
|
cy.get(".spectrum-Modal [data-cy='deploy-app-modal']")
|
|
|
|
.should("be.visible")
|
|
|
|
.within(() => {
|
|
|
|
cy.get(".spectrum-Button").contains("Publish").click({ force: true })
|
|
|
|
cy.wait(1000)
|
|
|
|
})
|
|
|
|
|
2022-07-26 15:43:06 +02:00
|
|
|
// Verify that the app url is presented correctly to the user
|
2022-05-19 14:32:05 +02:00
|
|
|
cy.get(".spectrum-Modal [data-cy='deploy-app-success-modal']")
|
|
|
|
.should("be.visible")
|
|
|
|
.within(() => {
|
|
|
|
let appUrl = Cypress.config().baseUrl + "/app/" + resolvedAppPath
|
|
|
|
cy.get("[data-cy='deployed-app-url'] input").should("have.value", appUrl)
|
|
|
|
cy.get(".spectrum-Button").contains("Done").click({ force: true })
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2022-06-01 19:54:14 +02:00
|
|
|
Cypress.Commands.add("alterAppVersion", (appId, version) => {
|
|
|
|
return cy
|
|
|
|
.request("put", `${Cypress.config().baseUrl}/api/applications/${appId}`, {
|
|
|
|
version: version || "0.0.1-alpha.0",
|
|
|
|
})
|
|
|
|
.then(resp => {
|
|
|
|
expect(resp.status).to.eq(200)
|
|
|
|
})
|
2021-03-05 15:36:38 +01:00
|
|
|
})
|
|
|
|
|
2022-06-01 19:54:14 +02:00
|
|
|
Cypress.Commands.add("importApp", (exportFilePath, name) => {
|
2022-06-30 12:41:11 +02:00
|
|
|
cy.visit(`${Cypress.config().baseUrl}/builder`, { timeout: 5000 })
|
2022-06-01 19:54:14 +02:00
|
|
|
|
|
|
|
cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`)
|
|
|
|
.its("body")
|
|
|
|
.then(val => {
|
|
|
|
if (val.length > 0) {
|
|
|
|
cy.get(`[data-cy="create-app-btn"]`).click({ force: true })
|
|
|
|
}
|
2022-06-30 14:53:16 +02:00
|
|
|
cy.wait(500)
|
|
|
|
cy.get(`[data-cy="import-app-btn"]`).click({
|
2022-06-08 19:08:45 +02:00
|
|
|
force: true,
|
|
|
|
})
|
2022-06-01 19:54:14 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
cy.get(".spectrum-Modal").within(() => {
|
|
|
|
cy.get("input").eq(1).should("have.focus")
|
|
|
|
|
|
|
|
cy.get(".spectrum-Dropzone").selectFile(exportFilePath, {
|
|
|
|
action: "drag-drop",
|
|
|
|
})
|
|
|
|
|
|
|
|
cy.get(".gallery .filename").contains("exported-app.txt")
|
|
|
|
|
|
|
|
if (name && name != "") {
|
|
|
|
cy.get("input").eq(0).type(name).should("have.value", name).blur()
|
|
|
|
}
|
|
|
|
cy.get(".confirm-wrap button")
|
|
|
|
.should("not.be.disabled")
|
|
|
|
.click({ force: true })
|
2022-06-30 12:41:11 +02:00
|
|
|
cy.wait(3000)
|
2022-06-01 19:54:14 +02:00
|
|
|
})
|
2020-09-03 13:02:15 +02:00
|
|
|
})
|
|
|
|
|
2022-06-01 19:54:14 +02:00
|
|
|
// Filters visible with 1 or more
|
|
|
|
Cypress.Commands.add("searchForApplication", appName => {
|
|
|
|
cy.visit(`${Cypress.config().baseUrl}/builder`)
|
|
|
|
cy.wait(2000)
|
|
|
|
|
|
|
|
// No app filter functionality if only 1 app exists
|
|
|
|
cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`)
|
|
|
|
.its("body")
|
|
|
|
.then(val => {
|
|
|
|
if (val.length < 2) {
|
|
|
|
return
|
|
|
|
} else {
|
|
|
|
// Searches for the app
|
|
|
|
cy.get(".filter").then(() => {
|
|
|
|
cy.get(".spectrum-Textfield").within(() => {
|
|
|
|
cy.get("input").eq(0).clear()
|
|
|
|
cy.get("input").eq(0).type(appName)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
// Assumes there are no others
|
|
|
|
Cypress.Commands.add("applicationInAppTable", appName => {
|
2022-06-30 14:53:16 +02:00
|
|
|
cy.visit(`${Cypress.config().baseUrl}/builder`, { timeout: 10000 })
|
2022-07-18 15:28:27 +02:00
|
|
|
cy.get(".appTable", { timeout: 5000 }).within(() => {
|
2022-06-01 19:54:14 +02:00
|
|
|
cy.get(".title").contains(appName).should("exist")
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
Cypress.Commands.add("createAppFromScratch", appName => {
|
|
|
|
cy.get(`[data-cy="create-app-btn"]`)
|
|
|
|
.contains("Start from scratch")
|
|
|
|
.click({ force: true })
|
|
|
|
cy.get(".spectrum-Modal").within(() => {
|
|
|
|
cy.get("input")
|
|
|
|
.eq(0)
|
|
|
|
.clear()
|
|
|
|
.type(appName)
|
|
|
|
.should("have.value", appName)
|
|
|
|
.blur()
|
|
|
|
cy.get(".spectrum-ButtonGroup").contains("Create app").click()
|
|
|
|
cy.wait(10000)
|
|
|
|
})
|
|
|
|
cy.createTable("Cypress Tests", true)
|
|
|
|
})
|
|
|
|
|
|
|
|
// TABLES
|
2022-01-21 15:41:53 +01:00
|
|
|
Cypress.Commands.add("createTable", (tableName, initialTable) => {
|
|
|
|
if (!initialTable) {
|
|
|
|
cy.navigateToDataSection()
|
2022-07-08 12:33:11 +02:00
|
|
|
cy.get(`[data-cy="new-table"]`, { timeout: 2000 }).click()
|
2022-01-21 15:41:53 +01:00
|
|
|
}
|
2022-06-29 19:28:32 +02:00
|
|
|
cy.wait(2000)
|
2022-07-08 12:33:11 +02:00
|
|
|
cy.get(".item", { timeout: 2000 })
|
2022-01-21 15:41:53 +01:00
|
|
|
.contains("Budibase DB")
|
|
|
|
.click({ force: true })
|
|
|
|
.then(() => {
|
2022-07-08 12:33:11 +02:00
|
|
|
cy.get(".spectrum-Button", { timeout: 2000 })
|
|
|
|
.contains("Continue")
|
|
|
|
.click({ force: true })
|
2022-01-21 15:41:53 +01:00
|
|
|
})
|
2022-07-08 12:33:11 +02:00
|
|
|
cy.get(".spectrum-Modal", { timeout: 2000 }).within(() => {
|
|
|
|
cy.get("input", { timeout: 2000 }).first().type(tableName).blur()
|
2021-05-03 09:31:09 +02:00
|
|
|
cy.get(".spectrum-ButtonGroup").contains("Create").click()
|
2020-10-08 12:36:16 +02:00
|
|
|
})
|
2022-07-26 19:23:05 +02:00
|
|
|
// Ensure modal has closed and table is created
|
|
|
|
cy.get(".spectrum-Modal").should("not.exist")
|
|
|
|
cy.get(".spectrum-Tabs-content", { timeout: 1000 }).should(
|
|
|
|
"contain",
|
|
|
|
tableName
|
|
|
|
)
|
2020-08-10 16:34:37 +02:00
|
|
|
})
|
2020-06-11 18:14:28 +02:00
|
|
|
|
2022-06-01 19:54:14 +02:00
|
|
|
Cypress.Commands.add("createTestTableWithData", () => {
|
|
|
|
cy.createTable("dog")
|
|
|
|
cy.addColumn("dog", "name", "Text")
|
|
|
|
cy.addColumn("dog", "age", "Number")
|
|
|
|
})
|
|
|
|
|
2021-10-08 11:56:44 +02:00
|
|
|
Cypress.Commands.add(
|
|
|
|
"addColumn",
|
|
|
|
(tableName, columnName, type, multiOptions = null) => {
|
|
|
|
// Select Table
|
|
|
|
cy.selectTable(tableName)
|
|
|
|
cy.contains(".nav-item", tableName).click()
|
|
|
|
cy.contains("Create column").click()
|
|
|
|
|
|
|
|
// Configure column
|
|
|
|
cy.get(".spectrum-Modal").within(() => {
|
|
|
|
cy.get("input").first().type(columnName).blur()
|
|
|
|
|
|
|
|
// Unset table display column
|
|
|
|
cy.contains("display column").click({ force: true })
|
|
|
|
cy.get(".spectrum-Picker-label").click()
|
|
|
|
cy.contains(type).click()
|
|
|
|
|
|
|
|
// Add options for Multi-select Type
|
|
|
|
if (multiOptions !== null) {
|
|
|
|
cy.get(".spectrum-Textfield-input").eq(1).type(multiOptions)
|
|
|
|
}
|
2021-09-27 19:19:25 +02:00
|
|
|
|
2021-10-08 11:56:44 +02:00
|
|
|
cy.contains("Save Column").click()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
)
|
2020-08-05 16:18:28 +02:00
|
|
|
|
2021-05-04 12:32:22 +02:00
|
|
|
Cypress.Commands.add("addRow", values => {
|
2021-04-28 16:08:43 +02:00
|
|
|
cy.contains("Create row").click()
|
|
|
|
cy.get(".spectrum-Modal").within(() => {
|
2020-10-05 12:13:09 +02:00
|
|
|
for (let i = 0; i < values.length; i++) {
|
2021-05-03 09:31:09 +02:00
|
|
|
cy.get("input").eq(i).type(values[i]).blur()
|
2020-10-05 12:13:09 +02:00
|
|
|
}
|
2021-05-03 09:31:09 +02:00
|
|
|
cy.get(".spectrum-ButtonGroup").contains("Create").click()
|
2020-10-05 12:13:09 +02:00
|
|
|
})
|
2020-06-11 12:04:31 +02:00
|
|
|
})
|
|
|
|
|
2021-09-27 19:19:25 +02:00
|
|
|
Cypress.Commands.add("addRowMultiValue", values => {
|
|
|
|
cy.contains("Create row").click()
|
2022-02-25 14:40:23 +01:00
|
|
|
cy.get(".spectrum-Modal").within(() => {
|
|
|
|
cy.get(".spectrum-Form-itemField")
|
|
|
|
.click()
|
|
|
|
.then(() => {
|
|
|
|
cy.get(".spectrum-Popover").within(() => {
|
|
|
|
for (let i = 0; i < values.length; i++) {
|
|
|
|
cy.get(".spectrum-Menu-item").eq(i).click()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
cy.get(".spectrum-Dialog-grid").click("top")
|
|
|
|
cy.get(".spectrum-ButtonGroup").contains("Create").click()
|
2021-10-08 11:56:44 +02:00
|
|
|
})
|
2022-02-25 14:40:23 +01:00
|
|
|
})
|
2021-09-27 19:19:25 +02:00
|
|
|
})
|
|
|
|
|
2022-06-01 19:54:14 +02:00
|
|
|
Cypress.Commands.add("selectTable", tableName => {
|
|
|
|
cy.expandBudibaseConnection()
|
|
|
|
cy.contains(".nav-item", tableName).click()
|
|
|
|
})
|
2022-03-29 00:21:38 +02:00
|
|
|
|
2022-06-01 19:54:14 +02:00
|
|
|
Cypress.Commands.add("addCustomSourceOptions", totalOptions => {
|
2022-07-22 17:33:00 +02:00
|
|
|
cy.get('[data-cy="customOptions-prop-control"]').within(() => {
|
|
|
|
cy.get(".spectrum-ActionButton-label").click({ force: true })
|
|
|
|
})
|
|
|
|
for (let i = 0; i < totalOptions; i++) {
|
|
|
|
// Add radio button options
|
|
|
|
cy.get(".spectrum-Button-label", { timeout: 1000 })
|
|
|
|
.contains("Add Option")
|
|
|
|
.click({ force: true })
|
|
|
|
.then(() => {
|
|
|
|
cy.get("[placeholder='Label']", { timeout: 500 }).eq(i).type(i)
|
|
|
|
cy.get("[placeholder='Value']").eq(i).type(i)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
// Save options
|
|
|
|
cy.get(".spectrum-Button").contains("Save").click({ force: true })
|
2020-06-11 12:56:16 +02:00
|
|
|
})
|
|
|
|
|
2022-07-20 18:44:30 +02:00
|
|
|
// DESIGN SECTION
|
2022-07-22 17:33:00 +02:00
|
|
|
Cypress.Commands.add("searchAndAddComponent", component => {
|
|
|
|
// Open component menu
|
|
|
|
cy.get(".spectrum-Button").contains("Component").click({ force: true })
|
|
|
|
|
|
|
|
// Search and add component
|
2022-07-26 15:43:06 +02:00
|
|
|
cy.wait(500)
|
|
|
|
cy.get(".spectrum-Textfield-input").clear().type(component)
|
2022-07-22 17:33:00 +02:00
|
|
|
cy.get(".body").within(() => {
|
|
|
|
cy.get(".component")
|
|
|
|
.contains(new RegExp("^" + component + "$"), { timeout: 3000 })
|
|
|
|
.click({ force: true })
|
|
|
|
})
|
|
|
|
cy.wait(1000)
|
|
|
|
cy.location().then(loc => {
|
|
|
|
const params = loc.pathname.split("/")
|
|
|
|
const componentId = params[params.length - 1]
|
|
|
|
cy.getComponent(componentId, { timeout: 3000 }).should("exist")
|
|
|
|
return cy.wrap(componentId)
|
|
|
|
})
|
|
|
|
})
|
2022-07-20 18:44:30 +02:00
|
|
|
|
2022-07-22 17:33:00 +02:00
|
|
|
Cypress.Commands.add("addComponent", (category, component) => {
|
2021-03-05 14:52:26 +01:00
|
|
|
if (category) {
|
2022-07-08 12:33:11 +02:00
|
|
|
cy.get(`[data-cy="category-${category}"]`, { timeout: 3000 }).click({
|
2022-06-17 18:41:07 +02:00
|
|
|
force: true,
|
|
|
|
})
|
2021-03-05 14:52:26 +01:00
|
|
|
}
|
2022-07-08 12:33:11 +02:00
|
|
|
cy.wait(500)
|
2021-10-08 11:56:44 +02:00
|
|
|
if (component) {
|
2022-07-08 12:33:11 +02:00
|
|
|
cy.get(`[data-cy="component-${component}"]`, { timeout: 3000 }).click({
|
2022-06-17 18:41:07 +02:00
|
|
|
force: true,
|
|
|
|
})
|
2021-09-27 19:19:25 +02:00
|
|
|
}
|
2022-05-31 23:57:33 +02:00
|
|
|
cy.wait(1000)
|
2021-05-04 12:32:22 +02:00
|
|
|
cy.location().then(loc => {
|
2021-03-05 14:52:26 +01:00
|
|
|
const params = loc.pathname.split("/")
|
2021-03-08 12:57:56 +01:00
|
|
|
const componentId = params[params.length - 1]
|
2022-07-08 12:33:11 +02:00
|
|
|
cy.getComponent(componentId, { timeout: 3000 }).should("exist")
|
2021-03-08 12:57:56 +01:00
|
|
|
return cy.wrap(componentId)
|
2021-03-05 14:52:26 +01:00
|
|
|
})
|
2020-06-11 16:40:07 +02:00
|
|
|
})
|
|
|
|
|
2021-05-04 12:32:22 +02:00
|
|
|
Cypress.Commands.add("getComponent", componentId => {
|
2021-03-05 14:52:26 +01:00
|
|
|
return cy
|
|
|
|
.get("iframe")
|
|
|
|
.its("0.contentDocument")
|
|
|
|
.should("exist")
|
|
|
|
.its("body")
|
2022-05-17 16:09:13 +02:00
|
|
|
.should("not.be.undefined")
|
2021-03-05 14:52:26 +01:00
|
|
|
.then(cy.wrap)
|
2022-05-17 16:09:13 +02:00
|
|
|
.find(`[data-id='${componentId}']`)
|
2020-06-11 18:14:28 +02:00
|
|
|
})
|
2020-06-24 17:16:06 +02:00
|
|
|
|
2022-04-22 15:57:13 +02:00
|
|
|
Cypress.Commands.add("createScreen", (route, accessLevelLabel) => {
|
2022-06-01 19:54:14 +02:00
|
|
|
// Blank Screen
|
2022-01-21 15:41:53 +01:00
|
|
|
cy.contains("Design").click()
|
2022-07-20 18:44:30 +02:00
|
|
|
cy.get(".header > .add-button").click()
|
2021-04-28 16:08:43 +02:00
|
|
|
cy.get(".spectrum-Modal").within(() => {
|
2022-04-26 16:56:11 +02:00
|
|
|
cy.get("[data-cy='blank-screen']").click()
|
2022-04-22 13:22:21 +02:00
|
|
|
cy.get(".spectrum-Button").contains("Continue").click({ force: true })
|
2022-01-21 15:41:53 +01:00
|
|
|
})
|
2022-06-29 19:28:32 +02:00
|
|
|
cy.wait(500)
|
2022-06-08 19:08:45 +02:00
|
|
|
cy.get(".spectrum-Dialog-grid", { timeout: 500 }).within(() => {
|
2022-04-07 13:22:16 +02:00
|
|
|
cy.get(".spectrum-Form-itemField").eq(0).type(route)
|
2022-06-29 19:28:32 +02:00
|
|
|
cy.get(".confirm-wrap").contains("Continue").click({ force: true })
|
2022-04-22 15:57:13 +02:00
|
|
|
})
|
2022-04-07 13:22:16 +02:00
|
|
|
|
2022-06-08 19:08:45 +02:00
|
|
|
cy.get(".spectrum-Modal", { timeout: 1000 }).within(() => {
|
2022-04-07 13:23:19 +02:00
|
|
|
if (accessLevelLabel) {
|
2022-04-07 13:22:16 +02:00
|
|
|
cy.get(".spectrum-Picker-label").click()
|
|
|
|
cy.wait(500)
|
|
|
|
cy.contains(accessLevelLabel).click()
|
|
|
|
}
|
2022-04-22 15:57:13 +02:00
|
|
|
cy.get(".spectrum-Button").contains("Done").click({ force: true })
|
|
|
|
})
|
|
|
|
})
|
2022-04-07 13:22:16 +02:00
|
|
|
|
2022-04-22 17:36:33 +02:00
|
|
|
Cypress.Commands.add(
|
|
|
|
"createDatasourceScreen",
|
2022-04-22 19:23:16 +02:00
|
|
|
(datasourceNames, accessLevelLabel) => {
|
2022-04-22 17:36:33 +02:00
|
|
|
cy.contains("Design").click()
|
2022-07-20 18:44:30 +02:00
|
|
|
cy.get(".header > .add-button").click()
|
2022-04-22 17:36:33 +02:00
|
|
|
cy.get(".spectrum-Modal").within(() => {
|
|
|
|
cy.get(".item").contains("Autogenerated screens").click()
|
|
|
|
cy.get(".spectrum-Button").contains("Continue").click({ force: true })
|
|
|
|
})
|
2022-06-08 19:08:45 +02:00
|
|
|
cy.get(".spectrum-Modal [data-cy='data-source-modal']", {
|
|
|
|
timeout: 500,
|
|
|
|
}).within(() => {
|
2022-04-22 19:23:16 +02:00
|
|
|
for (let i = 0; i < datasourceNames.length; i++) {
|
2022-06-29 19:28:32 +02:00
|
|
|
cy.wait(500)
|
2022-04-22 19:23:16 +02:00
|
|
|
cy.get(".data-source-entry").contains(datasourceNames[i]).click()
|
|
|
|
//Ensure the check mark is visible
|
|
|
|
cy.get(".data-source-entry")
|
|
|
|
.contains(datasourceNames[i])
|
|
|
|
.get(".data-source-check")
|
|
|
|
.should("exist")
|
|
|
|
}
|
|
|
|
|
2022-04-22 17:36:33 +02:00
|
|
|
cy.get(".spectrum-Button").contains("Confirm").click({ force: true })
|
|
|
|
})
|
2022-04-22 15:57:13 +02:00
|
|
|
|
2022-04-22 17:36:33 +02:00
|
|
|
cy.get(".spectrum-Modal").within(() => {
|
|
|
|
if (accessLevelLabel) {
|
|
|
|
cy.get(".spectrum-Picker-label").click()
|
|
|
|
cy.wait(500)
|
|
|
|
cy.contains(accessLevelLabel).click()
|
|
|
|
}
|
|
|
|
cy.get(".spectrum-Button").contains("Done").click({ force: true })
|
|
|
|
})
|
2022-01-21 15:41:53 +01:00
|
|
|
|
2022-04-22 17:36:33 +02:00
|
|
|
cy.contains("Design").click()
|
|
|
|
}
|
|
|
|
)
|
2022-04-22 15:57:13 +02:00
|
|
|
|
2022-04-08 10:56:20 +02:00
|
|
|
Cypress.Commands.add(
|
|
|
|
"createAutogeneratedScreens",
|
|
|
|
(screenNames, accessLevelLabel) => {
|
|
|
|
cy.navigateToAutogeneratedModal()
|
2022-04-07 13:22:16 +02:00
|
|
|
|
2022-04-08 10:56:20 +02:00
|
|
|
for (let i = 0; i < screenNames.length; i++) {
|
|
|
|
cy.get(".data-source-entry").contains(screenNames[i]).click()
|
|
|
|
}
|
|
|
|
|
|
|
|
cy.get(".spectrum-Modal").within(() => {
|
|
|
|
if (accessLevelLabel) {
|
|
|
|
cy.get(".spectrum-Picker-label").click()
|
|
|
|
cy.wait(500)
|
|
|
|
cy.contains(accessLevelLabel).click()
|
|
|
|
}
|
|
|
|
cy.get(".spectrum-Button").contains("Confirm").click({ force: true })
|
|
|
|
cy.wait(4000)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
)
|
2022-01-21 15:41:53 +01:00
|
|
|
|
2022-07-20 18:44:30 +02:00
|
|
|
Cypress.Commands.add("filterScreensAccessLevel", accessLevel => {
|
|
|
|
// Filters screens by access level dropdown
|
|
|
|
cy.get(".body").within(() => {
|
|
|
|
cy.get(".spectrum-Form-item").eq(1).click()
|
|
|
|
})
|
|
|
|
cy.get(".spectrum-Menu").within(() => {
|
|
|
|
cy.contains(accessLevel).click()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2022-07-20 20:21:30 +02:00
|
|
|
Cypress.Commands.add("deleteScreen", screen => {
|
|
|
|
// Navigates to Design section and deletes specified screen
|
|
|
|
cy.contains("Design").click()
|
|
|
|
cy.get(".body").within(() => {
|
|
|
|
cy.contains(screen)
|
|
|
|
.siblings(".actions")
|
|
|
|
.within(() => {
|
|
|
|
cy.get(".spectrum-Icon").click({ force: true })
|
|
|
|
})
|
|
|
|
})
|
|
|
|
cy.get(".spectrum-Menu > .spectrum-Menu-item > .spectrum-Menu-itemLabel")
|
|
|
|
.contains("Delete")
|
|
|
|
.click()
|
|
|
|
|
|
|
|
cy.get(
|
|
|
|
".spectrum-Dialog-grid > .spectrum-ButtonGroup > .confirm-wrap > .spectrum-Button"
|
|
|
|
).click({ force: true })
|
|
|
|
cy.get(".spectrum-Dialog-grid", { timeout: 10000 }).should("not.exist")
|
|
|
|
})
|
|
|
|
|
|
|
|
Cypress.Commands.add("deleteAllScreens", () => {
|
|
|
|
// Deletes all screens
|
|
|
|
cy.get(".body")
|
|
|
|
.find(".nav-item")
|
|
|
|
.its("length")
|
|
|
|
.then(len => {
|
|
|
|
for (let i = 0; i < len; i++) {
|
|
|
|
cy.get(".body > .nav-item")
|
|
|
|
.eq(0)
|
|
|
|
.invoke("text")
|
|
|
|
.then(text => {
|
|
|
|
cy.deleteScreen(text.trim())
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2022-06-01 19:54:14 +02:00
|
|
|
// NAVIGATION
|
|
|
|
Cypress.Commands.add("navigateToFrontend", () => {
|
|
|
|
// Clicks on Design tab and then the Home nav item
|
2022-06-08 19:08:45 +02:00
|
|
|
cy.wait(500)
|
2022-06-01 19:54:14 +02:00
|
|
|
cy.contains("Design").click()
|
2022-07-08 12:33:11 +02:00
|
|
|
cy.get(".spectrum-Search", { timeout: 2000 }).type("/")
|
2022-07-20 18:44:30 +02:00
|
|
|
cy.get(".nav-item", { timeout: 2000 }).contains("home").click({ force: true })
|
2022-04-01 15:41:45 +02:00
|
|
|
})
|
2022-03-29 00:21:38 +02:00
|
|
|
|
2022-06-01 19:54:14 +02:00
|
|
|
Cypress.Commands.add("navigateToDataSection", () => {
|
|
|
|
// Clicks on the Data tab
|
|
|
|
cy.wait(500)
|
|
|
|
cy.contains("Data").click()
|
2022-03-29 00:21:38 +02:00
|
|
|
})
|
|
|
|
|
2022-06-01 19:54:14 +02:00
|
|
|
Cypress.Commands.add("navigateToAutogeneratedModal", () => {
|
|
|
|
// Screen name must already exist within data source
|
|
|
|
cy.contains("Design").click()
|
2022-07-20 18:44:30 +02:00
|
|
|
cy.get(".header > .add-button").click()
|
2022-03-29 00:21:38 +02:00
|
|
|
cy.get(".spectrum-Modal").within(() => {
|
2022-07-20 18:44:30 +02:00
|
|
|
cy.get(".item", { timeout: 2000 })
|
|
|
|
.contains("Autogenerated screens")
|
|
|
|
.click({ force: true })
|
2022-06-01 19:54:14 +02:00
|
|
|
cy.get(".spectrum-Button").contains("Continue").click({ force: true })
|
|
|
|
cy.wait(500)
|
2022-03-29 00:21:38 +02:00
|
|
|
})
|
2022-01-21 15:41:53 +01:00
|
|
|
})
|
|
|
|
|
2022-06-01 19:54:14 +02:00
|
|
|
// DATASOURCES
|
2022-01-21 15:41:53 +01:00
|
|
|
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
|
2022-06-08 19:08:45 +02:00
|
|
|
cy.get(".item-list", { timeout: 1000 }).contains(datasourceName).click()
|
2022-01-21 15:41:53 +01:00
|
|
|
cy.get(".spectrum-Dialog-grid").within(() => {
|
|
|
|
cy.get(".spectrum-Button").contains("Continue").click({ force: true })
|
|
|
|
})
|
2022-06-27 19:28:21 +02:00
|
|
|
cy.wait(500)
|
2022-01-21 15:41:53 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
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
|
2022-06-08 19:08:45 +02:00
|
|
|
cy.get(".spectrum-Dialog-grid", { timeout: 500 }).within(() => {
|
2022-01-21 15:41:53 +01:00
|
|
|
cy.get(".form-row")
|
|
|
|
.eq(0)
|
|
|
|
.within(() => {
|
|
|
|
cy.get(".spectrum-Textfield").within(() => {
|
|
|
|
if (datasource == "Oracle") {
|
|
|
|
cy.get("input").clear().type(Cypress.env("oracle").HOST)
|
|
|
|
} else {
|
2022-04-13 17:02:57 +02:00
|
|
|
cy.get("input")
|
|
|
|
.clear({ force: true })
|
2022-04-25 17:25:42 +02:00
|
|
|
.type(Cypress.env("HOST_IP"), { force: true })
|
2022-01-21 15:41:53 +01:00
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
// 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)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2021-11-15 16:25:58 +01:00
|
|
|
})
|
2022-01-21 15:41:53 +01:00
|
|
|
// Click to fetch tables
|
|
|
|
if (skipFetch) {
|
|
|
|
cy.get(".spectrum-Dialog-grid").within(() => {
|
2022-01-21 18:50:16 +01:00
|
|
|
cy.get(".spectrum-Button")
|
|
|
|
.contains("Skip table fetch")
|
2022-01-21 15:41:53 +01:00
|
|
|
.click({ force: true })
|
|
|
|
})
|
2022-01-21 18:50:16 +01:00
|
|
|
} else {
|
2022-05-18 15:53:54 +02:00
|
|
|
cy.intercept("**/tables").as("datasourceTables")
|
2022-01-21 15:41:53 +01:00
|
|
|
cy.get(".spectrum-Dialog-grid").within(() => {
|
2022-01-21 18:50:16 +01:00
|
|
|
cy.get(".spectrum-Button")
|
|
|
|
.contains("Save and fetch tables")
|
2022-01-21 15:41:53 +01:00
|
|
|
.click({ force: true })
|
|
|
|
})
|
2022-05-18 15:53:54 +02:00
|
|
|
// Wait for tables to be fetched
|
2022-05-18 18:30:13 +02:00
|
|
|
cy.wait("@datasourceTables", { timeout: 60000 })
|
2022-01-21 15:41:53 +01:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2022-02-25 17:24:36 +01:00
|
|
|
Cypress.Commands.add("createRestQuery", (method, restUrl, queryPrettyName) => {
|
2022-01-21 15:41:53 +01:00
|
|
|
// addExternalDatasource should be called prior to this
|
|
|
|
// Configures REST datasource & sends query
|
2022-06-08 19:08:45 +02:00
|
|
|
cy.get(".spectrum-Button", { timeout: 1000 })
|
|
|
|
.contains("Add query")
|
|
|
|
.click({ force: true })
|
2022-01-21 15:41:53 +01:00
|
|
|
// 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 })
|
2022-06-08 19:08:45 +02:00
|
|
|
cy.get(".spectrum-Button", { timeout: 500 })
|
|
|
|
.contains("Save")
|
|
|
|
.click({ force: true })
|
2022-01-21 15:41:53 +01:00
|
|
|
cy.get(".hierarchy-items-container")
|
|
|
|
.should("contain", method)
|
2022-02-25 17:24:36 +01:00
|
|
|
.and("contain", queryPrettyName)
|
2021-10-15 18:36:10 +02:00
|
|
|
})
|
2022-06-01 19:54:14 +02:00
|
|
|
|
|
|
|
// MISC
|
|
|
|
Cypress.Commands.add("closeModal", () => {
|
2022-07-08 12:33:11 +02:00
|
|
|
cy.get(".spectrum-Modal", { timeout: 2000 }).within(() => {
|
2022-06-01 19:54:14 +02:00
|
|
|
cy.get(".close-icon").click()
|
|
|
|
cy.wait(1000) // Wait for modal to close
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
Cypress.Commands.add("expandBudibaseConnection", () => {
|
|
|
|
if (Cypress.$(".nav-item > .content > .opened").length === 0) {
|
|
|
|
// expand the Budibase DB connection string
|
|
|
|
cy.get(".icon.arrow").eq(0).click()
|
|
|
|
}
|
|
|
|
})
|