@nocobase/test 1.4.0-beta.1 → 1.4.0-beta.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/es/client/index.mjs +2002 -0
- package/es/e2e/index.mjs +22725 -0
- package/es/index.mjs +296 -0
- package/es/web/index.mjs +1600 -0
- package/package.json +3 -3
|
@@ -0,0 +1,2002 @@
|
|
|
1
|
+
import { waitFor, screen, render } from "@testing-library/react";
|
|
2
|
+
export * from "@testing-library/react";
|
|
3
|
+
import { observer, useForm, useFieldSchema } from "@formily/react";
|
|
4
|
+
import MockAdapter from "axios-mock-adapter";
|
|
5
|
+
import _, { pick, get } from "lodash";
|
|
6
|
+
import React, { Fragment } from "react";
|
|
7
|
+
import { Application, AntdSchemaComponentPlugin, SchemaSettingsPlugin, CollectionPlugin, LocalDataSource, SchemaSettings, SchemaComponent, DataBlockProvider } from "@nocobase/client";
|
|
8
|
+
import { expect as expect$1 } from "vitest";
|
|
9
|
+
import userEvent from "@testing-library/user-event";
|
|
10
|
+
import { default as default2 } from "@testing-library/user-event";
|
|
11
|
+
import { renderHook } from "@testing-library/react-hooks";
|
|
12
|
+
import { renderHook as renderHook2 } from "@testing-library/react-hooks";
|
|
13
|
+
const key = "data-source2";
|
|
14
|
+
const displayName = "Data Source 2";
|
|
15
|
+
const status = "loaded";
|
|
16
|
+
const type = "postgres";
|
|
17
|
+
const isDBInstance = true;
|
|
18
|
+
const collections = [
|
|
19
|
+
{
|
|
20
|
+
name: "test",
|
|
21
|
+
title: "test",
|
|
22
|
+
tableName: "test",
|
|
23
|
+
timestamps: false,
|
|
24
|
+
autoGenId: false,
|
|
25
|
+
filterTargetKey: "id",
|
|
26
|
+
fields: [
|
|
27
|
+
{
|
|
28
|
+
name: "id",
|
|
29
|
+
type: "integer",
|
|
30
|
+
allowNull: false,
|
|
31
|
+
primaryKey: false,
|
|
32
|
+
unique: false,
|
|
33
|
+
autoIncrement: true,
|
|
34
|
+
possibleTypes: [
|
|
35
|
+
"integer",
|
|
36
|
+
"sort"
|
|
37
|
+
],
|
|
38
|
+
rawType: "INTEGER",
|
|
39
|
+
"interface": "integer",
|
|
40
|
+
uiSchema: {
|
|
41
|
+
type: "number",
|
|
42
|
+
"x-component": "InputNumber",
|
|
43
|
+
"x-component-props": {
|
|
44
|
+
stringMode: true,
|
|
45
|
+
step: "1"
|
|
46
|
+
},
|
|
47
|
+
"x-validator": "integer",
|
|
48
|
+
title: "id"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "title",
|
|
53
|
+
type: "string",
|
|
54
|
+
allowNull: false,
|
|
55
|
+
primaryKey: false,
|
|
56
|
+
unique: false,
|
|
57
|
+
possibleTypes: [
|
|
58
|
+
"string",
|
|
59
|
+
"uuid",
|
|
60
|
+
"nanoid"
|
|
61
|
+
],
|
|
62
|
+
rawType: "CHARACTER VARYING(255)",
|
|
63
|
+
"interface": "input",
|
|
64
|
+
uiSchema: {
|
|
65
|
+
"x-component": "Input",
|
|
66
|
+
"x-component-props": {
|
|
67
|
+
style: {
|
|
68
|
+
width: "100%"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
title: "title"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: "content",
|
|
76
|
+
type: "text",
|
|
77
|
+
allowNull: true,
|
|
78
|
+
primaryKey: false,
|
|
79
|
+
unique: false,
|
|
80
|
+
rawType: "TEXT",
|
|
81
|
+
"interface": "textarea",
|
|
82
|
+
uiSchema: {
|
|
83
|
+
type: "string",
|
|
84
|
+
"x-component": "Input.TextArea",
|
|
85
|
+
title: "content"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
],
|
|
89
|
+
introspected: true
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "test2",
|
|
93
|
+
title: "test2",
|
|
94
|
+
tableName: "test2",
|
|
95
|
+
timestamps: false,
|
|
96
|
+
autoGenId: false,
|
|
97
|
+
filterTargetKey: "id",
|
|
98
|
+
fields: [
|
|
99
|
+
{
|
|
100
|
+
name: "id",
|
|
101
|
+
type: "integer",
|
|
102
|
+
allowNull: false,
|
|
103
|
+
primaryKey: true,
|
|
104
|
+
unique: false,
|
|
105
|
+
autoIncrement: true,
|
|
106
|
+
possibleTypes: [
|
|
107
|
+
"integer",
|
|
108
|
+
"sort"
|
|
109
|
+
],
|
|
110
|
+
rawType: "INTEGER",
|
|
111
|
+
"interface": "integer",
|
|
112
|
+
uiSchema: {
|
|
113
|
+
type: "number",
|
|
114
|
+
"x-component": "InputNumber",
|
|
115
|
+
"x-component-props": {
|
|
116
|
+
stringMode: true,
|
|
117
|
+
step: "1"
|
|
118
|
+
},
|
|
119
|
+
"x-validator": "integer",
|
|
120
|
+
title: "id"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: "title",
|
|
125
|
+
type: "string",
|
|
126
|
+
allowNull: true,
|
|
127
|
+
primaryKey: false,
|
|
128
|
+
unique: false,
|
|
129
|
+
possibleTypes: [
|
|
130
|
+
"string",
|
|
131
|
+
"uuid",
|
|
132
|
+
"nanoid"
|
|
133
|
+
],
|
|
134
|
+
rawType: "CHARACTER VARYING(255)",
|
|
135
|
+
"interface": "input",
|
|
136
|
+
uiSchema: {
|
|
137
|
+
"x-component": "Input",
|
|
138
|
+
"x-component-props": {
|
|
139
|
+
style: {
|
|
140
|
+
width: "100%"
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
title: "title"
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: "content",
|
|
148
|
+
type: "text",
|
|
149
|
+
allowNull: true,
|
|
150
|
+
primaryKey: false,
|
|
151
|
+
unique: false,
|
|
152
|
+
rawType: "TEXT",
|
|
153
|
+
"interface": "textarea",
|
|
154
|
+
uiSchema: {
|
|
155
|
+
type: "string",
|
|
156
|
+
"x-component": "Input.TextArea",
|
|
157
|
+
title: "content"
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
],
|
|
161
|
+
introspected: true
|
|
162
|
+
}
|
|
163
|
+
];
|
|
164
|
+
const dataSource2 = {
|
|
165
|
+
key,
|
|
166
|
+
displayName,
|
|
167
|
+
status,
|
|
168
|
+
type,
|
|
169
|
+
isDBInstance,
|
|
170
|
+
collections
|
|
171
|
+
};
|
|
172
|
+
const dataSourceMainCollections = [
|
|
173
|
+
{
|
|
174
|
+
key: "yzowed2vee0",
|
|
175
|
+
name: "users",
|
|
176
|
+
title: '{{t("Users")}}',
|
|
177
|
+
inherit: false,
|
|
178
|
+
hidden: false,
|
|
179
|
+
description: null,
|
|
180
|
+
fields: [
|
|
181
|
+
{
|
|
182
|
+
key: "6m3kn2pytkc",
|
|
183
|
+
name: "id",
|
|
184
|
+
type: "bigInt",
|
|
185
|
+
"interface": "id",
|
|
186
|
+
description: null,
|
|
187
|
+
collectionName: "users",
|
|
188
|
+
parentKey: null,
|
|
189
|
+
reverseKey: null,
|
|
190
|
+
autoIncrement: true,
|
|
191
|
+
primaryKey: true,
|
|
192
|
+
allowNull: false,
|
|
193
|
+
uiSchema: {
|
|
194
|
+
type: "number",
|
|
195
|
+
title: '{{t("ID")}}',
|
|
196
|
+
"x-component": "InputNumber",
|
|
197
|
+
"x-read-pretty": true
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
key: "8douy9r69x5",
|
|
202
|
+
name: "nickname",
|
|
203
|
+
type: "string",
|
|
204
|
+
"interface": "input",
|
|
205
|
+
description: null,
|
|
206
|
+
collectionName: "users",
|
|
207
|
+
parentKey: null,
|
|
208
|
+
reverseKey: null,
|
|
209
|
+
uiSchema: {
|
|
210
|
+
type: "string",
|
|
211
|
+
title: '{{t("Nickname")}}',
|
|
212
|
+
"x-component": "Input"
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
key: "vp191ptc0d7",
|
|
217
|
+
name: "username",
|
|
218
|
+
type: "string",
|
|
219
|
+
"interface": "input",
|
|
220
|
+
description: null,
|
|
221
|
+
collectionName: "users",
|
|
222
|
+
parentKey: null,
|
|
223
|
+
reverseKey: null,
|
|
224
|
+
unique: true,
|
|
225
|
+
uiSchema: {
|
|
226
|
+
type: "string",
|
|
227
|
+
title: '{{t("Username")}}',
|
|
228
|
+
"x-component": "Input",
|
|
229
|
+
"x-validator": {
|
|
230
|
+
username: true
|
|
231
|
+
},
|
|
232
|
+
required: true
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
key: "47o82qhkvdm",
|
|
237
|
+
name: "email",
|
|
238
|
+
type: "string",
|
|
239
|
+
"interface": "email",
|
|
240
|
+
description: null,
|
|
241
|
+
collectionName: "users",
|
|
242
|
+
parentKey: null,
|
|
243
|
+
reverseKey: null,
|
|
244
|
+
unique: true,
|
|
245
|
+
uiSchema: {
|
|
246
|
+
type: "string",
|
|
247
|
+
title: '{{t("Email")}}',
|
|
248
|
+
"x-component": "Input",
|
|
249
|
+
"x-validator": "email",
|
|
250
|
+
required: true
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
key: "q5i9ynhq325",
|
|
255
|
+
name: "phone",
|
|
256
|
+
type: "string",
|
|
257
|
+
"interface": "phone",
|
|
258
|
+
description: null,
|
|
259
|
+
collectionName: "users",
|
|
260
|
+
parentKey: null,
|
|
261
|
+
reverseKey: null,
|
|
262
|
+
unique: true,
|
|
263
|
+
uiSchema: {
|
|
264
|
+
type: "string",
|
|
265
|
+
title: '{{t("Phone")}}',
|
|
266
|
+
"x-component": "Input",
|
|
267
|
+
"x-validator": "phone",
|
|
268
|
+
required: true
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
key: "cc4aslvh9dv",
|
|
273
|
+
name: "password",
|
|
274
|
+
type: "password",
|
|
275
|
+
"interface": "password",
|
|
276
|
+
description: null,
|
|
277
|
+
collectionName: "users",
|
|
278
|
+
parentKey: null,
|
|
279
|
+
reverseKey: null,
|
|
280
|
+
hidden: true,
|
|
281
|
+
uiSchema: {
|
|
282
|
+
type: "string",
|
|
283
|
+
title: '{{t("Password")}}',
|
|
284
|
+
"x-component": "Password"
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
key: "e87ndyttazh",
|
|
289
|
+
name: "appLang",
|
|
290
|
+
type: "string",
|
|
291
|
+
"interface": null,
|
|
292
|
+
description: null,
|
|
293
|
+
collectionName: "users",
|
|
294
|
+
parentKey: null,
|
|
295
|
+
reverseKey: null
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
key: "snfbet0pe49",
|
|
299
|
+
name: "resetToken",
|
|
300
|
+
type: "string",
|
|
301
|
+
"interface": null,
|
|
302
|
+
description: null,
|
|
303
|
+
collectionName: "users",
|
|
304
|
+
parentKey: null,
|
|
305
|
+
reverseKey: null,
|
|
306
|
+
unique: true,
|
|
307
|
+
hidden: true
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
key: "j78yhz6wifd",
|
|
311
|
+
name: "systemSettings",
|
|
312
|
+
type: "json",
|
|
313
|
+
"interface": null,
|
|
314
|
+
description: null,
|
|
315
|
+
collectionName: "users",
|
|
316
|
+
parentKey: null,
|
|
317
|
+
reverseKey: null,
|
|
318
|
+
defaultValue: {}
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
key: "lkxqml8gchd",
|
|
322
|
+
name: "sort",
|
|
323
|
+
type: "sort",
|
|
324
|
+
"interface": null,
|
|
325
|
+
description: null,
|
|
326
|
+
collectionName: "users",
|
|
327
|
+
parentKey: null,
|
|
328
|
+
reverseKey: null,
|
|
329
|
+
hidden: true
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
key: "lt3pcrjngzc",
|
|
333
|
+
name: "createdById",
|
|
334
|
+
type: "context",
|
|
335
|
+
"interface": null,
|
|
336
|
+
description: null,
|
|
337
|
+
collectionName: "users",
|
|
338
|
+
parentKey: null,
|
|
339
|
+
reverseKey: null,
|
|
340
|
+
dataType: "bigInt",
|
|
341
|
+
dataIndex: "state.currentUser.id",
|
|
342
|
+
createOnly: true,
|
|
343
|
+
visible: true,
|
|
344
|
+
index: true
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
key: "lcfaf27uxyz",
|
|
348
|
+
name: "createdBy",
|
|
349
|
+
type: "belongsTo",
|
|
350
|
+
"interface": null,
|
|
351
|
+
description: null,
|
|
352
|
+
collectionName: "users",
|
|
353
|
+
parentKey: null,
|
|
354
|
+
reverseKey: null,
|
|
355
|
+
target: "users",
|
|
356
|
+
foreignKey: "createdById",
|
|
357
|
+
targetKey: "id"
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
key: "y6lwdb31r5t",
|
|
361
|
+
name: "updatedById",
|
|
362
|
+
type: "context",
|
|
363
|
+
"interface": null,
|
|
364
|
+
description: null,
|
|
365
|
+
collectionName: "users",
|
|
366
|
+
parentKey: null,
|
|
367
|
+
reverseKey: null,
|
|
368
|
+
dataType: "bigInt",
|
|
369
|
+
dataIndex: "state.currentUser.id",
|
|
370
|
+
visible: true,
|
|
371
|
+
index: true
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
key: "exhbmthsin0",
|
|
375
|
+
name: "updatedBy",
|
|
376
|
+
type: "belongsTo",
|
|
377
|
+
"interface": null,
|
|
378
|
+
description: null,
|
|
379
|
+
collectionName: "users",
|
|
380
|
+
parentKey: null,
|
|
381
|
+
reverseKey: null,
|
|
382
|
+
target: "users",
|
|
383
|
+
foreignKey: "updatedById",
|
|
384
|
+
targetKey: "id"
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
key: "s921nnlzdwi",
|
|
388
|
+
name: "roles",
|
|
389
|
+
type: "belongsToMany",
|
|
390
|
+
"interface": "m2m",
|
|
391
|
+
description: null,
|
|
392
|
+
collectionName: "users",
|
|
393
|
+
parentKey: null,
|
|
394
|
+
reverseKey: null,
|
|
395
|
+
target: "roles",
|
|
396
|
+
foreignKey: "userId",
|
|
397
|
+
otherKey: "roleName",
|
|
398
|
+
onDelete: "CASCADE",
|
|
399
|
+
sourceKey: "id",
|
|
400
|
+
targetKey: "name",
|
|
401
|
+
through: "rolesUsers",
|
|
402
|
+
uiSchema: {
|
|
403
|
+
type: "array",
|
|
404
|
+
title: '{{t("Roles")}}',
|
|
405
|
+
"x-component": "AssociationField",
|
|
406
|
+
"x-component-props": {
|
|
407
|
+
multiple: true,
|
|
408
|
+
fieldNames: {
|
|
409
|
+
label: "title",
|
|
410
|
+
value: "name"
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
key: "qe7b1rsct5h",
|
|
417
|
+
name: "jobs",
|
|
418
|
+
type: "belongsToMany",
|
|
419
|
+
"interface": null,
|
|
420
|
+
description: null,
|
|
421
|
+
collectionName: "users",
|
|
422
|
+
parentKey: null,
|
|
423
|
+
reverseKey: null,
|
|
424
|
+
through: "users_jobs",
|
|
425
|
+
foreignKey: "userId",
|
|
426
|
+
sourceKey: "id",
|
|
427
|
+
otherKey: "jobId",
|
|
428
|
+
targetKey: "id",
|
|
429
|
+
target: "jobs"
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
key: "vt0n1l1ruyz",
|
|
433
|
+
name: "usersJobs",
|
|
434
|
+
type: "hasMany",
|
|
435
|
+
"interface": null,
|
|
436
|
+
description: null,
|
|
437
|
+
collectionName: "users",
|
|
438
|
+
parentKey: null,
|
|
439
|
+
reverseKey: null,
|
|
440
|
+
target: "users_jobs",
|
|
441
|
+
foreignKey: "userId",
|
|
442
|
+
sourceKey: "id",
|
|
443
|
+
targetKey: "id"
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
key: "ekol7p60nry",
|
|
447
|
+
name: "sortName",
|
|
448
|
+
type: "sort",
|
|
449
|
+
"interface": "sort",
|
|
450
|
+
description: null,
|
|
451
|
+
collectionName: "users",
|
|
452
|
+
parentKey: null,
|
|
453
|
+
reverseKey: null,
|
|
454
|
+
uiSchema: {
|
|
455
|
+
type: "number",
|
|
456
|
+
"x-component": "InputNumber",
|
|
457
|
+
"x-component-props": {
|
|
458
|
+
stringMode: true,
|
|
459
|
+
step: "1"
|
|
460
|
+
},
|
|
461
|
+
"x-validator": "integer",
|
|
462
|
+
title: "sort"
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
],
|
|
466
|
+
category: [],
|
|
467
|
+
origin: "@nocobase/plugin-users",
|
|
468
|
+
dumpRules: {
|
|
469
|
+
group: "user"
|
|
470
|
+
},
|
|
471
|
+
sortable: "sort",
|
|
472
|
+
model: "UserModel",
|
|
473
|
+
createdBy: true,
|
|
474
|
+
updatedBy: true,
|
|
475
|
+
logging: true,
|
|
476
|
+
shared: true,
|
|
477
|
+
from: "db2cm",
|
|
478
|
+
filterTargetKey: "id"
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
key: "rmx938ttbue",
|
|
482
|
+
name: "roles",
|
|
483
|
+
title: '{{t("Roles")}}',
|
|
484
|
+
inherit: false,
|
|
485
|
+
hidden: false,
|
|
486
|
+
description: null,
|
|
487
|
+
fields: [
|
|
488
|
+
{
|
|
489
|
+
key: "l6thu4n5u6x",
|
|
490
|
+
name: "name",
|
|
491
|
+
type: "uid",
|
|
492
|
+
"interface": "input",
|
|
493
|
+
description: null,
|
|
494
|
+
collectionName: "roles",
|
|
495
|
+
parentKey: null,
|
|
496
|
+
reverseKey: null,
|
|
497
|
+
prefix: "r_",
|
|
498
|
+
primaryKey: true,
|
|
499
|
+
uiSchema: {
|
|
500
|
+
type: "string",
|
|
501
|
+
title: '{{t("Role UID")}}',
|
|
502
|
+
"x-component": "Input"
|
|
503
|
+
}
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
key: "yhfq9yv8z0p",
|
|
507
|
+
name: "title",
|
|
508
|
+
type: "string",
|
|
509
|
+
"interface": "input",
|
|
510
|
+
description: null,
|
|
511
|
+
collectionName: "roles",
|
|
512
|
+
parentKey: null,
|
|
513
|
+
reverseKey: null,
|
|
514
|
+
unique: true,
|
|
515
|
+
uiSchema: {
|
|
516
|
+
type: "string",
|
|
517
|
+
title: '{{t("Role name")}}',
|
|
518
|
+
"x-component": "Input"
|
|
519
|
+
},
|
|
520
|
+
translation: true
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
key: "vnhjlmopfuz",
|
|
524
|
+
name: "description",
|
|
525
|
+
type: "string",
|
|
526
|
+
"interface": null,
|
|
527
|
+
description: null,
|
|
528
|
+
collectionName: "roles",
|
|
529
|
+
parentKey: null,
|
|
530
|
+
reverseKey: null
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
key: "s4iqsehgxo6",
|
|
534
|
+
name: "strategy",
|
|
535
|
+
type: "json",
|
|
536
|
+
"interface": null,
|
|
537
|
+
description: null,
|
|
538
|
+
collectionName: "roles",
|
|
539
|
+
parentKey: null,
|
|
540
|
+
reverseKey: null
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
key: "75e4wnv873m",
|
|
544
|
+
name: "default",
|
|
545
|
+
type: "boolean",
|
|
546
|
+
"interface": null,
|
|
547
|
+
description: null,
|
|
548
|
+
collectionName: "roles",
|
|
549
|
+
parentKey: null,
|
|
550
|
+
reverseKey: null,
|
|
551
|
+
defaultValue: false
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
key: "nofdv0gte68",
|
|
555
|
+
name: "hidden",
|
|
556
|
+
type: "boolean",
|
|
557
|
+
"interface": null,
|
|
558
|
+
description: null,
|
|
559
|
+
collectionName: "roles",
|
|
560
|
+
parentKey: null,
|
|
561
|
+
reverseKey: null,
|
|
562
|
+
defaultValue: false
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
key: "bogzo1uvk84",
|
|
566
|
+
name: "allowConfigure",
|
|
567
|
+
type: "boolean",
|
|
568
|
+
"interface": null,
|
|
569
|
+
description: null,
|
|
570
|
+
collectionName: "roles",
|
|
571
|
+
parentKey: null,
|
|
572
|
+
reverseKey: null
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
key: "k3fvj8ddpp9",
|
|
576
|
+
name: "allowNewMenu",
|
|
577
|
+
type: "boolean",
|
|
578
|
+
"interface": null,
|
|
579
|
+
description: null,
|
|
580
|
+
collectionName: "roles",
|
|
581
|
+
parentKey: null,
|
|
582
|
+
reverseKey: null
|
|
583
|
+
},
|
|
584
|
+
{
|
|
585
|
+
key: "v1ditqsv1uk",
|
|
586
|
+
name: "menuUiSchemas",
|
|
587
|
+
type: "belongsToMany",
|
|
588
|
+
"interface": null,
|
|
589
|
+
description: null,
|
|
590
|
+
collectionName: "roles",
|
|
591
|
+
parentKey: null,
|
|
592
|
+
reverseKey: null,
|
|
593
|
+
target: "uiSchemas",
|
|
594
|
+
targetKey: "x-uid",
|
|
595
|
+
foreignKey: "roleName",
|
|
596
|
+
sourceKey: "name",
|
|
597
|
+
otherKey: "uiSchemaXUid",
|
|
598
|
+
through: "rolesUischemas"
|
|
599
|
+
},
|
|
600
|
+
{
|
|
601
|
+
key: "ccqhlcvgnz8",
|
|
602
|
+
name: "resources",
|
|
603
|
+
type: "hasMany",
|
|
604
|
+
"interface": null,
|
|
605
|
+
description: null,
|
|
606
|
+
collectionName: "roles",
|
|
607
|
+
parentKey: null,
|
|
608
|
+
reverseKey: null,
|
|
609
|
+
target: "dataSourcesRolesResources",
|
|
610
|
+
sourceKey: "name",
|
|
611
|
+
foreignKey: "roleName",
|
|
612
|
+
targetKey: "id"
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
key: "s4fshtx7oxv",
|
|
616
|
+
name: "snippets",
|
|
617
|
+
type: "set",
|
|
618
|
+
"interface": null,
|
|
619
|
+
description: null,
|
|
620
|
+
collectionName: "roles",
|
|
621
|
+
parentKey: null,
|
|
622
|
+
reverseKey: null,
|
|
623
|
+
defaultValue: [
|
|
624
|
+
"!ui.*",
|
|
625
|
+
"!pm",
|
|
626
|
+
"!pm.*"
|
|
627
|
+
]
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
key: "oyzvbhc60mp",
|
|
631
|
+
name: "users",
|
|
632
|
+
type: "belongsToMany",
|
|
633
|
+
"interface": null,
|
|
634
|
+
description: null,
|
|
635
|
+
collectionName: "roles",
|
|
636
|
+
parentKey: null,
|
|
637
|
+
reverseKey: null,
|
|
638
|
+
target: "users",
|
|
639
|
+
foreignKey: "roleName",
|
|
640
|
+
otherKey: "userId",
|
|
641
|
+
onDelete: "CASCADE",
|
|
642
|
+
sourceKey: "name",
|
|
643
|
+
targetKey: "id",
|
|
644
|
+
through: "rolesUsers"
|
|
645
|
+
},
|
|
646
|
+
{
|
|
647
|
+
key: "89yklh7lm3p",
|
|
648
|
+
name: "sort",
|
|
649
|
+
type: "sort",
|
|
650
|
+
"interface": null,
|
|
651
|
+
description: null,
|
|
652
|
+
collectionName: "roles",
|
|
653
|
+
parentKey: null,
|
|
654
|
+
reverseKey: null,
|
|
655
|
+
hidden: true
|
|
656
|
+
},
|
|
657
|
+
{
|
|
658
|
+
key: "iz5s22dinui",
|
|
659
|
+
name: "color",
|
|
660
|
+
type: "string",
|
|
661
|
+
"interface": "color",
|
|
662
|
+
description: null,
|
|
663
|
+
collectionName: "roles",
|
|
664
|
+
parentKey: null,
|
|
665
|
+
reverseKey: null,
|
|
666
|
+
defaultValue: "#1677FF",
|
|
667
|
+
uiSchema: {
|
|
668
|
+
type: "string",
|
|
669
|
+
"x-component": "ColorPicker",
|
|
670
|
+
"default": "#1677FF",
|
|
671
|
+
title: "color"
|
|
672
|
+
}
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
key: "o5nyb6isl62",
|
|
676
|
+
name: "long-text",
|
|
677
|
+
type: "text",
|
|
678
|
+
"interface": "textarea",
|
|
679
|
+
description: null,
|
|
680
|
+
collectionName: "roles",
|
|
681
|
+
parentKey: null,
|
|
682
|
+
reverseKey: null,
|
|
683
|
+
uiSchema: {
|
|
684
|
+
type: "string",
|
|
685
|
+
"x-component": "Input.TextArea",
|
|
686
|
+
title: "Long text"
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
],
|
|
690
|
+
category: [],
|
|
691
|
+
origin: "@nocobase/plugin-acl",
|
|
692
|
+
dumpRules: "required",
|
|
693
|
+
autoGenId: false,
|
|
694
|
+
model: "RoleModel",
|
|
695
|
+
filterTargetKey: "name",
|
|
696
|
+
sortable: true,
|
|
697
|
+
from: "db2cm"
|
|
698
|
+
},
|
|
699
|
+
{
|
|
700
|
+
key: "24gntrrr5a6",
|
|
701
|
+
name: "tree",
|
|
702
|
+
title: "TreeCollection",
|
|
703
|
+
inherit: false,
|
|
704
|
+
hidden: false,
|
|
705
|
+
description: null,
|
|
706
|
+
fields: [
|
|
707
|
+
{
|
|
708
|
+
key: "pcea3h3ivkg",
|
|
709
|
+
name: "parentId",
|
|
710
|
+
type: "bigInt",
|
|
711
|
+
"interface": "integer",
|
|
712
|
+
description: null,
|
|
713
|
+
collectionName: "t_4uamm7v51dj",
|
|
714
|
+
parentKey: null,
|
|
715
|
+
reverseKey: null,
|
|
716
|
+
isForeignKey: true,
|
|
717
|
+
uiSchema: {
|
|
718
|
+
type: "number",
|
|
719
|
+
title: '{{t("Parent ID")}}',
|
|
720
|
+
"x-component": "InputNumber",
|
|
721
|
+
"x-read-pretty": true
|
|
722
|
+
},
|
|
723
|
+
target: "t_4uamm7v51dj"
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
key: "185j2rf7o68",
|
|
727
|
+
name: "parent",
|
|
728
|
+
type: "belongsTo",
|
|
729
|
+
"interface": "m2o",
|
|
730
|
+
description: null,
|
|
731
|
+
collectionName: "t_4uamm7v51dj",
|
|
732
|
+
parentKey: null,
|
|
733
|
+
reverseKey: null,
|
|
734
|
+
foreignKey: "parentId",
|
|
735
|
+
treeParent: true,
|
|
736
|
+
onDelete: "CASCADE",
|
|
737
|
+
uiSchema: {
|
|
738
|
+
title: '{{t("Parent")}}',
|
|
739
|
+
"x-component": "AssociationField",
|
|
740
|
+
"x-component-props": {
|
|
741
|
+
multiple: false,
|
|
742
|
+
fieldNames: {
|
|
743
|
+
label: "id",
|
|
744
|
+
value: "id"
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
},
|
|
748
|
+
target: "t_4uamm7v51dj",
|
|
749
|
+
targetKey: "id"
|
|
750
|
+
},
|
|
751
|
+
{
|
|
752
|
+
key: "gjvso3p9sjn",
|
|
753
|
+
name: "children",
|
|
754
|
+
type: "hasMany",
|
|
755
|
+
"interface": "o2m",
|
|
756
|
+
description: null,
|
|
757
|
+
collectionName: "t_4uamm7v51dj",
|
|
758
|
+
parentKey: null,
|
|
759
|
+
reverseKey: null,
|
|
760
|
+
foreignKey: "parentId",
|
|
761
|
+
treeChildren: true,
|
|
762
|
+
onDelete: "CASCADE",
|
|
763
|
+
uiSchema: {
|
|
764
|
+
title: '{{t("Children")}}',
|
|
765
|
+
"x-component": "AssociationField",
|
|
766
|
+
"x-component-props": {
|
|
767
|
+
multiple: true,
|
|
768
|
+
fieldNames: {
|
|
769
|
+
label: "id",
|
|
770
|
+
value: "id"
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
},
|
|
774
|
+
target: "t_4uamm7v51dj",
|
|
775
|
+
targetKey: "id",
|
|
776
|
+
sourceKey: "id"
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
key: "j50f3am3c88",
|
|
780
|
+
name: "id",
|
|
781
|
+
type: "bigInt",
|
|
782
|
+
"interface": "integer",
|
|
783
|
+
description: null,
|
|
784
|
+
collectionName: "t_4uamm7v51dj",
|
|
785
|
+
parentKey: null,
|
|
786
|
+
reverseKey: null,
|
|
787
|
+
autoIncrement: true,
|
|
788
|
+
primaryKey: true,
|
|
789
|
+
allowNull: false,
|
|
790
|
+
uiSchema: {
|
|
791
|
+
type: "number",
|
|
792
|
+
title: '{{t("ID")}}',
|
|
793
|
+
"x-component": "InputNumber",
|
|
794
|
+
"x-read-pretty": true
|
|
795
|
+
},
|
|
796
|
+
target: "t_4uamm7v51dj"
|
|
797
|
+
},
|
|
798
|
+
{
|
|
799
|
+
key: "9szmn2ecqgs",
|
|
800
|
+
name: "f_y99u3pyj0bt",
|
|
801
|
+
type: "string",
|
|
802
|
+
"interface": "input",
|
|
803
|
+
description: null,
|
|
804
|
+
collectionName: "t_4uamm7v51dj",
|
|
805
|
+
parentKey: null,
|
|
806
|
+
reverseKey: null,
|
|
807
|
+
uiSchema: {
|
|
808
|
+
type: "string",
|
|
809
|
+
"x-component": "Input",
|
|
810
|
+
title: "Single line text"
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
],
|
|
814
|
+
category: [],
|
|
815
|
+
logging: true,
|
|
816
|
+
autoGenId: true,
|
|
817
|
+
createdAt: false,
|
|
818
|
+
createdBy: false,
|
|
819
|
+
updatedAt: false,
|
|
820
|
+
updatedBy: false,
|
|
821
|
+
template: "tree",
|
|
822
|
+
view: false,
|
|
823
|
+
tree: "adjacencyList",
|
|
824
|
+
filterTargetKey: "id"
|
|
825
|
+
},
|
|
826
|
+
{
|
|
827
|
+
key: "16ocj2rsg3t",
|
|
828
|
+
name: "interfaces",
|
|
829
|
+
title: "Interfaces",
|
|
830
|
+
inherit: false,
|
|
831
|
+
hidden: false,
|
|
832
|
+
description: null,
|
|
833
|
+
fields: [
|
|
834
|
+
{
|
|
835
|
+
key: "k2v39l19inp",
|
|
836
|
+
name: "id",
|
|
837
|
+
type: "bigInt",
|
|
838
|
+
"interface": "integer",
|
|
839
|
+
description: null,
|
|
840
|
+
collectionName: "interfaces",
|
|
841
|
+
parentKey: null,
|
|
842
|
+
reverseKey: null,
|
|
843
|
+
autoIncrement: true,
|
|
844
|
+
primaryKey: true,
|
|
845
|
+
allowNull: false,
|
|
846
|
+
uiSchema: {
|
|
847
|
+
type: "number",
|
|
848
|
+
title: '{{t("ID")}}',
|
|
849
|
+
"x-component": "InputNumber",
|
|
850
|
+
"x-read-pretty": true
|
|
851
|
+
}
|
|
852
|
+
},
|
|
853
|
+
{
|
|
854
|
+
key: "gfnqdj8sd01",
|
|
855
|
+
name: "createdAt",
|
|
856
|
+
type: "date",
|
|
857
|
+
"interface": "createdAt",
|
|
858
|
+
description: null,
|
|
859
|
+
collectionName: "interfaces",
|
|
860
|
+
parentKey: null,
|
|
861
|
+
reverseKey: null,
|
|
862
|
+
field: "createdAt",
|
|
863
|
+
uiSchema: {
|
|
864
|
+
type: "datetime",
|
|
865
|
+
title: '{{t("Created at")}}',
|
|
866
|
+
"x-component": "DatePicker",
|
|
867
|
+
"x-component-props": {},
|
|
868
|
+
"x-read-pretty": true
|
|
869
|
+
}
|
|
870
|
+
},
|
|
871
|
+
{
|
|
872
|
+
key: "3ddqrb1lle5",
|
|
873
|
+
name: "createdBy",
|
|
874
|
+
type: "belongsTo",
|
|
875
|
+
"interface": "createdBy",
|
|
876
|
+
description: null,
|
|
877
|
+
collectionName: "interfaces",
|
|
878
|
+
parentKey: null,
|
|
879
|
+
reverseKey: null,
|
|
880
|
+
target: "users",
|
|
881
|
+
foreignKey: "createdById",
|
|
882
|
+
uiSchema: {
|
|
883
|
+
type: "object",
|
|
884
|
+
title: '{{t("Created by")}}',
|
|
885
|
+
"x-component": "AssociationField",
|
|
886
|
+
"x-component-props": {
|
|
887
|
+
fieldNames: {
|
|
888
|
+
value: "id",
|
|
889
|
+
label: "nickname"
|
|
890
|
+
}
|
|
891
|
+
},
|
|
892
|
+
"x-read-pretty": true
|
|
893
|
+
},
|
|
894
|
+
targetKey: "id"
|
|
895
|
+
},
|
|
896
|
+
{
|
|
897
|
+
key: "9nc7gqqw0ht",
|
|
898
|
+
name: "updatedAt",
|
|
899
|
+
type: "date",
|
|
900
|
+
"interface": "updatedAt",
|
|
901
|
+
description: null,
|
|
902
|
+
collectionName: "interfaces",
|
|
903
|
+
parentKey: null,
|
|
904
|
+
reverseKey: null,
|
|
905
|
+
field: "updatedAt",
|
|
906
|
+
uiSchema: {
|
|
907
|
+
type: "string",
|
|
908
|
+
title: '{{t("Last updated at")}}',
|
|
909
|
+
"x-component": "DatePicker",
|
|
910
|
+
"x-component-props": {},
|
|
911
|
+
"x-read-pretty": true
|
|
912
|
+
}
|
|
913
|
+
},
|
|
914
|
+
{
|
|
915
|
+
key: "06wr4f2qi4w",
|
|
916
|
+
name: "updatedBy",
|
|
917
|
+
type: "belongsTo",
|
|
918
|
+
"interface": "updatedBy",
|
|
919
|
+
description: null,
|
|
920
|
+
collectionName: "interfaces",
|
|
921
|
+
parentKey: null,
|
|
922
|
+
reverseKey: null,
|
|
923
|
+
target: "users",
|
|
924
|
+
foreignKey: "updatedById",
|
|
925
|
+
uiSchema: {
|
|
926
|
+
type: "object",
|
|
927
|
+
title: '{{t("Last updated by")}}',
|
|
928
|
+
"x-component": "AssociationField",
|
|
929
|
+
"x-component-props": {
|
|
930
|
+
fieldNames: {
|
|
931
|
+
value: "id",
|
|
932
|
+
label: "nickname"
|
|
933
|
+
}
|
|
934
|
+
},
|
|
935
|
+
"x-read-pretty": true
|
|
936
|
+
},
|
|
937
|
+
targetKey: "id"
|
|
938
|
+
},
|
|
939
|
+
{
|
|
940
|
+
key: "g5beggm3aln",
|
|
941
|
+
name: "nano-iD",
|
|
942
|
+
type: "nanoid",
|
|
943
|
+
"interface": "nanoid",
|
|
944
|
+
description: null,
|
|
945
|
+
collectionName: "interfaces",
|
|
946
|
+
parentKey: null,
|
|
947
|
+
reverseKey: null,
|
|
948
|
+
customAlphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
949
|
+
size: 21,
|
|
950
|
+
autoFill: true,
|
|
951
|
+
uiSchema: {
|
|
952
|
+
type: "string",
|
|
953
|
+
"x-component": "NanoIDInput",
|
|
954
|
+
title: "Nano ID"
|
|
955
|
+
}
|
|
956
|
+
},
|
|
957
|
+
{
|
|
958
|
+
key: "wchbz23orvg",
|
|
959
|
+
name: "attachment",
|
|
960
|
+
type: "belongsToMany",
|
|
961
|
+
"interface": "attachment",
|
|
962
|
+
description: null,
|
|
963
|
+
collectionName: "interfaces",
|
|
964
|
+
parentKey: null,
|
|
965
|
+
reverseKey: null,
|
|
966
|
+
uiSchema: {
|
|
967
|
+
"x-component-props": {
|
|
968
|
+
accept: "image/*",
|
|
969
|
+
multiple: true
|
|
970
|
+
},
|
|
971
|
+
type: "array",
|
|
972
|
+
"x-component": "Upload.Attachment",
|
|
973
|
+
title: "Attachment"
|
|
974
|
+
},
|
|
975
|
+
target: "attachments",
|
|
976
|
+
through: "t_zj0zu7maytd",
|
|
977
|
+
foreignKey: "f_iek1e32gsq0",
|
|
978
|
+
otherKey: "f_dtc6w8dzyoo",
|
|
979
|
+
targetKey: "id",
|
|
980
|
+
sourceKey: "id"
|
|
981
|
+
}
|
|
982
|
+
],
|
|
983
|
+
category: [],
|
|
984
|
+
logging: true,
|
|
985
|
+
autoGenId: true,
|
|
986
|
+
createdAt: true,
|
|
987
|
+
createdBy: true,
|
|
988
|
+
updatedAt: true,
|
|
989
|
+
updatedBy: true,
|
|
990
|
+
template: "general",
|
|
991
|
+
view: false,
|
|
992
|
+
filterTargetKey: "id"
|
|
993
|
+
}
|
|
994
|
+
];
|
|
995
|
+
const dataSourceMainData = {
|
|
996
|
+
"users:list": {
|
|
997
|
+
data: [
|
|
998
|
+
{
|
|
999
|
+
createdAt: "2024-04-07T06:50:37.797Z",
|
|
1000
|
+
updatedAt: "2024-04-07T06:50:37.797Z",
|
|
1001
|
+
appLang: null,
|
|
1002
|
+
createdById: null,
|
|
1003
|
+
email: "admin@nocobase.com",
|
|
1004
|
+
f_1gx8uyn3wva: 1,
|
|
1005
|
+
id: 1,
|
|
1006
|
+
nickname: "Super Admin",
|
|
1007
|
+
phone: null,
|
|
1008
|
+
systemSettings: {},
|
|
1009
|
+
updatedById: null,
|
|
1010
|
+
username: "nocobase",
|
|
1011
|
+
roles: [
|
|
1012
|
+
{
|
|
1013
|
+
createdAt: "2024-04-07T06:50:37.700Z",
|
|
1014
|
+
updatedAt: "2024-04-07T06:50:37.700Z",
|
|
1015
|
+
allowConfigure: null,
|
|
1016
|
+
allowNewMenu: true,
|
|
1017
|
+
"default": true,
|
|
1018
|
+
description: null,
|
|
1019
|
+
hidden: false,
|
|
1020
|
+
color: "#1677FF",
|
|
1021
|
+
name: "member",
|
|
1022
|
+
snippets: [
|
|
1023
|
+
"!pm",
|
|
1024
|
+
"!pm.*",
|
|
1025
|
+
"!ui.*"
|
|
1026
|
+
],
|
|
1027
|
+
strategy: {
|
|
1028
|
+
actions: [
|
|
1029
|
+
"view",
|
|
1030
|
+
"update:own",
|
|
1031
|
+
"destroy:own",
|
|
1032
|
+
"create"
|
|
1033
|
+
]
|
|
1034
|
+
},
|
|
1035
|
+
title: '{{t("Member")}}',
|
|
1036
|
+
rolesUsers: {
|
|
1037
|
+
createdAt: "2024-04-07T06:50:37.854Z",
|
|
1038
|
+
updatedAt: "2024-04-07T06:50:37.854Z",
|
|
1039
|
+
"default": null,
|
|
1040
|
+
roleName: "member",
|
|
1041
|
+
userId: 1
|
|
1042
|
+
}
|
|
1043
|
+
},
|
|
1044
|
+
{
|
|
1045
|
+
createdAt: "2024-04-07T06:50:37.622Z",
|
|
1046
|
+
updatedAt: "2024-04-07T06:50:37.622Z",
|
|
1047
|
+
allowConfigure: null,
|
|
1048
|
+
allowNewMenu: null,
|
|
1049
|
+
"default": false,
|
|
1050
|
+
description: null,
|
|
1051
|
+
hidden: true,
|
|
1052
|
+
color: "#1677FF",
|
|
1053
|
+
name: "root",
|
|
1054
|
+
snippets: [
|
|
1055
|
+
"pm",
|
|
1056
|
+
"pm.*",
|
|
1057
|
+
"ui.*"
|
|
1058
|
+
],
|
|
1059
|
+
strategy: null,
|
|
1060
|
+
title: '{{t("Root")}}',
|
|
1061
|
+
rolesUsers: {
|
|
1062
|
+
createdAt: "2024-04-07T06:50:38.152Z",
|
|
1063
|
+
updatedAt: "2024-04-07T06:50:38.186Z",
|
|
1064
|
+
"default": true,
|
|
1065
|
+
roleName: "root",
|
|
1066
|
+
userId: 1
|
|
1067
|
+
}
|
|
1068
|
+
},
|
|
1069
|
+
{
|
|
1070
|
+
createdAt: "2024-04-07T06:50:37.657Z",
|
|
1071
|
+
updatedAt: "2024-04-07T06:50:37.657Z",
|
|
1072
|
+
allowConfigure: true,
|
|
1073
|
+
allowNewMenu: true,
|
|
1074
|
+
"default": false,
|
|
1075
|
+
description: null,
|
|
1076
|
+
hidden: false,
|
|
1077
|
+
name: "admin",
|
|
1078
|
+
color: "#1677FF",
|
|
1079
|
+
snippets: [
|
|
1080
|
+
"pm",
|
|
1081
|
+
"pm.*",
|
|
1082
|
+
"ui.*"
|
|
1083
|
+
],
|
|
1084
|
+
strategy: {
|
|
1085
|
+
actions: [
|
|
1086
|
+
"create",
|
|
1087
|
+
"view",
|
|
1088
|
+
"update",
|
|
1089
|
+
"destroy"
|
|
1090
|
+
]
|
|
1091
|
+
},
|
|
1092
|
+
title: '{{t("Admin")}}',
|
|
1093
|
+
rolesUsers: {
|
|
1094
|
+
createdAt: "2024-04-07T06:50:38.152Z",
|
|
1095
|
+
updatedAt: "2024-04-07T06:50:38.152Z",
|
|
1096
|
+
"default": null,
|
|
1097
|
+
roleName: "admin",
|
|
1098
|
+
userId: 1
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
]
|
|
1102
|
+
}
|
|
1103
|
+
],
|
|
1104
|
+
meta: {
|
|
1105
|
+
count: 1,
|
|
1106
|
+
page: 1,
|
|
1107
|
+
pageSize: 20,
|
|
1108
|
+
totalPage: 1,
|
|
1109
|
+
allowedActions: {
|
|
1110
|
+
view: [
|
|
1111
|
+
1
|
|
1112
|
+
],
|
|
1113
|
+
update: [
|
|
1114
|
+
1
|
|
1115
|
+
],
|
|
1116
|
+
destroy: []
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
},
|
|
1120
|
+
"users:get": {
|
|
1121
|
+
data: {
|
|
1122
|
+
createdAt: "2024-04-07T06:50:37.797Z",
|
|
1123
|
+
updatedAt: "2024-04-07T06:50:37.797Z",
|
|
1124
|
+
appLang: null,
|
|
1125
|
+
createdById: null,
|
|
1126
|
+
email: "admin@nocobase.com",
|
|
1127
|
+
f_1gx8uyn3wva: 1,
|
|
1128
|
+
id: 1,
|
|
1129
|
+
nickname: "Super Admin",
|
|
1130
|
+
phone: null,
|
|
1131
|
+
systemSettings: {},
|
|
1132
|
+
updatedById: null,
|
|
1133
|
+
username: "nocobase",
|
|
1134
|
+
roles: [
|
|
1135
|
+
{
|
|
1136
|
+
createdAt: "2024-04-07T06:50:37.700Z",
|
|
1137
|
+
updatedAt: "2024-04-07T06:50:37.700Z",
|
|
1138
|
+
allowConfigure: null,
|
|
1139
|
+
allowNewMenu: true,
|
|
1140
|
+
"default": true,
|
|
1141
|
+
description: null,
|
|
1142
|
+
hidden: false,
|
|
1143
|
+
color: "#1677FF",
|
|
1144
|
+
name: "member",
|
|
1145
|
+
snippets: [
|
|
1146
|
+
"!pm",
|
|
1147
|
+
"!pm.*",
|
|
1148
|
+
"!ui.*"
|
|
1149
|
+
],
|
|
1150
|
+
strategy: {
|
|
1151
|
+
actions: [
|
|
1152
|
+
"view",
|
|
1153
|
+
"update:own",
|
|
1154
|
+
"destroy:own",
|
|
1155
|
+
"create"
|
|
1156
|
+
]
|
|
1157
|
+
},
|
|
1158
|
+
title: '{{t("Member")}}',
|
|
1159
|
+
rolesUsers: {
|
|
1160
|
+
createdAt: "2024-04-07T06:50:37.854Z",
|
|
1161
|
+
updatedAt: "2024-04-07T06:50:37.854Z",
|
|
1162
|
+
"default": null,
|
|
1163
|
+
roleName: "member",
|
|
1164
|
+
userId: 1
|
|
1165
|
+
}
|
|
1166
|
+
},
|
|
1167
|
+
{
|
|
1168
|
+
createdAt: "2024-04-07T06:50:37.622Z",
|
|
1169
|
+
updatedAt: "2024-04-07T06:50:37.622Z",
|
|
1170
|
+
allowConfigure: null,
|
|
1171
|
+
allowNewMenu: null,
|
|
1172
|
+
"default": false,
|
|
1173
|
+
description: null,
|
|
1174
|
+
hidden: true,
|
|
1175
|
+
color: "#1677FF",
|
|
1176
|
+
name: "root",
|
|
1177
|
+
snippets: [
|
|
1178
|
+
"pm",
|
|
1179
|
+
"pm.*",
|
|
1180
|
+
"ui.*"
|
|
1181
|
+
],
|
|
1182
|
+
strategy: null,
|
|
1183
|
+
title: '{{t("Root")}}',
|
|
1184
|
+
rolesUsers: {
|
|
1185
|
+
createdAt: "2024-04-07T06:50:38.152Z",
|
|
1186
|
+
updatedAt: "2024-04-07T06:50:38.186Z",
|
|
1187
|
+
"default": true,
|
|
1188
|
+
roleName: "root",
|
|
1189
|
+
userId: 1
|
|
1190
|
+
}
|
|
1191
|
+
},
|
|
1192
|
+
{
|
|
1193
|
+
createdAt: "2024-04-07T06:50:37.657Z",
|
|
1194
|
+
updatedAt: "2024-04-07T06:50:37.657Z",
|
|
1195
|
+
allowConfigure: true,
|
|
1196
|
+
allowNewMenu: true,
|
|
1197
|
+
"default": false,
|
|
1198
|
+
description: null,
|
|
1199
|
+
hidden: false,
|
|
1200
|
+
name: "admin",
|
|
1201
|
+
color: "#1677FF",
|
|
1202
|
+
snippets: [
|
|
1203
|
+
"pm",
|
|
1204
|
+
"pm.*",
|
|
1205
|
+
"ui.*"
|
|
1206
|
+
],
|
|
1207
|
+
strategy: {
|
|
1208
|
+
actions: [
|
|
1209
|
+
"create",
|
|
1210
|
+
"view",
|
|
1211
|
+
"update",
|
|
1212
|
+
"destroy"
|
|
1213
|
+
]
|
|
1214
|
+
},
|
|
1215
|
+
title: '{{t("Admin")}}',
|
|
1216
|
+
rolesUsers: {
|
|
1217
|
+
createdAt: "2024-04-07T06:50:38.152Z",
|
|
1218
|
+
updatedAt: "2024-04-07T06:50:38.152Z",
|
|
1219
|
+
"default": null,
|
|
1220
|
+
roleName: "admin",
|
|
1221
|
+
userId: 1
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
]
|
|
1225
|
+
}
|
|
1226
|
+
},
|
|
1227
|
+
"roles:list": {
|
|
1228
|
+
data: [
|
|
1229
|
+
{
|
|
1230
|
+
createdAt: "2024-04-07T06:50:37.622Z",
|
|
1231
|
+
updatedAt: "2024-04-07T06:50:37.622Z",
|
|
1232
|
+
allowConfigure: null,
|
|
1233
|
+
allowNewMenu: null,
|
|
1234
|
+
"default": false,
|
|
1235
|
+
description: null,
|
|
1236
|
+
hidden: true,
|
|
1237
|
+
name: "root",
|
|
1238
|
+
color: "#1677FF",
|
|
1239
|
+
snippets: [
|
|
1240
|
+
"pm",
|
|
1241
|
+
"pm.*",
|
|
1242
|
+
"ui.*"
|
|
1243
|
+
],
|
|
1244
|
+
strategy: null,
|
|
1245
|
+
title: '{{t("Root")}}'
|
|
1246
|
+
},
|
|
1247
|
+
{
|
|
1248
|
+
createdAt: "2024-04-07T06:50:37.657Z",
|
|
1249
|
+
updatedAt: "2024-04-07T06:50:37.657Z",
|
|
1250
|
+
allowConfigure: true,
|
|
1251
|
+
allowNewMenu: true,
|
|
1252
|
+
"default": false,
|
|
1253
|
+
description: null,
|
|
1254
|
+
hidden: false,
|
|
1255
|
+
color: "#1677FF",
|
|
1256
|
+
name: "admin",
|
|
1257
|
+
snippets: [
|
|
1258
|
+
"pm",
|
|
1259
|
+
"pm.*",
|
|
1260
|
+
"ui.*"
|
|
1261
|
+
],
|
|
1262
|
+
strategy: {
|
|
1263
|
+
actions: [
|
|
1264
|
+
"create",
|
|
1265
|
+
"view",
|
|
1266
|
+
"update",
|
|
1267
|
+
"destroy"
|
|
1268
|
+
]
|
|
1269
|
+
},
|
|
1270
|
+
title: '{{t("Admin")}}'
|
|
1271
|
+
},
|
|
1272
|
+
{
|
|
1273
|
+
createdAt: "2024-04-07T06:50:37.700Z",
|
|
1274
|
+
updatedAt: "2024-04-07T06:50:37.700Z",
|
|
1275
|
+
allowConfigure: null,
|
|
1276
|
+
allowNewMenu: true,
|
|
1277
|
+
"default": true,
|
|
1278
|
+
description: null,
|
|
1279
|
+
color: "#1677FF",
|
|
1280
|
+
hidden: false,
|
|
1281
|
+
name: "member",
|
|
1282
|
+
snippets: [
|
|
1283
|
+
"!pm",
|
|
1284
|
+
"!pm.*",
|
|
1285
|
+
"!ui.*"
|
|
1286
|
+
],
|
|
1287
|
+
strategy: {
|
|
1288
|
+
actions: [
|
|
1289
|
+
"view",
|
|
1290
|
+
"update:own",
|
|
1291
|
+
"destroy:own",
|
|
1292
|
+
"create"
|
|
1293
|
+
]
|
|
1294
|
+
},
|
|
1295
|
+
title: '{{t("Member")}}'
|
|
1296
|
+
}
|
|
1297
|
+
],
|
|
1298
|
+
meta: {
|
|
1299
|
+
count: 3,
|
|
1300
|
+
page: 1,
|
|
1301
|
+
pageSize: 20,
|
|
1302
|
+
totalPage: 1,
|
|
1303
|
+
allowedActions: {
|
|
1304
|
+
view: [
|
|
1305
|
+
"root",
|
|
1306
|
+
"admin",
|
|
1307
|
+
"member"
|
|
1308
|
+
],
|
|
1309
|
+
update: [
|
|
1310
|
+
"root",
|
|
1311
|
+
"admin",
|
|
1312
|
+
"member"
|
|
1313
|
+
],
|
|
1314
|
+
destroy: []
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
},
|
|
1318
|
+
"roles:get": {
|
|
1319
|
+
data: {
|
|
1320
|
+
createdAt: "2024-04-07T06:50:37.622Z",
|
|
1321
|
+
updatedAt: "2024-04-07T06:50:37.622Z",
|
|
1322
|
+
allowConfigure: null,
|
|
1323
|
+
allowNewMenu: null,
|
|
1324
|
+
"default": false,
|
|
1325
|
+
description: null,
|
|
1326
|
+
hidden: true,
|
|
1327
|
+
name: "root",
|
|
1328
|
+
color: "#1677FF",
|
|
1329
|
+
snippets: [
|
|
1330
|
+
"pm",
|
|
1331
|
+
"pm.*",
|
|
1332
|
+
"ui.*"
|
|
1333
|
+
],
|
|
1334
|
+
strategy: null,
|
|
1335
|
+
title: '{{t("Root")}}'
|
|
1336
|
+
}
|
|
1337
|
+
},
|
|
1338
|
+
"tree:list": {
|
|
1339
|
+
data: [
|
|
1340
|
+
{
|
|
1341
|
+
id: 1,
|
|
1342
|
+
parentId: null,
|
|
1343
|
+
f_y99u3pyj0bt: "1"
|
|
1344
|
+
},
|
|
1345
|
+
{
|
|
1346
|
+
id: 2,
|
|
1347
|
+
parentId: 1,
|
|
1348
|
+
f_y99u3pyj0bt: "2"
|
|
1349
|
+
}
|
|
1350
|
+
],
|
|
1351
|
+
meta: {
|
|
1352
|
+
count: 2,
|
|
1353
|
+
page: 1,
|
|
1354
|
+
pageSize: 20,
|
|
1355
|
+
totalPage: 1,
|
|
1356
|
+
allowedActions: {
|
|
1357
|
+
view: [
|
|
1358
|
+
1,
|
|
1359
|
+
2
|
|
1360
|
+
],
|
|
1361
|
+
update: [
|
|
1362
|
+
1,
|
|
1363
|
+
2
|
|
1364
|
+
],
|
|
1365
|
+
destroy: [
|
|
1366
|
+
1,
|
|
1367
|
+
2
|
|
1368
|
+
]
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
};
|
|
1373
|
+
const sleep = async (timeout = 0) => {
|
|
1374
|
+
return new Promise((resolve) => {
|
|
1375
|
+
setTimeout(resolve, timeout);
|
|
1376
|
+
});
|
|
1377
|
+
};
|
|
1378
|
+
const defaultApis = {
|
|
1379
|
+
"uiSchemas:patch": { data: { result: "ok" } },
|
|
1380
|
+
"uiSchemas:batchPatch": { data: { result: "ok" } },
|
|
1381
|
+
"uiSchemas:saveAsTemplate": { data: { result: "ok" } },
|
|
1382
|
+
"users:update": { data: { result: "ok" } },
|
|
1383
|
+
"roles:update": { data: { result: "ok" } },
|
|
1384
|
+
...dataSourceMainData
|
|
1385
|
+
};
|
|
1386
|
+
function getProcessMockData(apis, key2) {
|
|
1387
|
+
if (typeof apis[key2] === "function") {
|
|
1388
|
+
return apis[key2];
|
|
1389
|
+
}
|
|
1390
|
+
return (config) => {
|
|
1391
|
+
var _a, _b;
|
|
1392
|
+
if (!apis[key2])
|
|
1393
|
+
return [404, { data: { message: "mock data not found" } }];
|
|
1394
|
+
if (((_a = config == null ? void 0 : config.params) == null ? void 0 : _a.pageSize) || ((_b = config == null ? void 0 : config.params) == null ? void 0 : _b.page)) {
|
|
1395
|
+
const { data, meta } = apis[key2];
|
|
1396
|
+
const pageSize = config.params.pageSize || (meta == null ? void 0 : meta.pageSize) || 20;
|
|
1397
|
+
const page = config.params.page || (meta == null ? void 0 : meta.page) || 1;
|
|
1398
|
+
return [
|
|
1399
|
+
200,
|
|
1400
|
+
{
|
|
1401
|
+
data: data.slice(pageSize * (page - 1), pageSize * page),
|
|
1402
|
+
meta: {
|
|
1403
|
+
...meta,
|
|
1404
|
+
page,
|
|
1405
|
+
pageSize,
|
|
1406
|
+
count: data.length,
|
|
1407
|
+
totalPage: Math.ceil(data.length / pageSize)
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
];
|
|
1411
|
+
}
|
|
1412
|
+
return [200, apis[key2]];
|
|
1413
|
+
};
|
|
1414
|
+
}
|
|
1415
|
+
const mockApi = (axiosInstance, apis = {}, delayResponse) => {
|
|
1416
|
+
const mock = new MockAdapter(axiosInstance, { delayResponse });
|
|
1417
|
+
Object.keys(apis).forEach((key2) => {
|
|
1418
|
+
mock.onAny(key2).reply(getProcessMockData(apis, key2));
|
|
1419
|
+
});
|
|
1420
|
+
return (apis2 = {}) => {
|
|
1421
|
+
Object.keys(apis2).forEach((key2) => {
|
|
1422
|
+
mock.onAny(key2).reply(getProcessMockData(apis2, key2));
|
|
1423
|
+
});
|
|
1424
|
+
};
|
|
1425
|
+
};
|
|
1426
|
+
const mockAppApi = (app, apis = {}, delayResponse) => {
|
|
1427
|
+
const mock = mockApi(app.apiClient.axios, apis, delayResponse);
|
|
1428
|
+
return mock;
|
|
1429
|
+
};
|
|
1430
|
+
const ShowFormData = observer(({ children }) => {
|
|
1431
|
+
const form = useForm();
|
|
1432
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("pre", { style: { marginBottom: 20 }, "data-testid": "form-data" }, JSON.stringify(form.values, null, 2)), children);
|
|
1433
|
+
});
|
|
1434
|
+
const getApp = (options) => {
|
|
1435
|
+
const {
|
|
1436
|
+
appOptions = {},
|
|
1437
|
+
schemaSettings,
|
|
1438
|
+
providers,
|
|
1439
|
+
disableAcl = true,
|
|
1440
|
+
apis: optionsApis = {},
|
|
1441
|
+
enableMultipleDataSource,
|
|
1442
|
+
designable,
|
|
1443
|
+
delayResponse
|
|
1444
|
+
} = options;
|
|
1445
|
+
const app = appOptions instanceof Application ? appOptions : new Application({
|
|
1446
|
+
...appOptions,
|
|
1447
|
+
disableAcl: appOptions.disableAcl || disableAcl,
|
|
1448
|
+
designable: appOptions.designable || designable
|
|
1449
|
+
});
|
|
1450
|
+
if (providers) {
|
|
1451
|
+
app.addProviders(providers);
|
|
1452
|
+
}
|
|
1453
|
+
if (schemaSettings) {
|
|
1454
|
+
app.schemaSettingsManager.add(schemaSettings);
|
|
1455
|
+
}
|
|
1456
|
+
app.addComponents({ CommonSchemaComponent, ShowFormData });
|
|
1457
|
+
app.pluginManager.add(AntdSchemaComponentPlugin);
|
|
1458
|
+
app.pluginManager.add(SchemaSettingsPlugin);
|
|
1459
|
+
app.pluginManager.add(CollectionPlugin, { config: { enableRemoteDataSource: false } });
|
|
1460
|
+
const apis = Object.assign({}, defaultApis, optionsApis);
|
|
1461
|
+
app.getCollectionManager().addCollections(dataSourceMainCollections);
|
|
1462
|
+
if (enableMultipleDataSource) {
|
|
1463
|
+
app.dataSourceManager.addDataSource(LocalDataSource, dataSource2);
|
|
1464
|
+
}
|
|
1465
|
+
mockAppApi(app, apis, delayResponse);
|
|
1466
|
+
const App = app.getRootComponent();
|
|
1467
|
+
return {
|
|
1468
|
+
App,
|
|
1469
|
+
app
|
|
1470
|
+
};
|
|
1471
|
+
};
|
|
1472
|
+
const getAppComponent = (options) => {
|
|
1473
|
+
const {
|
|
1474
|
+
schema: optionsSchema = {},
|
|
1475
|
+
Component,
|
|
1476
|
+
value,
|
|
1477
|
+
props,
|
|
1478
|
+
onChange,
|
|
1479
|
+
noWrapperSchema,
|
|
1480
|
+
enableUserListDataBlock,
|
|
1481
|
+
...otherOptions
|
|
1482
|
+
} = options;
|
|
1483
|
+
if (noWrapperSchema) {
|
|
1484
|
+
const { App: App2 } = getApp(options);
|
|
1485
|
+
return App2;
|
|
1486
|
+
}
|
|
1487
|
+
const schema = {
|
|
1488
|
+
type: "object",
|
|
1489
|
+
name: "test",
|
|
1490
|
+
default: value,
|
|
1491
|
+
"x-component": Component,
|
|
1492
|
+
"x-component-props": {
|
|
1493
|
+
onChange,
|
|
1494
|
+
...props
|
|
1495
|
+
},
|
|
1496
|
+
...optionsSchema
|
|
1497
|
+
};
|
|
1498
|
+
if (!schema.name) {
|
|
1499
|
+
schema.name = "test";
|
|
1500
|
+
}
|
|
1501
|
+
if (!schema["x-uid"]) {
|
|
1502
|
+
schema["x-uid"] = "test";
|
|
1503
|
+
}
|
|
1504
|
+
if (!schema.type) {
|
|
1505
|
+
schema.type = "void";
|
|
1506
|
+
}
|
|
1507
|
+
const TestDemo = () => {
|
|
1508
|
+
if (!enableUserListDataBlock) {
|
|
1509
|
+
return /* @__PURE__ */ React.createElement(SchemaComponent, { schema });
|
|
1510
|
+
}
|
|
1511
|
+
return /* @__PURE__ */ React.createElement(DataBlockProvider, { collection: "users", action: "list" }, /* @__PURE__ */ React.createElement(SchemaComponent, { schema }));
|
|
1512
|
+
};
|
|
1513
|
+
const { App } = getApp({
|
|
1514
|
+
...otherOptions,
|
|
1515
|
+
providers: [TestDemo]
|
|
1516
|
+
});
|
|
1517
|
+
return App;
|
|
1518
|
+
};
|
|
1519
|
+
function addXReadPrettyToEachLayer(obj = {}) {
|
|
1520
|
+
obj["x-read-pretty"] = true;
|
|
1521
|
+
_.forOwn(obj, (value, key2) => {
|
|
1522
|
+
if (_.isObject(value)) {
|
|
1523
|
+
addXReadPrettyToEachLayer(value);
|
|
1524
|
+
}
|
|
1525
|
+
});
|
|
1526
|
+
return obj;
|
|
1527
|
+
}
|
|
1528
|
+
function setSchemaWithSettings(options) {
|
|
1529
|
+
const { Component, settingPath } = options;
|
|
1530
|
+
const SINGLE_SETTINGS_NAME = "testSettings";
|
|
1531
|
+
const testSettings = new SchemaSettings({
|
|
1532
|
+
name: SINGLE_SETTINGS_NAME,
|
|
1533
|
+
items: [
|
|
1534
|
+
{
|
|
1535
|
+
name: "test",
|
|
1536
|
+
Component
|
|
1537
|
+
}
|
|
1538
|
+
]
|
|
1539
|
+
});
|
|
1540
|
+
if (!options.schema) {
|
|
1541
|
+
options.schema = {};
|
|
1542
|
+
}
|
|
1543
|
+
if (settingPath) {
|
|
1544
|
+
const schema = get(options.schema, settingPath);
|
|
1545
|
+
schema["x-settings"] = SINGLE_SETTINGS_NAME;
|
|
1546
|
+
} else {
|
|
1547
|
+
options.schema["x-settings"] = SINGLE_SETTINGS_NAME;
|
|
1548
|
+
}
|
|
1549
|
+
if (!options.appOptions) {
|
|
1550
|
+
options.appOptions = {};
|
|
1551
|
+
}
|
|
1552
|
+
if (options.appOptions instanceof Application) {
|
|
1553
|
+
options.appOptions.schemaSettingsManager.add(testSettings);
|
|
1554
|
+
} else {
|
|
1555
|
+
if (!options.appOptions.schemaSettings) {
|
|
1556
|
+
options.appOptions.schemaSettings = [];
|
|
1557
|
+
}
|
|
1558
|
+
options.appOptions.schemaSettings.push(testSettings);
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
function withSchema(Component, name) {
|
|
1562
|
+
const ComponentValue = observer((props) => {
|
|
1563
|
+
const schema = useFieldSchema();
|
|
1564
|
+
const schemaValue = pick(schema.toJSON(), [
|
|
1565
|
+
"title",
|
|
1566
|
+
"description",
|
|
1567
|
+
"enum",
|
|
1568
|
+
"x-component-props",
|
|
1569
|
+
"x-decorator-props",
|
|
1570
|
+
"x-linkage-rules"
|
|
1571
|
+
]);
|
|
1572
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("pre", { "data-testid": `test-schema` }, JSON.stringify(schemaValue, void 0, 2)), /* @__PURE__ */ React.createElement(Component, { ...props }));
|
|
1573
|
+
});
|
|
1574
|
+
ComponentValue.displayName = `withSchema(${Component.displayName || Component.name})`;
|
|
1575
|
+
return ComponentValue;
|
|
1576
|
+
}
|
|
1577
|
+
const CommonSchemaComponent = withSchema(function CommonSchemaComponent2(props) {
|
|
1578
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, props.children);
|
|
1579
|
+
});
|
|
1580
|
+
const expectNoTsError = expect$1;
|
|
1581
|
+
const WaitApp = async () => {
|
|
1582
|
+
await waitFor(() => {
|
|
1583
|
+
expectNoTsError(screen.queryByText("Loading...")).not.toBeInTheDocument();
|
|
1584
|
+
});
|
|
1585
|
+
const loadError = screen.queryByText("App Error");
|
|
1586
|
+
if (loadError) {
|
|
1587
|
+
expectNoTsError(screen.queryByText("App Error")).not.toBeInTheDocument();
|
|
1588
|
+
}
|
|
1589
|
+
const renderError = screen.queryByText("Render Failed");
|
|
1590
|
+
if (renderError) {
|
|
1591
|
+
expectNoTsError(screen.queryByText("Render Failed")).not.toBeInTheDocument();
|
|
1592
|
+
}
|
|
1593
|
+
};
|
|
1594
|
+
function getFormItemElement({ container = document.body, Component, label }) {
|
|
1595
|
+
const preSelector = `div[aria-label^="block-item-${Component}-"]`;
|
|
1596
|
+
const selector = label ? `${preSelector}[aria-label$="${label}"]` : preSelector;
|
|
1597
|
+
const formItem = container.querySelector(selector);
|
|
1598
|
+
expectNoTsError(formItem).toBeInTheDocument();
|
|
1599
|
+
return formItem;
|
|
1600
|
+
}
|
|
1601
|
+
async function iconChecker(options) {
|
|
1602
|
+
const formItem = getFormItemElement({ Component: "IconPicker", ...options });
|
|
1603
|
+
if (options.oldValue) {
|
|
1604
|
+
expectNoTsError(formItem.querySelector("span[role=img]")).toHaveAttribute("aria-label", options.oldValue);
|
|
1605
|
+
}
|
|
1606
|
+
if (options.newValue) {
|
|
1607
|
+
await userEvent.click(formItem.querySelector("span[role=img]") || formItem.querySelector("button"));
|
|
1608
|
+
await waitFor(() => {
|
|
1609
|
+
expectNoTsError(screen.queryByRole("tooltip")).toBeInTheDocument();
|
|
1610
|
+
expectNoTsError(screen.getByRole("tooltip").querySelector(".ant-popover-title")).toHaveTextContent("Icon");
|
|
1611
|
+
});
|
|
1612
|
+
await userEvent.click(screen.getByRole("tooltip").querySelector(`span[aria-label="${options.newValue}"]`));
|
|
1613
|
+
await waitFor(() => {
|
|
1614
|
+
expectNoTsError(screen.queryByRole("tooltip")).not.toBeInTheDocument();
|
|
1615
|
+
});
|
|
1616
|
+
expectNoTsError(formItem.querySelector("span[role=img]")).toHaveAttribute("aria-label", options.newValue);
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
async function radioChecker(options) {
|
|
1620
|
+
const formItem = getFormItemElement({ Component: "Radio.Group", ...options });
|
|
1621
|
+
const radioGroup = formItem.querySelector(".ant-radio-group");
|
|
1622
|
+
if (options.oldValue) {
|
|
1623
|
+
expectNoTsError(radioGroup.querySelector(".ant-radio-wrapper-checked")).toHaveTextContent(options.oldValue);
|
|
1624
|
+
}
|
|
1625
|
+
if (options.newValue) {
|
|
1626
|
+
const el = [...radioGroup.querySelectorAll(".ant-radio-wrapper")].find((el2) => el2.textContent === options.newValue);
|
|
1627
|
+
expectNoTsError(el).toBeInTheDocument();
|
|
1628
|
+
await userEvent.click(el);
|
|
1629
|
+
await waitFor(() => {
|
|
1630
|
+
expectNoTsError(radioGroup.querySelector(".ant-radio-wrapper-checked")).toHaveTextContent(options.newValue);
|
|
1631
|
+
});
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
async function inputChecker(options) {
|
|
1635
|
+
const formItem = getFormItemElement({ Component: "Input", ...options });
|
|
1636
|
+
const input = formItem.querySelector("input");
|
|
1637
|
+
if (options.oldValue) {
|
|
1638
|
+
expectNoTsError(input).toHaveValue(options.oldValue);
|
|
1639
|
+
}
|
|
1640
|
+
if (options.newValue) {
|
|
1641
|
+
await userEvent.clear(input);
|
|
1642
|
+
await userEvent.type(input, options.newValue);
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
async function numberChecker(options) {
|
|
1646
|
+
const formItem = getFormItemElement({ Component: "InputNumber", ...options });
|
|
1647
|
+
const input = formItem.querySelector("input");
|
|
1648
|
+
if (options.oldValue) {
|
|
1649
|
+
expectNoTsError(input).toHaveValue(options.oldValue);
|
|
1650
|
+
}
|
|
1651
|
+
if (options.newValue) {
|
|
1652
|
+
await userEvent.clear(input);
|
|
1653
|
+
await userEvent.type(input, String(options.newValue));
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
async function textareaChecker(options) {
|
|
1657
|
+
const formItem = getFormItemElement({ Component: "Input.TextArea", ...options });
|
|
1658
|
+
const textarea = formItem.querySelector("textarea");
|
|
1659
|
+
if (options.oldValue) {
|
|
1660
|
+
expectNoTsError(textarea).toHaveValue(options.oldValue);
|
|
1661
|
+
}
|
|
1662
|
+
if (options.newValue) {
|
|
1663
|
+
await userEvent.clear(textarea);
|
|
1664
|
+
await userEvent.type(textarea, options.newValue);
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
async function collectionFieldChecker(options) {
|
|
1668
|
+
const formItem = getFormItemElement({ Component: "CollectionField", label: options.field, ...options });
|
|
1669
|
+
const input = formItem.querySelector("input");
|
|
1670
|
+
if (options.oldValue) {
|
|
1671
|
+
expectNoTsError(input).toHaveValue(options.oldValue);
|
|
1672
|
+
}
|
|
1673
|
+
if (options.newValue) {
|
|
1674
|
+
await userEvent.clear(input);
|
|
1675
|
+
await userEvent.type(input, options.newValue);
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
const checkers = {
|
|
1679
|
+
icon: iconChecker,
|
|
1680
|
+
radio: radioChecker,
|
|
1681
|
+
input: inputChecker,
|
|
1682
|
+
collectionField: collectionFieldChecker,
|
|
1683
|
+
number: numberChecker,
|
|
1684
|
+
textarea: textareaChecker
|
|
1685
|
+
};
|
|
1686
|
+
async function checkFormItems(list) {
|
|
1687
|
+
for (const item of list) {
|
|
1688
|
+
const type2 = item.type;
|
|
1689
|
+
const checker = checkers[type2];
|
|
1690
|
+
await checker(item);
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
async function checkModal(options) {
|
|
1694
|
+
const { triggerText, modalTitle, confirmTitle, submitText = "OK", formItems = [] } = options;
|
|
1695
|
+
await waitFor(() => {
|
|
1696
|
+
expectNoTsError(screen.queryByText(triggerText)).toBeInTheDocument();
|
|
1697
|
+
});
|
|
1698
|
+
await userEvent.click(screen.getByText(triggerText));
|
|
1699
|
+
await waitFor(() => {
|
|
1700
|
+
expectNoTsError(screen.queryByRole("dialog")).toBeInTheDocument();
|
|
1701
|
+
});
|
|
1702
|
+
const dialog = screen.getByRole("dialog");
|
|
1703
|
+
if (modalTitle) {
|
|
1704
|
+
expectNoTsError(dialog.querySelector(".ant-modal-title")).toHaveTextContent(modalTitle);
|
|
1705
|
+
}
|
|
1706
|
+
if (confirmTitle) {
|
|
1707
|
+
expectNoTsError(dialog.querySelector(".ant-modal-confirm-title")).toHaveTextContent(confirmTitle);
|
|
1708
|
+
}
|
|
1709
|
+
if (options.contentText) {
|
|
1710
|
+
expectNoTsError(dialog).toHaveTextContent(options.contentText);
|
|
1711
|
+
}
|
|
1712
|
+
if (options.beforeCheck) {
|
|
1713
|
+
await options.beforeCheck();
|
|
1714
|
+
}
|
|
1715
|
+
if (options.customCheck) {
|
|
1716
|
+
await options.customCheck();
|
|
1717
|
+
}
|
|
1718
|
+
await checkFormItems(formItems);
|
|
1719
|
+
await userEvent.click(screen.getByText(submitText));
|
|
1720
|
+
await waitFor(() => {
|
|
1721
|
+
expectNoTsError(screen.queryByRole("dialog")).not.toBeInTheDocument();
|
|
1722
|
+
});
|
|
1723
|
+
if (options.afterSubmit) {
|
|
1724
|
+
await sleep(100);
|
|
1725
|
+
await options.afterSubmit();
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
async function checkSchema(matchObj, name) {
|
|
1729
|
+
const objText = screen.queryByTestId(name ? `test-schema-${name}` : `test-schema`);
|
|
1730
|
+
await waitFor(() => {
|
|
1731
|
+
expect$1(JSON.parse(objText.textContent)).toMatchObject(matchObj);
|
|
1732
|
+
});
|
|
1733
|
+
}
|
|
1734
|
+
const renderAppOptions = async (options) => {
|
|
1735
|
+
const App = getAppComponent(options);
|
|
1736
|
+
const res = render(/* @__PURE__ */ React.createElement(App, null));
|
|
1737
|
+
await WaitApp();
|
|
1738
|
+
return res;
|
|
1739
|
+
};
|
|
1740
|
+
const renderReadPrettyApp = (options) => {
|
|
1741
|
+
return renderAppOptions({ ...options, schema: addXReadPrettyToEachLayer(options.schema) });
|
|
1742
|
+
};
|
|
1743
|
+
const renderHookWithApp = async (options) => {
|
|
1744
|
+
const { hook: useHook, props, Wrapper = Fragment, ...otherOptions } = options;
|
|
1745
|
+
const { App } = getApp(otherOptions);
|
|
1746
|
+
const WrapperValue = ({ children }) => /* @__PURE__ */ React.createElement(App, null, /* @__PURE__ */ React.createElement(Wrapper, null, children));
|
|
1747
|
+
const res = renderHook(() => useHook(), { wrapper: WrapperValue, initialProps: props });
|
|
1748
|
+
await WaitApp();
|
|
1749
|
+
return res;
|
|
1750
|
+
};
|
|
1751
|
+
async function showSettingsMenu(container = document) {
|
|
1752
|
+
await waitFor(() => {
|
|
1753
|
+
expectNoTsError(container.querySelector('[aria-label^="designer-schema-settings-"]')).toBeInTheDocument();
|
|
1754
|
+
});
|
|
1755
|
+
await userEvent.hover(container.querySelector('[aria-label^="designer-schema-settings-"]'));
|
|
1756
|
+
await waitFor(() => {
|
|
1757
|
+
expectNoTsError(screen.queryByTestId("schema-settings-menu")).toBeInTheDocument();
|
|
1758
|
+
});
|
|
1759
|
+
}
|
|
1760
|
+
const renderSettings = async (options = {}) => {
|
|
1761
|
+
const { container = () => document, ...appOptions } = options;
|
|
1762
|
+
const result = await renderAppOptions({ ...appOptions, designable: true });
|
|
1763
|
+
const containerElement = container();
|
|
1764
|
+
await showSettingsMenu(containerElement);
|
|
1765
|
+
return result;
|
|
1766
|
+
};
|
|
1767
|
+
const renderReadPrettySettings = async (options = {}) => {
|
|
1768
|
+
const { container = () => document, ...appOptions } = options;
|
|
1769
|
+
const result = await renderReadPrettyApp({ ...appOptions, designable: true });
|
|
1770
|
+
const containerElement = container();
|
|
1771
|
+
await showSettingsMenu(containerElement);
|
|
1772
|
+
return result;
|
|
1773
|
+
};
|
|
1774
|
+
const renderSingleSettings = (options) => {
|
|
1775
|
+
setSchemaWithSettings(options);
|
|
1776
|
+
return renderSettings(options);
|
|
1777
|
+
};
|
|
1778
|
+
const renderReadPrettySingleSettings = (options) => {
|
|
1779
|
+
setSchemaWithSettings(options);
|
|
1780
|
+
options.schema = addXReadPrettyToEachLayer(options.schema);
|
|
1781
|
+
return renderSettings(options);
|
|
1782
|
+
};
|
|
1783
|
+
async function checkDeleteSetting(options) {
|
|
1784
|
+
if (options.modalChecker) {
|
|
1785
|
+
await checkModal({
|
|
1786
|
+
triggerText: options.title,
|
|
1787
|
+
contentText: "Are you sure you want to delete it?",
|
|
1788
|
+
...options.modalChecker,
|
|
1789
|
+
async afterSubmit() {
|
|
1790
|
+
if (options.modalChecker.afterSubmit) {
|
|
1791
|
+
await options.modalChecker.afterSubmit();
|
|
1792
|
+
}
|
|
1793
|
+
if (options.deletedText) {
|
|
1794
|
+
expectNoTsError(screen.queryByText(options.deletedText)).not.toBeInTheDocument();
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
});
|
|
1798
|
+
}
|
|
1799
|
+
if (options.afterClick) {
|
|
1800
|
+
await options.afterClick();
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
async function checkModalSetting(options) {
|
|
1804
|
+
if (options.modalChecker) {
|
|
1805
|
+
await checkModal({
|
|
1806
|
+
triggerText: options.title,
|
|
1807
|
+
...options.modalChecker
|
|
1808
|
+
});
|
|
1809
|
+
}
|
|
1810
|
+
if (options.afterClick) {
|
|
1811
|
+
await options.afterClick();
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
async function checkSwitchSetting(options) {
|
|
1815
|
+
if (options.beforeClick) {
|
|
1816
|
+
await options.beforeClick();
|
|
1817
|
+
}
|
|
1818
|
+
const formItem = screen.getByTitle(options.title);
|
|
1819
|
+
const switchElement = formItem.querySelector("button[role=switch]");
|
|
1820
|
+
let oldChecked = switchElement.getAttribute("aria-checked");
|
|
1821
|
+
const afterClick = async () => {
|
|
1822
|
+
const formItem2 = screen.queryByTitle(options.title);
|
|
1823
|
+
if (formItem2) {
|
|
1824
|
+
const switchElement2 = formItem2.querySelector("button[role=switch]");
|
|
1825
|
+
const newChecked = switchElement2.getAttribute("aria-checked");
|
|
1826
|
+
expect$1(newChecked).not.toBe(oldChecked);
|
|
1827
|
+
oldChecked = newChecked;
|
|
1828
|
+
} else {
|
|
1829
|
+
await showSettingsMenu();
|
|
1830
|
+
}
|
|
1831
|
+
};
|
|
1832
|
+
if (options.afterFirstClick) {
|
|
1833
|
+
await userEvent.click(formItem.querySelector("button[role=switch]"));
|
|
1834
|
+
await waitFor(async () => {
|
|
1835
|
+
await afterClick();
|
|
1836
|
+
});
|
|
1837
|
+
await options.afterFirstClick();
|
|
1838
|
+
}
|
|
1839
|
+
if (options.afterSecondClick) {
|
|
1840
|
+
await userEvent.click(screen.getByText(options.title));
|
|
1841
|
+
await waitFor(async () => {
|
|
1842
|
+
await afterClick();
|
|
1843
|
+
});
|
|
1844
|
+
await options.afterSecondClick();
|
|
1845
|
+
}
|
|
1846
|
+
if (options.afterThirdClick) {
|
|
1847
|
+
await userEvent.click(screen.getByText(options.title));
|
|
1848
|
+
await waitFor(async () => {
|
|
1849
|
+
await afterClick();
|
|
1850
|
+
});
|
|
1851
|
+
await options.afterThirdClick();
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
async function checkSelectSetting(options) {
|
|
1855
|
+
if (options.beforeSelect) {
|
|
1856
|
+
await options.beforeSelect();
|
|
1857
|
+
}
|
|
1858
|
+
const formItem = screen.getByTitle(options.title);
|
|
1859
|
+
if (options.oldValue) {
|
|
1860
|
+
expectNoTsError(formItem).toHaveTextContent(options.oldValue);
|
|
1861
|
+
}
|
|
1862
|
+
if (options.options) {
|
|
1863
|
+
const getListbox = () => document.querySelector(`.select-popup-${options.title.replaceAll(" ", "-")}`);
|
|
1864
|
+
expectNoTsError(formItem.querySelector(".ant-select-selector")).toBeInTheDocument();
|
|
1865
|
+
await userEvent.click(formItem.querySelector(".ant-select-selector"));
|
|
1866
|
+
await waitFor(() => {
|
|
1867
|
+
expectNoTsError(getListbox()).toBeInTheDocument();
|
|
1868
|
+
});
|
|
1869
|
+
for (const option of options.options) {
|
|
1870
|
+
const listbox = getListbox();
|
|
1871
|
+
expectNoTsError(listbox).toHaveTextContent(option.label);
|
|
1872
|
+
if (option.checker) {
|
|
1873
|
+
const item = [...listbox.querySelectorAll(".ant-select-item-option-content")].find(
|
|
1874
|
+
(item2) => item2.textContent === option.label
|
|
1875
|
+
);
|
|
1876
|
+
await userEvent.click(item);
|
|
1877
|
+
await waitFor(() => {
|
|
1878
|
+
expectNoTsError(screen.getByTitle(options.title)).toHaveTextContent(option.label);
|
|
1879
|
+
});
|
|
1880
|
+
await option.checker();
|
|
1881
|
+
await userEvent.click(screen.getByTitle(options.title).querySelector(".ant-select-selection-item"));
|
|
1882
|
+
await waitFor(() => {
|
|
1883
|
+
expectNoTsError(getListbox()).toBeInTheDocument();
|
|
1884
|
+
});
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
const types = {
|
|
1890
|
+
switch: checkSwitchSetting,
|
|
1891
|
+
modal: checkModalSetting,
|
|
1892
|
+
delete: checkDeleteSetting,
|
|
1893
|
+
select: checkSelectSetting
|
|
1894
|
+
};
|
|
1895
|
+
async function checkSettings(list, checkLength = false) {
|
|
1896
|
+
if (checkLength) {
|
|
1897
|
+
const menuList = screen.getByTestId("schema-settings-menu");
|
|
1898
|
+
expect$1(menuList.querySelectorAll('li[role="menuitem"]')).toHaveLength(list.length);
|
|
1899
|
+
}
|
|
1900
|
+
for (const item of list) {
|
|
1901
|
+
if (!screen.queryByTestId("schema-settings-menu")) {
|
|
1902
|
+
await showSettingsMenu();
|
|
1903
|
+
}
|
|
1904
|
+
const type2 = item.type;
|
|
1905
|
+
const checker = types[type2];
|
|
1906
|
+
await checker(item);
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1909
|
+
async function checkBlockTitle(oldValue) {
|
|
1910
|
+
const newValue = "new test";
|
|
1911
|
+
await checkSettings([
|
|
1912
|
+
{
|
|
1913
|
+
type: "modal",
|
|
1914
|
+
title: "Edit block title",
|
|
1915
|
+
modalChecker: {
|
|
1916
|
+
modalTitle: "Edit block title",
|
|
1917
|
+
formItems: [
|
|
1918
|
+
{
|
|
1919
|
+
type: "input",
|
|
1920
|
+
label: "Block title",
|
|
1921
|
+
oldValue,
|
|
1922
|
+
newValue
|
|
1923
|
+
}
|
|
1924
|
+
],
|
|
1925
|
+
async afterSubmit() {
|
|
1926
|
+
await waitFor(() => {
|
|
1927
|
+
expectNoTsError(screen.queryByText(newValue)).toBeInTheDocument();
|
|
1928
|
+
});
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
]);
|
|
1933
|
+
}
|
|
1934
|
+
async function checkFieldTitle(oldValue) {
|
|
1935
|
+
const newValue = "new test";
|
|
1936
|
+
await checkSettings([
|
|
1937
|
+
{
|
|
1938
|
+
type: "modal",
|
|
1939
|
+
title: "Edit field title",
|
|
1940
|
+
modalChecker: {
|
|
1941
|
+
modalTitle: "Edit field title",
|
|
1942
|
+
formItems: [
|
|
1943
|
+
{
|
|
1944
|
+
type: "input",
|
|
1945
|
+
label: "Field title",
|
|
1946
|
+
oldValue,
|
|
1947
|
+
newValue
|
|
1948
|
+
}
|
|
1949
|
+
],
|
|
1950
|
+
async afterSubmit() {
|
|
1951
|
+
await waitFor(() => {
|
|
1952
|
+
expectNoTsError(screen.queryByText(newValue)).toBeInTheDocument();
|
|
1953
|
+
});
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
]);
|
|
1958
|
+
}
|
|
1959
|
+
function customRender(ui, options = {}) {
|
|
1960
|
+
return render(ui, {
|
|
1961
|
+
// wrap provider(s) here if needed
|
|
1962
|
+
wrapper: ({ children }) => children,
|
|
1963
|
+
...options
|
|
1964
|
+
});
|
|
1965
|
+
}
|
|
1966
|
+
async function waitForApp() {
|
|
1967
|
+
return waitFor(() => {
|
|
1968
|
+
expect(screen.queryByText("Loading...")).not.toBeInTheDocument();
|
|
1969
|
+
});
|
|
1970
|
+
}
|
|
1971
|
+
async function renderApp(element) {
|
|
1972
|
+
const res = render(element);
|
|
1973
|
+
await waitForApp();
|
|
1974
|
+
return res;
|
|
1975
|
+
}
|
|
1976
|
+
export {
|
|
1977
|
+
WaitApp,
|
|
1978
|
+
checkBlockTitle,
|
|
1979
|
+
checkDeleteSetting,
|
|
1980
|
+
checkFieldTitle,
|
|
1981
|
+
checkModal,
|
|
1982
|
+
checkModalSetting,
|
|
1983
|
+
checkSchema,
|
|
1984
|
+
checkSelectSetting,
|
|
1985
|
+
checkSettings,
|
|
1986
|
+
checkSwitchSetting,
|
|
1987
|
+
expectNoTsError,
|
|
1988
|
+
customRender as render,
|
|
1989
|
+
renderApp,
|
|
1990
|
+
renderAppOptions,
|
|
1991
|
+
renderHook2 as renderHook,
|
|
1992
|
+
renderHookWithApp,
|
|
1993
|
+
renderReadPrettyApp,
|
|
1994
|
+
renderReadPrettySettings,
|
|
1995
|
+
renderReadPrettySingleSettings,
|
|
1996
|
+
renderSettings,
|
|
1997
|
+
renderSingleSettings,
|
|
1998
|
+
showSettingsMenu,
|
|
1999
|
+
sleep,
|
|
2000
|
+
default2 as userEvent,
|
|
2001
|
+
waitForApp
|
|
2002
|
+
};
|