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