Merge branch 'master' of https://github.com/Budibase/budibase into britechart/donut-demo
This commit is contained in:
commit
9983feb1f0
|
@ -32,4 +32,5 @@ jobs:
|
|||
- run: yarn test
|
||||
env:
|
||||
CI: true
|
||||
name: Budibase CI
|
||||
name: Budibase CI
|
||||
- run: yarn test:e2e:ci
|
||||
|
|
|
@ -26,7 +26,8 @@
|
|||
"lint": "eslint packages",
|
||||
"lint:fix": "eslint --fix packages",
|
||||
"format": "prettier --write \"{,!(node_modules)/**/}*.{js,jsx,svelte}\"",
|
||||
"test:e2e": "lerna run cy:test"
|
||||
"test:e2e": "lerna run cy:test",
|
||||
"test:e2e:ci": "lerna run cy:ci"
|
||||
},
|
||||
"dependencies": {
|
||||
"@material/icon-button": "4.0.0",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"baseUrl": "http://localhost:4001/_builder/",
|
||||
"video": false
|
||||
}
|
||||
"baseUrl": "http://localhost:4001/_builder/",
|
||||
"video": true,
|
||||
"projectId": "bmbemn"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"budibase": "CB373643-3FC4-4902-9E31-449C0ED066B6"
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
context('Create an Application', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
cy.server()
|
||||
cy.visit('localhost:4001/_builder')
|
||||
})
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
context('Create Components', () => {
|
||||
xcontext('Create Components', () => {
|
||||
|
||||
before(() => {
|
||||
cy.server()
|
||||
cy.visit('localhost:4001/_builder')
|
||||
// https://on.cypress.io/type
|
||||
cy.createApp('Model App', 'Model App Description')
|
||||
|
@ -22,8 +23,8 @@ context('Create Components', () => {
|
|||
})
|
||||
it('change the font size of the headline', () => {
|
||||
cy.contains('Typography').click()
|
||||
cy.get('input[name="font-size"]')
|
||||
.type('60px')
|
||||
cy.get('[data-cy=font-size-prop-control]').click()
|
||||
cy.contains("60px").click()
|
||||
cy.contains('Design').click()
|
||||
|
||||
getIframeBody().contains('An Amazing headline!').should('have.css', 'font-size', '60px')
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
context('Create a Model', () => {
|
||||
xcontext('Create a Model', () => {
|
||||
|
||||
before(() => {
|
||||
cy.visit('localhost:4001/_builder')
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
context('Create a User', () => {
|
||||
|
||||
before(() => {
|
||||
cy.server()
|
||||
cy.visit('localhost:4001/_builder')
|
||||
// https://on.cypress.io/type
|
||||
cy.createApp('User App', 'This app is used to test user creation')
|
||||
|
@ -8,12 +9,9 @@ context('Create a User', () => {
|
|||
|
||||
// https://on.cypress.io/interacting-with-elements
|
||||
it('should create a user', () => {
|
||||
// Close Model modal that shows up after creating an app
|
||||
cy.get('.close').click()
|
||||
|
||||
cy.createUser('bbuser', 'test', 'ADMIN')
|
||||
|
||||
// Check to make sure user was created!
|
||||
cy.contains('bbuser').should('have.text', 'bbuser')
|
||||
cy.get("input[disabled]").should('have.value', 'bbuser')
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
context('Create a workflow', () => {
|
||||
xcontext('Create a workflow', () => {
|
||||
|
||||
before(() => {
|
||||
cy.server()
|
||||
cy.visit('localhost:4001/_builder')
|
||||
|
||||
cy.createApp('Workflow Test App', 'This app is used to test that workflows do in fact work!')
|
||||
|
@ -9,11 +10,9 @@ context('Create a workflow', () => {
|
|||
// https://on.cypress.io/interacting-with-elements
|
||||
it('should create a workflow', () => {
|
||||
cy.createModel('dog', 'name', 'age')
|
||||
cy.createUser('bbuser', 'test', 'ADMIN')
|
||||
|
||||
|
||||
cy.contains('workflow').click()
|
||||
cy.get('.new-workflow-button').click()
|
||||
cy.contains('Create New Workflow').click()
|
||||
cy.get('input').type('Add Record')
|
||||
cy.contains('Save').click()
|
||||
|
||||
|
@ -28,14 +27,13 @@ context('Create a workflow', () => {
|
|||
cy.get(':nth-child(3) > .budibase__input').type('11')
|
||||
|
||||
// Save
|
||||
cy.get('[data-cy=save-workflow-setup]').click()
|
||||
cy.get('.workflow-button').click()
|
||||
cy.contains('Save Workflow').click()
|
||||
|
||||
// Activate Workflow
|
||||
cy.get('[data-cy=activate-workflow]').click()
|
||||
|
||||
})
|
||||
it('should add record when a new record is added', () => {
|
||||
xit('should add record when a new record is added', () => {
|
||||
cy.contains('backend').click()
|
||||
|
||||
cy.addRecord('bob', '15')
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
|
||||
context('Screen Tests', () => {
|
||||
before(() => {
|
||||
cy.server()
|
||||
cy.visit('localhost:4001/_builder')
|
||||
cy.createApp('Conor Cy App', 'Model App Description')
|
||||
cy.navigateToFrontend()
|
||||
})
|
||||
|
||||
it('Should successful create a screen', () => {
|
||||
cy.createScreen("test Screen")
|
||||
cy.createScreen("test Screen", "/test")
|
||||
})
|
||||
|
||||
it('Should rename a screen', () => {
|
||||
|
|
|
@ -19,4 +19,5 @@
|
|||
module.exports = (on, config) => {
|
||||
// `on` is used to hook into various events Cypress emits
|
||||
// `config` is the resolved Cypress config
|
||||
require("cypress-terminal-report/src/installLogsPrinter")(on)
|
||||
}
|
||||
|
|
|
@ -1,17 +1,23 @@
|
|||
// What this script does:
|
||||
// 1. Removes the old test folder if it exists (.budibase-cypress)
|
||||
// 2. Initialises using `.budibase-cypress`
|
||||
// 1. Removes the old test folder if it exists (.budibase)
|
||||
// 2. Initialises using `.budibase`
|
||||
// 3. Runs the server using said folder
|
||||
|
||||
const rimraf = require("rimraf")
|
||||
const { join } = require("path")
|
||||
const homedir = join(require("os").homedir(), ".budibase-cypress")
|
||||
const init = require("../../cli/src/commands/init/initHandler")
|
||||
const run = require("../../cli/src/commands/run/runHandler")
|
||||
const initialiseBudibase = require("../../server/src/utilities/initialiseBudibase")
|
||||
|
||||
const homedir = join(require("os").homedir(), ".budibase")
|
||||
|
||||
rimraf.sync(homedir)
|
||||
|
||||
init({ dir: homedir, clientId: "cypress-test" }).then(() => {
|
||||
delete require.cache[require.resolve("../../server/src/environment")]
|
||||
run({ dir: homedir })
|
||||
})
|
||||
process.env.BUDIBASE_API_KEY = "6BE826CB-6B30-4AEC-8777-2E90464633DE"
|
||||
process.env.NODE_ENV = "cypress"
|
||||
|
||||
initialiseBudibase({ dir: homedir, clientId: "cypress-test" })
|
||||
.then(() => {
|
||||
delete require.cache[require.resolve("../../server/src/environment")]
|
||||
run({ dir: homedir })
|
||||
})
|
||||
.catch(e => console.error(e))
|
||||
|
|
|
@ -24,69 +24,81 @@
|
|||
// -- This will overwrite an existing command --
|
||||
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
|
||||
|
||||
Cypress.Commands.add("createApp", (name, description) => {
|
||||
cy.get(".banner-button")
|
||||
.click()
|
||||
.get('input[name="name"]')
|
||||
.type(name)
|
||||
.should("have.value", name)
|
||||
Cypress.Commands.add("createApp", name => {
|
||||
cy.contains("Create New Web App").click()
|
||||
|
||||
cy.get('textarea[name="description"]')
|
||||
.type(description)
|
||||
.should("have.value", description)
|
||||
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.get("input[name=applicationName]")
|
||||
.type(name)
|
||||
.should("have.value", name)
|
||||
|
||||
cy.contains("Save").click()
|
||||
cy.contains("Next").click()
|
||||
|
||||
cy.get("input[name=username]")
|
||||
.click()
|
||||
.type("test")
|
||||
cy.get("input[name=password]")
|
||||
.click()
|
||||
.type("test")
|
||||
cy.contains("Submit").click()
|
||||
cy.contains("Create New Table", {
|
||||
timeout: 10000,
|
||||
}).should("be.visible")
|
||||
})
|
||||
})
|
||||
Cypress.Commands.add("createModel", (modelName, firstField, secondField) => {
|
||||
|
||||
Cypress.Commands.add("createModel", modelName => {
|
||||
// Enter model name
|
||||
cy.get("[data-cy=Name]")
|
||||
.click()
|
||||
.type(modelName)
|
||||
cy.contains("Create New Table").click()
|
||||
cy.get("[data-cy=table-name-input]").type(modelName)
|
||||
|
||||
// Add 'name' field
|
||||
cy.get("[data-cy=add-new-model-field]").click()
|
||||
cy.get("[data-cy=Name]")
|
||||
.click()
|
||||
.type(firstField)
|
||||
cy.contains("Save").click()
|
||||
cy.contains("Add").click()
|
||||
cy.contains("Plain Text").click()
|
||||
|
||||
// Add 'age' field
|
||||
cy.get("[data-cy=add-new-model-field]").click()
|
||||
cy.contains("Add").click()
|
||||
cy.contains("Number").click()
|
||||
|
||||
cy.get("[data-cy=Name]")
|
||||
.click()
|
||||
.type(secondField)
|
||||
cy.get("select").select("number")
|
||||
cy.contains("Save").click()
|
||||
cy.contains(secondField).should("exist")
|
||||
|
||||
// Save model
|
||||
cy.contains("Save").click()
|
||||
cy.contains(modelName).click()
|
||||
})
|
||||
|
||||
Cypress.Commands.add("addRecord", (firstField, secondField) => {
|
||||
cy.contains("Create new record").click()
|
||||
cy.contains("Create New Record").click()
|
||||
|
||||
cy.get("[data-cy=name-input]")
|
||||
.click()
|
||||
.type(firstField)
|
||||
cy.get("[data-cy=age-input]")
|
||||
.click()
|
||||
.type(secondField)
|
||||
cy.get("[data-cy='Plain Text-input']").type(firstField)
|
||||
cy.get("[data-cy=Number-input]").type(secondField)
|
||||
|
||||
// Save
|
||||
cy.contains("Save").click()
|
||||
})
|
||||
|
||||
Cypress.Commands.add("createUser", (username, password, level) => {
|
||||
Cypress.Commands.add("createUser", (username, password) => {
|
||||
// Create User
|
||||
cy.get(".nav-group-header > .ri-add-line").click()
|
||||
cy.get(".toprightnav > .settings").click()
|
||||
cy.contains("Users").click()
|
||||
|
||||
cy.get("[data-cy=username]").type(username)
|
||||
cy.get("[data-cy=password]").type(password)
|
||||
cy.get("[data-cy=accessLevel]").select(level)
|
||||
cy.get("[name=Name]")
|
||||
.first()
|
||||
.type(username)
|
||||
cy.get("[name=Password]")
|
||||
.first()
|
||||
.type(password)
|
||||
|
||||
// Save
|
||||
cy.contains("Save").click()
|
||||
cy.get(".create-button").click()
|
||||
})
|
||||
|
||||
Cypress.Commands.add("addHeadlineComponent", text => {
|
||||
|
@ -95,7 +107,8 @@ Cypress.Commands.add("addHeadlineComponent", text => {
|
|||
cy.get("[data-cy=Text]").click()
|
||||
cy.get("[data-cy=Headline]").click()
|
||||
cy.get(".tabs > :nth-child(2)").click()
|
||||
cy.get('input[type="text"]').type(text)
|
||||
cy.contains("Settings").click()
|
||||
cy.get('input[name="text"]').type(text)
|
||||
cy.contains("Design").click()
|
||||
})
|
||||
Cypress.Commands.add("addButtonComponent", () => {
|
||||
|
@ -105,9 +118,7 @@ Cypress.Commands.add("addButtonComponent", () => {
|
|||
})
|
||||
|
||||
Cypress.Commands.add("navigateToFrontend", () => {
|
||||
cy.get(".close", { timeout: 10000 }).click()
|
||||
cy.contains("frontend").click()
|
||||
cy.get(".close", { timeout: 10000 }).click()
|
||||
})
|
||||
|
||||
Cypress.Commands.add("createScreen", (screenName, route) => {
|
||||
|
|
|
@ -19,3 +19,4 @@ import "./commands"
|
|||
|
||||
// Alternatively you can use CommonJS syntax:
|
||||
// require('./commands')
|
||||
require("cypress-terminal-report/src/installLogsCollector")()
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
"cy:setup": "node ./cypress/setup.js",
|
||||
"cy:run": "cypress run",
|
||||
"cy:open": "cypress open",
|
||||
"cy:test": "start-server-and-test cy:setup http://localhost:4001/_builder cy:run"
|
||||
"cy:run:ci": "cypress run --browser electron --record --key f308590b-6070-41af-b970-794a3823d451",
|
||||
"cy:test": "start-server-and-test cy:setup http://localhost:4001/_builder cy:run",
|
||||
"cy:ci": "start-server-and-test cy:setup http://localhost:4001/_builder cy:run:ci"
|
||||
},
|
||||
"jest": {
|
||||
"globals": {
|
||||
|
@ -93,6 +95,7 @@
|
|||
"babel-jest": "^24.8.0",
|
||||
"browser-sync": "^2.26.7",
|
||||
"cypress": "^4.8.0",
|
||||
"cypress-terminal-report": "^1.4.1",
|
||||
"eslint-plugin-cypress": "^2.11.1",
|
||||
"http-proxy-middleware": "^0.19.1",
|
||||
"jest": "^24.8.0",
|
||||
|
@ -116,4 +119,4 @@
|
|||
"svelte-jester": "^1.0.6"
|
||||
},
|
||||
"gitHead": "115189f72a850bfb52b65ec61d932531bf327072"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ import posthog from "posthog-js"
|
|||
|
||||
function activate() {
|
||||
Sentry.init({ dsn: process.env.SENTRY_DSN })
|
||||
if (!process.env.POSTHOG_TOKEN) return
|
||||
posthog.init(process.env.POSTHOG_TOKEN, {
|
||||
api_host: process.env.POSTHOG_URL,
|
||||
})
|
||||
|
@ -13,7 +14,7 @@ function captureException(err) {
|
|||
}
|
||||
|
||||
function captureEvent(event) {
|
||||
if (process.env.NODE_ENV !== "production") return
|
||||
if (!process.env.POSTHOG_TOKEN) return
|
||||
posthog.capture(event)
|
||||
}
|
||||
|
||||
|
|
|
@ -99,6 +99,7 @@
|
|||
<div class="titled-input">
|
||||
<header>Name</header>
|
||||
<input
|
||||
data-cy="table-name-input"
|
||||
type="text"
|
||||
class="budibase__input"
|
||||
bind:value={$backendUiStore.draftModel.name} />
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
}
|
||||
</script>
|
||||
|
||||
<span class="topnavitemright" on:click={showSettingsModal}>
|
||||
<span class="topnavitemright settings" on:click={showSettingsModal}>
|
||||
<SettingsIcon />
|
||||
</span>
|
||||
|
||||
|
|
|
@ -14,14 +14,6 @@
|
|||
|
||||
const getProperties = name => panelDefinition[name]
|
||||
|
||||
onMount(() => {
|
||||
// if(propGroup) {
|
||||
// propGroup.addEventListener("scroll", function(e){
|
||||
// console.log("I SCROLLED", e.target.scrollTop)
|
||||
// })
|
||||
// }
|
||||
})
|
||||
|
||||
function onChange(category) {
|
||||
selectedCategory = category
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
<div class="property-control">
|
||||
<div class="label">{label}</div>
|
||||
<div class="control">
|
||||
<div data-cy={`${key}-prop-control`} class="control">
|
||||
<svelte:component
|
||||
this={control}
|
||||
{...handlevalueKey(value)}
|
||||
|
|
|
@ -29,5 +29,5 @@
|
|||
"uuid": "^7.0.3",
|
||||
"yargs": "^14.2.0"
|
||||
},
|
||||
"gitHead": "eff4fa93ca1db11b97b5fdedc0c488413e277eb8"
|
||||
"gitHead": "284cceb9b703c38566c6e6363c022f79a08d5691"
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@ module.exports = async ({ dir }) => {
|
|||
|
||||
// dont make this a variable or top level require
|
||||
// it will cause environment module to be loaded prematurely
|
||||
return require("@budibase/server/src/app")().then(server => {
|
||||
server.on("close", () => console.log("Server Closed"))
|
||||
console.log(`Budibase running on ${JSON.stringify(server.address())}`)
|
||||
})
|
||||
const server = require("@budibase/server/src/app")
|
||||
server.on("close", () => console.log("Server Closed"))
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
],
|
||||
"version": "0.1.13",
|
||||
"license": "MIT",
|
||||
"gitHead": "eff4fa93ca1db11b97b5fdedc0c488413e277eb8",
|
||||
"gitHead": "284cceb9b703c38566c6e6363c022f79a08d5691",
|
||||
"dependencies": {
|
||||
"@material/card": "4.0.0"
|
||||
}
|
||||
|
|
|
@ -97,5 +97,5 @@
|
|||
"./scripts/jestSetup.js"
|
||||
]
|
||||
},
|
||||
"gitHead": "eff4fa93ca1db11b97b5fdedc0c488413e277eb8"
|
||||
"gitHead": "284cceb9b703c38566c6e6363c022f79a08d5691"
|
||||
}
|
||||
|
|
|
@ -207,7 +207,7 @@ const getClientId = ctx => {
|
|||
env.CLIENT_ID
|
||||
|
||||
if (!clientId) {
|
||||
ctx.throw(400, "ClientId not suplied")
|
||||
ctx.throw(400, "ClientId not supplied")
|
||||
}
|
||||
return clientId
|
||||
}
|
||||
|
|
|
@ -68,7 +68,9 @@ exports.save = async function(ctx) {
|
|||
|
||||
ctx.eventEmitter &&
|
||||
ctx.eventEmitter.emit(`record:save`, {
|
||||
record,
|
||||
args: {
|
||||
record,
|
||||
},
|
||||
instanceId: ctx.user.instanceId,
|
||||
})
|
||||
ctx.body = record
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
const recordController = require("../../record")
|
||||
|
||||
module.exports = async function saveRecord({ args, instanceId }) {
|
||||
module.exports = async function saveRecord({ args, context }) {
|
||||
const { model, ...record } = args.record
|
||||
|
||||
const ctx = {
|
||||
params: {
|
||||
instanceId,
|
||||
instanceId: context.instanceId,
|
||||
modelId: model._id,
|
||||
},
|
||||
request: {
|
||||
body: record,
|
||||
},
|
||||
user: { instanceId },
|
||||
user: { instanceId: context.instanceId },
|
||||
}
|
||||
|
||||
await recordController.save(ctx)
|
||||
|
|
|
@ -44,7 +44,9 @@ router
|
|||
useAppRootPath: true,
|
||||
}
|
||||
ctx.isDev =
|
||||
process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "jest"
|
||||
process.env.NODE_ENV !== "production" &&
|
||||
process.env.NODE_ENV !== "jest" &&
|
||||
process.env.NODE_ENV !== "cypress"
|
||||
await next()
|
||||
})
|
||||
.use(authenticated)
|
||||
|
|
|
@ -18,7 +18,7 @@ async function executeRelevantWorkflows(event, eventType) {
|
|||
workflowOrchestrator.strategy = serverStrategy
|
||||
|
||||
for (let workflow of workflows) {
|
||||
workflowOrchestrator.execute(workflow)
|
||||
workflowOrchestrator.execute(workflow, event)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@ exports.Orchestrator = class Orchestrator {
|
|||
this._strategy = strategy()
|
||||
}
|
||||
|
||||
async execute(workflow) {
|
||||
async execute(workflow, context) {
|
||||
if (workflow.live) {
|
||||
this._strategy.run(workflow.definition)
|
||||
this._strategy.run(workflow.definition, context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,12 +35,15 @@ exports.serverStrategy = () => ({
|
|||
|
||||
return mappedArgs
|
||||
},
|
||||
run: async function(workflow) {
|
||||
run: async function(workflow, context) {
|
||||
for (let block of workflow.steps) {
|
||||
if (block.type === "CLIENT") continue
|
||||
|
||||
const action = require(`../api/controllers/workflow/actions/${block.actionId}`)
|
||||
const response = await action({ args: this.bindContextArgs(block.args) })
|
||||
const response = await action({
|
||||
args: this.bindContextArgs(block.args),
|
||||
context,
|
||||
})
|
||||
|
||||
this.context = {
|
||||
...this.context,
|
||||
|
|
|
@ -18,7 +18,6 @@ exports.downloadExtractComponentLibraries = async appFolder => {
|
|||
// Need to download tarballs directly from NPM as our users may not have node on their machine
|
||||
for (let lib of LIBRARIES) {
|
||||
// download tarball
|
||||
// TODO: make sure the latest version is always downloaded
|
||||
const registryUrl = `https://registry.npmjs.org/@budibase/${lib}/-/${lib}-${packageJson.version}.tgz`
|
||||
const response = await fetch(registryUrl)
|
||||
if (!response.ok)
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
],
|
||||
"version": "0.1.13",
|
||||
"license": "MIT",
|
||||
"gitHead": "eff4fa93ca1db11b97b5fdedc0c488413e277eb8",
|
||||
"gitHead": "284cceb9b703c38566c6e6363c022f79a08d5691",
|
||||
"dependencies": {
|
||||
"@beyonk/svelte-googlemaps": "^2.2.0",
|
||||
"britecharts": "^2.16.0",
|
||||
|
|
Loading…
Reference in New Issue