@budibase/server 1.0.199 → 1.0.200-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Dockerfile +2 -0
- package/builder/assets/index.359da19e.js +1315 -0
- package/builder/index.html +1 -1
- package/coverage/clover.xml +2089 -2001
- package/coverage/coverage-final.json +121 -122
- package/coverage/lcov-report/api/controllers/apikeys.js.html +6 -6
- package/coverage/lcov-report/api/controllers/auth.js.html +7 -7
- package/coverage/lcov-report/api/controllers/automation.js.html +174 -72
- package/coverage/lcov-report/api/controllers/backup.js.html +30 -6
- package/coverage/lcov-report/api/controllers/cloud.js.html +11 -11
- package/coverage/lcov-report/api/controllers/component.js.html +5 -5
- package/coverage/lcov-report/api/controllers/datasource.js.html +53 -41
- package/coverage/lcov-report/api/controllers/dev.js.html +94 -70
- package/coverage/lcov-report/api/controllers/index.html +57 -72
- package/coverage/lcov-report/api/controllers/integration.js.html +8 -8
- package/coverage/lcov-report/api/controllers/layout.js.html +28 -19
- package/coverage/lcov-report/api/controllers/metadata.js.html +9 -9
- package/coverage/lcov-report/api/controllers/migrations.js.html +4 -4
- package/coverage/lcov-report/api/controllers/permission.js.html +15 -15
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/validation.js.html +10 -10
- package/coverage/lcov-report/api/controllers/role.js.html +78 -48
- package/coverage/lcov-report/api/controllers/routing.js.html +9 -9
- package/coverage/lcov-report/api/controllers/row/external.js.html +19 -19
- package/coverage/lcov-report/api/controllers/row/index.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +54 -54
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +9 -9
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +24 -24
- package/coverage/lcov-report/api/controllers/row/utils.js.html +24 -24
- package/coverage/lcov-report/api/controllers/screen.js.html +56 -20
- package/coverage/lcov-report/api/controllers/script.js.html +4 -4
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +49 -49
- package/coverage/lcov-report/api/controllers/table/external.js.html +23 -17
- package/coverage/lcov-report/api/controllers/table/index.html +26 -26
- package/coverage/lcov-report/api/controllers/table/index.js.html +85 -49
- package/coverage/lcov-report/api/controllers/templates.js.html +6 -6
- package/coverage/lcov-report/api/controllers/user.js.html +19 -19
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +11 -11
- package/coverage/lcov-report/api/controllers/view/index.html +21 -21
- package/coverage/lcov-report/api/controllers/view/index.js.html +275 -65
- package/coverage/lcov-report/api/controllers/view/utils.js.html +23 -23
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +40 -40
- package/coverage/lcov-report/api/controllers/webhook.js.html +17 -17
- package/coverage/lcov-report/api/index.html +15 -15
- package/coverage/lcov-report/api/index.js.html +39 -45
- package/coverage/lcov-report/api/routes/analytics.js.html +7 -13
- package/coverage/lcov-report/api/routes/apikeys.js.html +8 -8
- package/coverage/lcov-report/api/routes/auth.js.html +6 -6
- package/coverage/lcov-report/api/routes/automation.js.html +11 -11
- package/coverage/lcov-report/api/routes/backup.js.html +8 -8
- package/coverage/lcov-report/api/routes/cloud.js.html +8 -8
- package/coverage/lcov-report/api/routes/component.js.html +8 -8
- package/coverage/lcov-report/api/routes/datasource.js.html +9 -9
- package/coverage/lcov-report/api/routes/deploy.js.html +8 -8
- package/coverage/lcov-report/api/routes/dev.js.html +13 -13
- package/coverage/lcov-report/api/routes/index.html +1 -1
- package/coverage/lcov-report/api/routes/integration.js.html +8 -8
- package/coverage/lcov-report/api/routes/layout.js.html +8 -8
- package/coverage/lcov-report/api/routes/metadata.js.html +9 -9
- package/coverage/lcov-report/api/routes/migrations.js.html +7 -7
- package/coverage/lcov-report/api/routes/permission.js.html +9 -9
- package/coverage/lcov-report/api/routes/query.js.html +10 -10
- package/coverage/lcov-report/api/routes/role.js.html +9 -9
- package/coverage/lcov-report/api/routes/routing.js.html +8 -8
- package/coverage/lcov-report/api/routes/screen.js.html +9 -9
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/table.js.html +10 -10
- package/coverage/lcov-report/api/routes/templates.js.html +8 -8
- package/coverage/lcov-report/api/routes/user.js.html +8 -8
- package/coverage/lcov-report/api/routes/utils/index.html +1 -1
- package/coverage/lcov-report/api/routes/utils/validators.js.html +36 -36
- package/coverage/lcov-report/api/routes/view.js.html +10 -10
- package/coverage/lcov-report/api/routes/webhook.js.html +9 -9
- package/coverage/lcov-report/automations/actions.js.html +25 -25
- package/coverage/lcov-report/automations/automationUtils.js.html +8 -8
- package/coverage/lcov-report/automations/bullboard.js.html +35 -35
- package/coverage/lcov-report/automations/index.html +29 -29
- package/coverage/lcov-report/automations/index.js.html +29 -17
- package/coverage/lcov-report/automations/steps/bash.js.html +7 -7
- package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
- package/coverage/lcov-report/automations/steps/discord.js.html +7 -7
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +6 -6
- package/coverage/lcov-report/automations/steps/executeScript.js.html +6 -6
- package/coverage/lcov-report/automations/steps/filter.js.html +7 -7
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +5 -5
- package/coverage/lcov-report/automations/steps/loop.js.html +2 -2
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +8 -8
- package/coverage/lcov-report/automations/steps/queryRows.js.html +10 -10
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +5 -5
- package/coverage/lcov-report/automations/steps/serverLog.js.html +3 -3
- package/coverage/lcov-report/automations/steps/slack.js.html +5 -5
- package/coverage/lcov-report/automations/steps/updateRow.js.html +6 -6
- package/coverage/lcov-report/automations/steps/utils.js.html +3 -3
- package/coverage/lcov-report/automations/steps/zapier.js.html +5 -5
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +8 -8
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +2 -2
- package/coverage/lcov-report/automations/triggers.js.html +18 -18
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +30 -30
- package/coverage/lcov-report/constants/layouts.js.html +5 -5
- package/coverage/lcov-report/constants/screens.js.html +4 -4
- package/coverage/lcov-report/db/inMemoryView.js.html +5 -5
- package/coverage/lcov-report/db/index.html +1 -1
- package/coverage/lcov-report/db/index.js.html +9 -9
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +17 -17
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +36 -36
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +19 -19
- package/coverage/lcov-report/db/newid.js.html +4 -4
- package/coverage/lcov-report/db/utils.js.html +81 -81
- package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +7 -7
- package/coverage/lcov-report/events/utils.js.html +10 -10
- package/coverage/lcov-report/index.html +74 -74
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +5 -5
- package/coverage/lcov-report/middleware/builder.js.html +20 -20
- package/coverage/lcov-report/middleware/currentapp.js.html +49 -49
- package/coverage/lcov-report/middleware/index.html +1 -1
- package/coverage/lcov-report/middleware/joi-validator.js.html +14 -14
- package/coverage/lcov-report/middleware/publicApi.js.html +5 -5
- package/coverage/lcov-report/middleware/resourceId.js.html +29 -29
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +4 -4
- package/coverage/lcov-report/threads/automation.js.html +1 -1
- package/coverage/lcov-report/threads/index.html +1 -1
- package/coverage/lcov-report/threads/query.js.html +1 -1
- package/coverage/lcov-report/threads/utils.js.html +13 -13
- package/coverage/lcov-report/utilities/budibaseDir.js.html +3 -3
- package/coverage/lcov-report/utilities/centralPath.js.html +14 -14
- package/coverage/lcov-report/utilities/csvParser.js.html +34 -34
- package/coverage/lcov-report/utilities/global.js.html +28 -28
- package/coverage/lcov-report/utilities/index.html +25 -25
- package/coverage/lcov-report/utilities/index.js.html +41 -41
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +18 -18
- package/coverage/lcov-report/utilities/queue/index.html +15 -15
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +6 -6
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +59 -59
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +15 -15
- package/coverage/lcov-report/utilities/scriptRunner.js.html +5 -5
- package/coverage/lcov-report/utilities/security.js.html +8 -8
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +30 -30
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +7 -7
- package/coverage/lcov-report/utilities/workerRequests.js.html +29 -29
- package/coverage/lcov.info +2903 -2762
- package/dist/api/controllers/analytics.js +7 -30
- package/dist/api/controllers/application.js +56 -16
- package/dist/api/controllers/automation.js +31 -2
- package/dist/api/controllers/backup.js +7 -0
- package/dist/api/controllers/datasource.js +8 -2
- package/dist/api/controllers/deploy/index.js +6 -2
- package/dist/api/controllers/dev.js +9 -2
- package/dist/api/controllers/layout.js +3 -0
- package/dist/api/controllers/query/import/index.js +12 -2
- package/dist/api/controllers/query/import/sources/curl.js +3 -0
- package/dist/api/controllers/query/import/sources/openapi2.js +3 -0
- package/dist/api/controllers/query/import/sources/openapi3.js +3 -0
- package/dist/api/controllers/query/index.js +16 -2
- package/dist/api/controllers/role.js +11 -0
- package/dist/api/controllers/screen.js +10 -1
- package/dist/api/controllers/static/index.js +29 -15
- package/dist/api/controllers/table/external.js +2 -0
- package/dist/api/controllers/table/index.js +12 -0
- package/dist/api/controllers/table/utils.js +3 -3
- package/dist/api/controllers/view/index.js +62 -6
- package/dist/api/index.js +2 -4
- package/dist/api/routes/analytics.js +1 -3
- package/dist/app.js +16 -8
- package/dist/automations/index.js +4 -0
- package/dist/environment.js +4 -2
- package/dist/migrations/functions/backfill/app/automations.js +31 -0
- package/dist/migrations/functions/backfill/app/datasources.js +28 -0
- package/dist/migrations/functions/backfill/app/layouts.js +33 -0
- package/dist/migrations/functions/backfill/app/queries.js +32 -0
- package/dist/migrations/functions/backfill/app/roles.js +28 -0
- package/dist/migrations/functions/backfill/app/screens.js +28 -0
- package/dist/migrations/functions/backfill/app/tables.js +40 -0
- package/dist/migrations/functions/backfill/app.js +175 -0
- package/dist/migrations/functions/backfill/global/configs.js +61 -0
- package/dist/migrations/functions/backfill/global/quotas.js +60 -0
- package/dist/migrations/functions/backfill/global/users.js +50 -0
- package/dist/migrations/functions/backfill/global.js +189 -0
- package/dist/migrations/functions/backfill/index.js +32 -0
- package/dist/migrations/functions/backfill/installation.js +81 -0
- package/dist/migrations/index.js +95 -31
- package/dist/migrations/tests/helpers.js +72 -0
- package/dist/migrations/tests/structures.js +37 -0
- package/dist/package.json +79 -69
- package/dist/tests/utilities/TestConfiguration.js +121 -93
- package/dist/tests/utilities/structures.js +45 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/nodemon.json +1 -1
- package/package.json +80 -70
- package/scripts/dev/manage.js +2 -0
- package/scripts/jestSetup.js +7 -0
- package/scripts/likeCypress.ts +1 -1
- package/src/api/controllers/analytics.ts +8 -0
- package/src/api/controllers/application.ts +60 -18
- package/src/api/controllers/automation.js +36 -2
- package/src/api/controllers/backup.js +8 -0
- package/src/api/controllers/datasource.js +8 -4
- package/src/api/controllers/deploy/index.ts +6 -2
- package/src/api/controllers/dev.js +10 -2
- package/src/api/controllers/layout.js +3 -0
- package/src/api/controllers/query/import/index.ts +16 -3
- package/src/api/controllers/query/import/sources/base/index.ts +2 -1
- package/src/api/controllers/query/import/sources/curl.ts +4 -0
- package/src/api/controllers/query/import/sources/openapi2.ts +4 -0
- package/src/api/controllers/query/import/sources/openapi3.ts +4 -0
- package/src/api/controllers/query/import/tests/index.spec.js +20 -7
- package/src/api/controllers/query/index.ts +16 -3
- package/src/api/controllers/role.js +10 -0
- package/src/api/controllers/screen.js +13 -1
- package/src/api/controllers/static/index.js +28 -15
- package/src/api/controllers/table/external.js +2 -0
- package/src/api/controllers/table/index.js +12 -0
- package/src/api/controllers/table/utils.ts +4 -4
- package/src/api/controllers/view/index.js +76 -6
- package/src/api/index.js +2 -4
- package/src/api/routes/analytics.js +1 -3
- package/src/api/routes/public/utils/Endpoint.ts +1 -1
- package/src/api/routes/tests/__snapshots__/datasource.spec.js.snap +5 -1
- package/src/api/routes/tests/application.spec.js +64 -4
- package/src/api/routes/tests/automation.spec.js +168 -60
- package/src/api/routes/tests/backup.spec.js +2 -0
- package/src/api/routes/tests/data/export.txt +1 -0
- package/src/api/routes/tests/datasource.spec.js +5 -0
- package/src/api/routes/tests/deployment.spec.js +25 -0
- package/src/api/routes/tests/dev.spec.js +40 -0
- package/src/api/routes/tests/layout.spec.js +4 -0
- package/src/api/routes/tests/query.spec.js +56 -13
- package/src/api/routes/tests/role.spec.js +40 -7
- package/src/api/routes/tests/row.spec.js +2 -3
- package/src/api/routes/tests/screen.spec.js +30 -4
- package/src/api/routes/tests/static.spec.js +120 -54
- package/src/api/routes/tests/table.spec.js +102 -38
- package/src/api/routes/tests/view.spec.js +222 -43
- package/src/app.ts +18 -9
- package/src/automations/index.js +4 -0
- package/src/automations/tests/delay.spec.js +4 -0
- package/src/environment.js +5 -2
- package/src/migrations/functions/backfill/app/automations.ts +26 -0
- package/src/migrations/functions/backfill/app/datasources.ts +22 -0
- package/src/migrations/functions/backfill/app/layouts.ts +29 -0
- package/src/migrations/functions/backfill/app/queries.ts +33 -0
- package/src/migrations/functions/backfill/app/roles.ts +22 -0
- package/src/migrations/functions/backfill/app/screens.ts +22 -0
- package/src/migrations/functions/backfill/app/tables.ts +36 -0
- package/src/migrations/functions/backfill/app.ts +148 -0
- package/src/migrations/functions/backfill/global/configs.ts +66 -0
- package/src/migrations/functions/backfill/global/quotas.ts +60 -0
- package/src/migrations/functions/backfill/global/users.ts +49 -0
- package/src/migrations/functions/backfill/global.ts +194 -0
- package/src/migrations/functions/backfill/index.ts +7 -0
- package/src/migrations/functions/backfill/installation.ts +51 -0
- package/src/migrations/index.ts +120 -51
- package/src/migrations/tests/helpers.ts +40 -0
- package/src/migrations/tests/index.spec.ts +132 -0
- package/src/migrations/tests/structures.ts +66 -0
- package/src/module.d.ts +0 -1
- package/src/tests/utilities/TestConfiguration.js +138 -90
- package/src/tests/utilities/structures.js +71 -0
- package/tsconfig.build.json +20 -5
- package/tsconfig.json +22 -17
- package/builder/assets/index.107ba2e5.js +0 -1315
- package/coverage/lcov-report/api/controllers/analytics.js.html +0 -202
- package/src/api/controllers/analytics.js +0 -39
package/src/api/index.js
CHANGED
|
@@ -7,7 +7,8 @@ Array [
|
|
|
7
7
|
"entities": Array [
|
|
8
8
|
Object {
|
|
9
9
|
"_id": "ta_users",
|
|
10
|
-
"_rev": "1-
|
|
10
|
+
"_rev": "1-6f4013e796887f1771bf7837598d87e7",
|
|
11
|
+
"createdAt": "2020-01-01T00:00:00.000Z",
|
|
11
12
|
"name": "Users",
|
|
12
13
|
"primaryDisplay": "email",
|
|
13
14
|
"schema": Object {
|
|
@@ -72,6 +73,7 @@ Array [
|
|
|
72
73
|
},
|
|
73
74
|
},
|
|
74
75
|
"type": "table",
|
|
76
|
+
"updatedAt": "2020-01-01T00:00:00.000Z",
|
|
75
77
|
"views": Object {},
|
|
76
78
|
},
|
|
77
79
|
],
|
|
@@ -81,9 +83,11 @@ Array [
|
|
|
81
83
|
},
|
|
82
84
|
Object {
|
|
83
85
|
"config": Object {},
|
|
86
|
+
"createdAt": "2020-01-01T00:00:00.000Z",
|
|
84
87
|
"name": "Test",
|
|
85
88
|
"source": "POSTGRES",
|
|
86
89
|
"type": "datasource",
|
|
90
|
+
"updatedAt": "2020-01-01T00:00:00.000Z",
|
|
87
91
|
},
|
|
88
92
|
]
|
|
89
93
|
`;
|
|
@@ -18,6 +18,7 @@ const {
|
|
|
18
18
|
} = require("./utilities/TestFunctions")
|
|
19
19
|
const setup = require("./utilities")
|
|
20
20
|
const { AppStatus } = require("../../../db/utils")
|
|
21
|
+
const { events } = require("@budibase/backend-core")
|
|
21
22
|
|
|
22
23
|
describe("/applications", () => {
|
|
23
24
|
let request = setup.getRequest()
|
|
@@ -28,17 +29,49 @@ describe("/applications", () => {
|
|
|
28
29
|
beforeEach(async () => {
|
|
29
30
|
await clearAllApps()
|
|
30
31
|
await config.init()
|
|
32
|
+
jest.clearAllMocks()
|
|
31
33
|
})
|
|
32
34
|
|
|
33
35
|
describe("create", () => {
|
|
34
|
-
it("
|
|
36
|
+
it("creates empty app", async () => {
|
|
35
37
|
const res = await request
|
|
36
38
|
.post("/api/applications")
|
|
37
|
-
.
|
|
39
|
+
.field("name", "My App")
|
|
38
40
|
.set(config.defaultHeaders())
|
|
39
41
|
.expect("Content-Type", /json/)
|
|
40
42
|
.expect(200)
|
|
41
43
|
expect(res.body._id).toBeDefined()
|
|
44
|
+
expect(events.app.created).toBeCalledTimes(1)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it("creates app from template", async () => {
|
|
48
|
+
const res = await request
|
|
49
|
+
.post("/api/applications")
|
|
50
|
+
.field("name", "My App")
|
|
51
|
+
.field("useTemplate", "true")
|
|
52
|
+
.field("templateKey", "test")
|
|
53
|
+
.field("templateString", "{}") // override the file download
|
|
54
|
+
.set(config.defaultHeaders())
|
|
55
|
+
.expect("Content-Type", /json/)
|
|
56
|
+
.expect(200)
|
|
57
|
+
expect(res.body._id).toBeDefined()
|
|
58
|
+
expect(events.app.created).toBeCalledTimes(1)
|
|
59
|
+
expect(events.app.templateImported).toBeCalledTimes(1)
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
it("creates app from file", async () => {
|
|
64
|
+
const res = await request
|
|
65
|
+
.post("/api/applications")
|
|
66
|
+
.field("name", "My App")
|
|
67
|
+
.field("useTemplate", "true")
|
|
68
|
+
.set(config.defaultHeaders())
|
|
69
|
+
.attach('templateFile', 'src/api/routes/tests/data/export.txt')
|
|
70
|
+
.expect("Content-Type", /json/)
|
|
71
|
+
.expect(200)
|
|
72
|
+
expect(res.body._id).toBeDefined()
|
|
73
|
+
expect(events.app.created).toBeCalledTimes(1)
|
|
74
|
+
expect(events.app.fileImported).toBeCalledTimes(1)
|
|
42
75
|
})
|
|
43
76
|
|
|
44
77
|
it("should apply authorization to endpoint", async () => {
|
|
@@ -101,7 +134,32 @@ describe("/applications", () => {
|
|
|
101
134
|
.set(config.defaultHeaders())
|
|
102
135
|
.expect("Content-Type", /json/)
|
|
103
136
|
.expect(200)
|
|
104
|
-
expect(res.body.
|
|
137
|
+
expect(res.body._rev).toBeDefined()
|
|
138
|
+
expect(events.app.updated).toBeCalledTimes(1)
|
|
139
|
+
})
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
describe("delete", () => {
|
|
143
|
+
it("should delete app", async () => {
|
|
144
|
+
await config.createApp("to-delete")
|
|
145
|
+
const appId = config.getAppId()
|
|
146
|
+
await request
|
|
147
|
+
.delete(`/api/applications/${appId}`)
|
|
148
|
+
.set(config.defaultHeaders())
|
|
149
|
+
.expect("Content-Type", /json/)
|
|
150
|
+
.expect(200)
|
|
151
|
+
expect(events.app.deleted).toBeCalledTimes(1)
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
it("should unpublish app", async () => {
|
|
155
|
+
await config.createApp("to-unpublish")
|
|
156
|
+
const appId = config.getProdAppId()
|
|
157
|
+
await request
|
|
158
|
+
.delete(`/api/applications/${appId}?unpublish=true`)
|
|
159
|
+
.set(config.defaultHeaders())
|
|
160
|
+
.expect("Content-Type", /json/)
|
|
161
|
+
.expect(200)
|
|
162
|
+
expect(events.app.unpublished).toBeCalledTimes(1)
|
|
105
163
|
})
|
|
106
164
|
})
|
|
107
165
|
|
|
@@ -113,6 +171,7 @@ describe("/applications", () => {
|
|
|
113
171
|
.set(config.defaultHeaders())
|
|
114
172
|
.expect("Content-Type", /json/)
|
|
115
173
|
.expect(200)
|
|
174
|
+
expect(events.app.versionUpdated).toBeCalledTimes(1)
|
|
116
175
|
})
|
|
117
176
|
it("should be able to revert the app client library version", async () => {
|
|
118
177
|
// We need to first update the version so that we can then revert
|
|
@@ -126,6 +185,7 @@ describe("/applications", () => {
|
|
|
126
185
|
.set(config.defaultHeaders())
|
|
127
186
|
.expect("Content-Type", /json/)
|
|
128
187
|
.expect(200)
|
|
188
|
+
expect(events.app.versionReverted).toBeCalledTimes(1)
|
|
129
189
|
})
|
|
130
190
|
})
|
|
131
191
|
|
|
@@ -141,7 +201,7 @@ describe("/applications", () => {
|
|
|
141
201
|
.set(headers)
|
|
142
202
|
.expect("Content-Type", /json/)
|
|
143
203
|
.expect(200)
|
|
144
|
-
expect(res.body.
|
|
204
|
+
expect(res.body._rev).toBeDefined()
|
|
145
205
|
// retrieve the app to check it
|
|
146
206
|
const getRes = await request
|
|
147
207
|
.get(`/api/applications/${config.getAppId()}/appPackage`)
|
|
@@ -5,17 +5,14 @@ const {
|
|
|
5
5
|
testAutomation,
|
|
6
6
|
} = require("./utilities/TestFunctions")
|
|
7
7
|
const setup = require("./utilities")
|
|
8
|
-
const { basicAutomation } = setup.structures
|
|
9
|
-
|
|
8
|
+
const { basicAutomation, newAutomation, automationTrigger, automationStep } = setup.structures
|
|
10
9
|
const MAX_RETRIES = 4
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
let TRIGGER_DEFINITIONS = {}
|
|
10
|
+
const { TRIGGER_DEFINITIONS, ACTION_DEFINITIONS } = require("../../../automations")
|
|
11
|
+
const { events } = require("@budibase/backend-core")
|
|
14
12
|
|
|
15
13
|
describe("/automations", () => {
|
|
16
14
|
let request = setup.getRequest()
|
|
17
15
|
let config = setup.getConfig()
|
|
18
|
-
let automation
|
|
19
16
|
|
|
20
17
|
afterAll(setup.afterAll)
|
|
21
18
|
|
|
@@ -32,7 +29,6 @@ describe("/automations", () => {
|
|
|
32
29
|
.expect(200)
|
|
33
30
|
|
|
34
31
|
expect(Object.keys(res.body).length).not.toEqual(0)
|
|
35
|
-
ACTION_DEFINITIONS = res.body
|
|
36
32
|
})
|
|
37
33
|
|
|
38
34
|
it("returns a list of definitions for triggerInfo", async () => {
|
|
@@ -43,7 +39,6 @@ describe("/automations", () => {
|
|
|
43
39
|
.expect(200)
|
|
44
40
|
|
|
45
41
|
expect(Object.keys(res.body).length).not.toEqual(0)
|
|
46
|
-
TRIGGER_DEFINITIONS = res.body
|
|
47
42
|
})
|
|
48
43
|
|
|
49
44
|
it("returns all of the definitions in one", async () => {
|
|
@@ -53,76 +48,59 @@ describe("/automations", () => {
|
|
|
53
48
|
.expect('Content-Type', /json/)
|
|
54
49
|
.expect(200)
|
|
55
50
|
|
|
56
|
-
|
|
51
|
+
let definitionsLength = Object.keys(ACTION_DEFINITIONS).length
|
|
52
|
+
definitionsLength-- // OUTGOING_WEBHOOK is deprecated
|
|
53
|
+
|
|
54
|
+
expect(Object.keys(res.body.action).length).toBeGreaterThanOrEqual(definitionsLength)
|
|
57
55
|
expect(Object.keys(res.body.trigger).length).toEqual(Object.keys(TRIGGER_DEFINITIONS).length)
|
|
58
56
|
})
|
|
59
57
|
})
|
|
60
58
|
|
|
61
59
|
describe("create", () => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
trigger.id = "wadiawdo34"
|
|
66
|
-
let createAction = ACTION_DEFINITIONS["CREATE_ROW"]
|
|
67
|
-
createAction.inputs.row = {
|
|
68
|
-
name: "{{trigger.row.name}}",
|
|
69
|
-
description: "{{trigger.row.description}}"
|
|
70
|
-
}
|
|
71
|
-
createAction.id = "awde444wk"
|
|
60
|
+
it("creates an automation with no steps", async () => {
|
|
61
|
+
const automation = newAutomation()
|
|
62
|
+
automation.definition.steps = []
|
|
72
63
|
|
|
73
|
-
autoConfig.definition.steps.push(createAction)
|
|
74
|
-
autoConfig.definition.trigger = trigger
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
it("returns a success message when the automation is successfully created", async () => {
|
|
78
64
|
const res = await request
|
|
79
65
|
.post(`/api/automations`)
|
|
80
66
|
.set(config.defaultHeaders())
|
|
81
|
-
.send(
|
|
67
|
+
.send(automation)
|
|
82
68
|
.expect('Content-Type', /json/)
|
|
83
69
|
.expect(200)
|
|
84
70
|
|
|
85
71
|
expect(res.body.message).toEqual("Automation created successfully")
|
|
86
72
|
expect(res.body.automation.name).toEqual("My Automation")
|
|
87
73
|
expect(res.body.automation._id).not.toEqual(null)
|
|
88
|
-
automation
|
|
74
|
+
expect(events.automation.created).toBeCalledTimes(1)
|
|
75
|
+
expect(events.automation.stepCreated).not.toBeCalled()
|
|
89
76
|
})
|
|
90
77
|
|
|
91
|
-
it("
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
78
|
+
it("creates an automation with steps", async () => {
|
|
79
|
+
const automation = newAutomation()
|
|
80
|
+
automation.definition.steps.push(automationStep())
|
|
81
|
+
jest.clearAllMocks()
|
|
82
|
+
|
|
95
83
|
const res = await request
|
|
96
84
|
.post(`/api/automations`)
|
|
97
85
|
.set(config.defaultHeaders())
|
|
98
|
-
.send(
|
|
99
|
-
.expect('Content-Type', /json/)
|
|
100
|
-
.expect(200)
|
|
101
|
-
const originalAuto = res.body.automation
|
|
102
|
-
expect(originalAuto._id).toBeDefined()
|
|
103
|
-
expect(originalAuto._rev).toBeDefined()
|
|
104
|
-
// try removing the webhook trigger
|
|
105
|
-
const newConfig = originalAuto
|
|
106
|
-
newConfig.definition.trigger = TRIGGER_DEFINITIONS["ROW_SAVED"]
|
|
107
|
-
newConfig.definition.trigger.id = "row_saved_id"
|
|
108
|
-
const newRes = await request
|
|
109
|
-
.post(`/api/automations`)
|
|
110
|
-
.set(config.defaultHeaders())
|
|
111
|
-
.send(newConfig)
|
|
86
|
+
.send(automation)
|
|
112
87
|
.expect('Content-Type', /json/)
|
|
113
88
|
.expect(200)
|
|
114
|
-
|
|
115
|
-
expect(
|
|
116
|
-
expect(
|
|
117
|
-
expect(
|
|
89
|
+
|
|
90
|
+
expect(res.body.message).toEqual("Automation created successfully")
|
|
91
|
+
expect(res.body.automation.name).toEqual("My Automation")
|
|
92
|
+
expect(res.body.automation._id).not.toEqual(null)
|
|
93
|
+
expect(events.automation.created).toBeCalledTimes(1)
|
|
94
|
+
expect(events.automation.stepCreated).toBeCalledTimes(2)
|
|
118
95
|
})
|
|
119
96
|
|
|
120
97
|
it("should apply authorization to endpoint", async () => {
|
|
98
|
+
const automation = newAutomation()
|
|
121
99
|
await checkBuilderEndpoint({
|
|
122
100
|
config,
|
|
123
101
|
method: "POST",
|
|
124
102
|
url: `/api/automations`,
|
|
125
|
-
body:
|
|
103
|
+
body: automation
|
|
126
104
|
})
|
|
127
105
|
})
|
|
128
106
|
})
|
|
@@ -140,15 +118,23 @@ describe("/automations", () => {
|
|
|
140
118
|
})
|
|
141
119
|
})
|
|
142
120
|
|
|
143
|
-
describe("
|
|
144
|
-
it("
|
|
121
|
+
describe("test", () => {
|
|
122
|
+
it("tests the automation successfully", async () => {
|
|
145
123
|
let table = await config.createTable()
|
|
124
|
+
let automation = newAutomation()
|
|
146
125
|
automation.definition.trigger.inputs.tableId = table._id
|
|
147
|
-
automation.definition.steps[0].inputs
|
|
126
|
+
automation.definition.steps[0].inputs = {
|
|
127
|
+
row: {
|
|
128
|
+
name: "{{trigger.row.name}}",
|
|
129
|
+
description: "{{trigger.row.description}}",
|
|
130
|
+
tableId: table._id
|
|
131
|
+
}
|
|
132
|
+
}
|
|
148
133
|
automation.appId = config.appId
|
|
149
134
|
automation = await config.createAutomation(automation)
|
|
150
135
|
await setup.delay(500)
|
|
151
136
|
const res = await testAutomation(config, automation)
|
|
137
|
+
expect(events.automation.tested).toBeCalledTimes(1)
|
|
152
138
|
// this looks a bit mad but we don't actually have a way to wait for a response from the automation to
|
|
153
139
|
// know that it has finished all of its actions - this is currently the best way
|
|
154
140
|
// also when this runs in CI it is very temper-mental so for now trying to make run stable by repeating until it works
|
|
@@ -170,20 +156,141 @@ describe("/automations", () => {
|
|
|
170
156
|
})
|
|
171
157
|
|
|
172
158
|
describe("update", () => {
|
|
173
|
-
it("updates a automations data", async () => {
|
|
174
|
-
automation = await config.createAutomation(automation)
|
|
175
|
-
automation.name = "Updated Name"
|
|
176
|
-
automation.type = "automation"
|
|
177
159
|
|
|
178
|
-
|
|
160
|
+
const update = async (automation) => {
|
|
161
|
+
return request
|
|
179
162
|
.put(`/api/automations`)
|
|
180
163
|
.set(config.defaultHeaders())
|
|
181
164
|
.send(automation)
|
|
182
165
|
.expect('Content-Type', /json/)
|
|
183
166
|
.expect(200)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const updateWithPost = async (automation) => {
|
|
170
|
+
return request
|
|
171
|
+
.post(`/api/automations`)
|
|
172
|
+
.set(config.defaultHeaders())
|
|
173
|
+
.send(automation)
|
|
174
|
+
.expect('Content-Type', /json/)
|
|
175
|
+
.expect(200)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
it("updates a automations name", async () => {
|
|
179
|
+
let automation = newAutomation()
|
|
180
|
+
await config.createAutomation(automation)
|
|
181
|
+
automation.name = "Updated Name"
|
|
182
|
+
jest.clearAllMocks()
|
|
183
|
+
|
|
184
|
+
const res = await update(automation)
|
|
185
|
+
|
|
186
|
+
const automationRes = res.body.automation
|
|
187
|
+
const message = res.body.message
|
|
188
|
+
|
|
189
|
+
// doc attributes
|
|
190
|
+
expect(automationRes._id).toEqual(automation._id)
|
|
191
|
+
expect(automationRes._rev).toBeDefined()
|
|
192
|
+
expect(automationRes._rev).not.toEqual(automation._rev)
|
|
193
|
+
// content updates
|
|
194
|
+
expect(automationRes.name).toEqual("Updated Name")
|
|
195
|
+
expect(message).toEqual(`Automation ${automation._id} updated successfully.`)
|
|
196
|
+
// events
|
|
197
|
+
expect(events.automation.created).not.toBeCalled()
|
|
198
|
+
expect(events.automation.stepCreated).not.toBeCalled()
|
|
199
|
+
expect(events.automation.stepDeleted).not.toBeCalled()
|
|
200
|
+
expect(events.automation.triggerUpdated).not.toBeCalled()
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
it("updates a automations name using POST request", async () => {
|
|
205
|
+
let automation = newAutomation()
|
|
206
|
+
await config.createAutomation(automation)
|
|
207
|
+
automation.name = "Updated Name"
|
|
208
|
+
jest.clearAllMocks()
|
|
209
|
+
|
|
210
|
+
// the POST request will defer to the update
|
|
211
|
+
// when an id has been supplied.
|
|
212
|
+
const res = await updateWithPost(automation)
|
|
213
|
+
|
|
214
|
+
const automationRes = res.body.automation
|
|
215
|
+
const message = res.body.message
|
|
216
|
+
// doc attributes
|
|
217
|
+
expect(automationRes._id).toEqual(automation._id)
|
|
218
|
+
expect(automationRes._rev).toBeDefined()
|
|
219
|
+
expect(automationRes._rev).not.toEqual(automation._rev)
|
|
220
|
+
// content updates
|
|
221
|
+
expect(automationRes.name).toEqual("Updated Name")
|
|
222
|
+
expect(message).toEqual(`Automation ${automation._id} updated successfully.`)
|
|
223
|
+
// events
|
|
224
|
+
expect(events.automation.created).not.toBeCalled()
|
|
225
|
+
expect(events.automation.stepCreated).not.toBeCalled()
|
|
226
|
+
expect(events.automation.stepDeleted).not.toBeCalled()
|
|
227
|
+
expect(events.automation.triggerUpdated).not.toBeCalled()
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
it("updates an automation trigger", async () => {
|
|
231
|
+
let automation = newAutomation()
|
|
232
|
+
automation = await config.createAutomation(automation)
|
|
233
|
+
automation.definition.trigger = automationTrigger(TRIGGER_DEFINITIONS.WEBHOOK)
|
|
234
|
+
jest.clearAllMocks()
|
|
235
|
+
|
|
236
|
+
await update(automation)
|
|
237
|
+
|
|
238
|
+
// events
|
|
239
|
+
expect(events.automation.created).not.toBeCalled()
|
|
240
|
+
expect(events.automation.stepCreated).not.toBeCalled()
|
|
241
|
+
expect(events.automation.stepDeleted).not.toBeCalled()
|
|
242
|
+
expect(events.automation.triggerUpdated).toBeCalledTimes(1)
|
|
243
|
+
})
|
|
244
|
+
|
|
245
|
+
it("adds automation steps", async () => {
|
|
246
|
+
let automation = newAutomation()
|
|
247
|
+
automation = await config.createAutomation(automation)
|
|
248
|
+
automation.definition.steps.push(automationStep())
|
|
249
|
+
automation.definition.steps.push(automationStep())
|
|
250
|
+
jest.clearAllMocks()
|
|
251
|
+
|
|
252
|
+
// check the post request honours updates with same id
|
|
253
|
+
await update(automation)
|
|
254
|
+
|
|
255
|
+
// events
|
|
256
|
+
expect(events.automation.stepCreated).toBeCalledTimes(2)
|
|
257
|
+
expect(events.automation.created).not.toBeCalled()
|
|
258
|
+
expect(events.automation.stepDeleted).not.toBeCalled()
|
|
259
|
+
expect(events.automation.triggerUpdated).not.toBeCalled()
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
it("removes automation steps", async () => {
|
|
264
|
+
let automation = newAutomation()
|
|
265
|
+
automation.definition.steps.push(automationStep())
|
|
266
|
+
automation = await config.createAutomation(automation)
|
|
267
|
+
automation.definition.steps = []
|
|
268
|
+
jest.clearAllMocks()
|
|
269
|
+
|
|
270
|
+
// check the post request honours updates with same id
|
|
271
|
+
await update(automation)
|
|
272
|
+
|
|
273
|
+
// events
|
|
274
|
+
expect(events.automation.stepDeleted).toBeCalledTimes(2)
|
|
275
|
+
expect(events.automation.stepCreated).not.toBeCalled()
|
|
276
|
+
expect(events.automation.created).not.toBeCalled()
|
|
277
|
+
expect(events.automation.triggerUpdated).not.toBeCalled()
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
it("adds and removes automation steps", async () => {
|
|
281
|
+
let automation = newAutomation()
|
|
282
|
+
automation = await config.createAutomation(automation)
|
|
283
|
+
automation.definition.steps = [automationStep(), automationStep()]
|
|
284
|
+
jest.clearAllMocks()
|
|
285
|
+
|
|
286
|
+
// check the post request honours updates with same id
|
|
287
|
+
await update(automation)
|
|
184
288
|
|
|
185
|
-
|
|
186
|
-
|
|
289
|
+
// events
|
|
290
|
+
expect(events.automation.stepCreated).toBeCalledTimes(2)
|
|
291
|
+
expect(events.automation.stepDeleted).toBeCalledTimes(1)
|
|
292
|
+
expect(events.automation.created).not.toBeCalled()
|
|
293
|
+
expect(events.automation.triggerUpdated).not.toBeCalled()
|
|
187
294
|
})
|
|
188
295
|
})
|
|
189
296
|
|
|
@@ -219,7 +326,8 @@ describe("/automations", () => {
|
|
|
219
326
|
.expect('Content-Type', /json/)
|
|
220
327
|
.expect(200)
|
|
221
328
|
|
|
222
|
-
|
|
329
|
+
expect(res.body.id).toEqual(automation._id)
|
|
330
|
+
expect(events.automation.deleted).toBeCalledTimes(1)
|
|
223
331
|
})
|
|
224
332
|
|
|
225
333
|
it("should apply authorization to endpoint", async () => {
|
|
@@ -2,6 +2,7 @@ jest.mock("../../../utilities/fileSystem/utilities")
|
|
|
2
2
|
|
|
3
3
|
const { checkBuilderEndpoint } = require("./utilities/TestFunctions")
|
|
4
4
|
const setup = require("./utilities")
|
|
5
|
+
const { events } = require("@budibase/backend-core")
|
|
5
6
|
|
|
6
7
|
describe("/backups", () => {
|
|
7
8
|
let request = setup.getRequest()
|
|
@@ -21,6 +22,7 @@ describe("/backups", () => {
|
|
|
21
22
|
.expect(200)
|
|
22
23
|
expect(res.text).toBeDefined()
|
|
23
24
|
expect(res.text.includes(`"db_name":"${config.getAppId()}"`)).toEqual(true)
|
|
25
|
+
expect(events.app.exported.mock.calls.length).toBe(1)
|
|
24
26
|
})
|
|
25
27
|
|
|
26
28
|
it("should apply authorization to endpoint", async () => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -5,6 +5,7 @@ let { basicDatasource } = setup.structures
|
|
|
5
5
|
let { checkBuilderEndpoint } = require("./utilities/TestFunctions")
|
|
6
6
|
const pg = require("pg")
|
|
7
7
|
const { checkCacheForDynamicVariable } = require("../../../threads/utils")
|
|
8
|
+
const { events } = require("@budibase/backend-core")
|
|
8
9
|
|
|
9
10
|
describe("/datasources", () => {
|
|
10
11
|
let request = setup.getRequest()
|
|
@@ -16,6 +17,7 @@ describe("/datasources", () => {
|
|
|
16
17
|
beforeEach(async () => {
|
|
17
18
|
await config.init()
|
|
18
19
|
datasource = await config.createDatasource()
|
|
20
|
+
jest.clearAllMocks()
|
|
19
21
|
})
|
|
20
22
|
|
|
21
23
|
describe("create", () => {
|
|
@@ -29,6 +31,7 @@ describe("/datasources", () => {
|
|
|
29
31
|
|
|
30
32
|
expect(res.body.datasource.name).toEqual("Test")
|
|
31
33
|
expect(res.body.errors).toBeUndefined()
|
|
34
|
+
expect(events.datasource.created).toBeCalledTimes(1)
|
|
32
35
|
})
|
|
33
36
|
})
|
|
34
37
|
|
|
@@ -44,6 +47,7 @@ describe("/datasources", () => {
|
|
|
44
47
|
|
|
45
48
|
expect(res.body.datasource.name).toEqual("Updated Test")
|
|
46
49
|
expect(res.body.errors).toBeUndefined()
|
|
50
|
+
expect(events.datasource.updated).toBeCalledTimes(1)
|
|
47
51
|
})
|
|
48
52
|
|
|
49
53
|
describe("dynamic variables", () => {
|
|
@@ -160,6 +164,7 @@ describe("/datasources", () => {
|
|
|
160
164
|
.expect(200)
|
|
161
165
|
|
|
162
166
|
expect(res.body.length).toEqual(1)
|
|
167
|
+
expect(events.datasource.deleted).toBeCalledTimes(1)
|
|
163
168
|
})
|
|
164
169
|
|
|
165
170
|
it("should apply authorization to endpoint", async () => {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const setup = require("./utilities")
|
|
2
|
+
const { events } = require("@budibase/backend-core")
|
|
3
|
+
|
|
4
|
+
describe("/deployments", () => {
|
|
5
|
+
let request = setup.getRequest()
|
|
6
|
+
let config = setup.getConfig()
|
|
7
|
+
|
|
8
|
+
afterAll(setup.afterAll)
|
|
9
|
+
|
|
10
|
+
beforeEach(async () => {
|
|
11
|
+
await config.init()
|
|
12
|
+
jest.clearAllMocks()
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
describe("deploy", () => {
|
|
16
|
+
it("should deploy the application", async () => {
|
|
17
|
+
await request
|
|
18
|
+
.post(`/api/deploy`)
|
|
19
|
+
.set(config.defaultHeaders())
|
|
20
|
+
.expect("Content-Type", /json/)
|
|
21
|
+
.expect(200)
|
|
22
|
+
expect(events.app.published.mock.calls.length).toBe(1)
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
})
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const setup = require("./utilities")
|
|
2
|
+
const { events } = require("@budibase/backend-core")
|
|
3
|
+
const version = require("../../../../package.json").version
|
|
4
|
+
|
|
5
|
+
describe("/dev", () => {
|
|
6
|
+
let request = setup.getRequest()
|
|
7
|
+
let config = setup.getConfig()
|
|
8
|
+
|
|
9
|
+
afterAll(setup.afterAll)
|
|
10
|
+
|
|
11
|
+
beforeEach(async () => {
|
|
12
|
+
await config.init()
|
|
13
|
+
jest.clearAllMocks()
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
describe("revert", () => {
|
|
17
|
+
it("should revert the application", async () => {
|
|
18
|
+
await request
|
|
19
|
+
.post(`/api/dev/${config.getAppId()}/revert`)
|
|
20
|
+
.set(config.defaultHeaders())
|
|
21
|
+
.expect("Content-Type", /json/)
|
|
22
|
+
.expect(200)
|
|
23
|
+
expect(events.app.reverted).toBeCalledTimes(1)
|
|
24
|
+
})
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
describe("version", () => {
|
|
28
|
+
it("should get the installation version", async () => {
|
|
29
|
+
const res = await request
|
|
30
|
+
.get(`/api/dev/version`)
|
|
31
|
+
.set(config.defaultHeaders())
|
|
32
|
+
.expect("Content-Type", /json/)
|
|
33
|
+
.expect(200)
|
|
34
|
+
|
|
35
|
+
expect(res.body.version).toBe(version)
|
|
36
|
+
expect(events.version.checked).toBeCalledTimes(1)
|
|
37
|
+
expect(events.version.checked).toBeCalledWith(version)
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
})
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const { checkBuilderEndpoint } = require("./utilities/TestFunctions")
|
|
2
2
|
const setup = require("./utilities")
|
|
3
3
|
const { basicLayout } = setup.structures
|
|
4
|
+
const { events } = require("@budibase/backend-core")
|
|
4
5
|
|
|
5
6
|
describe("/layouts", () => {
|
|
6
7
|
let request = setup.getRequest()
|
|
@@ -12,6 +13,7 @@ describe("/layouts", () => {
|
|
|
12
13
|
beforeEach(async () => {
|
|
13
14
|
await config.init()
|
|
14
15
|
layout = await config.createLayout()
|
|
16
|
+
jest.clearAllMocks()
|
|
15
17
|
})
|
|
16
18
|
|
|
17
19
|
describe("save", () => {
|
|
@@ -23,6 +25,7 @@ describe("/layouts", () => {
|
|
|
23
25
|
.expect("Content-Type", /json/)
|
|
24
26
|
.expect(200)
|
|
25
27
|
expect(res.body._rev).toBeDefined()
|
|
28
|
+
expect(events.layout.created).toBeCalledTimes(1)
|
|
26
29
|
})
|
|
27
30
|
|
|
28
31
|
it("should apply authorization to endpoint", async () => {
|
|
@@ -42,6 +45,7 @@ describe("/layouts", () => {
|
|
|
42
45
|
.expect("Content-Type", /json/)
|
|
43
46
|
.expect(200)
|
|
44
47
|
expect(res.body.message).toBeDefined()
|
|
48
|
+
expect(events.layout.deleted).toBeCalledTimes(1)
|
|
45
49
|
})
|
|
46
50
|
|
|
47
51
|
it("should apply authorization to endpoint", async () => {
|