Fixing app cypress test cases.
This commit is contained in:
parent
921eb39227
commit
1146d508fd
|
@ -1,6 +1,5 @@
|
|||
const { newid } = require("../hashing")
|
||||
const Replication = require("./Replication")
|
||||
const { getCouch } = require("./index")
|
||||
|
||||
const UNICODE_MAX = "\ufff0"
|
||||
const SEPARATOR = "_"
|
||||
|
@ -164,8 +163,7 @@ exports.getDeployedAppID = appId => {
|
|||
* different users/companies apps as there is no security around it - all apps are returned.
|
||||
* @return {Promise<object[]>} returns the app information document stored in each app database.
|
||||
*/
|
||||
exports.getAllApps = async ({ dev, all } = {}) => {
|
||||
const CouchDB = getCouch()
|
||||
exports.getAllApps = async ({ CouchDB, dev, all } = {}) => {
|
||||
let allDbs = await CouchDB.allDbs()
|
||||
const appDbNames = allDbs.filter(dbName =>
|
||||
dbName.startsWith(exports.APP_PREFIX)
|
||||
|
|
|
@ -6,12 +6,8 @@
|
|||
//
|
||||
|
||||
Cypress.Commands.add("login", () => {
|
||||
cy.getCookie("budibase:auth").then(cookie => {
|
||||
// Already logged in
|
||||
if (cookie) return
|
||||
|
||||
cy.visit(`localhost:${Cypress.env("PORT")}/builder`)
|
||||
|
||||
cy.wait(100)
|
||||
cy.url().then(url => {
|
||||
if (url.includes("builder/admin")) {
|
||||
// create admin user
|
||||
|
@ -21,6 +17,7 @@ Cypress.Commands.add("login", () => {
|
|||
cy.contains("Create super admin user").click()
|
||||
}
|
||||
// login
|
||||
cy.contains("Sign in to Budibase").then(() => {
|
||||
cy.get("input").first().type("test@test.com")
|
||||
cy.get('input[type="password"]').type("test")
|
||||
cy.get("button").first().click()
|
||||
|
@ -32,23 +29,12 @@ Cypress.Commands.add("createApp", name => {
|
|||
cy.visit(`localhost:${Cypress.env("PORT")}/builder`)
|
||||
// wait for init API calls on visit
|
||||
cy.wait(100)
|
||||
cy.contains("Create New Web App").click()
|
||||
cy.get("body")
|
||||
.then($body => {
|
||||
if ($body.find("input[name=apiKey]").length) {
|
||||
// input was found, do something else here
|
||||
cy.get("input[name=apiKey]").type(name).should("have.value", name)
|
||||
cy.contains("Next").click()
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
cy.contains("Create app").click()
|
||||
cy.get("body").then(() => {
|
||||
cy.get(".spectrum-Modal")
|
||||
.within(() => {
|
||||
cy.get("input").eq(0).type(name).should("have.value", name).blur()
|
||||
cy.contains("Next").click()
|
||||
cy.get("input").eq(1).type("test@test.com").blur()
|
||||
cy.get("input").eq(2).type("test").blur()
|
||||
cy.contains("Submit").click()
|
||||
cy.contains("Create app").click()
|
||||
})
|
||||
.then(() => {
|
||||
cy.get("[data-cy=new-table]", {
|
||||
|
@ -59,10 +45,14 @@ Cypress.Commands.add("createApp", name => {
|
|||
})
|
||||
|
||||
Cypress.Commands.add("deleteApp", name => {
|
||||
cy.contains("Create your first app").then($first => {
|
||||
if ($first.length === 1) {
|
||||
return
|
||||
}
|
||||
cy.visit(`localhost:${Cypress.env("PORT")}/builder`)
|
||||
cy.get(".apps").then($apps => {
|
||||
cy.get(".app").then($app => {
|
||||
cy.wait(1000)
|
||||
if ($apps.find(`[data-cy="app-${name}"]`).length) {
|
||||
if ($app.find(`[data-cy="app-${name}"]`).length) {
|
||||
cy.get(`[data-cy="app-${name}"]`).contains("Open").click()
|
||||
cy.get("[data-cy=settings-icon]").click()
|
||||
cy.get(".spectrum-Dialog").within(() => {
|
||||
|
@ -73,6 +63,7 @@ Cypress.Commands.add("deleteApp", name => {
|
|||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Cypress.Commands.add("createTestApp", () => {
|
||||
const appName = "Cypress Tests"
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
Cypress.Cookies.defaults({
|
||||
preserve: "budibase:auth",
|
||||
})
|
|
@ -14,7 +14,6 @@
|
|||
// ***********************************************************
|
||||
|
||||
// Import commands.js using ES2015 syntax:
|
||||
import "./cookies"
|
||||
import "./commands"
|
||||
|
||||
// Alternatively you can use CommonJS syntax:
|
||||
|
|
|
@ -116,7 +116,7 @@ async function createInstance(template) {
|
|||
exports.fetch = async function (ctx) {
|
||||
const dev = ctx.query && ctx.query.status === AppStatus.DEV
|
||||
const all = ctx.query && ctx.query.status === AppStatus.ALL
|
||||
const apps = await getAllApps({ dev, all })
|
||||
const apps = await getAllApps({ CouchDB, dev, all })
|
||||
|
||||
// get the locks for all the dev apps
|
||||
if (dev || all) {
|
||||
|
@ -192,9 +192,6 @@ exports.create = async function (ctx) {
|
|||
instance: instance,
|
||||
updatedAt: new Date().toISOString(),
|
||||
createdAt: new Date().toISOString(),
|
||||
deployment: {
|
||||
type: "cloud",
|
||||
},
|
||||
}
|
||||
const instanceDb = new CouchDB(appId)
|
||||
await instanceDb.put(newApplication)
|
||||
|
|
|
@ -8,7 +8,7 @@ const CouchDB = require("../../../db")
|
|||
|
||||
exports.fetch = async ctx => {
|
||||
// always use the dev apps as they'll be most up to date (true)
|
||||
const apps = await getAllApps({ dev: true })
|
||||
const apps = await getAllApps({ CouchDB, dev: true })
|
||||
const promises = []
|
||||
for (let app of apps) {
|
||||
// use dev app IDs
|
||||
|
|
Loading…
Reference in New Issue