expressa 2.0.18 → 2.0.19
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/.circleci/config.yml +21 -21
- package/.eslintrc.json +29 -29
- package/LICENSE +21 -21
- package/README.md +137 -137
- package/auth/index.js +76 -76
- package/auth/jwt.js +31 -31
- package/controllers/collections.js +260 -260
- package/controllers/install.js +105 -105
- package/controllers/status.js +43 -43
- package/controllers/users.js +52 -52
- package/cypress/fixtures/example.json +4 -4
- package/cypress/integration/0_install_spec.js +8 -8
- package/cypress/integration/custom_collections.js +28 -28
- package/cypress/integration/home.js +9 -9
- package/cypress/integration/settings.js +34 -34
- package/cypress/integration/users.js +61 -61
- package/cypress/plugins/index.js +17 -17
- package/cypress/support/commands.js +54 -54
- package/cypress/support/index.js +20 -20
- package/cypress/support/util.js +10 -10
- package/cypress.json +4 -4
- package/db/cached.js +40 -40
- package/db/file.js +112 -112
- package/db/memory.js +79 -79
- package/db/mongo.js +86 -86
- package/db/postgres.js +93 -93
- package/doc/authentication.md +38 -38
- package/doc/automatic-fields.md +12 -12
- package/doc/blogexample.md +16 -16
- package/doc/custom-endpoints.md +20 -20
- package/doc/database.md +23 -23
- package/doc/development.md +33 -33
- package/doc/listeners.md +103 -103
- package/doc/modules.md +8 -8
- package/doc/permissions.md +14 -14
- package/doc/relationships.md +65 -65
- package/doc/testing.md +47 -47
- package/doc/uploading-files.md +53 -53
- package/index.js +297 -297
- package/listeners.js +65 -65
- package/listeners_collection_permissions.js +29 -29
- package/listeners_users.js +96 -96
- package/listeners_validation.js +43 -43
- package/middleware/logging.js +30 -30
- package/middleware/permissions.js +41 -41
- package/modules/access_keys/access_keys.js +32 -32
- package/modules/admin/.babelrc +19 -19
- package/modules/admin/.editorconfig +14 -14
- package/modules/admin/.eslintignore +5 -5
- package/modules/admin/.eslintrc.js +197 -197
- package/modules/admin/.postcssrc.js +10 -10
- package/modules/admin/.travis.yml +5 -5
- package/modules/admin/LICENSE +21 -21
- package/modules/admin/README.md +88 -88
- package/modules/admin/build/build.js +45 -45
- package/modules/admin/build/check-versions.js +64 -64
- package/modules/admin/build/utils.js +108 -108
- package/modules/admin/build/vue-loader.conf.js +5 -5
- package/modules/admin/build/webpack.base.conf.js +112 -112
- package/modules/admin/build/webpack.dev.conf.js +95 -95
- package/modules/admin/build/webpack.prod.conf.js +112 -112
- package/modules/admin/config/dev.env.js +8 -8
- package/modules/admin/config/index.js +86 -86
- package/modules/admin/config/prod.env.js +5 -5
- package/modules/admin/dist/164c6167c1f3c497c07c.woff +1 -0
- package/modules/admin/dist/42ac07abc8473600c41f.ttf +1 -0
- package/modules/admin/dist/86dccb18a7eb4be8ef1a.woff +1 -0
- package/modules/admin/dist/c45297c558e0318fc9c5.ttf +1 -0
- package/modules/admin/dist/c717c9930715e24fa12c.woff +1 -0
- package/modules/admin/dist/ca6f07ef23f24cc2738a.ttf +1 -0
- package/modules/admin/dist/css/269.f7d5c7d5.css +37 -0
- package/modules/admin/dist/css/269.f7d5c7d5.css.gz +0 -0
- package/modules/admin/dist/css/451.c6646d20.css +1 -0
- package/modules/admin/dist/css/451.c6646d20.css.gz +0 -0
- package/modules/admin/dist/css/572.74d8e965.css +34 -0
- package/modules/admin/dist/css/572.74d8e965.css.gz +0 -0
- package/modules/admin/dist/css/651.e946bda7.css +6 -0
- package/modules/admin/dist/css/651.e946bda7.css.gz +0 -0
- package/modules/admin/dist/css/699.d1f90954.css +8 -0
- package/modules/admin/dist/css/699.d1f90954.css.gz +0 -0
- package/modules/admin/dist/css/750.4086915d.css +2 -0
- package/modules/admin/dist/css/750.4086915d.css.gz +0 -0
- package/modules/admin/dist/css/864.506917a4.css +7 -0
- package/modules/admin/dist/css/864.506917a4.css.gz +0 -0
- package/modules/admin/dist/css/899.506917a4.css +7 -0
- package/modules/admin/dist/css/899.506917a4.css.gz +0 -0
- package/modules/admin/dist/css/950.1fd9d57c.css +7 -0
- package/modules/admin/dist/css/950.1fd9d57c.css.gz +0 -0
- package/modules/admin/dist/css/app.11cc6245.css +39 -0
- package/modules/admin/dist/css/app.11cc6245.css.gz +0 -0
- package/modules/admin/dist/css/app.2e1b0d79.css +591 -0
- package/modules/admin/dist/css/app.2e1b0d79.css.gz +0 -0
- package/modules/admin/dist/css/app.4d43d0fd.css +592 -0
- package/modules/admin/dist/css/app.4d43d0fd.css.gz +0 -0
- package/modules/admin/dist/css/app.abace109.css +1 -0
- package/modules/admin/dist/css/app.abace109.css.gz +0 -0
- package/modules/admin/dist/css/chunk-elementUI.67ad86d7.css +1 -0
- package/modules/admin/dist/css/chunk-elementUI.67ad86d7.css.gz +0 -0
- package/modules/admin/dist/css/chunk-elementUI.9e660bfd.css +1 -0
- package/modules/admin/dist/css/chunk-elementUI.9e660bfd.css.gz +0 -0
- package/modules/admin/dist/css/chunk-elementUI.c77cf142.css +1 -0
- package/modules/admin/dist/css/chunk-elementUI.c77cf142.css.gz +0 -0
- package/modules/admin/dist/css/chunk-elementUI.f1625b35.css +1 -0
- package/modules/admin/dist/css/chunk-elementUI.f1625b35.css.gz +0 -0
- package/modules/admin/dist/css/chunk-elementUI.f25dfb9b.css +1 -0
- package/modules/admin/dist/css/chunk-elementUI.f25dfb9b.css.gz +0 -0
- package/modules/admin/dist/css/chunk-libs.de0d8484.css +551 -0
- package/modules/admin/dist/css/chunk-libs.de0d8484.css.gz +0 -0
- package/modules/admin/dist/index.html +1 -1
- package/modules/admin/dist/static/fonts/element-icons.313f7da.woff +0 -0
- package/modules/admin/dist/static/fonts/element-icons.4520188.ttf +0 -0
- package/modules/admin/dist/static/js/269.7245ceaf.js +1 -0
- package/modules/admin/dist/static/js/269.7245ceaf.js.gz +0 -0
- package/modules/admin/dist/static/js/451.645974a8.js +1 -0
- package/modules/admin/dist/static/js/451.645974a8.js.gz +0 -0
- package/modules/admin/dist/static/js/460.962d5bc0.js +1 -0
- package/modules/admin/dist/static/js/460.962d5bc0.js.gz +0 -0
- package/modules/admin/dist/static/js/556.1e08866a.js +1 -0
- package/modules/admin/dist/static/js/556.1e08866a.js.gz +0 -0
- package/modules/admin/dist/static/js/572.13392e1d.js +1 -0
- package/modules/admin/dist/static/js/572.13392e1d.js.gz +0 -0
- package/modules/admin/dist/static/js/603.7b34a650.js +1 -0
- package/modules/admin/dist/static/js/603.7b34a650.js.gz +0 -0
- package/modules/admin/dist/static/js/637.26413baa.js +1 -0
- package/modules/admin/dist/static/js/637.26413baa.js.gz +0 -0
- package/modules/admin/dist/static/js/651.564b24b6.js +1 -0
- package/modules/admin/dist/static/js/651.564b24b6.js.gz +0 -0
- package/modules/admin/dist/static/js/653.02ec1098.js +1 -0
- package/modules/admin/dist/static/js/653.02ec1098.js.gz +0 -0
- package/modules/admin/dist/static/js/699.c7564884.js +1 -0
- package/modules/admin/dist/static/js/699.c7564884.js.gz +0 -0
- package/modules/admin/dist/static/js/750.50c950da.js +1 -0
- package/modules/admin/dist/static/js/750.50c950da.js.gz +0 -0
- package/modules/admin/dist/static/js/864.4f43847d.js +1 -0
- package/modules/admin/dist/static/js/864.4f43847d.js.gz +0 -0
- package/modules/admin/dist/static/js/950.d4ff0a18.js +1 -0
- package/modules/admin/dist/static/js/950.d4ff0a18.js.gz +0 -0
- package/modules/admin/dist/static/js/app.981e71b3.js +2 -0
- package/modules/admin/dist/static/js/{chunk-libs.06c38828.js.LICENSE.txt → app.981e71b3.js.LICENSE.txt} +15 -18
- package/modules/admin/dist/static/js/app.981e71b3.js.LICENSE.txt.gz +0 -0
- package/modules/admin/dist/static/js/app.981e71b3.js.gz +0 -0
- package/modules/admin/index.html +16 -16
- package/modules/admin/package.json +101 -101
- package/modules/admin/src/App.vue +11 -11
- package/modules/admin/src/api/login.js +26 -26
- package/modules/admin/src/api/table.js +9 -9
- package/modules/admin/src/components/Breadcrumb/index.vue +79 -79
- package/modules/admin/src/components/Hamburger/index.vue +62 -62
- package/modules/admin/src/components/JSONEditor.vue +180 -180
- package/modules/admin/src/components/SvgIcon/index.vue +43 -43
- package/modules/admin/src/icons/index.js +9 -9
- package/modules/admin/src/icons/svgo.yml +22 -22
- package/modules/admin/src/main.js +42 -42
- package/modules/admin/src/permission.js +49 -49
- package/modules/admin/src/router/index.js +200 -200
- package/modules/admin/src/store/getters.js +11 -11
- package/modules/admin/src/store/index.js +17 -17
- package/modules/admin/src/store/modules/app.js +43 -43
- package/modules/admin/src/store/modules/user.js +104 -104
- package/modules/admin/src/styles/element-ui.scss +29 -29
- package/modules/admin/src/styles/index.scss +78 -78
- package/modules/admin/src/styles/mixin.scss +27 -27
- package/modules/admin/src/styles/sidebar.scss +133 -133
- package/modules/admin/src/styles/transition.scss +46 -46
- package/modules/admin/src/styles/variables.scss +4 -4
- package/modules/admin/src/utils/auth.js +15 -15
- package/modules/admin/src/utils/index.js +74 -74
- package/modules/admin/src/utils/request.js +48 -48
- package/modules/admin/src/utils/validate.js +31 -31
- package/modules/admin/src/views/404.vue +235 -235
- package/modules/admin/src/views/Dev.vue +33 -33
- package/modules/admin/src/views/EditDocument.vue +116 -116
- package/modules/admin/src/views/Endpoints.vue +279 -279
- package/modules/admin/src/views/Home.vue +84 -84
- package/modules/admin/src/views/Install.vue +79 -79
- package/modules/admin/src/views/ListDocuments.vue +72 -72
- package/modules/admin/src/views/ListDocuments2.vue +462 -462
- package/modules/admin/src/views/ManageListeners.vue +67 -67
- package/modules/admin/src/views/ManageMiddleware.vue +43 -43
- package/modules/admin/src/views/ManagePermissions.vue +75 -75
- package/modules/admin/src/views/ViewRequest.vue +77 -77
- package/modules/admin/src/views/form/index.vue +91 -91
- package/modules/admin/src/views/layout/Layout.vue +69 -69
- package/modules/admin/src/views/layout/components/AppMain.vue +41 -41
- package/modules/admin/src/views/layout/components/Navbar.vue +97 -97
- package/modules/admin/src/views/layout/components/Sidebar/Item.vue +29 -29
- package/modules/admin/src/views/layout/components/Sidebar/Link.vue +39 -39
- package/modules/admin/src/views/layout/components/Sidebar/SidebarItem.vue +103 -103
- package/modules/admin/src/views/layout/components/Sidebar/index.vue +62 -62
- package/modules/admin/src/views/layout/components/index.js +3 -3
- package/modules/admin/src/views/layout/mixin/ResizeHandler.js +41 -41
- package/modules/admin/src/views/login/index.vue +195 -195
- package/modules/admin/src/views/tree/index.vue +77 -77
- package/modules/collections/collections.js +39 -39
- package/modules/core/core.js +197 -197
- package/modules/logging/logging.js +88 -88
- package/modules/permissions/permissions.js +106 -106
- package/package.json +59 -59
- package/scripts/expressa +12 -12
- package/scripts/run_cypress_tests.sh +5 -5
- package/scripts/run_db_tests.sh +8 -8
- package/test/0-install.js +96 -96
- package/test/collections.js +431 -431
- package/test/collections.querying.js +288 -288
- package/test/db.js +258 -258
- package/test/db.strings.js +73 -73
- package/test/db.updating.js +144 -144
- package/test/logging.js +29 -29
- package/test/test.js +93 -93
- package/test/testserver.js +17 -17
- package/test/testutils.js +136 -136
- package/test/users.js +425 -425
- package/util.js +522 -522
- package/modules/admin/dist/index.html.gz +0 -0
- package/modules/admin/dist/static/css/app.9dd57eea.css +0 -1
- package/modules/admin/dist/static/css/app.9dd57eea.css.gz +0 -0
- package/modules/admin/dist/static/css/chunk-5061.ce0e4bdb.css +0 -1
- package/modules/admin/dist/static/css/chunk-5061.ce0e4bdb.css.gz +0 -0
- package/modules/admin/dist/static/css/chunk-5b97.7f9cb53e.css +0 -1
- package/modules/admin/dist/static/css/chunk-5b97.7f9cb53e.css.gz +0 -0
- package/modules/admin/dist/static/css/chunk-621e.b826be8d.css +0 -1
- package/modules/admin/dist/static/css/chunk-621e.b826be8d.css.gz +0 -0
- package/modules/admin/dist/static/css/chunk-656b.9c828b00.css +0 -1
- package/modules/admin/dist/static/css/chunk-656b.9c828b00.css.gz +0 -0
- package/modules/admin/dist/static/css/chunk-7291.13514e45.css +0 -0
- package/modules/admin/dist/static/css/chunk-7291.13514e45.css.gz +0 -0
- package/modules/admin/dist/static/css/chunk-7f29.9c828b00.css +0 -1
- package/modules/admin/dist/static/css/chunk-7f29.9c828b00.css.gz +0 -0
- package/modules/admin/dist/static/css/chunk-9a95.c647a2ef.css +0 -1
- package/modules/admin/dist/static/css/chunk-9a95.c647a2ef.css.gz +0 -0
- package/modules/admin/dist/static/css/chunk-b423.5f239333.css +0 -0
- package/modules/admin/dist/static/css/chunk-b423.5f239333.css.gz +0 -0
- package/modules/admin/dist/static/css/chunk-bd5f.aefa49d7.css +0 -1
- package/modules/admin/dist/static/css/chunk-bd5f.aefa49d7.css.gz +0 -0
- package/modules/admin/dist/static/css/chunk-e374.025d58bb.css +0 -1
- package/modules/admin/dist/static/css/chunk-e374.025d58bb.css.gz +0 -0
- package/modules/admin/dist/static/css/chunk-elementUI.3d004d9f.css +0 -1
- package/modules/admin/dist/static/css/chunk-elementUI.3d004d9f.css.gz +0 -0
- package/modules/admin/dist/static/css/chunk-f075.3a895a1e.css +0 -1
- package/modules/admin/dist/static/css/chunk-f075.3a895a1e.css.gz +0 -0
- package/modules/admin/dist/static/css/chunk-libs.327ad89e.css +0 -14
- package/modules/admin/dist/static/css/chunk-libs.327ad89e.css.gz +0 -0
- package/modules/admin/dist/static/fonts/element-icons.6f0a763.ttf +0 -0
- package/modules/admin/dist/static/js/app.e9461593.js +0 -1
- package/modules/admin/dist/static/js/app.e9461593.js.gz +0 -0
- package/modules/admin/dist/static/js/chunk-09d8.561880e0.js +0 -2
- package/modules/admin/dist/static/js/chunk-09d8.561880e0.js.LICENSE.txt +0 -13
- package/modules/admin/dist/static/js/chunk-09d8.561880e0.js.LICENSE.txt.gz +0 -0
- package/modules/admin/dist/static/js/chunk-09d8.561880e0.js.gz +0 -0
- package/modules/admin/dist/static/js/chunk-5061.83e6ccfa.js +0 -1
- package/modules/admin/dist/static/js/chunk-5061.83e6ccfa.js.gz +0 -0
- package/modules/admin/dist/static/js/chunk-5b97.ac360086.js +0 -1
- package/modules/admin/dist/static/js/chunk-5b97.ac360086.js.gz +0 -0
- package/modules/admin/dist/static/js/chunk-5e17.a2b69611.js +0 -1
- package/modules/admin/dist/static/js/chunk-5e17.a2b69611.js.gz +0 -0
- package/modules/admin/dist/static/js/chunk-621e.ccf42393.js +0 -1
- package/modules/admin/dist/static/js/chunk-621e.ccf42393.js.gz +0 -0
- package/modules/admin/dist/static/js/chunk-656b.9d5b03c0.js +0 -1
- package/modules/admin/dist/static/js/chunk-656b.9d5b03c0.js.gz +0 -0
- package/modules/admin/dist/static/js/chunk-7291.590524e9.js +0 -1
- package/modules/admin/dist/static/js/chunk-7291.590524e9.js.gz +0 -0
- package/modules/admin/dist/static/js/chunk-7f29.6ffc142e.js +0 -1
- package/modules/admin/dist/static/js/chunk-7f29.6ffc142e.js.gz +0 -0
- package/modules/admin/dist/static/js/chunk-9a95.bdd76583.js +0 -1
- package/modules/admin/dist/static/js/chunk-9a95.bdd76583.js.gz +0 -0
- package/modules/admin/dist/static/js/chunk-b423.387c504c.js +0 -1
- package/modules/admin/dist/static/js/chunk-b423.387c504c.js.gz +0 -0
- package/modules/admin/dist/static/js/chunk-bd5f.e9509f10.js +0 -1
- package/modules/admin/dist/static/js/chunk-bd5f.e9509f10.js.gz +0 -0
- package/modules/admin/dist/static/js/chunk-e374.7c87a0dd.js +0 -1
- package/modules/admin/dist/static/js/chunk-e374.7c87a0dd.js.gz +0 -0
- package/modules/admin/dist/static/js/chunk-e7c3.e5df8ceb.js +0 -1
- package/modules/admin/dist/static/js/chunk-e7c3.e5df8ceb.js.gz +0 -0
- package/modules/admin/dist/static/js/chunk-elementUI.b0c99c08.js +0 -1
- package/modules/admin/dist/static/js/chunk-elementUI.b0c99c08.js.gz +0 -0
- package/modules/admin/dist/static/js/chunk-f075.315ceec1.js +0 -1
- package/modules/admin/dist/static/js/chunk-f075.315ceec1.js.gz +0 -0
- package/modules/admin/dist/static/js/chunk-libs.06c38828.js +0 -2
- package/modules/admin/dist/static/js/chunk-libs.06c38828.js.LICENSE.txt.gz +0 -0
- package/modules/admin/dist/static/js/chunk-libs.06c38828.js.gz +0 -0
- /package/modules/admin/dist/static/img/{404.a57b6f3.png → 404.4cf6930.png} +0 -0
|
@@ -1,288 +1,288 @@
|
|
|
1
|
-
const request = require('supertest')
|
|
2
|
-
const chai = require('chai')
|
|
3
|
-
const expect = chai.expect
|
|
4
|
-
const testutils = require('./testutils')
|
|
5
|
-
const { app, api } = testutils
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Verify pagination
|
|
9
|
-
* Note: these tests are not for verifying db implemementations, see db.js
|
|
10
|
-
*/
|
|
11
|
-
describe('querying collections', function () {
|
|
12
|
-
it('create doc 1', async function () {
|
|
13
|
-
const token = await testutils.getUserWithPermissions(api, 'testdoc: create')
|
|
14
|
-
await request(app)
|
|
15
|
-
.post('/testdoc')
|
|
16
|
-
.set('x-access-token', token)
|
|
17
|
-
.send({
|
|
18
|
-
_id: 'test1',
|
|
19
|
-
title: 'doc1',
|
|
20
|
-
arr: ['testing'],
|
|
21
|
-
data: {
|
|
22
|
-
number: 0,
|
|
23
|
-
field: 'test111'
|
|
24
|
-
}
|
|
25
|
-
})
|
|
26
|
-
.expect(200)
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it('create doc 2', async function () {
|
|
30
|
-
const token = await testutils.getUserWithPermissions(api, 'testdoc: create')
|
|
31
|
-
await request(app)
|
|
32
|
-
.post('/testdoc')
|
|
33
|
-
.set('x-access-token', token)
|
|
34
|
-
.send({
|
|
35
|
-
title: 'doc2',
|
|
36
|
-
data: {
|
|
37
|
-
number: -3
|
|
38
|
-
}
|
|
39
|
-
})
|
|
40
|
-
.expect(200)
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
it('create doc 3', async function () {
|
|
44
|
-
const token = await testutils.getUserWithPermissions(api, 'testdoc: create')
|
|
45
|
-
await request(app)
|
|
46
|
-
.post('/testdoc')
|
|
47
|
-
.set('x-access-token', token)
|
|
48
|
-
.send({
|
|
49
|
-
_id: 'testid123',
|
|
50
|
-
title: 'doc3',
|
|
51
|
-
data: {
|
|
52
|
-
number: 25,
|
|
53
|
-
field: 'test'
|
|
54
|
-
}
|
|
55
|
-
})
|
|
56
|
-
.expect(200)
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
it('create doc 4', async function () {
|
|
60
|
-
const token = await testutils.getUserWithPermissions(api, 'testdoc: create')
|
|
61
|
-
await request(app)
|
|
62
|
-
.post('/testdoc')
|
|
63
|
-
.set('x-access-token', token)
|
|
64
|
-
.send({
|
|
65
|
-
_id: 'testid1234',
|
|
66
|
-
title: 'doc4',
|
|
67
|
-
data: {
|
|
68
|
-
number: 2,
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
.expect(200)
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
let token
|
|
76
|
-
|
|
77
|
-
it('read doc by id', async function () {
|
|
78
|
-
token = await testutils.getUserWithPermissions(api, 'testdoc: view')
|
|
79
|
-
const res = await request(app)
|
|
80
|
-
.get('/testdoc/testid123')
|
|
81
|
-
.set('x-access-token', token)
|
|
82
|
-
.expect(200)
|
|
83
|
-
expect(res.body.title).to.equal('doc3')
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
it('read doc by missing id returns 404', async function () {
|
|
87
|
-
const res = await request(app)
|
|
88
|
-
.get('/testdoc/missingdoc')
|
|
89
|
-
.set('x-access-token', token)
|
|
90
|
-
.expect(404)
|
|
91
|
-
expect(res.body.error).to.equal('document not found')
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
it('read entire collection', async function () {
|
|
95
|
-
const res = await request(app)
|
|
96
|
-
.get('/testdoc')
|
|
97
|
-
.set('x-access-token', token)
|
|
98
|
-
.expect(200)
|
|
99
|
-
expect(res.body).to.have.lengthOf(4)
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
it('return docs matching deep field', async function () {
|
|
103
|
-
const res = await request(app)
|
|
104
|
-
.get('/testdoc?query={"data.field":"test"}')
|
|
105
|
-
.set('x-access-token', token)
|
|
106
|
-
.expect(200)
|
|
107
|
-
expect(res.body[0].title).to.equal('doc3')
|
|
108
|
-
expect(res.body).to.have.lengthOf(1)
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
it('return docs matching array field', async function () {
|
|
112
|
-
const res = await request(app)
|
|
113
|
-
.get('/testdoc?query={"arr": "testing"}')
|
|
114
|
-
.set('x-access-token', token)
|
|
115
|
-
.expect(200)
|
|
116
|
-
expect(res.body[0].title).to.equal('doc1')
|
|
117
|
-
expect(res.body).to.have.lengthOf(1)
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
it('errors without permission', async function () {
|
|
121
|
-
await request(app)
|
|
122
|
-
.get('/testdoc')
|
|
123
|
-
.expect(401)
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
it('page 0 returns an error', async function () {
|
|
127
|
-
await request(app)
|
|
128
|
-
.get('/testdoc?limit=2&page=0')
|
|
129
|
-
.set('x-access-token', token)
|
|
130
|
-
.expect(400)
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
it('returns page 1 correctly', async function () {
|
|
134
|
-
const res = await request(app)
|
|
135
|
-
.get('/testdoc?limit=2&page=1')
|
|
136
|
-
.set('x-access-token', token)
|
|
137
|
-
.expect(200)
|
|
138
|
-
expect(res.body.itemsTotal).to.equal(4)
|
|
139
|
-
expect(res.body.itemsPerPage).to.equal(2)
|
|
140
|
-
expect(res.body.pages).to.equal(2)
|
|
141
|
-
expect(res.body.pagePrev).to.equal(undefined)
|
|
142
|
-
expect(res.body.pageNext).to.equal(2)
|
|
143
|
-
expect(res.body.data).to.have.lengthOf(2)
|
|
144
|
-
|
|
145
|
-
expect(res.body.data[0].title).to.equal('doc1')
|
|
146
|
-
expect(res.body.data[1].title).to.equal('doc2')
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
it('returns page 2 correctly', async function () {
|
|
150
|
-
const res = await request(app)
|
|
151
|
-
.get('/testdoc?limit=2&page=2')
|
|
152
|
-
.set('x-access-token', token)
|
|
153
|
-
.expect(200)
|
|
154
|
-
expect(res.body.itemsTotal).to.equal(4)
|
|
155
|
-
expect(res.body.itemsPerPage).to.equal(2)
|
|
156
|
-
expect(res.body.pages).to.equal(2)
|
|
157
|
-
expect(res.body.pagePrev).to.equal(1)
|
|
158
|
-
expect(res.body.pageNext).to.equal(undefined)
|
|
159
|
-
expect(res.body.data).to.have.lengthOf(2)
|
|
160
|
-
|
|
161
|
-
expect(res.body.data[0].title).to.equal('doc3')
|
|
162
|
-
expect(res.body.data[1].title).to.equal('doc4')
|
|
163
|
-
})
|
|
164
|
-
|
|
165
|
-
it('pagemetadisable url parameter strips additional page detail', async function () {
|
|
166
|
-
const res = await request(app)
|
|
167
|
-
.get('/testdoc?limit=2&page=2&pagemetadisable=1')
|
|
168
|
-
.set('x-access-token', token)
|
|
169
|
-
.expect(200)
|
|
170
|
-
expect(res.body.itemsTotal).to.equal(undefined)
|
|
171
|
-
expect(res.body.itemsPerPage).to.equal(2)
|
|
172
|
-
expect(res.body.pages).to.equal(undefined)
|
|
173
|
-
expect(res.body.pagePrev).to.equal(1)
|
|
174
|
-
expect(res.body.pageNext).to.equal(undefined)
|
|
175
|
-
expect(res.body.data).to.have.lengthOf(2)
|
|
176
|
-
|
|
177
|
-
expect(res.body.data[0].title).to.equal('doc3')
|
|
178
|
-
expect(res.body.data[1].title).to.equal('doc4')
|
|
179
|
-
})
|
|
180
|
-
|
|
181
|
-
it('page 3 is empty', async function () {
|
|
182
|
-
const res = await request(app)
|
|
183
|
-
.get('/testdoc?limit=2&page=3')
|
|
184
|
-
.set('x-access-token', token)
|
|
185
|
-
.expect(200)
|
|
186
|
-
expect(res.body.itemsTotal).to.equal(4)
|
|
187
|
-
expect(res.body.itemsPerPage).to.equal(2)
|
|
188
|
-
expect(res.body.pages).to.equal(2)
|
|
189
|
-
expect(res.body.pagePrev).to.equal(2)
|
|
190
|
-
expect(res.body.pageNext).to.equal(undefined)
|
|
191
|
-
expect(res.body.data).to.have.lengthOf(0)
|
|
192
|
-
})
|
|
193
|
-
|
|
194
|
-
it('page 4 is empty', async function () {
|
|
195
|
-
const res = await request(app)
|
|
196
|
-
.get('/testdoc?limit=2&page=3')
|
|
197
|
-
.set('x-access-token', token)
|
|
198
|
-
.expect(200)
|
|
199
|
-
expect(res.body.itemsTotal).to.equal(4)
|
|
200
|
-
expect(res.body.itemsPerPage).to.equal(2)
|
|
201
|
-
expect(res.body.pages).to.equal(2)
|
|
202
|
-
expect(res.body.pagePrev).to.equal(2)
|
|
203
|
-
expect(res.body.pageNext).to.equal(undefined)
|
|
204
|
-
expect(res.body.data).to.have.lengthOf(0)
|
|
205
|
-
})
|
|
206
|
-
|
|
207
|
-
it('pagination works with query', async function () {
|
|
208
|
-
const res = await request(app)
|
|
209
|
-
.get('/testdoc?query={"data.number":2}&limit=2&page=1')
|
|
210
|
-
.set('x-access-token', token)
|
|
211
|
-
.expect(200)
|
|
212
|
-
expect(res.body.itemsTotal).to.equal(1)
|
|
213
|
-
expect(res.body.itemsPerPage).to.equal(2)
|
|
214
|
-
expect(res.body.pages).to.equal(1)
|
|
215
|
-
expect(res.body.pagePrev).to.equal(undefined)
|
|
216
|
-
expect(res.body.pageNext).to.equal(undefined)
|
|
217
|
-
expect(res.body.data).to.have.lengthOf(1)
|
|
218
|
-
expect(res.body.data[0].title).to.equal('doc4')
|
|
219
|
-
})
|
|
220
|
-
|
|
221
|
-
it('sort by deep field ascending', async function () {
|
|
222
|
-
const token = await testutils.getUserWithPermissions(api, 'testdoc: view')
|
|
223
|
-
const res = await request(app)
|
|
224
|
-
.get('/testdoc?orderby={"data.number":1}')
|
|
225
|
-
.set('x-access-token', token)
|
|
226
|
-
.expect(200)
|
|
227
|
-
expect(res.body).to.have.lengthOf(4)
|
|
228
|
-
expect(res.body[0].title).to.equal('doc2') // -2
|
|
229
|
-
expect(res.body[1].title).to.equal('doc1') // 0
|
|
230
|
-
expect(res.body[2].title).to.equal('doc4') // 2
|
|
231
|
-
expect(res.body[3].title).to.equal('doc3') // 25
|
|
232
|
-
})
|
|
233
|
-
|
|
234
|
-
it('sort by deep field descending', async function () {
|
|
235
|
-
const token = await testutils.getUserWithPermissions(api, 'testdoc: view')
|
|
236
|
-
const res = await request(app)
|
|
237
|
-
.get('/testdoc?orderby={"meta.created":-1}')
|
|
238
|
-
.set('x-access-token', token)
|
|
239
|
-
.expect(200)
|
|
240
|
-
expect(res.body).to.have.lengthOf(4)
|
|
241
|
-
expect(res.body[0].title).to.equal('doc4')
|
|
242
|
-
expect(res.body[1].title).to.equal('doc3')
|
|
243
|
-
expect(res.body[2].title).to.equal('doc2')
|
|
244
|
-
expect(res.body[3].title).to.equal('doc1')
|
|
245
|
-
})
|
|
246
|
-
|
|
247
|
-
it('project a specific field', async function () {
|
|
248
|
-
const token = await testutils.getUserWithPermissions(api, 'testdoc: view')
|
|
249
|
-
const res = await request(app)
|
|
250
|
-
.get('/testdoc?fields={"title":1}')
|
|
251
|
-
.set('x-access-token', token)
|
|
252
|
-
.expect(200)
|
|
253
|
-
expect(res.body).to.have.lengthOf(4)
|
|
254
|
-
expect(res.body[0].title.substring(0, 3)).to.equal('doc')
|
|
255
|
-
expect(res.body[0].data).to.be.undefined
|
|
256
|
-
})
|
|
257
|
-
|
|
258
|
-
it('project a specific field on get', async function () {
|
|
259
|
-
const token = await testutils.getUserWithPermissions(api, 'testdoc: view')
|
|
260
|
-
const res = await request(app)
|
|
261
|
-
.get('/testdoc/test1?fields={"title":1}')
|
|
262
|
-
.set('x-access-token', token)
|
|
263
|
-
.expect(200)
|
|
264
|
-
expect(res.body.title).to.equal('doc1')
|
|
265
|
-
expect(res.body.data).to.be.undefined
|
|
266
|
-
})
|
|
267
|
-
|
|
268
|
-
it('project deep fields', async function() {
|
|
269
|
-
const token = await testutils.getUserWithPermissions(api, 'testdoc: view')
|
|
270
|
-
const res = await request(app)
|
|
271
|
-
.get('/testdoc?fields={"data":1}')
|
|
272
|
-
.set('x-access-token', token)
|
|
273
|
-
.expect(200)
|
|
274
|
-
expect(res.body).to.have.lengthOf(4)
|
|
275
|
-
expect(res.body[0].title).to.be.undefined
|
|
276
|
-
expect(res.body[0].data.number).to.not.be.undefined
|
|
277
|
-
expect(res.body[0].data.field).to.not.be.undefined
|
|
278
|
-
|
|
279
|
-
const res2 = await request(app)
|
|
280
|
-
.get('/testdoc?fields={"data.number":1}')
|
|
281
|
-
.set('x-access-token', token)
|
|
282
|
-
.expect(200)
|
|
283
|
-
expect(res2.body).to.have.lengthOf(4)
|
|
284
|
-
expect(res2.body[0].title).to.be.undefined
|
|
285
|
-
expect(res2.body[0].data.number).to.not.be.undefined
|
|
286
|
-
expect(res2.body[0].data.field).to.be.undefined
|
|
287
|
-
})
|
|
288
|
-
})
|
|
1
|
+
const request = require('supertest')
|
|
2
|
+
const chai = require('chai')
|
|
3
|
+
const expect = chai.expect
|
|
4
|
+
const testutils = require('./testutils')
|
|
5
|
+
const { app, api } = testutils
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Verify pagination
|
|
9
|
+
* Note: these tests are not for verifying db implemementations, see db.js
|
|
10
|
+
*/
|
|
11
|
+
describe('querying collections', function () {
|
|
12
|
+
it('create doc 1', async function () {
|
|
13
|
+
const token = await testutils.getUserWithPermissions(api, 'testdoc: create')
|
|
14
|
+
await request(app)
|
|
15
|
+
.post('/testdoc')
|
|
16
|
+
.set('x-access-token', token)
|
|
17
|
+
.send({
|
|
18
|
+
_id: 'test1',
|
|
19
|
+
title: 'doc1',
|
|
20
|
+
arr: ['testing'],
|
|
21
|
+
data: {
|
|
22
|
+
number: 0,
|
|
23
|
+
field: 'test111'
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
.expect(200)
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('create doc 2', async function () {
|
|
30
|
+
const token = await testutils.getUserWithPermissions(api, 'testdoc: create')
|
|
31
|
+
await request(app)
|
|
32
|
+
.post('/testdoc')
|
|
33
|
+
.set('x-access-token', token)
|
|
34
|
+
.send({
|
|
35
|
+
title: 'doc2',
|
|
36
|
+
data: {
|
|
37
|
+
number: -3
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
.expect(200)
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it('create doc 3', async function () {
|
|
44
|
+
const token = await testutils.getUserWithPermissions(api, 'testdoc: create')
|
|
45
|
+
await request(app)
|
|
46
|
+
.post('/testdoc')
|
|
47
|
+
.set('x-access-token', token)
|
|
48
|
+
.send({
|
|
49
|
+
_id: 'testid123',
|
|
50
|
+
title: 'doc3',
|
|
51
|
+
data: {
|
|
52
|
+
number: 25,
|
|
53
|
+
field: 'test'
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
.expect(200)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it('create doc 4', async function () {
|
|
60
|
+
const token = await testutils.getUserWithPermissions(api, 'testdoc: create')
|
|
61
|
+
await request(app)
|
|
62
|
+
.post('/testdoc')
|
|
63
|
+
.set('x-access-token', token)
|
|
64
|
+
.send({
|
|
65
|
+
_id: 'testid1234',
|
|
66
|
+
title: 'doc4',
|
|
67
|
+
data: {
|
|
68
|
+
number: 2,
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
.expect(200)
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
let token
|
|
76
|
+
|
|
77
|
+
it('read doc by id', async function () {
|
|
78
|
+
token = await testutils.getUserWithPermissions(api, 'testdoc: view')
|
|
79
|
+
const res = await request(app)
|
|
80
|
+
.get('/testdoc/testid123')
|
|
81
|
+
.set('x-access-token', token)
|
|
82
|
+
.expect(200)
|
|
83
|
+
expect(res.body.title).to.equal('doc3')
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
it('read doc by missing id returns 404', async function () {
|
|
87
|
+
const res = await request(app)
|
|
88
|
+
.get('/testdoc/missingdoc')
|
|
89
|
+
.set('x-access-token', token)
|
|
90
|
+
.expect(404)
|
|
91
|
+
expect(res.body.error).to.equal('document not found')
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
it('read entire collection', async function () {
|
|
95
|
+
const res = await request(app)
|
|
96
|
+
.get('/testdoc')
|
|
97
|
+
.set('x-access-token', token)
|
|
98
|
+
.expect(200)
|
|
99
|
+
expect(res.body).to.have.lengthOf(4)
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
it('return docs matching deep field', async function () {
|
|
103
|
+
const res = await request(app)
|
|
104
|
+
.get('/testdoc?query={"data.field":"test"}')
|
|
105
|
+
.set('x-access-token', token)
|
|
106
|
+
.expect(200)
|
|
107
|
+
expect(res.body[0].title).to.equal('doc3')
|
|
108
|
+
expect(res.body).to.have.lengthOf(1)
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
it('return docs matching array field', async function () {
|
|
112
|
+
const res = await request(app)
|
|
113
|
+
.get('/testdoc?query={"arr": "testing"}')
|
|
114
|
+
.set('x-access-token', token)
|
|
115
|
+
.expect(200)
|
|
116
|
+
expect(res.body[0].title).to.equal('doc1')
|
|
117
|
+
expect(res.body).to.have.lengthOf(1)
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
it('errors without permission', async function () {
|
|
121
|
+
await request(app)
|
|
122
|
+
.get('/testdoc')
|
|
123
|
+
.expect(401)
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
it('page 0 returns an error', async function () {
|
|
127
|
+
await request(app)
|
|
128
|
+
.get('/testdoc?limit=2&page=0')
|
|
129
|
+
.set('x-access-token', token)
|
|
130
|
+
.expect(400)
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
it('returns page 1 correctly', async function () {
|
|
134
|
+
const res = await request(app)
|
|
135
|
+
.get('/testdoc?limit=2&page=1')
|
|
136
|
+
.set('x-access-token', token)
|
|
137
|
+
.expect(200)
|
|
138
|
+
expect(res.body.itemsTotal).to.equal(4)
|
|
139
|
+
expect(res.body.itemsPerPage).to.equal(2)
|
|
140
|
+
expect(res.body.pages).to.equal(2)
|
|
141
|
+
expect(res.body.pagePrev).to.equal(undefined)
|
|
142
|
+
expect(res.body.pageNext).to.equal(2)
|
|
143
|
+
expect(res.body.data).to.have.lengthOf(2)
|
|
144
|
+
|
|
145
|
+
expect(res.body.data[0].title).to.equal('doc1')
|
|
146
|
+
expect(res.body.data[1].title).to.equal('doc2')
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
it('returns page 2 correctly', async function () {
|
|
150
|
+
const res = await request(app)
|
|
151
|
+
.get('/testdoc?limit=2&page=2')
|
|
152
|
+
.set('x-access-token', token)
|
|
153
|
+
.expect(200)
|
|
154
|
+
expect(res.body.itemsTotal).to.equal(4)
|
|
155
|
+
expect(res.body.itemsPerPage).to.equal(2)
|
|
156
|
+
expect(res.body.pages).to.equal(2)
|
|
157
|
+
expect(res.body.pagePrev).to.equal(1)
|
|
158
|
+
expect(res.body.pageNext).to.equal(undefined)
|
|
159
|
+
expect(res.body.data).to.have.lengthOf(2)
|
|
160
|
+
|
|
161
|
+
expect(res.body.data[0].title).to.equal('doc3')
|
|
162
|
+
expect(res.body.data[1].title).to.equal('doc4')
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
it('pagemetadisable url parameter strips additional page detail', async function () {
|
|
166
|
+
const res = await request(app)
|
|
167
|
+
.get('/testdoc?limit=2&page=2&pagemetadisable=1')
|
|
168
|
+
.set('x-access-token', token)
|
|
169
|
+
.expect(200)
|
|
170
|
+
expect(res.body.itemsTotal).to.equal(undefined)
|
|
171
|
+
expect(res.body.itemsPerPage).to.equal(2)
|
|
172
|
+
expect(res.body.pages).to.equal(undefined)
|
|
173
|
+
expect(res.body.pagePrev).to.equal(1)
|
|
174
|
+
expect(res.body.pageNext).to.equal(undefined)
|
|
175
|
+
expect(res.body.data).to.have.lengthOf(2)
|
|
176
|
+
|
|
177
|
+
expect(res.body.data[0].title).to.equal('doc3')
|
|
178
|
+
expect(res.body.data[1].title).to.equal('doc4')
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
it('page 3 is empty', async function () {
|
|
182
|
+
const res = await request(app)
|
|
183
|
+
.get('/testdoc?limit=2&page=3')
|
|
184
|
+
.set('x-access-token', token)
|
|
185
|
+
.expect(200)
|
|
186
|
+
expect(res.body.itemsTotal).to.equal(4)
|
|
187
|
+
expect(res.body.itemsPerPage).to.equal(2)
|
|
188
|
+
expect(res.body.pages).to.equal(2)
|
|
189
|
+
expect(res.body.pagePrev).to.equal(2)
|
|
190
|
+
expect(res.body.pageNext).to.equal(undefined)
|
|
191
|
+
expect(res.body.data).to.have.lengthOf(0)
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
it('page 4 is empty', async function () {
|
|
195
|
+
const res = await request(app)
|
|
196
|
+
.get('/testdoc?limit=2&page=3')
|
|
197
|
+
.set('x-access-token', token)
|
|
198
|
+
.expect(200)
|
|
199
|
+
expect(res.body.itemsTotal).to.equal(4)
|
|
200
|
+
expect(res.body.itemsPerPage).to.equal(2)
|
|
201
|
+
expect(res.body.pages).to.equal(2)
|
|
202
|
+
expect(res.body.pagePrev).to.equal(2)
|
|
203
|
+
expect(res.body.pageNext).to.equal(undefined)
|
|
204
|
+
expect(res.body.data).to.have.lengthOf(0)
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
it('pagination works with query', async function () {
|
|
208
|
+
const res = await request(app)
|
|
209
|
+
.get('/testdoc?query={"data.number":2}&limit=2&page=1')
|
|
210
|
+
.set('x-access-token', token)
|
|
211
|
+
.expect(200)
|
|
212
|
+
expect(res.body.itemsTotal).to.equal(1)
|
|
213
|
+
expect(res.body.itemsPerPage).to.equal(2)
|
|
214
|
+
expect(res.body.pages).to.equal(1)
|
|
215
|
+
expect(res.body.pagePrev).to.equal(undefined)
|
|
216
|
+
expect(res.body.pageNext).to.equal(undefined)
|
|
217
|
+
expect(res.body.data).to.have.lengthOf(1)
|
|
218
|
+
expect(res.body.data[0].title).to.equal('doc4')
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
it('sort by deep field ascending', async function () {
|
|
222
|
+
const token = await testutils.getUserWithPermissions(api, 'testdoc: view')
|
|
223
|
+
const res = await request(app)
|
|
224
|
+
.get('/testdoc?orderby={"data.number":1}')
|
|
225
|
+
.set('x-access-token', token)
|
|
226
|
+
.expect(200)
|
|
227
|
+
expect(res.body).to.have.lengthOf(4)
|
|
228
|
+
expect(res.body[0].title).to.equal('doc2') // -2
|
|
229
|
+
expect(res.body[1].title).to.equal('doc1') // 0
|
|
230
|
+
expect(res.body[2].title).to.equal('doc4') // 2
|
|
231
|
+
expect(res.body[3].title).to.equal('doc3') // 25
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
it('sort by deep field descending', async function () {
|
|
235
|
+
const token = await testutils.getUserWithPermissions(api, 'testdoc: view')
|
|
236
|
+
const res = await request(app)
|
|
237
|
+
.get('/testdoc?orderby={"meta.created":-1}')
|
|
238
|
+
.set('x-access-token', token)
|
|
239
|
+
.expect(200)
|
|
240
|
+
expect(res.body).to.have.lengthOf(4)
|
|
241
|
+
expect(res.body[0].title).to.equal('doc4')
|
|
242
|
+
expect(res.body[1].title).to.equal('doc3')
|
|
243
|
+
expect(res.body[2].title).to.equal('doc2')
|
|
244
|
+
expect(res.body[3].title).to.equal('doc1')
|
|
245
|
+
})
|
|
246
|
+
|
|
247
|
+
it('project a specific field', async function () {
|
|
248
|
+
const token = await testutils.getUserWithPermissions(api, 'testdoc: view')
|
|
249
|
+
const res = await request(app)
|
|
250
|
+
.get('/testdoc?fields={"title":1}')
|
|
251
|
+
.set('x-access-token', token)
|
|
252
|
+
.expect(200)
|
|
253
|
+
expect(res.body).to.have.lengthOf(4)
|
|
254
|
+
expect(res.body[0].title.substring(0, 3)).to.equal('doc')
|
|
255
|
+
expect(res.body[0].data).to.be.undefined
|
|
256
|
+
})
|
|
257
|
+
|
|
258
|
+
it('project a specific field on get', async function () {
|
|
259
|
+
const token = await testutils.getUserWithPermissions(api, 'testdoc: view')
|
|
260
|
+
const res = await request(app)
|
|
261
|
+
.get('/testdoc/test1?fields={"title":1}')
|
|
262
|
+
.set('x-access-token', token)
|
|
263
|
+
.expect(200)
|
|
264
|
+
expect(res.body.title).to.equal('doc1')
|
|
265
|
+
expect(res.body.data).to.be.undefined
|
|
266
|
+
})
|
|
267
|
+
|
|
268
|
+
it('project deep fields', async function() {
|
|
269
|
+
const token = await testutils.getUserWithPermissions(api, 'testdoc: view')
|
|
270
|
+
const res = await request(app)
|
|
271
|
+
.get('/testdoc?fields={"data":1}')
|
|
272
|
+
.set('x-access-token', token)
|
|
273
|
+
.expect(200)
|
|
274
|
+
expect(res.body).to.have.lengthOf(4)
|
|
275
|
+
expect(res.body[0].title).to.be.undefined
|
|
276
|
+
expect(res.body[0].data.number).to.not.be.undefined
|
|
277
|
+
expect(res.body[0].data.field).to.not.be.undefined
|
|
278
|
+
|
|
279
|
+
const res2 = await request(app)
|
|
280
|
+
.get('/testdoc?fields={"data.number":1}')
|
|
281
|
+
.set('x-access-token', token)
|
|
282
|
+
.expect(200)
|
|
283
|
+
expect(res2.body).to.have.lengthOf(4)
|
|
284
|
+
expect(res2.body[0].title).to.be.undefined
|
|
285
|
+
expect(res2.body[0].data.number).to.not.be.undefined
|
|
286
|
+
expect(res2.body[0].data.field).to.be.undefined
|
|
287
|
+
})
|
|
288
|
+
})
|