@appsemble/cli 0.30.1 → 0.30.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/README.md +3 -3
- package/lib/app.test.js +1265 -1264
- package/lib/asset.test.js +68 -67
- package/lib/block.test.js +143 -142
- package/lib/config.test.js +205 -203
- package/lib/group.test.js +543 -542
- package/lib/organization.test.js +188 -187
- package/lib/resource.test.js +321 -320
- package/package.json +8 -7
- package/templates/apps/empty/app-definition.yaml +2 -2
- package/templates/blocks/mini-jsx/package.json +1 -1
- package/templates/blocks/preact/package.json +2 -2
- package/templates/blocks/vanilla/package.json +1 -1
- package/vitest.setup.js +11 -0
package/lib/resource.test.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolveFixture } from '@appsemble/node-utils';
|
|
2
|
-
import { createServer, createTestUser, models, setArgv
|
|
2
|
+
import { createServer, createTestUser, models, setArgv } from '@appsemble/server';
|
|
3
3
|
import { PredefinedOrganizationRole } from '@appsemble/types';
|
|
4
4
|
import { setTestApp } from 'axios-test-instance';
|
|
5
5
|
import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
@@ -11,34 +11,102 @@ const argv = { host: 'http://localhost', secret: 'test', aesSecret: 'testSecret'
|
|
|
11
11
|
let user;
|
|
12
12
|
let organization;
|
|
13
13
|
let testApp;
|
|
14
|
-
|
|
15
|
-
beforeAll(() => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
19
|
-
beforeEach(async () => {
|
|
20
|
-
vi.clearAllTimers();
|
|
21
|
-
vi.setSystemTime(0);
|
|
22
|
-
const server = await createServer();
|
|
23
|
-
testApp = await setTestApp(server);
|
|
24
|
-
initAxios({ remote: testApp.defaults.baseURL });
|
|
25
|
-
user = await createTestUser();
|
|
26
|
-
organization = await Organization.create({
|
|
27
|
-
id: 'testorganization',
|
|
28
|
-
name: 'Test Organization',
|
|
14
|
+
describe('resource', () => {
|
|
15
|
+
beforeAll(() => {
|
|
16
|
+
vi.useFakeTimers();
|
|
17
|
+
setArgv(argv);
|
|
29
18
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
19
|
+
beforeEach(async () => {
|
|
20
|
+
vi.clearAllTimers();
|
|
21
|
+
vi.setSystemTime(0);
|
|
22
|
+
const server = await createServer();
|
|
23
|
+
testApp = await setTestApp(server);
|
|
24
|
+
initAxios({ remote: testApp.defaults.baseURL });
|
|
25
|
+
user = await createTestUser();
|
|
26
|
+
organization = await Organization.create({
|
|
27
|
+
id: 'testorganization',
|
|
28
|
+
name: 'Test Organization',
|
|
29
|
+
});
|
|
30
|
+
await OrganizationMember.create({
|
|
31
|
+
OrganizationId: organization.id,
|
|
32
|
+
UserId: user.id,
|
|
33
|
+
role: PredefinedOrganizationRole.Owner,
|
|
34
|
+
});
|
|
35
|
+
await Organization.create({ id: 'appsemble', name: 'Appsemble' });
|
|
34
36
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
afterAll(() => {
|
|
38
|
+
vi.useRealTimers();
|
|
39
|
+
});
|
|
40
|
+
describe('publishResource', () => {
|
|
41
|
+
it('should publish resources from a file', async () => {
|
|
42
|
+
const resourceDefinition = {
|
|
43
|
+
roles: ['$public'],
|
|
44
|
+
schema: {
|
|
45
|
+
type: 'object',
|
|
46
|
+
additionalProperties: false,
|
|
47
|
+
required: ['name'],
|
|
48
|
+
properties: {
|
|
49
|
+
name: {
|
|
50
|
+
type: 'string',
|
|
51
|
+
},
|
|
52
|
+
email: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
format: 'email',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
const app = await App.create({
|
|
60
|
+
path: 'test-app',
|
|
61
|
+
definition: {
|
|
62
|
+
resources: { test: resourceDefinition },
|
|
63
|
+
name: 'Test App',
|
|
64
|
+
defaultPage: 'Test Page',
|
|
65
|
+
},
|
|
66
|
+
vapidPublicKey: 'a',
|
|
67
|
+
vapidPrivateKey: 'b',
|
|
68
|
+
visibility: 'public',
|
|
69
|
+
OrganizationId: organization.id,
|
|
70
|
+
});
|
|
71
|
+
await authorizeCLI('resources:write', testApp);
|
|
72
|
+
await publishResource({
|
|
73
|
+
appId: app.id,
|
|
74
|
+
definition: resourceDefinition,
|
|
75
|
+
path: resolveFixture('resources/test.json'),
|
|
76
|
+
remote: testApp.defaults.baseURL,
|
|
77
|
+
type: 'test',
|
|
78
|
+
seed: false,
|
|
79
|
+
});
|
|
80
|
+
const resources = await Resource.findAll({
|
|
81
|
+
where: { AppId: app.id },
|
|
82
|
+
});
|
|
83
|
+
expect(resources.map((r) => r.toJSON())).toMatchInlineSnapshot(`
|
|
84
|
+
[
|
|
85
|
+
{
|
|
86
|
+
"$created": "1970-01-01T00:00:00.000Z",
|
|
87
|
+
"$updated": "1970-01-01T00:00:00.000Z",
|
|
88
|
+
"email": "test@example.com",
|
|
89
|
+
"id": 1,
|
|
90
|
+
"name": "John Doe",
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"$created": "1970-01-01T00:00:00.000Z",
|
|
94
|
+
"$updated": "1970-01-01T00:00:00.000Z",
|
|
95
|
+
"email": "test2@example.com",
|
|
96
|
+
"id": 2,
|
|
97
|
+
"name": "Jane Doe",
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"$created": "1970-01-01T00:00:00.000Z",
|
|
101
|
+
"$updated": "1970-01-01T00:00:00.000Z",
|
|
102
|
+
"id": 3,
|
|
103
|
+
"name": "test name",
|
|
104
|
+
},
|
|
105
|
+
]
|
|
106
|
+
`);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
it('should throw if there is an error', async () => {
|
|
42
110
|
const resourceDefinition = {
|
|
43
111
|
roles: ['$public'],
|
|
44
112
|
schema: {
|
|
@@ -69,324 +137,257 @@ describe('publishResource', () => {
|
|
|
69
137
|
OrganizationId: organization.id,
|
|
70
138
|
});
|
|
71
139
|
await authorizeCLI('resources:write', testApp);
|
|
72
|
-
await
|
|
140
|
+
await app.destroy();
|
|
141
|
+
await expect(() => publishResource({
|
|
73
142
|
appId: app.id,
|
|
74
143
|
definition: resourceDefinition,
|
|
75
144
|
path: resolveFixture('resources/test.json'),
|
|
76
145
|
remote: testApp.defaults.baseURL,
|
|
77
146
|
type: 'test',
|
|
78
147
|
seed: false,
|
|
79
|
-
});
|
|
80
|
-
const resources = await Resource.findAll({
|
|
81
|
-
where: { AppId: app.id },
|
|
82
|
-
});
|
|
83
|
-
expect(resources.map((r) => r.toJSON())).toMatchInlineSnapshot(`
|
|
84
|
-
[
|
|
85
|
-
{
|
|
86
|
-
"$created": "1970-01-01T00:00:00.000Z",
|
|
87
|
-
"$updated": "1970-01-01T00:00:00.000Z",
|
|
88
|
-
"email": "test@example.com",
|
|
89
|
-
"id": 1,
|
|
90
|
-
"name": "John Doe",
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
"$created": "1970-01-01T00:00:00.000Z",
|
|
94
|
-
"$updated": "1970-01-01T00:00:00.000Z",
|
|
95
|
-
"email": "test2@example.com",
|
|
96
|
-
"id": 2,
|
|
97
|
-
"name": "Jane Doe",
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
"$created": "1970-01-01T00:00:00.000Z",
|
|
101
|
-
"$updated": "1970-01-01T00:00:00.000Z",
|
|
102
|
-
"id": 3,
|
|
103
|
-
"name": "test name",
|
|
104
|
-
},
|
|
105
|
-
]
|
|
106
|
-
`);
|
|
148
|
+
})).rejects.toThrow('Request failed with status code 404');
|
|
107
149
|
});
|
|
108
|
-
|
|
109
|
-
it('should
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
150
|
+
describe('updateResource', () => {
|
|
151
|
+
it('should update existing resources', async () => {
|
|
152
|
+
const resourceDefinition = {
|
|
153
|
+
roles: ['$public'],
|
|
154
|
+
schema: {
|
|
155
|
+
type: 'object',
|
|
156
|
+
additionalProperties: false,
|
|
157
|
+
required: ['name'],
|
|
158
|
+
properties: {
|
|
159
|
+
name: {
|
|
160
|
+
type: 'string',
|
|
161
|
+
},
|
|
162
|
+
email: {
|
|
163
|
+
type: 'string',
|
|
164
|
+
format: 'email',
|
|
165
|
+
},
|
|
166
|
+
},
|
|
119
167
|
},
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
168
|
+
};
|
|
169
|
+
const app = await App.create({
|
|
170
|
+
path: 'test-app',
|
|
171
|
+
definition: {
|
|
172
|
+
resources: { test: resourceDefinition },
|
|
173
|
+
name: 'Test App',
|
|
174
|
+
defaultPage: 'Test Page',
|
|
123
175
|
},
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
visibility: 'public',
|
|
137
|
-
OrganizationId: organization.id,
|
|
138
|
-
});
|
|
139
|
-
await authorizeCLI('resources:write', testApp);
|
|
140
|
-
await app.destroy();
|
|
141
|
-
await expect(() => publishResource({
|
|
142
|
-
appId: app.id,
|
|
143
|
-
definition: resourceDefinition,
|
|
144
|
-
path: resolveFixture('resources/test.json'),
|
|
145
|
-
remote: testApp.defaults.baseURL,
|
|
146
|
-
type: 'test',
|
|
147
|
-
seed: false,
|
|
148
|
-
})).rejects.toThrow('Request failed with status code 404');
|
|
149
|
-
});
|
|
150
|
-
describe('updateResource', () => {
|
|
151
|
-
it('should update existing resources', async () => {
|
|
152
|
-
const resourceDefinition = {
|
|
153
|
-
roles: ['$public'],
|
|
154
|
-
schema: {
|
|
155
|
-
type: 'object',
|
|
156
|
-
additionalProperties: false,
|
|
157
|
-
required: ['name'],
|
|
158
|
-
properties: {
|
|
159
|
-
name: {
|
|
160
|
-
type: 'string',
|
|
176
|
+
vapidPublicKey: 'a',
|
|
177
|
+
vapidPrivateKey: 'b',
|
|
178
|
+
visibility: 'public',
|
|
179
|
+
OrganizationId: organization.id,
|
|
180
|
+
});
|
|
181
|
+
await Resource.bulkCreate([
|
|
182
|
+
{
|
|
183
|
+
id: 1,
|
|
184
|
+
type: 'test',
|
|
185
|
+
AppId: app.id,
|
|
186
|
+
data: {
|
|
187
|
+
name: 'Hello World',
|
|
161
188
|
},
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
id: 2,
|
|
192
|
+
type: 'test',
|
|
193
|
+
AppId: app.id,
|
|
194
|
+
data: {
|
|
195
|
+
name: 'World Hello',
|
|
196
|
+
email: 'hello@example.com',
|
|
165
197
|
},
|
|
166
198
|
},
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
},
|
|
176
|
-
vapidPublicKey: 'a',
|
|
177
|
-
vapidPrivateKey: 'b',
|
|
178
|
-
visibility: 'public',
|
|
179
|
-
OrganizationId: organization.id,
|
|
180
|
-
});
|
|
181
|
-
await Resource.bulkCreate([
|
|
182
|
-
{
|
|
183
|
-
id: 1,
|
|
184
|
-
type: 'test',
|
|
185
|
-
AppId: app.id,
|
|
186
|
-
data: {
|
|
187
|
-
name: 'Hello World',
|
|
199
|
+
{
|
|
200
|
+
id: 3,
|
|
201
|
+
type: 'test',
|
|
202
|
+
AppId: app.id,
|
|
203
|
+
data: {
|
|
204
|
+
name: 'Random name',
|
|
205
|
+
email: 'removed@example.com',
|
|
206
|
+
},
|
|
188
207
|
},
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
208
|
+
]);
|
|
209
|
+
await authorizeCLI('resources:write', testApp);
|
|
210
|
+
await updateResource({
|
|
211
|
+
appId: app.id,
|
|
212
|
+
resourceName: 'test',
|
|
213
|
+
remote: testApp.defaults.baseURL,
|
|
214
|
+
path: resolveFixture('resources/test-update.json'),
|
|
215
|
+
});
|
|
216
|
+
const resources = await Resource.findAll();
|
|
217
|
+
expect(resources.map((r) => r.toJSON())).toMatchInlineSnapshot(`
|
|
218
|
+
[
|
|
219
|
+
{
|
|
220
|
+
"$created": "1970-01-01T00:00:00.000Z",
|
|
221
|
+
"$updated": "1970-01-01T00:00:00.000Z",
|
|
222
|
+
"email": "test@example.com",
|
|
223
|
+
"id": 1,
|
|
224
|
+
"name": "John Doe",
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
"$created": "1970-01-01T00:00:00.000Z",
|
|
228
|
+
"$updated": "1970-01-01T00:00:00.000Z",
|
|
229
|
+
"email": "test2@example.com",
|
|
230
|
+
"id": 2,
|
|
231
|
+
"name": "Jane Doe",
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
"$created": "1970-01-01T00:00:00.000Z",
|
|
235
|
+
"$updated": "1970-01-01T00:00:00.000Z",
|
|
236
|
+
"id": 3,
|
|
237
|
+
"name": "test name",
|
|
238
|
+
},
|
|
239
|
+
]
|
|
240
|
+
`);
|
|
241
|
+
});
|
|
242
|
+
it('should throw if the resource to be updated does not exist', async () => {
|
|
243
|
+
const resourceDefinition = {
|
|
244
|
+
roles: ['$public'],
|
|
245
|
+
schema: {
|
|
246
|
+
type: 'object',
|
|
247
|
+
additionalProperties: false,
|
|
248
|
+
required: ['name'],
|
|
249
|
+
properties: {
|
|
250
|
+
name: {
|
|
251
|
+
type: 'string',
|
|
252
|
+
},
|
|
253
|
+
email: {
|
|
254
|
+
type: 'string',
|
|
255
|
+
format: 'email',
|
|
256
|
+
},
|
|
257
|
+
},
|
|
197
258
|
},
|
|
198
|
-
}
|
|
199
|
-
{
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
email: 'removed@example.com',
|
|
259
|
+
};
|
|
260
|
+
const app = await App.create({
|
|
261
|
+
path: 'test-app',
|
|
262
|
+
definition: {
|
|
263
|
+
resources: { test: resourceDefinition },
|
|
264
|
+
name: 'Test App',
|
|
265
|
+
defaultPage: 'Test Page',
|
|
206
266
|
},
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
{
|
|
220
|
-
"$created": "1970-01-01T00:00:00.000Z",
|
|
221
|
-
"$updated": "1970-01-01T00:00:00.000Z",
|
|
222
|
-
"email": "test@example.com",
|
|
223
|
-
"id": 1,
|
|
224
|
-
"name": "John Doe",
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
"$created": "1970-01-01T00:00:00.000Z",
|
|
228
|
-
"$updated": "1970-01-01T00:00:00.000Z",
|
|
229
|
-
"email": "test2@example.com",
|
|
230
|
-
"id": 2,
|
|
231
|
-
"name": "Jane Doe",
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
"$created": "1970-01-01T00:00:00.000Z",
|
|
235
|
-
"$updated": "1970-01-01T00:00:00.000Z",
|
|
236
|
-
"id": 3,
|
|
237
|
-
"name": "test name",
|
|
238
|
-
},
|
|
239
|
-
]
|
|
240
|
-
`);
|
|
241
|
-
});
|
|
242
|
-
it('should throw if the resource to be updated does not exist', async () => {
|
|
243
|
-
const resourceDefinition = {
|
|
244
|
-
roles: ['$public'],
|
|
245
|
-
schema: {
|
|
246
|
-
type: 'object',
|
|
247
|
-
additionalProperties: false,
|
|
248
|
-
required: ['name'],
|
|
249
|
-
properties: {
|
|
250
|
-
name: {
|
|
251
|
-
type: 'string',
|
|
267
|
+
vapidPublicKey: 'a',
|
|
268
|
+
vapidPrivateKey: 'b',
|
|
269
|
+
visibility: 'public',
|
|
270
|
+
OrganizationId: organization.id,
|
|
271
|
+
});
|
|
272
|
+
await Resource.bulkCreate([
|
|
273
|
+
{
|
|
274
|
+
id: 1,
|
|
275
|
+
type: 'test',
|
|
276
|
+
AppId: app.id,
|
|
277
|
+
data: {
|
|
278
|
+
name: 'Hello World',
|
|
252
279
|
},
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
id: 2,
|
|
283
|
+
type: 'test',
|
|
284
|
+
AppId: app.id,
|
|
285
|
+
data: {
|
|
286
|
+
name: 'World Hello',
|
|
287
|
+
email: 'hello@example.com',
|
|
256
288
|
},
|
|
257
289
|
},
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
},
|
|
267
|
-
vapidPublicKey: 'a',
|
|
268
|
-
vapidPrivateKey: 'b',
|
|
269
|
-
visibility: 'public',
|
|
270
|
-
OrganizationId: organization.id,
|
|
290
|
+
]);
|
|
291
|
+
await authorizeCLI('resources:write', testApp);
|
|
292
|
+
await expect(() => updateResource({
|
|
293
|
+
appId: app.id,
|
|
294
|
+
resourceName: 'test',
|
|
295
|
+
remote: testApp.defaults.baseURL,
|
|
296
|
+
path: resolveFixture('resources/test-update.json'),
|
|
297
|
+
})).rejects.toThrow('Request failed with status code 404');
|
|
271
298
|
});
|
|
272
|
-
|
|
273
|
-
{
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
299
|
+
it('should not update if there are no IDs in resource file', async () => {
|
|
300
|
+
const resourceDefinition = {
|
|
301
|
+
roles: ['$public'],
|
|
302
|
+
schema: {
|
|
303
|
+
type: 'object',
|
|
304
|
+
additionalProperties: false,
|
|
305
|
+
required: ['name'],
|
|
306
|
+
properties: {
|
|
307
|
+
name: {
|
|
308
|
+
type: 'string',
|
|
309
|
+
},
|
|
310
|
+
email: {
|
|
311
|
+
type: 'string',
|
|
312
|
+
format: 'email',
|
|
313
|
+
},
|
|
314
|
+
},
|
|
279
315
|
},
|
|
280
|
-
}
|
|
281
|
-
{
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
email: 'hello@example.com',
|
|
316
|
+
};
|
|
317
|
+
const app = await App.create({
|
|
318
|
+
path: 'test-app',
|
|
319
|
+
definition: {
|
|
320
|
+
resources: { test: resourceDefinition },
|
|
321
|
+
name: 'Test App',
|
|
322
|
+
defaultPage: 'Test Page',
|
|
288
323
|
},
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
roles: ['$public'],
|
|
302
|
-
schema: {
|
|
303
|
-
type: 'object',
|
|
304
|
-
additionalProperties: false,
|
|
305
|
-
required: ['name'],
|
|
306
|
-
properties: {
|
|
307
|
-
name: {
|
|
308
|
-
type: 'string',
|
|
309
|
-
},
|
|
310
|
-
email: {
|
|
311
|
-
type: 'string',
|
|
312
|
-
format: 'email',
|
|
324
|
+
vapidPublicKey: 'a',
|
|
325
|
+
vapidPrivateKey: 'b',
|
|
326
|
+
visibility: 'public',
|
|
327
|
+
OrganizationId: organization.id,
|
|
328
|
+
});
|
|
329
|
+
await Resource.bulkCreate([
|
|
330
|
+
{
|
|
331
|
+
id: 1,
|
|
332
|
+
type: 'test',
|
|
333
|
+
AppId: app.id,
|
|
334
|
+
data: {
|
|
335
|
+
name: 'Hello World',
|
|
313
336
|
},
|
|
314
337
|
},
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
},
|
|
324
|
-
vapidPublicKey: 'a',
|
|
325
|
-
vapidPrivateKey: 'b',
|
|
326
|
-
visibility: 'public',
|
|
327
|
-
OrganizationId: organization.id,
|
|
328
|
-
});
|
|
329
|
-
await Resource.bulkCreate([
|
|
330
|
-
{
|
|
331
|
-
id: 1,
|
|
332
|
-
type: 'test',
|
|
333
|
-
AppId: app.id,
|
|
334
|
-
data: {
|
|
335
|
-
name: 'Hello World',
|
|
336
|
-
},
|
|
337
|
-
},
|
|
338
|
-
{
|
|
339
|
-
id: 2,
|
|
340
|
-
type: 'test',
|
|
341
|
-
AppId: app.id,
|
|
342
|
-
data: {
|
|
343
|
-
name: 'World Hello',
|
|
344
|
-
email: 'hello@example.com',
|
|
338
|
+
{
|
|
339
|
+
id: 2,
|
|
340
|
+
type: 'test',
|
|
341
|
+
AppId: app.id,
|
|
342
|
+
data: {
|
|
343
|
+
name: 'World Hello',
|
|
344
|
+
email: 'hello@example.com',
|
|
345
|
+
},
|
|
345
346
|
},
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
347
|
+
]);
|
|
348
|
+
await authorizeCLI('resources:write', testApp);
|
|
349
|
+
const resources = await Resource.findAll();
|
|
350
|
+
expect(resources.map((r) => r.toJSON())).toMatchInlineSnapshot(`
|
|
351
|
+
[
|
|
352
|
+
{
|
|
353
|
+
"$created": "1970-01-01T00:00:00.000Z",
|
|
354
|
+
"$updated": "1970-01-01T00:00:00.000Z",
|
|
355
|
+
"id": 1,
|
|
356
|
+
"name": "Hello World",
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
"$created": "1970-01-01T00:00:00.000Z",
|
|
360
|
+
"$updated": "1970-01-01T00:00:00.000Z",
|
|
361
|
+
"email": "hello@example.com",
|
|
362
|
+
"id": 2,
|
|
363
|
+
"name": "World Hello",
|
|
364
|
+
},
|
|
365
|
+
]
|
|
366
|
+
`);
|
|
367
|
+
await updateResource({
|
|
368
|
+
appId: app.id,
|
|
369
|
+
resourceName: 'test',
|
|
370
|
+
remote: testApp.defaults.baseURL,
|
|
371
|
+
path: resolveFixture('resources/test.json'),
|
|
372
|
+
});
|
|
373
|
+
expect(resources.map((r) => r.toJSON())).toMatchInlineSnapshot(`
|
|
374
|
+
[
|
|
375
|
+
{
|
|
376
|
+
"$created": "1970-01-01T00:00:00.000Z",
|
|
377
|
+
"$updated": "1970-01-01T00:00:00.000Z",
|
|
378
|
+
"id": 1,
|
|
379
|
+
"name": "Hello World",
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
"$created": "1970-01-01T00:00:00.000Z",
|
|
383
|
+
"$updated": "1970-01-01T00:00:00.000Z",
|
|
384
|
+
"email": "hello@example.com",
|
|
385
|
+
"id": 2,
|
|
386
|
+
"name": "World Hello",
|
|
387
|
+
},
|
|
388
|
+
]
|
|
389
|
+
`);
|
|
372
390
|
});
|
|
373
|
-
expect(resources.map((r) => r.toJSON())).toMatchInlineSnapshot(`
|
|
374
|
-
[
|
|
375
|
-
{
|
|
376
|
-
"$created": "1970-01-01T00:00:00.000Z",
|
|
377
|
-
"$updated": "1970-01-01T00:00:00.000Z",
|
|
378
|
-
"id": 1,
|
|
379
|
-
"name": "Hello World",
|
|
380
|
-
},
|
|
381
|
-
{
|
|
382
|
-
"$created": "1970-01-01T00:00:00.000Z",
|
|
383
|
-
"$updated": "1970-01-01T00:00:00.000Z",
|
|
384
|
-
"email": "hello@example.com",
|
|
385
|
-
"id": 2,
|
|
386
|
-
"name": "World Hello",
|
|
387
|
-
},
|
|
388
|
-
]
|
|
389
|
-
`);
|
|
390
391
|
});
|
|
391
392
|
});
|
|
392
393
|
//# sourceMappingURL=resource.test.js.map
|