slice-machine-ui 2.16.2-alpha.jp-cr-empty-customtypes.1 → 2.16.2-alpha.jp-cr-ui-fix-invalid-fields-checked.1
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/out/404.html +1 -1
- package/out/_next/static/{xnrtmfRZsORP9Q_a5DySO → -b_7ATSiEFTCqrUK1sPZq}/_buildManifest.js +1 -1
- package/out/_next/static/chunks/630-ffb67177d6d9784c.js +1 -0
- package/out/_next/static/chunks/pages/{_app-a27cc92bf2c85218.js → _app-d387cf057dfd4f7f.js} +1 -1
- package/out/changelog.html +1 -1
- package/out/changes.html +1 -1
- package/out/custom-types/[customTypeId].html +1 -1
- package/out/custom-types.html +1 -1
- package/out/index.html +1 -1
- package/out/labs.html +1 -1
- package/out/page-types/[pageTypeId].html +1 -1
- package/out/settings.html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
- package/out/slices.html +1 -1
- package/package.json +3 -3
- package/src/features/builder/fields/contentRelationship/ContentRelationshipFieldPicker.tsx +287 -127
- package/src/features/builder/fields/contentRelationship/__tests__/ContentRelationshipFieldPicker.test.ts +1086 -168
- package/src/legacy/lib/models/common/widgets/ContentRelationship/index.ts +1 -2
- package/src/utils/tracking/getLinkTrackingProperties.ts +3 -1
- package/out/_next/static/chunks/630-fdfc5e7140814b4c.js +0 -1
- /package/out/_next/static/{xnrtmfRZsORP9Q_a5DySO → -b_7ATSiEFTCqrUK1sPZq}/_ssgManifest.js +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CustomType } from "@prismicio/types-internal/lib/customtypes";
|
|
1
2
|
import { describe, expect, it } from "vitest";
|
|
2
3
|
|
|
3
4
|
import {
|
|
@@ -6,260 +7,1177 @@ import {
|
|
|
6
7
|
} from "../ContentRelationshipFieldPicker";
|
|
7
8
|
|
|
8
9
|
describe("ContentRelationshipFieldPicker", () => {
|
|
9
|
-
|
|
10
|
-
const
|
|
10
|
+
describe("countPickedFields", () => {
|
|
11
|
+
const allCustomTypes: CustomType[] = [
|
|
12
|
+
{
|
|
13
|
+
id: "ct1",
|
|
14
|
+
label: "CT 1",
|
|
15
|
+
repeatable: false,
|
|
16
|
+
status: true,
|
|
17
|
+
json: {
|
|
18
|
+
Main: {
|
|
19
|
+
f1: {
|
|
20
|
+
type: "Link",
|
|
21
|
+
config: {
|
|
22
|
+
select: "document",
|
|
23
|
+
customtypes: ["ct2"],
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
f2: {
|
|
27
|
+
type: "Link",
|
|
28
|
+
config: {
|
|
29
|
+
select: "document",
|
|
30
|
+
customtypes: ["ct2"],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
g1: {
|
|
34
|
+
type: "Group",
|
|
35
|
+
config: {
|
|
36
|
+
fields: {
|
|
37
|
+
f1: {
|
|
38
|
+
type: "Boolean",
|
|
39
|
+
},
|
|
40
|
+
f2: {
|
|
41
|
+
type: "Link",
|
|
42
|
+
config: {
|
|
43
|
+
select: "document",
|
|
44
|
+
customtypes: ["ct2"],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: "ct2",
|
|
55
|
+
label: "CT 2",
|
|
56
|
+
repeatable: false,
|
|
57
|
+
status: true,
|
|
58
|
+
json: {
|
|
59
|
+
Main: {
|
|
60
|
+
f1: {
|
|
61
|
+
type: "Boolean",
|
|
62
|
+
},
|
|
63
|
+
g2: {
|
|
64
|
+
type: "Group",
|
|
65
|
+
config: {
|
|
66
|
+
fields: {
|
|
67
|
+
f1: {
|
|
68
|
+
type: "Boolean",
|
|
69
|
+
},
|
|
70
|
+
f2: {
|
|
71
|
+
type: "Boolean",
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
];
|
|
11
80
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
);
|
|
81
|
+
it("should count picked fields with a custom type as string", () => {
|
|
82
|
+
const customtypes = ["ct1"];
|
|
15
83
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
84
|
+
const result = countPickedFields(
|
|
85
|
+
convertLinkCustomtypesToFieldCheckMap({
|
|
86
|
+
linkCustomtypes: customtypes,
|
|
87
|
+
allCustomTypes,
|
|
88
|
+
}),
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
expect(result).toEqual({
|
|
92
|
+
pickedFields: 0,
|
|
93
|
+
nestedPickedFields: 0,
|
|
94
|
+
});
|
|
19
95
|
});
|
|
20
|
-
});
|
|
21
96
|
|
|
22
|
-
|
|
23
|
-
|
|
97
|
+
it("should count picked fields with multiple custom types as string", () => {
|
|
98
|
+
const customtypes = ["ct1", "ct2"];
|
|
24
99
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
100
|
+
const result = countPickedFields(
|
|
101
|
+
convertLinkCustomtypesToFieldCheckMap({
|
|
102
|
+
linkCustomtypes: customtypes,
|
|
103
|
+
allCustomTypes,
|
|
104
|
+
}),
|
|
105
|
+
);
|
|
28
106
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
107
|
+
expect(result).toEqual({
|
|
108
|
+
pickedFields: 0,
|
|
109
|
+
nestedPickedFields: 0,
|
|
110
|
+
});
|
|
32
111
|
});
|
|
33
|
-
});
|
|
34
112
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
113
|
+
it("should count picked fields with custom type as object and one field", () => {
|
|
114
|
+
const customtypes = [
|
|
115
|
+
{
|
|
116
|
+
id: "ct1",
|
|
117
|
+
fields: ["f1"],
|
|
118
|
+
},
|
|
119
|
+
];
|
|
120
|
+
|
|
121
|
+
const result = countPickedFields(
|
|
122
|
+
convertLinkCustomtypesToFieldCheckMap({
|
|
123
|
+
linkCustomtypes: customtypes,
|
|
124
|
+
allCustomTypes,
|
|
125
|
+
}),
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
expect(result).toEqual({
|
|
129
|
+
pickedFields: 1,
|
|
130
|
+
nestedPickedFields: 0,
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it("should count picked fields with custom type as object and one nested field", () => {
|
|
135
|
+
const customtypes = [
|
|
136
|
+
{
|
|
137
|
+
id: "ct1",
|
|
138
|
+
fields: [
|
|
139
|
+
{
|
|
140
|
+
id: "f1",
|
|
141
|
+
customtypes: [
|
|
142
|
+
{
|
|
143
|
+
id: "ct2",
|
|
144
|
+
fields: ["f1"],
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
},
|
|
150
|
+
];
|
|
151
|
+
|
|
152
|
+
const result = countPickedFields(
|
|
153
|
+
convertLinkCustomtypesToFieldCheckMap({
|
|
154
|
+
linkCustomtypes: customtypes,
|
|
155
|
+
allCustomTypes,
|
|
156
|
+
}),
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
expect(result).toEqual({
|
|
160
|
+
pickedFields: 1,
|
|
161
|
+
nestedPickedFields: 1,
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it("should count picked fields with custom type as object with group field", () => {
|
|
166
|
+
const customtypes = [
|
|
167
|
+
{
|
|
168
|
+
id: "ct1",
|
|
169
|
+
fields: [
|
|
170
|
+
{
|
|
171
|
+
id: "g1",
|
|
172
|
+
fields: ["f1", "f2"],
|
|
173
|
+
},
|
|
174
|
+
],
|
|
175
|
+
},
|
|
176
|
+
];
|
|
177
|
+
|
|
178
|
+
const test = convertLinkCustomtypesToFieldCheckMap({
|
|
179
|
+
linkCustomtypes: customtypes,
|
|
180
|
+
allCustomTypes,
|
|
181
|
+
});
|
|
182
|
+
const result = countPickedFields(test);
|
|
42
183
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
184
|
+
expect(result).toEqual({
|
|
185
|
+
pickedFields: 2,
|
|
186
|
+
nestedPickedFields: 0,
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it("should count picked fields with custom type as object with group field and nested custom type", () => {
|
|
191
|
+
const customtypes = [
|
|
192
|
+
{
|
|
193
|
+
id: "ct1",
|
|
194
|
+
fields: [
|
|
195
|
+
{
|
|
196
|
+
id: "g1",
|
|
197
|
+
fields: [
|
|
198
|
+
"f1",
|
|
199
|
+
{
|
|
200
|
+
id: "f2",
|
|
201
|
+
customtypes: [
|
|
202
|
+
{
|
|
203
|
+
id: "ct2",
|
|
204
|
+
fields: ["f1"],
|
|
205
|
+
},
|
|
206
|
+
],
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
},
|
|
210
|
+
],
|
|
211
|
+
},
|
|
212
|
+
];
|
|
213
|
+
|
|
214
|
+
const result = countPickedFields(
|
|
215
|
+
convertLinkCustomtypesToFieldCheckMap({
|
|
216
|
+
linkCustomtypes: customtypes,
|
|
217
|
+
allCustomTypes,
|
|
218
|
+
}),
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
expect(result).toEqual({
|
|
222
|
+
pickedFields: 2,
|
|
223
|
+
nestedPickedFields: 1,
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it("should count picked fields with custom type as object with group field, nested custom type and nested group field", () => {
|
|
228
|
+
const customtypes = [
|
|
229
|
+
{
|
|
230
|
+
id: "ct1",
|
|
231
|
+
fields: [
|
|
232
|
+
{
|
|
233
|
+
id: "g1",
|
|
234
|
+
fields: [
|
|
235
|
+
"f1",
|
|
236
|
+
{
|
|
237
|
+
id: "f2",
|
|
238
|
+
customtypes: [
|
|
239
|
+
{
|
|
240
|
+
id: "ct2",
|
|
241
|
+
fields: [
|
|
242
|
+
"f1",
|
|
243
|
+
{
|
|
244
|
+
id: "g2",
|
|
245
|
+
fields: ["f1", "f2"],
|
|
246
|
+
},
|
|
247
|
+
],
|
|
248
|
+
},
|
|
249
|
+
],
|
|
250
|
+
},
|
|
251
|
+
],
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
},
|
|
255
|
+
];
|
|
256
|
+
|
|
257
|
+
const result = countPickedFields(
|
|
258
|
+
convertLinkCustomtypesToFieldCheckMap({
|
|
259
|
+
linkCustomtypes: customtypes,
|
|
260
|
+
allCustomTypes,
|
|
261
|
+
}),
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
expect(result).toEqual({
|
|
265
|
+
pickedFields: 4,
|
|
266
|
+
nestedPickedFields: 3,
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
it("should count picked fields with custom type as object with nested custom type and nested group field", () => {
|
|
271
|
+
const customtypes = [
|
|
272
|
+
{
|
|
273
|
+
id: "ct1",
|
|
274
|
+
fields: [
|
|
275
|
+
"f1",
|
|
276
|
+
{
|
|
277
|
+
id: "f2",
|
|
278
|
+
customtypes: [
|
|
279
|
+
{
|
|
280
|
+
id: "ct2",
|
|
281
|
+
fields: [
|
|
282
|
+
"f1",
|
|
283
|
+
{
|
|
284
|
+
id: "g2",
|
|
285
|
+
fields: ["f1", "f2"],
|
|
286
|
+
},
|
|
287
|
+
],
|
|
288
|
+
},
|
|
289
|
+
],
|
|
290
|
+
},
|
|
291
|
+
],
|
|
292
|
+
},
|
|
293
|
+
];
|
|
294
|
+
|
|
295
|
+
const result = countPickedFields(
|
|
296
|
+
convertLinkCustomtypesToFieldCheckMap({
|
|
297
|
+
linkCustomtypes: customtypes,
|
|
298
|
+
allCustomTypes,
|
|
299
|
+
}),
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
expect(result).toEqual({
|
|
303
|
+
pickedFields: 4,
|
|
304
|
+
nestedPickedFields: 3,
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
it("should count picked fields with custom type as object with nested custom type without fields", () => {
|
|
309
|
+
const customtypes = [
|
|
310
|
+
{
|
|
311
|
+
id: "ct1",
|
|
312
|
+
fields: [
|
|
313
|
+
"f1",
|
|
314
|
+
{
|
|
315
|
+
id: "f2",
|
|
316
|
+
customtypes: [
|
|
317
|
+
{
|
|
318
|
+
id: "ct2",
|
|
319
|
+
fields: [],
|
|
320
|
+
},
|
|
321
|
+
],
|
|
322
|
+
},
|
|
323
|
+
],
|
|
324
|
+
},
|
|
325
|
+
];
|
|
326
|
+
|
|
327
|
+
const result = countPickedFields(
|
|
328
|
+
convertLinkCustomtypesToFieldCheckMap({
|
|
329
|
+
linkCustomtypes: customtypes,
|
|
330
|
+
allCustomTypes,
|
|
331
|
+
}),
|
|
332
|
+
);
|
|
333
|
+
|
|
334
|
+
expect(result).toEqual({
|
|
335
|
+
pickedFields: 1,
|
|
336
|
+
nestedPickedFields: 0,
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
it("should count picked fields with custom type as object with group field without fields", () => {
|
|
341
|
+
const customtypes = [
|
|
342
|
+
{
|
|
343
|
+
id: "ct1",
|
|
344
|
+
fields: [
|
|
345
|
+
"f1",
|
|
346
|
+
{
|
|
347
|
+
id: "g1",
|
|
348
|
+
fields: [],
|
|
349
|
+
},
|
|
350
|
+
],
|
|
351
|
+
},
|
|
352
|
+
];
|
|
46
353
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
354
|
+
const result = countPickedFields(
|
|
355
|
+
convertLinkCustomtypesToFieldCheckMap({
|
|
356
|
+
linkCustomtypes: customtypes,
|
|
357
|
+
allCustomTypes,
|
|
358
|
+
}),
|
|
359
|
+
);
|
|
360
|
+
|
|
361
|
+
expect(result).toEqual({
|
|
362
|
+
pickedFields: 1,
|
|
363
|
+
nestedPickedFields: 0,
|
|
364
|
+
});
|
|
50
365
|
});
|
|
51
366
|
});
|
|
52
367
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
{
|
|
56
|
-
id: "
|
|
57
|
-
|
|
368
|
+
describe("createContentRelationshipFieldCheckMap", () => {
|
|
369
|
+
it("should include existing/valid referenced fields", () => {
|
|
370
|
+
const customType: CustomType = {
|
|
371
|
+
id: "customType",
|
|
372
|
+
label: "Custom Type",
|
|
373
|
+
repeatable: false,
|
|
374
|
+
status: true,
|
|
375
|
+
json: {
|
|
376
|
+
Main: {
|
|
377
|
+
textField: {
|
|
378
|
+
type: "Text",
|
|
379
|
+
},
|
|
380
|
+
booleanField: {
|
|
381
|
+
type: "Boolean",
|
|
382
|
+
},
|
|
383
|
+
structuredTextField: {
|
|
384
|
+
type: "StructuredText",
|
|
385
|
+
},
|
|
386
|
+
imageField: {
|
|
387
|
+
type: "Image",
|
|
388
|
+
},
|
|
389
|
+
linkField: {
|
|
390
|
+
type: "Link",
|
|
391
|
+
},
|
|
392
|
+
colorField: {
|
|
393
|
+
type: "Color",
|
|
394
|
+
},
|
|
395
|
+
dateField: {
|
|
396
|
+
type: "Date",
|
|
397
|
+
},
|
|
398
|
+
geoPointField: {
|
|
399
|
+
type: "GeoPoint",
|
|
400
|
+
},
|
|
401
|
+
slicesField: {
|
|
402
|
+
type: "GeoPoint",
|
|
403
|
+
},
|
|
404
|
+
numberField: {
|
|
405
|
+
type: "Number",
|
|
406
|
+
},
|
|
407
|
+
rangeField: {
|
|
408
|
+
type: "Range",
|
|
409
|
+
},
|
|
410
|
+
selectField: {
|
|
411
|
+
type: "Select",
|
|
412
|
+
},
|
|
413
|
+
timestampField: {
|
|
414
|
+
type: "Timestamp",
|
|
415
|
+
},
|
|
416
|
+
separatorField: {
|
|
417
|
+
type: "Separator",
|
|
418
|
+
},
|
|
419
|
+
tableField: {
|
|
420
|
+
type: "Table",
|
|
421
|
+
},
|
|
422
|
+
integrationFieldsField: {
|
|
423
|
+
type: "IntegrationFields",
|
|
424
|
+
},
|
|
425
|
+
},
|
|
426
|
+
},
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
const result = convertLinkCustomtypesToFieldCheckMap({
|
|
430
|
+
linkCustomtypes: [
|
|
58
431
|
{
|
|
59
|
-
id: "
|
|
60
|
-
|
|
432
|
+
id: "customType",
|
|
433
|
+
fields: [
|
|
434
|
+
"textField",
|
|
435
|
+
"booleanField",
|
|
436
|
+
"structuredTextField",
|
|
437
|
+
"imageField",
|
|
438
|
+
"linkField",
|
|
439
|
+
"colorField",
|
|
440
|
+
"dateField",
|
|
441
|
+
"geoPointField",
|
|
442
|
+
"slicesField",
|
|
443
|
+
"numberField",
|
|
444
|
+
"rangeField",
|
|
445
|
+
"selectField",
|
|
446
|
+
"timestampField",
|
|
447
|
+
"separatorField",
|
|
448
|
+
"tableField",
|
|
449
|
+
"integrationFieldsField",
|
|
450
|
+
],
|
|
451
|
+
},
|
|
452
|
+
],
|
|
453
|
+
allCustomTypes: [customType],
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
expect(result).toEqual({
|
|
457
|
+
customType: {
|
|
458
|
+
textField: {
|
|
459
|
+
type: "checkbox",
|
|
460
|
+
value: true,
|
|
461
|
+
},
|
|
462
|
+
booleanField: {
|
|
463
|
+
type: "checkbox",
|
|
464
|
+
value: true,
|
|
465
|
+
},
|
|
466
|
+
structuredTextField: {
|
|
467
|
+
type: "checkbox",
|
|
468
|
+
value: true,
|
|
469
|
+
},
|
|
470
|
+
imageField: {
|
|
471
|
+
type: "checkbox",
|
|
472
|
+
value: true,
|
|
473
|
+
},
|
|
474
|
+
linkField: {
|
|
475
|
+
type: "checkbox",
|
|
476
|
+
value: true,
|
|
477
|
+
},
|
|
478
|
+
colorField: {
|
|
479
|
+
type: "checkbox",
|
|
480
|
+
value: true,
|
|
481
|
+
},
|
|
482
|
+
dateField: {
|
|
483
|
+
type: "checkbox",
|
|
484
|
+
value: true,
|
|
485
|
+
},
|
|
486
|
+
geoPointField: {
|
|
487
|
+
type: "checkbox",
|
|
488
|
+
value: true,
|
|
489
|
+
},
|
|
490
|
+
slicesField: {
|
|
491
|
+
type: "checkbox",
|
|
492
|
+
value: true,
|
|
493
|
+
},
|
|
494
|
+
numberField: {
|
|
495
|
+
type: "checkbox",
|
|
496
|
+
value: true,
|
|
497
|
+
},
|
|
498
|
+
rangeField: {
|
|
499
|
+
type: "checkbox",
|
|
500
|
+
value: true,
|
|
501
|
+
},
|
|
502
|
+
selectField: {
|
|
503
|
+
type: "checkbox",
|
|
504
|
+
value: true,
|
|
505
|
+
},
|
|
506
|
+
timestampField: {
|
|
507
|
+
type: "checkbox",
|
|
508
|
+
value: true,
|
|
509
|
+
},
|
|
510
|
+
separatorField: {
|
|
511
|
+
type: "checkbox",
|
|
512
|
+
value: true,
|
|
513
|
+
},
|
|
514
|
+
tableField: {
|
|
515
|
+
type: "checkbox",
|
|
516
|
+
value: true,
|
|
517
|
+
},
|
|
518
|
+
integrationFieldsField: {
|
|
519
|
+
type: "checkbox",
|
|
520
|
+
value: true,
|
|
521
|
+
},
|
|
522
|
+
},
|
|
523
|
+
});
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
it("should not include non-existing/invalid referenced fields", () => {
|
|
527
|
+
const customType2: CustomType = {
|
|
528
|
+
id: "customType2",
|
|
529
|
+
label: "Custom Type 2",
|
|
530
|
+
repeatable: false,
|
|
531
|
+
status: true,
|
|
532
|
+
json: {
|
|
533
|
+
Main: {
|
|
534
|
+
booleanField: {
|
|
535
|
+
type: "Boolean",
|
|
536
|
+
},
|
|
537
|
+
},
|
|
538
|
+
},
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
const customType: CustomType = {
|
|
542
|
+
id: "customType",
|
|
543
|
+
label: "Custom Type",
|
|
544
|
+
repeatable: false,
|
|
545
|
+
status: true,
|
|
546
|
+
json: {
|
|
547
|
+
Main: {
|
|
548
|
+
mdField: {
|
|
549
|
+
type: "StructuredText",
|
|
550
|
+
},
|
|
551
|
+
crField: {
|
|
552
|
+
type: "Link",
|
|
553
|
+
config: {
|
|
554
|
+
select: "document",
|
|
555
|
+
customtypes: ["customType2"],
|
|
556
|
+
},
|
|
557
|
+
},
|
|
558
|
+
groupField: {
|
|
559
|
+
type: "Group",
|
|
560
|
+
config: {
|
|
561
|
+
fields: {
|
|
562
|
+
groupFieldA: {
|
|
563
|
+
type: "Boolean",
|
|
564
|
+
},
|
|
565
|
+
},
|
|
566
|
+
},
|
|
567
|
+
},
|
|
568
|
+
},
|
|
569
|
+
},
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
const result = convertLinkCustomtypesToFieldCheckMap({
|
|
573
|
+
linkCustomtypes: [
|
|
574
|
+
{
|
|
575
|
+
id: "customType",
|
|
576
|
+
fields: [
|
|
577
|
+
"mdField",
|
|
578
|
+
"nonExistingField",
|
|
579
|
+
{
|
|
580
|
+
id: "nonExistingGroup",
|
|
581
|
+
fields: ["groupFieldA"],
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
id: "crField",
|
|
585
|
+
customtypes: [
|
|
586
|
+
{
|
|
587
|
+
id: "customType2",
|
|
588
|
+
fields: ["nonExistingNestedField"],
|
|
589
|
+
},
|
|
590
|
+
],
|
|
591
|
+
},
|
|
61
592
|
{
|
|
62
|
-
id: "
|
|
63
|
-
fields: ["
|
|
593
|
+
id: "groupField",
|
|
594
|
+
fields: ["nonExistingGroupField"],
|
|
64
595
|
},
|
|
65
596
|
],
|
|
66
597
|
},
|
|
67
598
|
],
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const result = countPickedFields(
|
|
72
|
-
convertLinkCustomtypesToFieldCheckMap(customtypes),
|
|
73
|
-
);
|
|
599
|
+
allCustomTypes: [customType, customType2],
|
|
600
|
+
});
|
|
74
601
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
602
|
+
expect(result).toEqual({
|
|
603
|
+
customType: {
|
|
604
|
+
mdField: {
|
|
605
|
+
type: "checkbox",
|
|
606
|
+
value: true,
|
|
607
|
+
},
|
|
608
|
+
},
|
|
609
|
+
});
|
|
78
610
|
});
|
|
79
|
-
});
|
|
80
611
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
612
|
+
it("should not include an invalid field (uid, slices & choice)", () => {
|
|
613
|
+
const customType: CustomType = {
|
|
614
|
+
id: "customType",
|
|
615
|
+
label: "Custom Type",
|
|
616
|
+
repeatable: false,
|
|
617
|
+
status: true,
|
|
618
|
+
json: {
|
|
619
|
+
Main: {
|
|
620
|
+
booleanField: {
|
|
621
|
+
type: "Boolean",
|
|
622
|
+
},
|
|
623
|
+
typeUid: {
|
|
624
|
+
type: "UID",
|
|
625
|
+
},
|
|
626
|
+
uid: {
|
|
627
|
+
type: "Boolean",
|
|
628
|
+
},
|
|
629
|
+
choice: {
|
|
630
|
+
type: "Choice",
|
|
631
|
+
config: {
|
|
632
|
+
choices: {
|
|
633
|
+
choice1: {
|
|
634
|
+
type: "Boolean",
|
|
635
|
+
},
|
|
636
|
+
},
|
|
637
|
+
},
|
|
638
|
+
},
|
|
639
|
+
slices: {
|
|
640
|
+
type: "Slices",
|
|
641
|
+
config: {
|
|
642
|
+
choices: {
|
|
643
|
+
slice1: {
|
|
644
|
+
type: "SharedSlice",
|
|
645
|
+
},
|
|
646
|
+
},
|
|
647
|
+
},
|
|
648
|
+
},
|
|
649
|
+
},
|
|
650
|
+
},
|
|
651
|
+
};
|
|
652
|
+
|
|
653
|
+
const result = convertLinkCustomtypesToFieldCheckMap({
|
|
654
|
+
linkCustomtypes: [
|
|
86
655
|
{
|
|
87
|
-
id: "
|
|
88
|
-
fields: ["
|
|
656
|
+
id: "customType",
|
|
657
|
+
fields: ["booleanField", "typeUid", "uid", "choice", "slices"],
|
|
89
658
|
},
|
|
90
659
|
],
|
|
91
|
-
|
|
92
|
-
|
|
660
|
+
allCustomTypes: [customType],
|
|
661
|
+
});
|
|
93
662
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
663
|
+
expect(result).toEqual({
|
|
664
|
+
customType: {
|
|
665
|
+
booleanField: {
|
|
666
|
+
type: "checkbox",
|
|
667
|
+
value: true,
|
|
668
|
+
},
|
|
669
|
+
},
|
|
670
|
+
});
|
|
671
|
+
});
|
|
97
672
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
673
|
+
it("should include a correctly referenced group field", () => {
|
|
674
|
+
const customType: CustomType = {
|
|
675
|
+
id: "customType",
|
|
676
|
+
label: "Custom Type",
|
|
677
|
+
repeatable: false,
|
|
678
|
+
status: true,
|
|
679
|
+
json: {
|
|
680
|
+
Main: {
|
|
681
|
+
groupField: {
|
|
682
|
+
type: "Group",
|
|
683
|
+
config: {
|
|
684
|
+
label: "Group Field",
|
|
685
|
+
fields: {
|
|
686
|
+
booleanField: {
|
|
687
|
+
type: "Boolean",
|
|
688
|
+
config: {
|
|
689
|
+
label: "Boolean Field",
|
|
690
|
+
},
|
|
691
|
+
},
|
|
692
|
+
},
|
|
693
|
+
},
|
|
694
|
+
},
|
|
695
|
+
},
|
|
696
|
+
},
|
|
697
|
+
};
|
|
698
|
+
|
|
699
|
+
const result = convertLinkCustomtypesToFieldCheckMap({
|
|
700
|
+
linkCustomtypes: [
|
|
701
|
+
{
|
|
702
|
+
id: "customType",
|
|
703
|
+
fields: [
|
|
704
|
+
{
|
|
705
|
+
id: "groupField",
|
|
706
|
+
fields: ["booleanField"],
|
|
707
|
+
},
|
|
708
|
+
],
|
|
709
|
+
},
|
|
710
|
+
],
|
|
711
|
+
allCustomTypes: [customType],
|
|
712
|
+
});
|
|
713
|
+
|
|
714
|
+
expect(result).toEqual({
|
|
715
|
+
customType: {
|
|
716
|
+
groupField: {
|
|
717
|
+
type: "group",
|
|
718
|
+
value: {
|
|
719
|
+
booleanField: {
|
|
720
|
+
type: "checkbox",
|
|
721
|
+
value: true,
|
|
722
|
+
},
|
|
723
|
+
},
|
|
724
|
+
},
|
|
725
|
+
},
|
|
726
|
+
});
|
|
101
727
|
});
|
|
102
|
-
});
|
|
103
728
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
729
|
+
it("should include a field correctly referenced as a group inside a nested custom type", () => {
|
|
730
|
+
const customType: CustomType = {
|
|
731
|
+
id: "customType",
|
|
732
|
+
label: "Custom Type",
|
|
733
|
+
repeatable: false,
|
|
734
|
+
status: true,
|
|
735
|
+
json: {
|
|
736
|
+
Main: {
|
|
737
|
+
groupField: {
|
|
738
|
+
type: "Group",
|
|
739
|
+
config: {
|
|
740
|
+
label: "Group Field",
|
|
741
|
+
fields: {
|
|
742
|
+
booleanField: {
|
|
743
|
+
type: "Boolean",
|
|
744
|
+
config: {
|
|
745
|
+
label: "Boolean Field",
|
|
746
|
+
},
|
|
747
|
+
},
|
|
748
|
+
},
|
|
749
|
+
},
|
|
750
|
+
},
|
|
751
|
+
},
|
|
752
|
+
},
|
|
753
|
+
};
|
|
754
|
+
|
|
755
|
+
const customTypeWithContentRelationship: CustomType = {
|
|
756
|
+
id: "customTypeWithContentRelationship",
|
|
757
|
+
label: "Custom Type With Content Relationship",
|
|
758
|
+
repeatable: false,
|
|
759
|
+
status: true,
|
|
760
|
+
json: {
|
|
761
|
+
Main: {
|
|
762
|
+
contentRelationshipField: {
|
|
763
|
+
type: "Link",
|
|
764
|
+
config: {
|
|
765
|
+
select: "document",
|
|
766
|
+
customtypes: ["customType"],
|
|
767
|
+
},
|
|
768
|
+
},
|
|
769
|
+
},
|
|
770
|
+
},
|
|
771
|
+
};
|
|
772
|
+
|
|
773
|
+
const result = convertLinkCustomtypesToFieldCheckMap({
|
|
774
|
+
linkCustomtypes: [
|
|
109
775
|
{
|
|
110
|
-
id: "
|
|
776
|
+
id: "customTypeWithContentRelationship",
|
|
111
777
|
fields: [
|
|
112
|
-
"f1",
|
|
113
778
|
{
|
|
114
|
-
id: "
|
|
779
|
+
id: "contentRelationshipField",
|
|
115
780
|
customtypes: [
|
|
116
781
|
{
|
|
117
|
-
id: "
|
|
118
|
-
fields: [
|
|
782
|
+
id: "customType",
|
|
783
|
+
fields: [
|
|
784
|
+
{
|
|
785
|
+
id: "groupField",
|
|
786
|
+
fields: ["booleanField"],
|
|
787
|
+
},
|
|
788
|
+
],
|
|
119
789
|
},
|
|
120
790
|
],
|
|
121
791
|
},
|
|
122
792
|
],
|
|
123
793
|
},
|
|
124
794
|
],
|
|
125
|
-
|
|
126
|
-
|
|
795
|
+
allCustomTypes: [customType, customTypeWithContentRelationship],
|
|
796
|
+
});
|
|
797
|
+
|
|
798
|
+
expect(result).toEqual({
|
|
799
|
+
customTypeWithContentRelationship: {
|
|
800
|
+
contentRelationshipField: {
|
|
801
|
+
type: "contentRelationship",
|
|
802
|
+
value: {
|
|
803
|
+
customType: {
|
|
804
|
+
groupField: {
|
|
805
|
+
type: "group",
|
|
806
|
+
value: {
|
|
807
|
+
booleanField: {
|
|
808
|
+
type: "checkbox",
|
|
809
|
+
value: true,
|
|
810
|
+
},
|
|
811
|
+
},
|
|
812
|
+
},
|
|
813
|
+
},
|
|
814
|
+
},
|
|
815
|
+
},
|
|
816
|
+
},
|
|
817
|
+
});
|
|
818
|
+
});
|
|
127
819
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
820
|
+
it("should not include a regular field incorrectly referenced as a group", () => {
|
|
821
|
+
const customType: CustomType = {
|
|
822
|
+
id: "customType",
|
|
823
|
+
label: "Custom Type",
|
|
824
|
+
repeatable: false,
|
|
825
|
+
status: true,
|
|
826
|
+
json: {
|
|
827
|
+
Main: {
|
|
828
|
+
booleanField: {
|
|
829
|
+
type: "Boolean",
|
|
830
|
+
},
|
|
831
|
+
},
|
|
832
|
+
},
|
|
833
|
+
};
|
|
834
|
+
|
|
835
|
+
const result = convertLinkCustomtypesToFieldCheckMap({
|
|
836
|
+
linkCustomtypes: [
|
|
837
|
+
{
|
|
838
|
+
id: "customType",
|
|
839
|
+
fields: [
|
|
840
|
+
{
|
|
841
|
+
id: "groupField",
|
|
842
|
+
fields: ["booleanField"],
|
|
843
|
+
},
|
|
844
|
+
],
|
|
845
|
+
},
|
|
846
|
+
],
|
|
847
|
+
allCustomTypes: [customType],
|
|
848
|
+
});
|
|
131
849
|
|
|
132
|
-
|
|
133
|
-
pickedFields: 2,
|
|
134
|
-
nestedPickedFields: 1,
|
|
850
|
+
expect(result).toEqual({});
|
|
135
851
|
});
|
|
136
|
-
});
|
|
137
852
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
853
|
+
it("should not include a field referenced as a group field when it's not one", () => {
|
|
854
|
+
const customType: CustomType = {
|
|
855
|
+
id: "customType",
|
|
856
|
+
label: "Custom Type",
|
|
857
|
+
repeatable: false,
|
|
858
|
+
status: true,
|
|
859
|
+
json: {
|
|
860
|
+
Main: {
|
|
861
|
+
booleanField: {
|
|
862
|
+
type: "Boolean",
|
|
863
|
+
},
|
|
864
|
+
},
|
|
865
|
+
},
|
|
866
|
+
};
|
|
867
|
+
|
|
868
|
+
const result = convertLinkCustomtypesToFieldCheckMap({
|
|
869
|
+
linkCustomtypes: [
|
|
870
|
+
{
|
|
871
|
+
id: "customType",
|
|
872
|
+
fields: [
|
|
873
|
+
{
|
|
874
|
+
id: "booleanField",
|
|
875
|
+
fields: ["fieldA"],
|
|
876
|
+
},
|
|
877
|
+
],
|
|
878
|
+
},
|
|
879
|
+
],
|
|
880
|
+
allCustomTypes: [customType],
|
|
881
|
+
});
|
|
882
|
+
|
|
883
|
+
expect(result).toEqual({});
|
|
884
|
+
});
|
|
885
|
+
|
|
886
|
+
it("should not include a group field referenced as a regular field (string/no picked fields)", () => {
|
|
887
|
+
const customType: CustomType = {
|
|
888
|
+
id: "customType",
|
|
889
|
+
label: "Custom Type",
|
|
890
|
+
repeatable: false,
|
|
891
|
+
status: true,
|
|
892
|
+
json: {
|
|
893
|
+
Main: {
|
|
894
|
+
groupField: {
|
|
895
|
+
type: "Group",
|
|
896
|
+
config: {
|
|
897
|
+
label: "Group Field",
|
|
898
|
+
fields: {
|
|
899
|
+
booleanField: {
|
|
900
|
+
type: "Boolean",
|
|
901
|
+
config: {
|
|
902
|
+
label: "Boolean Field",
|
|
903
|
+
},
|
|
904
|
+
},
|
|
905
|
+
},
|
|
906
|
+
},
|
|
907
|
+
},
|
|
908
|
+
},
|
|
909
|
+
},
|
|
910
|
+
};
|
|
911
|
+
|
|
912
|
+
const result = convertLinkCustomtypesToFieldCheckMap({
|
|
913
|
+
linkCustomtypes: [
|
|
143
914
|
{
|
|
144
|
-
id: "
|
|
915
|
+
id: "customType",
|
|
916
|
+
fields: ["groupField"],
|
|
917
|
+
},
|
|
918
|
+
],
|
|
919
|
+
allCustomTypes: [customType],
|
|
920
|
+
});
|
|
921
|
+
|
|
922
|
+
expect(result).toEqual({});
|
|
923
|
+
});
|
|
924
|
+
|
|
925
|
+
it("should not include a field referenced as a content relationship field when it's not one", () => {
|
|
926
|
+
const customTypeA: CustomType = {
|
|
927
|
+
id: "customTypeA",
|
|
928
|
+
label: "Custom Type A",
|
|
929
|
+
repeatable: false,
|
|
930
|
+
status: true,
|
|
931
|
+
json: {
|
|
932
|
+
Main: {
|
|
933
|
+
booleanField: {
|
|
934
|
+
type: "Boolean",
|
|
935
|
+
},
|
|
936
|
+
},
|
|
937
|
+
},
|
|
938
|
+
};
|
|
939
|
+
const customTypeB: CustomType = {
|
|
940
|
+
id: "customTypeB",
|
|
941
|
+
label: "Custom Type B",
|
|
942
|
+
repeatable: false,
|
|
943
|
+
status: true,
|
|
944
|
+
json: {
|
|
945
|
+
Main: {
|
|
946
|
+
colorField: {
|
|
947
|
+
type: "Color",
|
|
948
|
+
},
|
|
949
|
+
},
|
|
950
|
+
},
|
|
951
|
+
};
|
|
952
|
+
|
|
953
|
+
const result = convertLinkCustomtypesToFieldCheckMap({
|
|
954
|
+
linkCustomtypes: [
|
|
955
|
+
{
|
|
956
|
+
id: "customTypeA",
|
|
145
957
|
fields: [
|
|
146
|
-
"f1",
|
|
147
958
|
{
|
|
148
|
-
id: "
|
|
959
|
+
id: "booleanField",
|
|
149
960
|
customtypes: [
|
|
150
961
|
{
|
|
151
|
-
id: "
|
|
152
|
-
fields: [
|
|
153
|
-
"f1",
|
|
154
|
-
{
|
|
155
|
-
id: "g2",
|
|
156
|
-
fields: ["f1", "f2"],
|
|
157
|
-
},
|
|
158
|
-
],
|
|
962
|
+
id: "customTypeB",
|
|
963
|
+
fields: ["colorField"],
|
|
159
964
|
},
|
|
160
965
|
],
|
|
161
966
|
},
|
|
162
967
|
],
|
|
163
968
|
},
|
|
164
969
|
],
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const result = countPickedFields(
|
|
169
|
-
convertLinkCustomtypesToFieldCheckMap(customtypes),
|
|
170
|
-
);
|
|
970
|
+
allCustomTypes: [customTypeB, customTypeA],
|
|
971
|
+
});
|
|
171
972
|
|
|
172
|
-
|
|
173
|
-
pickedFields: 4,
|
|
174
|
-
nestedPickedFields: 3,
|
|
973
|
+
expect(result).toEqual({});
|
|
175
974
|
});
|
|
176
|
-
});
|
|
177
975
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
976
|
+
it("should not include a content relationship field if it references a non existing custom type", () => {
|
|
977
|
+
const customTypeWithField: CustomType = {
|
|
978
|
+
id: "customTypeWithField",
|
|
979
|
+
label: "Custom Type With Field",
|
|
980
|
+
repeatable: false,
|
|
981
|
+
status: true,
|
|
982
|
+
json: {
|
|
983
|
+
Main: {
|
|
984
|
+
colorField: {
|
|
985
|
+
type: "Color",
|
|
986
|
+
config: {
|
|
987
|
+
label: "Color Field",
|
|
988
|
+
},
|
|
989
|
+
},
|
|
990
|
+
},
|
|
991
|
+
},
|
|
992
|
+
};
|
|
993
|
+
const customType: CustomType = {
|
|
994
|
+
id: "customType",
|
|
995
|
+
label: "Custom Type",
|
|
996
|
+
repeatable: false,
|
|
997
|
+
status: true,
|
|
998
|
+
json: {
|
|
999
|
+
Main: {
|
|
1000
|
+
contentRelationshipField: {
|
|
1001
|
+
type: "Link",
|
|
1002
|
+
config: {
|
|
1003
|
+
select: "document",
|
|
1004
|
+
customtypes: ["customTypeWithField"],
|
|
1005
|
+
},
|
|
1006
|
+
},
|
|
1007
|
+
groupField: {
|
|
1008
|
+
type: "Group",
|
|
1009
|
+
config: {
|
|
1010
|
+
fields: {
|
|
1011
|
+
contentRelationshipFieldInsideGroup: {
|
|
1012
|
+
type: "Link",
|
|
1013
|
+
config: {
|
|
1014
|
+
select: "document",
|
|
1015
|
+
customtypes: ["customTypeWithField"],
|
|
1016
|
+
},
|
|
1017
|
+
},
|
|
1018
|
+
},
|
|
1019
|
+
},
|
|
1020
|
+
},
|
|
1021
|
+
},
|
|
1022
|
+
},
|
|
1023
|
+
};
|
|
1024
|
+
|
|
1025
|
+
const result = convertLinkCustomtypesToFieldCheckMap({
|
|
1026
|
+
linkCustomtypes: [
|
|
184
1027
|
{
|
|
185
|
-
id: "
|
|
186
|
-
|
|
1028
|
+
id: "customType",
|
|
1029
|
+
fields: [
|
|
1030
|
+
{
|
|
1031
|
+
id: "contentRelationshipField",
|
|
1032
|
+
customtypes: [
|
|
1033
|
+
{
|
|
1034
|
+
id: "nonExistingCustomType",
|
|
1035
|
+
fields: ["colorField"],
|
|
1036
|
+
},
|
|
1037
|
+
],
|
|
1038
|
+
},
|
|
187
1039
|
{
|
|
188
|
-
id: "
|
|
1040
|
+
id: "groupField",
|
|
189
1041
|
fields: [
|
|
190
|
-
"f1",
|
|
191
1042
|
{
|
|
192
|
-
id: "
|
|
193
|
-
|
|
1043
|
+
id: "contentRelationshipFieldInsideGroup",
|
|
1044
|
+
customtypes: [
|
|
1045
|
+
{
|
|
1046
|
+
id: "nonExistingCustomType",
|
|
1047
|
+
fields: ["colorField"],
|
|
1048
|
+
},
|
|
1049
|
+
],
|
|
194
1050
|
},
|
|
195
1051
|
],
|
|
196
1052
|
},
|
|
197
1053
|
],
|
|
198
1054
|
},
|
|
199
1055
|
],
|
|
200
|
-
|
|
201
|
-
|
|
1056
|
+
allCustomTypes: [customType, customTypeWithField],
|
|
1057
|
+
});
|
|
1058
|
+
|
|
1059
|
+
expect(result).toEqual({});
|
|
1060
|
+
});
|
|
202
1061
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
1062
|
+
it("should not include a regular field referenced as a content relationship field", () => {
|
|
1063
|
+
const customType: CustomType = {
|
|
1064
|
+
id: "customType",
|
|
1065
|
+
label: "Custom Type",
|
|
1066
|
+
repeatable: false,
|
|
1067
|
+
status: true,
|
|
1068
|
+
json: {
|
|
1069
|
+
Main: {
|
|
1070
|
+
booleanField: {
|
|
1071
|
+
type: "Boolean",
|
|
1072
|
+
},
|
|
1073
|
+
},
|
|
1074
|
+
},
|
|
1075
|
+
};
|
|
206
1076
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
1077
|
+
const result = convertLinkCustomtypesToFieldCheckMap({
|
|
1078
|
+
linkCustomtypes: [
|
|
1079
|
+
{
|
|
1080
|
+
id: "customType",
|
|
1081
|
+
fields: [
|
|
1082
|
+
{
|
|
1083
|
+
id: "booleanField",
|
|
1084
|
+
customtypes: [],
|
|
1085
|
+
},
|
|
1086
|
+
],
|
|
1087
|
+
},
|
|
1088
|
+
],
|
|
1089
|
+
allCustomTypes: [customType],
|
|
1090
|
+
});
|
|
1091
|
+
|
|
1092
|
+
expect(result).toEqual({});
|
|
210
1093
|
});
|
|
211
|
-
});
|
|
212
1094
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
1095
|
+
it("should not include a regular field referenced as a group field", () => {
|
|
1096
|
+
const customType: CustomType = {
|
|
1097
|
+
id: "customType",
|
|
1098
|
+
label: "Custom Type",
|
|
1099
|
+
repeatable: false,
|
|
1100
|
+
status: true,
|
|
1101
|
+
json: {
|
|
1102
|
+
Main: {
|
|
1103
|
+
booleanField: {
|
|
1104
|
+
type: "Boolean",
|
|
1105
|
+
},
|
|
1106
|
+
},
|
|
1107
|
+
},
|
|
1108
|
+
};
|
|
1109
|
+
|
|
1110
|
+
const result = convertLinkCustomtypesToFieldCheckMap({
|
|
1111
|
+
linkCustomtypes: [
|
|
219
1112
|
{
|
|
220
|
-
id: "
|
|
221
|
-
|
|
1113
|
+
id: "customType",
|
|
1114
|
+
fields: [
|
|
222
1115
|
{
|
|
223
|
-
id: "
|
|
1116
|
+
id: "booleanField",
|
|
224
1117
|
fields: [],
|
|
225
1118
|
},
|
|
226
1119
|
],
|
|
227
1120
|
},
|
|
228
1121
|
],
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
const result = countPickedFields(
|
|
233
|
-
convertLinkCustomtypesToFieldCheckMap(customtypes),
|
|
234
|
-
);
|
|
1122
|
+
allCustomTypes: [customType],
|
|
1123
|
+
});
|
|
235
1124
|
|
|
236
|
-
|
|
237
|
-
pickedFields: 1,
|
|
238
|
-
nestedPickedFields: 0,
|
|
1125
|
+
expect(result).toEqual({});
|
|
239
1126
|
});
|
|
240
|
-
});
|
|
241
1127
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
id: "ct1",
|
|
246
|
-
fields: [
|
|
247
|
-
"f1",
|
|
1128
|
+
it("should not check for valid fields if allCustomTypes prop is not provided", () => {
|
|
1129
|
+
const result = convertLinkCustomtypesToFieldCheckMap({
|
|
1130
|
+
linkCustomtypes: [
|
|
248
1131
|
{
|
|
249
|
-
id: "
|
|
250
|
-
fields: [
|
|
1132
|
+
id: "customTypeA",
|
|
1133
|
+
fields: [
|
|
1134
|
+
"fieldA",
|
|
1135
|
+
{
|
|
1136
|
+
id: "groupA",
|
|
1137
|
+
fields: ["groupFieldA"],
|
|
1138
|
+
},
|
|
1139
|
+
{
|
|
1140
|
+
id: "contentRelationshipA",
|
|
1141
|
+
customtypes: [
|
|
1142
|
+
{
|
|
1143
|
+
id: "customTypeB",
|
|
1144
|
+
fields: ["fieldB"],
|
|
1145
|
+
},
|
|
1146
|
+
],
|
|
1147
|
+
},
|
|
1148
|
+
],
|
|
251
1149
|
},
|
|
252
1150
|
],
|
|
253
|
-
}
|
|
254
|
-
];
|
|
255
|
-
|
|
256
|
-
const result = countPickedFields(
|
|
257
|
-
convertLinkCustomtypesToFieldCheckMap(customtypes),
|
|
258
|
-
);
|
|
1151
|
+
});
|
|
259
1152
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
1153
|
+
expect(result).toEqual({
|
|
1154
|
+
customTypeA: {
|
|
1155
|
+
fieldA: {
|
|
1156
|
+
type: "checkbox",
|
|
1157
|
+
value: true,
|
|
1158
|
+
},
|
|
1159
|
+
groupA: {
|
|
1160
|
+
type: "group",
|
|
1161
|
+
value: {
|
|
1162
|
+
groupFieldA: {
|
|
1163
|
+
type: "checkbox",
|
|
1164
|
+
value: true,
|
|
1165
|
+
},
|
|
1166
|
+
},
|
|
1167
|
+
},
|
|
1168
|
+
contentRelationshipA: {
|
|
1169
|
+
type: "contentRelationship",
|
|
1170
|
+
value: {
|
|
1171
|
+
customTypeB: {
|
|
1172
|
+
fieldB: {
|
|
1173
|
+
type: "checkbox",
|
|
1174
|
+
value: true,
|
|
1175
|
+
},
|
|
1176
|
+
},
|
|
1177
|
+
},
|
|
1178
|
+
},
|
|
1179
|
+
},
|
|
1180
|
+
});
|
|
263
1181
|
});
|
|
264
1182
|
});
|
|
265
1183
|
});
|