Updating Automation cypress tests, now functional.

This commit is contained in:
mike12345567 2021-05-25 15:57:38 +01:00
parent 08fef5fabd
commit 069de1fdb1
7 changed files with 50 additions and 52 deletions

View File

@ -1,9 +1,9 @@
{ {
"baseUrl": "http://localhost:10000/builder/", "baseUrl": "http://localhost:10001/builder/",
"video": true, "video": true,
"projectId": "bmbemn", "projectId": "bmbemn",
"env": { "env": {
"PORT": "10000", "PORT": "10001",
"JWT_SECRET": "test" "JWT_SECRET": "test"
} }
} }

View File

@ -8,31 +8,27 @@ context("Create a automation", () => {
it("should create a automation", () => { it("should create a automation", () => {
cy.createTestTableWithData() cy.createTestTableWithData()
cy.contains("automate").click() cy.contains("Automate").click()
cy.get("[data-cy=new-automation]").click() cy.get("[data-cy='new-screen'] > .spectrum-Icon").click()
cy.get(".modal").within(() => { cy.get(".spectrum-Dialog-grid").within(() => {
cy.get("input").type("Add Row") cy.get("input").type("Add Row")
cy.get(".buttons") cy.get(".spectrum-Button--cta").click()
.contains("Create")
.click()
}) })
// Add trigger // Add trigger
cy.contains("Trigger").click() cy.contains("Trigger").click()
cy.contains("Row Created").click() cy.contains("Row Created").click()
cy.get(".setup").within(() => { cy.get(".setup").within(() => {
cy.get("select") cy.get(".spectrum-Picker-label").click()
.first() cy.contains("dog").click()
.select("dog")
}) })
// Create action // Create action
cy.contains("Action").click() cy.contains("Action").click()
cy.contains("Create Row").click() cy.contains("Create Row").click()
cy.get(".setup").within(() => { cy.get(".setup").within(() => {
cy.get("select") cy.get(".spectrum-Picker-label").click()
.first() cy.contains("dog").click()
.select("dog")
cy.get("input") cy.get("input")
.first() .first()
.type("goodboy") .type("goodboy")
@ -45,12 +41,11 @@ context("Create a automation", () => {
cy.contains("Save Automation").click() cy.contains("Save Automation").click()
// Activate Automation // Activate Automation
cy.get("[data-cy=activate-automation]").click() cy.get("[aria-label=PlayCircle]").click()
cy.get(".ri-stop-circle-fill.highlighted").should("be.visible")
}) })
it("should add row when a new row is added", () => { it("should add row when a new row is added", () => {
cy.contains("data").click() cy.contains("Data").click()
cy.addRow(["Rover", 15]) cy.addRow(["Rover", 15])
cy.reload() cy.reload()
cy.contains("goodboy").should("have.text", "goodboy") cy.contains("goodboy").should("have.text", "goodboy")

View File

@ -3,7 +3,9 @@ const path = require("path")
const tmpdir = path.join(require("os").tmpdir(), ".budibase") const tmpdir = path.join(require("os").tmpdir(), ".budibase")
const WORKER_PORT = "4002" // these run on ports we don't normally use so that they can run alongside the
// normal development system
const WORKER_PORT = "10002"
const MAIN_PORT = cypressConfig.env.PORT const MAIN_PORT = cypressConfig.env.PORT
process.env.BUDIBASE_API_KEY = "6BE826CB-6B30-4AEC-8777-2E90464633DE" process.env.BUDIBASE_API_KEY = "6BE826CB-6B30-4AEC-8777-2E90464633DE"
process.env.NODE_ENV = "cypress" process.env.NODE_ENV = "cypress"
@ -12,8 +14,8 @@ process.env.PORT = MAIN_PORT
process.env.JWT_SECRET = cypressConfig.env.JWT_SECRET process.env.JWT_SECRET = cypressConfig.env.JWT_SECRET
process.env.COUCH_URL = `leveldb://${tmpdir}/.data/` process.env.COUCH_URL = `leveldb://${tmpdir}/.data/`
process.env.SELF_HOSTED = 1 process.env.SELF_HOSTED = 1
process.env.WORKER_URL = "http://localhost:4002/" process.env.WORKER_URL = "http://localhost:10002/"
process.env.MINIO_URL = "http://localhost:10000/" process.env.MINIO_URL = `http://localhost:${MAIN_PORT}/`
process.env.MINIO_ACCESS_KEY = "budibase" process.env.MINIO_ACCESS_KEY = "budibase"
process.env.MINIO_SECRET_KEY = "budibase" process.env.MINIO_SECRET_KEY = "budibase"
process.env.COUCH_DB_USER = "budibase" process.env.COUCH_DB_USER = "budibase"

View File

@ -7,7 +7,7 @@
Cypress.Commands.add("login", () => { Cypress.Commands.add("login", () => {
cy.visit(`localhost:${Cypress.env("PORT")}/builder`) cy.visit(`localhost:${Cypress.env("PORT")}/builder`)
cy.wait(100) cy.wait(500)
cy.url().then(url => { cy.url().then(url => {
if (url.includes("builder/admin")) { if (url.includes("builder/admin")) {
// create admin user // create admin user
@ -16,12 +16,14 @@ Cypress.Commands.add("login", () => {
cy.get('input[type="password"]').eq(1).type("test") cy.get('input[type="password"]').eq(1).type("test")
cy.contains("Create super admin user").click() cy.contains("Create super admin user").click()
} }
if (url.includes("builder/auth/login") || url.includes("builder/admin")) {
// login // login
cy.contains("Sign in to Budibase").then(() => { cy.contains("Sign in to Budibase").then(() => {
cy.get("input").first().type("test@test.com") cy.get("input").first().type("test@test.com")
cy.get('input[type="password"]').type("test") cy.get('input[type="password"]').type("test")
cy.get("button").first().click() cy.get("button").first().click()
}) })
}
}) })
}) })
@ -44,30 +46,23 @@ Cypress.Commands.add("createApp", name => {
}) })
}) })
Cypress.Commands.add("deleteApp", name => { Cypress.Commands.add("deleteApp", () => {
cy.contains("Create your first app").then($first => {
if ($first.length === 1) {
return
}
cy.visit(`localhost:${Cypress.env("PORT")}/builder`) cy.visit(`localhost:${Cypress.env("PORT")}/builder`)
cy.get(".app").then($app => {
cy.wait(1000) cy.wait(1000)
if ($app.find(`[data-cy="app-${name}"]`).length) {
cy.get(`[data-cy="app-${name}"]`).contains("Open").click() const firstAppHeader = Object.values(Cypress.$("h1")).filter(
cy.get("[data-cy=settings-icon]").click() $h1 => typeof $h1 === "string" && $h1.includes("Create your first app")
cy.get(".spectrum-Dialog").within(() => { )
cy.contains("Danger Zone").click() if (firstAppHeader.length === 0) {
cy.get("input").type("DELETE").blur() cy.get(".hoverable > use").click()
cy.contains("Delete Entire App").click() cy.contains("Delete").click()
}) cy.get(".spectrum-Button--warning").click()
} }
}) })
})
})
Cypress.Commands.add("createTestApp", () => { Cypress.Commands.add("createTestApp", () => {
const appName = "Cypress Tests" const appName = "Cypress Tests"
cy.deleteApp(appName) cy.deleteApp()
cy.createApp(appName, "This app is used for Cypress testing.") cy.createApp(appName, "This app is used for Cypress testing.")
}) })
@ -98,8 +93,10 @@ Cypress.Commands.add("addColumn", (tableName, columnName, type) => {
// Unset table display column // Unset table display column
cy.contains("display column").click({ force: true }) cy.contains("display column").click({ force: true })
cy.get("select").select(type) cy.get(".spectrum-Picker-label").click()
cy.contains("Save").click() cy.contains(type).click()
cy.contains("Save Column").click()
}) })
}) })

View File

@ -0,0 +1,3 @@
Cypress.Cookies.defaults({
preserve: "budibase:auth",
})

View File

@ -15,6 +15,7 @@
// Import commands.js using ES2015 syntax: // Import commands.js using ES2015 syntax:
import "./commands" import "./commands"
import "./cookies"
// Alternatively you can use CommonJS syntax: // Alternatively you can use CommonJS syntax:
// require('./commands') // require('./commands')

View File

@ -15,9 +15,9 @@
"cy:run": "cypress run", "cy:run": "cypress run",
"cy:open": "cypress open", "cy:open": "cypress open",
"cy:run:ci": "cypress run --record --key f308590b-6070-41af-b970-794a3823d451", "cy:run:ci": "cypress run --record --key f308590b-6070-41af-b970-794a3823d451",
"cy:test": "start-server-and-test cy:setup http://localhost:10000/builder cy:run", "cy:test": "start-server-and-test cy:setup http://localhost:10001/builder cy:run",
"cy:ci": "start-server-and-test cy:setup http://localhost:10000/builder cy:run:ci", "cy:ci": "start-server-and-test cy:setup http://localhost:10001/builder cy:run:ci",
"cy:debug": "start-server-and-test cy:setup http://localhost:10000/builder cy:open" "cy:debug": "start-server-and-test cy:setup http://localhost:10001/builder cy:open"
}, },
"jest": { "jest": {
"globals": { "globals": {