@budibase/server 1.0.200-alpha.3 → 1.0.200
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 +0 -2
- package/builder/assets/index.f83b3433.js +1315 -0
- package/builder/index.html +1 -1
- package/coverage/clover.xml +1998 -2086
- package/coverage/coverage-final.json +122 -121
- package/coverage/lcov-report/api/controllers/analytics.js.html +202 -0
- 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 +72 -174
- package/coverage/lcov-report/api/controllers/backup.js.html +6 -30
- 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 +41 -53
- package/coverage/lcov-report/api/controllers/dev.js.html +70 -94
- package/coverage/lcov-report/api/controllers/index.html +72 -57
- package/coverage/lcov-report/api/controllers/integration.js.html +8 -8
- package/coverage/lcov-report/api/controllers/layout.js.html +19 -28
- 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 +48 -78
- 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 +20 -56
- 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 +17 -23
- package/coverage/lcov-report/api/controllers/table/index.html +26 -26
- package/coverage/lcov-report/api/controllers/table/index.js.html +49 -85
- 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 +65 -275
- 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 +45 -39
- package/coverage/lcov-report/api/routes/analytics.js.html +13 -7
- 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 +17 -29
- 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 +7 -7
- 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 +2762 -2903
- package/dist/api/controllers/analytics.js +30 -7
- package/dist/api/controllers/application.js +16 -56
- package/dist/api/controllers/automation.js +2 -31
- package/dist/api/controllers/backup.js +0 -7
- package/dist/api/controllers/datasource.js +2 -8
- package/dist/api/controllers/deploy/index.js +2 -6
- package/dist/api/controllers/dev.js +2 -9
- package/dist/api/controllers/layout.js +0 -3
- package/dist/api/controllers/query/import/index.js +2 -12
- package/dist/api/controllers/query/import/sources/curl.js +0 -3
- package/dist/api/controllers/query/import/sources/openapi2.js +0 -3
- package/dist/api/controllers/query/import/sources/openapi3.js +0 -3
- package/dist/api/controllers/query/index.js +2 -16
- package/dist/api/controllers/role.js +0 -11
- package/dist/api/controllers/screen.js +1 -10
- package/dist/api/controllers/static/index.js +15 -29
- package/dist/api/controllers/table/external.js +0 -2
- package/dist/api/controllers/table/index.js +0 -12
- package/dist/api/controllers/table/utils.js +3 -3
- package/dist/api/controllers/view/index.js +6 -62
- package/dist/api/index.js +4 -2
- package/dist/api/routes/analytics.js +3 -1
- package/dist/app.js +8 -16
- package/dist/automations/index.js +0 -4
- package/dist/automations/steps/executeQuery.js +1 -1
- package/dist/environment.js +2 -4
- package/dist/integrations/firebase.js +0 -1
- package/dist/migrations/index.js +31 -95
- package/dist/package.json +69 -79
- package/dist/tests/utilities/TestConfiguration.js +93 -121
- package/dist/tests/utilities/structures.js +0 -45
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/nodemon.json +1 -1
- package/package.json +70 -80
- package/scripts/dev/manage.js +0 -2
- package/scripts/jestSetup.js +0 -7
- package/scripts/likeCypress.ts +1 -1
- package/src/api/controllers/analytics.js +39 -0
- package/src/api/controllers/application.ts +18 -60
- package/src/api/controllers/automation.js +2 -36
- package/src/api/controllers/backup.js +0 -8
- package/src/api/controllers/datasource.js +4 -8
- package/src/api/controllers/deploy/index.ts +2 -6
- package/src/api/controllers/dev.js +2 -10
- package/src/api/controllers/layout.js +0 -3
- package/src/api/controllers/query/import/index.ts +3 -16
- package/src/api/controllers/query/import/sources/base/index.ts +1 -2
- package/src/api/controllers/query/import/sources/curl.ts +0 -4
- package/src/api/controllers/query/import/sources/openapi2.ts +0 -4
- package/src/api/controllers/query/import/sources/openapi3.ts +0 -4
- package/src/api/controllers/query/import/tests/index.spec.js +7 -20
- package/src/api/controllers/query/index.ts +3 -16
- package/src/api/controllers/role.js +0 -10
- package/src/api/controllers/screen.js +1 -13
- package/src/api/controllers/static/index.js +15 -28
- package/src/api/controllers/table/external.js +0 -2
- package/src/api/controllers/table/index.js +0 -12
- package/src/api/controllers/table/utils.ts +4 -4
- package/src/api/controllers/view/index.js +6 -76
- package/src/api/index.js +4 -2
- package/src/api/routes/analytics.js +3 -1
- package/src/api/routes/public/utils/Endpoint.ts +1 -1
- package/src/api/routes/tests/__snapshots__/datasource.spec.js.snap +1 -5
- package/src/api/routes/tests/application.spec.js +4 -64
- package/src/api/routes/tests/automation.spec.js +60 -168
- package/src/api/routes/tests/backup.spec.js +0 -2
- package/src/api/routes/tests/datasource.spec.js +0 -5
- package/src/api/routes/tests/layout.spec.js +0 -4
- package/src/api/routes/tests/query.spec.js +13 -56
- package/src/api/routes/tests/role.spec.js +7 -40
- package/src/api/routes/tests/row.spec.js +3 -2
- package/src/api/routes/tests/screen.spec.js +4 -30
- package/src/api/routes/tests/static.spec.js +54 -120
- package/src/api/routes/tests/table.spec.js +38 -102
- package/src/api/routes/tests/view.spec.js +43 -222
- package/src/app.ts +9 -18
- package/src/automations/index.js +0 -4
- package/src/automations/steps/executeQuery.js +1 -1
- package/src/automations/tests/delay.spec.js +0 -4
- package/src/environment.js +2 -5
- package/src/integrations/firebase.ts +0 -1
- package/src/migrations/index.ts +51 -120
- package/src/module.d.ts +1 -0
- package/src/tests/utilities/TestConfiguration.js +90 -138
- package/src/tests/utilities/structures.js +0 -71
- package/tsconfig.build.json +5 -20
- package/tsconfig.json +17 -22
- package/builder/assets/index.05491b9d.js +0 -1315
- package/dist/migrations/functions/backfill/app/automations.js +0 -31
- package/dist/migrations/functions/backfill/app/datasources.js +0 -28
- package/dist/migrations/functions/backfill/app/layouts.js +0 -33
- package/dist/migrations/functions/backfill/app/queries.js +0 -32
- package/dist/migrations/functions/backfill/app/roles.js +0 -28
- package/dist/migrations/functions/backfill/app/screens.js +0 -28
- package/dist/migrations/functions/backfill/app/tables.js +0 -40
- package/dist/migrations/functions/backfill/app.js +0 -175
- package/dist/migrations/functions/backfill/global/configs.js +0 -61
- package/dist/migrations/functions/backfill/global/quotas.js +0 -60
- package/dist/migrations/functions/backfill/global/users.js +0 -50
- package/dist/migrations/functions/backfill/global.js +0 -189
- package/dist/migrations/functions/backfill/index.js +0 -32
- package/dist/migrations/functions/backfill/installation.js +0 -80
- package/dist/migrations/tests/helpers.js +0 -72
- package/dist/migrations/tests/structures.js +0 -37
- package/src/api/controllers/analytics.ts +0 -8
- package/src/api/routes/tests/data/export.txt +0 -1
- package/src/api/routes/tests/deployment.spec.js +0 -25
- package/src/api/routes/tests/dev.spec.js +0 -40
- package/src/migrations/functions/backfill/app/automations.ts +0 -26
- package/src/migrations/functions/backfill/app/datasources.ts +0 -22
- package/src/migrations/functions/backfill/app/layouts.ts +0 -29
- package/src/migrations/functions/backfill/app/queries.ts +0 -33
- package/src/migrations/functions/backfill/app/roles.ts +0 -22
- package/src/migrations/functions/backfill/app/screens.ts +0 -22
- package/src/migrations/functions/backfill/app/tables.ts +0 -36
- package/src/migrations/functions/backfill/app.ts +0 -148
- package/src/migrations/functions/backfill/global/configs.ts +0 -66
- package/src/migrations/functions/backfill/global/quotas.ts +0 -60
- package/src/migrations/functions/backfill/global/users.ts +0 -49
- package/src/migrations/functions/backfill/global.ts +0 -194
- package/src/migrations/functions/backfill/index.ts +0 -7
- package/src/migrations/functions/backfill/installation.ts +0 -50
- package/src/migrations/tests/helpers.ts +0 -40
- package/src/migrations/tests/index.spec.ts +0 -132
- package/src/migrations/tests/structures.ts +0 -66
|
@@ -13,7 +13,6 @@ const setup = require("./utilities")
|
|
|
13
13
|
const { checkBuilderEndpoint } = require("./utilities/TestFunctions")
|
|
14
14
|
const { checkCacheForDynamicVariable } = require("../../../threads/utils")
|
|
15
15
|
const { basicQuery, basicDatasource } = setup.structures
|
|
16
|
-
const { events } = require("@budibase/backend-core")
|
|
17
16
|
|
|
18
17
|
describe("/queries", () => {
|
|
19
18
|
let request = setup.getRequest()
|
|
@@ -39,46 +38,16 @@ describe("/queries", () => {
|
|
|
39
38
|
return { datasource, query }
|
|
40
39
|
}
|
|
41
40
|
|
|
42
|
-
const createQuery = async (query) => {
|
|
43
|
-
return request
|
|
44
|
-
.post(`/api/queries`)
|
|
45
|
-
.send(query)
|
|
46
|
-
.set(config.defaultHeaders())
|
|
47
|
-
.expect("Content-Type", /json/)
|
|
48
|
-
.expect(200)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
41
|
describe("create", () => {
|
|
52
42
|
it("should create a new query", async () => {
|
|
53
43
|
const { _id } = await config.createDatasource()
|
|
54
44
|
const query = basicQuery(_id)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
expect(res.body).toEqual({
|
|
62
|
-
_rev: res.body._rev,
|
|
63
|
-
_id: res.body._id,
|
|
64
|
-
...query,
|
|
65
|
-
createdAt: new Date().toISOString(),
|
|
66
|
-
updatedAt: new Date().toISOString()
|
|
67
|
-
})
|
|
68
|
-
expect(events.query.created).toBeCalledTimes(1)
|
|
69
|
-
expect(events.query.updated).not.toBeCalled()
|
|
70
|
-
})
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
describe("update", () => {
|
|
74
|
-
it("should update query", async () => {
|
|
75
|
-
const { _id } = await config.createDatasource()
|
|
76
|
-
const query = basicQuery(_id)
|
|
77
|
-
const res = await createQuery(query)
|
|
78
|
-
jest.clearAllMocks()
|
|
79
|
-
query._id = res.body._id
|
|
80
|
-
query._rev = res.body._rev
|
|
81
|
-
await createQuery(query)
|
|
45
|
+
const res = await request
|
|
46
|
+
.post(`/api/queries`)
|
|
47
|
+
.send(query)
|
|
48
|
+
.set(config.defaultHeaders())
|
|
49
|
+
.expect("Content-Type", /json/)
|
|
50
|
+
.expect(200)
|
|
82
51
|
|
|
83
52
|
expect(res.res.statusMessage).toEqual(
|
|
84
53
|
`Query ${query.name} saved successfully.`
|
|
@@ -87,11 +56,7 @@ describe("/queries", () => {
|
|
|
87
56
|
_rev: res.body._rev,
|
|
88
57
|
_id: res.body._id,
|
|
89
58
|
...query,
|
|
90
|
-
createdAt: new Date().toISOString(),
|
|
91
|
-
updatedAt: new Date().toISOString()
|
|
92
59
|
})
|
|
93
|
-
expect(events.query.created).not.toBeCalled()
|
|
94
|
-
expect(events.query.updated).toBeCalledTimes(1)
|
|
95
60
|
})
|
|
96
61
|
})
|
|
97
62
|
|
|
@@ -108,9 +73,7 @@ describe("/queries", () => {
|
|
|
108
73
|
{
|
|
109
74
|
_rev: query._rev,
|
|
110
75
|
_id: query._id,
|
|
111
|
-
createdAt: new Date().toISOString(),
|
|
112
76
|
...basicQuery(datasource._id),
|
|
113
|
-
updatedAt: new Date().toISOString(),
|
|
114
77
|
readable: true,
|
|
115
78
|
},
|
|
116
79
|
])
|
|
@@ -186,8 +149,6 @@ describe("/queries", () => {
|
|
|
186
149
|
.expect(200)
|
|
187
150
|
|
|
188
151
|
expect(res.body).toEqual([])
|
|
189
|
-
expect(events.query.deleted).toBeCalledTimes(1)
|
|
190
|
-
expect(events.query.deleted).toBeCalledWith(datasource, query)
|
|
191
152
|
})
|
|
192
153
|
|
|
193
154
|
it("should apply authorization to endpoint", async () => {
|
|
@@ -201,25 +162,21 @@ describe("/queries", () => {
|
|
|
201
162
|
|
|
202
163
|
describe("preview", () => {
|
|
203
164
|
it("should be able to preview the query", async () => {
|
|
204
|
-
const query = {
|
|
205
|
-
datasourceId: datasource._id,
|
|
206
|
-
parameters: {},
|
|
207
|
-
fields: {},
|
|
208
|
-
queryVerb: "read",
|
|
209
|
-
name: datasource.name,
|
|
210
|
-
}
|
|
211
165
|
const res = await request
|
|
212
166
|
.post(`/api/queries/preview`)
|
|
213
|
-
.send(
|
|
167
|
+
.send({
|
|
168
|
+
datasourceId: datasource._id,
|
|
169
|
+
parameters: {},
|
|
170
|
+
fields: {},
|
|
171
|
+
queryVerb: "read",
|
|
172
|
+
name: datasource.name,
|
|
173
|
+
})
|
|
214
174
|
.set(config.defaultHeaders())
|
|
215
175
|
.expect("Content-Type", /json/)
|
|
216
176
|
.expect(200)
|
|
217
177
|
// these responses come from the mock
|
|
218
178
|
expect(res.body.schemaFields).toEqual(["a", "b"])
|
|
219
179
|
expect(res.body.rows.length).toEqual(1)
|
|
220
|
-
expect(events.query.previewed).toBeCalledTimes(1)
|
|
221
|
-
datasource.config = { schema: "public" }
|
|
222
|
-
expect(events.query.previewed).toBeCalledWith(datasource, query)
|
|
223
180
|
})
|
|
224
181
|
|
|
225
182
|
it("should apply authorization to endpoint", async () => {
|
|
@@ -4,7 +4,6 @@ const {
|
|
|
4
4
|
} = require("@budibase/backend-core/permissions")
|
|
5
5
|
const setup = require("./utilities")
|
|
6
6
|
const { basicRole } = setup.structures
|
|
7
|
-
const { events } = require("@budibase/backend-core")
|
|
8
7
|
|
|
9
8
|
describe("/roles", () => {
|
|
10
9
|
let request = setup.getRequest()
|
|
@@ -16,48 +15,20 @@ describe("/roles", () => {
|
|
|
16
15
|
await config.init()
|
|
17
16
|
})
|
|
18
17
|
|
|
19
|
-
const createRole = async (role) => {
|
|
20
|
-
if (!role) {
|
|
21
|
-
role = basicRole()
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return request
|
|
25
|
-
.post(`/api/roles`)
|
|
26
|
-
.send(role)
|
|
27
|
-
.set(config.defaultHeaders())
|
|
28
|
-
.expect("Content-Type", /json/)
|
|
29
|
-
.expect(200)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
18
|
describe("create", () => {
|
|
33
19
|
it("returns a success message when role is successfully created", async () => {
|
|
34
|
-
const res = await
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
expect(res.body._rev).toBeDefined()
|
|
41
|
-
expect(events.role.updated).not.toBeCalled()
|
|
42
|
-
expect(events.role.created).toBeCalledTimes(1)
|
|
43
|
-
expect(events.role.created).toBeCalledWith(res.body)
|
|
44
|
-
})
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
describe("update", () => {
|
|
48
|
-
it("updates a role", async () => {
|
|
49
|
-
let res = await createRole()
|
|
50
|
-
jest.clearAllMocks()
|
|
51
|
-
res = await createRole(res.body)
|
|
20
|
+
const res = await request
|
|
21
|
+
.post(`/api/roles`)
|
|
22
|
+
.send(basicRole())
|
|
23
|
+
.set(config.defaultHeaders())
|
|
24
|
+
.expect("Content-Type", /json/)
|
|
25
|
+
.expect(200)
|
|
52
26
|
|
|
53
27
|
expect(res.res.statusMessage).toEqual(
|
|
54
28
|
"Role 'NewRole' created successfully."
|
|
55
29
|
)
|
|
56
30
|
expect(res.body._id).toBeDefined()
|
|
57
31
|
expect(res.body._rev).toBeDefined()
|
|
58
|
-
expect(events.role.created).not.toBeCalled()
|
|
59
|
-
expect(events.role.updated).toBeCalledTimes(1)
|
|
60
|
-
expect(events.role.updated).toBeCalledWith(res.body)
|
|
61
32
|
})
|
|
62
33
|
})
|
|
63
34
|
|
|
@@ -109,10 +80,8 @@ describe("/roles", () => {
|
|
|
109
80
|
it("should delete custom roles", async () => {
|
|
110
81
|
const customRole = await config.createRole({
|
|
111
82
|
name: "user",
|
|
112
|
-
permissionId: BUILTIN_PERMISSION_IDS.READ_ONLY
|
|
113
|
-
inherits: BUILTIN_ROLE_IDS.BASIC,
|
|
83
|
+
permissionId: BUILTIN_PERMISSION_IDS.READ_ONLY
|
|
114
84
|
})
|
|
115
|
-
delete customRole._rev_tree
|
|
116
85
|
await request
|
|
117
86
|
.delete(`/api/roles/${customRole._id}/${customRole._rev}`)
|
|
118
87
|
.set(config.defaultHeaders())
|
|
@@ -121,8 +90,6 @@ describe("/roles", () => {
|
|
|
121
90
|
.get(`/api/roles/${customRole._id}`)
|
|
122
91
|
.set(config.defaultHeaders())
|
|
123
92
|
.expect(404)
|
|
124
|
-
expect(events.role.deleted).toBeCalledTimes(1)
|
|
125
|
-
expect(events.role.deleted).toBeCalledWith(customRole)
|
|
126
93
|
})
|
|
127
94
|
})
|
|
128
95
|
})
|
|
@@ -5,6 +5,9 @@ const { doInAppContext } = require("@budibase/backend-core/context")
|
|
|
5
5
|
const { doInTenant } = require("@budibase/backend-core/tenancy")
|
|
6
6
|
const { quotas, QuotaUsageType, StaticQuotaName, MonthlyQuotaName } = require("@budibase/pro")
|
|
7
7
|
|
|
8
|
+
// mock the fetch for the search system
|
|
9
|
+
jest.mock("node-fetch")
|
|
10
|
+
|
|
8
11
|
describe("/rows", () => {
|
|
9
12
|
let request = setup.getRequest()
|
|
10
13
|
let config = setup.getConfig()
|
|
@@ -100,8 +103,6 @@ describe("/rows", () => {
|
|
|
100
103
|
_id: existing._id,
|
|
101
104
|
_rev: existing._rev,
|
|
102
105
|
type: "row",
|
|
103
|
-
createdAt: "2020-01-01T00:00:00.000Z",
|
|
104
|
-
updatedAt: "2020-01-01T00:00:00.000Z",
|
|
105
106
|
})
|
|
106
107
|
await assertQueryUsage(queryUsage + 1)
|
|
107
108
|
})
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const { checkBuilderEndpoint } = require("./utilities/TestFunctions")
|
|
2
2
|
const setup = require("./utilities")
|
|
3
3
|
const { basicScreen } = setup.structures
|
|
4
|
-
const { events } = require("@budibase/backend-core")
|
|
5
4
|
|
|
6
5
|
describe("/screens", () => {
|
|
7
6
|
let request = setup.getRequest()
|
|
@@ -36,40 +35,16 @@ describe("/screens", () => {
|
|
|
36
35
|
})
|
|
37
36
|
|
|
38
37
|
describe("save", () => {
|
|
39
|
-
|
|
38
|
+
it("should be able to save a screen", async () => {
|
|
39
|
+
const screenCfg = basicScreen()
|
|
40
40
|
const res = await request
|
|
41
41
|
.post(`/api/screens`)
|
|
42
|
-
.send(
|
|
42
|
+
.send(screenCfg)
|
|
43
43
|
.set(config.defaultHeaders())
|
|
44
44
|
.expect("Content-Type", /json/)
|
|
45
45
|
.expect(200)
|
|
46
|
-
return res
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
it("should be able to create a screen", async () => {
|
|
50
|
-
jest.clearAllMocks()
|
|
51
|
-
|
|
52
|
-
const screen = basicScreen()
|
|
53
|
-
const res = await saveScreen(screen)
|
|
54
|
-
|
|
55
|
-
expect(res.body._rev).toBeDefined()
|
|
56
|
-
expect(res.body.name).toEqual(screen.name)
|
|
57
|
-
expect(events.screen.created).toBeCalledTimes(1)
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
it("should be able to update a screen", async () => {
|
|
61
|
-
const screen = basicScreen()
|
|
62
|
-
let res = await saveScreen(screen)
|
|
63
|
-
screen._id = res.body._id
|
|
64
|
-
screen._rev = res.body._rev
|
|
65
|
-
screen.name = "edit"
|
|
66
|
-
jest.clearAllMocks()
|
|
67
|
-
|
|
68
|
-
res = await saveScreen(screen)
|
|
69
|
-
|
|
70
46
|
expect(res.body._rev).toBeDefined()
|
|
71
|
-
expect(res.body.name).toEqual(
|
|
72
|
-
expect(events.screen.created).not.toBeCalled()
|
|
47
|
+
expect(res.body.name).toEqual(screenCfg.name)
|
|
73
48
|
})
|
|
74
49
|
|
|
75
50
|
it("should apply authorization to endpoint", async () => {
|
|
@@ -89,7 +64,6 @@ describe("/screens", () => {
|
|
|
89
64
|
.expect("Content-Type", /json/)
|
|
90
65
|
.expect(200)
|
|
91
66
|
expect(res.body.message).toBeDefined()
|
|
92
|
-
expect(events.screen.deleted).toBeCalledTimes(1)
|
|
93
67
|
})
|
|
94
68
|
|
|
95
69
|
it("should apply authorization to endpoint", async () => {
|
|
@@ -14,9 +14,8 @@ jest.mock("aws-sdk", () => ({
|
|
|
14
14
|
}))
|
|
15
15
|
|
|
16
16
|
const setup = require("./utilities")
|
|
17
|
-
const { events, constants } = require("@budibase/backend-core")
|
|
18
17
|
|
|
19
|
-
describe("/
|
|
18
|
+
describe("/attachments", () => {
|
|
20
19
|
let request = setup.getRequest()
|
|
21
20
|
let config = setup.getConfig()
|
|
22
21
|
let app
|
|
@@ -27,138 +26,73 @@ describe("/static", () => {
|
|
|
27
26
|
app = await config.init()
|
|
28
27
|
})
|
|
29
28
|
|
|
30
|
-
describe("
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
describe("/app", () => {
|
|
44
|
-
|
|
45
|
-
beforeEach(() => {
|
|
46
|
-
jest.clearAllMocks()
|
|
29
|
+
describe("generateSignedUrls", () => {
|
|
30
|
+
let datasource
|
|
31
|
+
|
|
32
|
+
beforeEach(async () => {
|
|
33
|
+
datasource = await config.createDatasource({
|
|
34
|
+
datasource: {
|
|
35
|
+
type: "datasource",
|
|
36
|
+
name: "Test",
|
|
37
|
+
source: "S3",
|
|
38
|
+
config: {},
|
|
39
|
+
},
|
|
40
|
+
})
|
|
47
41
|
})
|
|
48
42
|
|
|
49
|
-
it("should
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
it("should be able to generate a signed upload URL", async () => {
|
|
44
|
+
const bucket = "foo"
|
|
45
|
+
const key = "bar"
|
|
53
46
|
const res = await request
|
|
54
|
-
.
|
|
55
|
-
.
|
|
47
|
+
.post(`/api/attachments/${datasource._id}/url`)
|
|
48
|
+
.send({ bucket, key })
|
|
49
|
+
.set(config.defaultHeaders())
|
|
50
|
+
.expect("Content-Type", /json/)
|
|
56
51
|
.expect(200)
|
|
57
|
-
|
|
58
|
-
expect(res.body.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
expect(events.serve.servedAppPreview).not.toBeCalled()
|
|
52
|
+
expect(res.body.signedUrl).toEqual("my-url")
|
|
53
|
+
expect(res.body.publicUrl).toEqual(
|
|
54
|
+
`https://${bucket}.s3.eu-west-1.amazonaws.com/${key}`
|
|
55
|
+
)
|
|
62
56
|
})
|
|
63
57
|
|
|
64
|
-
it("should
|
|
65
|
-
const headers = config.defaultHeaders()
|
|
66
|
-
delete headers[constants.Headers.APP_ID]
|
|
67
|
-
|
|
58
|
+
it("should handle an invalid datasource ID", async () => {
|
|
68
59
|
const res = await request
|
|
69
|
-
.
|
|
70
|
-
.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
60
|
+
.post(`/api/attachments/foo/url`)
|
|
61
|
+
.send({
|
|
62
|
+
bucket: "foo",
|
|
63
|
+
key: "bar",
|
|
64
|
+
})
|
|
65
|
+
.set(config.defaultHeaders())
|
|
66
|
+
.expect("Content-Type", /json/)
|
|
67
|
+
.expect(400)
|
|
68
|
+
expect(res.body.message).toEqual(
|
|
69
|
+
"The specified datasource could not be found"
|
|
70
|
+
)
|
|
77
71
|
})
|
|
78
72
|
|
|
79
|
-
it("should
|
|
73
|
+
it("should require a bucket parameter", async () => {
|
|
80
74
|
const res = await request
|
|
81
|
-
.
|
|
75
|
+
.post(`/api/attachments/${datasource._id}/url`)
|
|
76
|
+
.send({
|
|
77
|
+
bucket: undefined,
|
|
78
|
+
key: "bar",
|
|
79
|
+
})
|
|
82
80
|
.set(config.defaultHeaders())
|
|
83
|
-
.expect(
|
|
84
|
-
|
|
85
|
-
expect(res.body.
|
|
86
|
-
expect(events.serve.servedAppPreview).toBeCalledTimes(1)
|
|
87
|
-
expect(events.serve.servedAppPreview).toBeCalledWith(res.body)
|
|
88
|
-
expect(events.serve.servedApp).not.toBeCalled()
|
|
81
|
+
.expect("Content-Type", /json/)
|
|
82
|
+
.expect(400)
|
|
83
|
+
expect(res.body.message).toEqual("bucket and key values are required")
|
|
89
84
|
})
|
|
90
|
-
})
|
|
91
85
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
datasource = await config.createDatasource({
|
|
98
|
-
datasource: {
|
|
99
|
-
type: "datasource",
|
|
100
|
-
name: "Test",
|
|
101
|
-
source: "S3",
|
|
102
|
-
config: {},
|
|
103
|
-
},
|
|
86
|
+
it("should require a key parameter", async () => {
|
|
87
|
+
const res = await request
|
|
88
|
+
.post(`/api/attachments/${datasource._id}/url`)
|
|
89
|
+
.send({
|
|
90
|
+
bucket: "foo",
|
|
104
91
|
})
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const key = "bar"
|
|
110
|
-
const res = await request
|
|
111
|
-
.post(`/api/attachments/${datasource._id}/url`)
|
|
112
|
-
.send({ bucket, key })
|
|
113
|
-
.set(config.defaultHeaders())
|
|
114
|
-
.expect("Content-Type", /json/)
|
|
115
|
-
.expect(200)
|
|
116
|
-
expect(res.body.signedUrl).toEqual("my-url")
|
|
117
|
-
expect(res.body.publicUrl).toEqual(
|
|
118
|
-
`https://${bucket}.s3.eu-west-1.amazonaws.com/${key}`
|
|
119
|
-
)
|
|
120
|
-
})
|
|
121
|
-
|
|
122
|
-
it("should handle an invalid datasource ID", async () => {
|
|
123
|
-
const res = await request
|
|
124
|
-
.post(`/api/attachments/foo/url`)
|
|
125
|
-
.send({
|
|
126
|
-
bucket: "foo",
|
|
127
|
-
key: "bar",
|
|
128
|
-
})
|
|
129
|
-
.set(config.defaultHeaders())
|
|
130
|
-
.expect("Content-Type", /json/)
|
|
131
|
-
.expect(400)
|
|
132
|
-
expect(res.body.message).toEqual(
|
|
133
|
-
"The specified datasource could not be found"
|
|
134
|
-
)
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
it("should require a bucket parameter", async () => {
|
|
138
|
-
const res = await request
|
|
139
|
-
.post(`/api/attachments/${datasource._id}/url`)
|
|
140
|
-
.send({
|
|
141
|
-
bucket: undefined,
|
|
142
|
-
key: "bar",
|
|
143
|
-
})
|
|
144
|
-
.set(config.defaultHeaders())
|
|
145
|
-
.expect("Content-Type", /json/)
|
|
146
|
-
.expect(400)
|
|
147
|
-
expect(res.body.message).toEqual("bucket and key values are required")
|
|
148
|
-
})
|
|
149
|
-
|
|
150
|
-
it("should require a key parameter", async () => {
|
|
151
|
-
const res = await request
|
|
152
|
-
.post(`/api/attachments/${datasource._id}/url`)
|
|
153
|
-
.send({
|
|
154
|
-
bucket: "foo",
|
|
155
|
-
})
|
|
156
|
-
.set(config.defaultHeaders())
|
|
157
|
-
.expect("Content-Type", /json/)
|
|
158
|
-
.expect(400)
|
|
159
|
-
expect(res.body.message).toEqual("bucket and key values are required")
|
|
160
|
-
})
|
|
92
|
+
.set(config.defaultHeaders())
|
|
93
|
+
.expect("Content-Type", /json/)
|
|
94
|
+
.expect(400)
|
|
95
|
+
expect(res.body.message).toEqual("bucket and key values are required")
|
|
161
96
|
})
|
|
162
97
|
})
|
|
163
|
-
|
|
164
98
|
})
|
|
@@ -2,7 +2,6 @@ const { checkBuilderEndpoint } = require("./utilities/TestFunctions")
|
|
|
2
2
|
const { getAppDB } = require("@budibase/backend-core/context")
|
|
3
3
|
const setup = require("./utilities")
|
|
4
4
|
const { basicTable } = setup.structures
|
|
5
|
-
const { events } = require("@budibase/backend-core")
|
|
6
5
|
|
|
7
6
|
describe("/tables", () => {
|
|
8
7
|
let request = setup.getRequest()
|
|
@@ -15,76 +14,24 @@ describe("/tables", () => {
|
|
|
15
14
|
})
|
|
16
15
|
|
|
17
16
|
describe("create", () => {
|
|
18
|
-
|
|
19
|
-
beforeEach(() => {
|
|
20
|
-
jest.clearAllMocks()
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
const createTable = (table) => {
|
|
24
|
-
if (!table) {
|
|
25
|
-
table = basicTable()
|
|
26
|
-
}
|
|
27
|
-
return request
|
|
28
|
-
.post(`/api/tables`)
|
|
29
|
-
.send(table)
|
|
30
|
-
.set(config.defaultHeaders())
|
|
31
|
-
.expect('Content-Type', /json/)
|
|
32
|
-
.expect(200)
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
17
|
it("returns a success message when the table is successfully created", async () => {
|
|
37
|
-
const res = await createTable()
|
|
38
|
-
|
|
39
|
-
expect(res.res.statusMessage).toEqual("Table TestTable saved successfully.")
|
|
40
|
-
expect(res.body.name).toEqual("TestTable")
|
|
41
|
-
expect(events.table.created).toBeCalledTimes(1)
|
|
42
|
-
expect(events.table.created).toBeCalledWith(res.body)
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it("creates a table via data import CSV", async () => {
|
|
46
|
-
const table = basicTable()
|
|
47
|
-
table.dataImport = {
|
|
48
|
-
csvString: "\"name\",\"description\"\n\"test-name\",\"test-desc\"",
|
|
49
|
-
}
|
|
50
|
-
table.dataImport.schema = table.schema
|
|
51
|
-
|
|
52
|
-
const res = await createTable(table)
|
|
53
|
-
|
|
54
|
-
expect(events.table.created).toBeCalledTimes(1)
|
|
55
|
-
expect(events.table.created).toBeCalledWith(res.body)
|
|
56
|
-
expect(events.table.imported).toBeCalledTimes(1)
|
|
57
|
-
expect(events.table.imported).toBeCalledWith(res.body, "csv")
|
|
58
|
-
expect(events.rows.imported).toBeCalledTimes(1)
|
|
59
|
-
expect(events.rows.imported).toBeCalledWith(res.body, "csv", 1)
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
it("should apply authorization to endpoint", async () => {
|
|
63
|
-
await checkBuilderEndpoint({
|
|
64
|
-
config,
|
|
65
|
-
method: "POST",
|
|
66
|
-
url: `/api/tables`,
|
|
67
|
-
body: basicTable()
|
|
68
|
-
})
|
|
69
|
-
})
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
describe("update", () => {
|
|
73
|
-
it("updates a table", async () => {
|
|
74
|
-
const testTable = await config.createTable()
|
|
75
|
-
|
|
76
18
|
const res = await request
|
|
77
19
|
.post(`/api/tables`)
|
|
78
|
-
.send(
|
|
20
|
+
.send({
|
|
21
|
+
name: "TestTable",
|
|
22
|
+
key: "name",
|
|
23
|
+
schema: {
|
|
24
|
+
name: {type: "string"}
|
|
25
|
+
}
|
|
26
|
+
})
|
|
79
27
|
.set(config.defaultHeaders())
|
|
80
28
|
.expect('Content-Type', /json/)
|
|
81
29
|
.expect(200)
|
|
82
|
-
|
|
83
|
-
expect(
|
|
84
|
-
expect(events.table.updated).toBeCalledWith(res.body)
|
|
30
|
+
expect(res.res.statusMessage).toEqual("Table TestTable saved successfully.")
|
|
31
|
+
expect(res.body.name).toEqual("TestTable")
|
|
85
32
|
})
|
|
86
33
|
|
|
87
|
-
it("
|
|
34
|
+
it("renames all the row fields for a table when a schema key is renamed", async () => {
|
|
88
35
|
const testTable = await config.createTable()
|
|
89
36
|
|
|
90
37
|
const testRow = await request
|
|
@@ -127,44 +74,19 @@ describe("/tables", () => {
|
|
|
127
74
|
expect(res.body.name).toBeUndefined()
|
|
128
75
|
})
|
|
129
76
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
expect(res.body.schema.email).toBeDefined()
|
|
142
|
-
expect(res.body.schema.roleId).toBeDefined()
|
|
143
|
-
})
|
|
144
|
-
})
|
|
145
|
-
})
|
|
146
|
-
|
|
147
|
-
describe("import", () => {
|
|
148
|
-
it("imports rows successfully", async () => {
|
|
149
|
-
const table = await config.createTable()
|
|
150
|
-
const importRequest = {
|
|
151
|
-
dataImport: {
|
|
152
|
-
csvString: "\"name\",\"description\"\n\"test-name\",\"test-desc\"",
|
|
153
|
-
schema: table.schema
|
|
77
|
+
it("should apply authorization to endpoint", async () => {
|
|
78
|
+
await checkBuilderEndpoint({
|
|
79
|
+
config,
|
|
80
|
+
method: "POST",
|
|
81
|
+
url: `/api/tables`,
|
|
82
|
+
body: {
|
|
83
|
+
name: "TestTable",
|
|
84
|
+
key: "name",
|
|
85
|
+
schema: {
|
|
86
|
+
name: {type: "string"}
|
|
87
|
+
}
|
|
154
88
|
}
|
|
155
|
-
}
|
|
156
|
-
jest.clearAllMocks()
|
|
157
|
-
|
|
158
|
-
await request
|
|
159
|
-
.post(`/api/tables/${table._id}/import`)
|
|
160
|
-
.send(importRequest)
|
|
161
|
-
.set(config.defaultHeaders())
|
|
162
|
-
.expect('Content-Type', /json/)
|
|
163
|
-
.expect(200)
|
|
164
|
-
|
|
165
|
-
expect(events.table.created).not.toHaveBeenCalled()
|
|
166
|
-
expect(events.rows.imported).toBeCalledTimes(1)
|
|
167
|
-
expect(events.rows.imported).toBeCalledWith(table, "csv", 1)
|
|
89
|
+
})
|
|
168
90
|
})
|
|
169
91
|
})
|
|
170
92
|
|
|
@@ -231,6 +153,22 @@ describe("/tables", () => {
|
|
|
231
153
|
})
|
|
232
154
|
})
|
|
233
155
|
|
|
156
|
+
describe("updating user table", () => {
|
|
157
|
+
it("should add roleId and email field when adjusting user table schema", async () => {
|
|
158
|
+
const res = await request
|
|
159
|
+
.post(`/api/tables`)
|
|
160
|
+
.send({
|
|
161
|
+
...basicTable(),
|
|
162
|
+
_id: "ta_users",
|
|
163
|
+
})
|
|
164
|
+
.set(config.defaultHeaders())
|
|
165
|
+
.expect('Content-Type', /json/)
|
|
166
|
+
.expect(200)
|
|
167
|
+
expect(res.body.schema.email).toBeDefined()
|
|
168
|
+
expect(res.body.schema.roleId).toBeDefined()
|
|
169
|
+
})
|
|
170
|
+
})
|
|
171
|
+
|
|
234
172
|
describe("validate csv", () => {
|
|
235
173
|
it("should be able to validate a CSV layout", async () => {
|
|
236
174
|
const res = await request
|
|
@@ -267,8 +205,6 @@ describe("/tables", () => {
|
|
|
267
205
|
.expect('Content-Type', /json/)
|
|
268
206
|
.expect(200)
|
|
269
207
|
expect(res.body.message).toEqual(`Table ${testTable._id} deleted.`)
|
|
270
|
-
expect(events.table.deleted).toBeCalledTimes(1)
|
|
271
|
-
expect(events.table.deleted).toBeCalledWith(testTable)
|
|
272
208
|
})
|
|
273
209
|
|
|
274
210
|
it("deletes linked references to the table after deletion", async () => {
|