@localazy/strapi-plugin 0.1.10 → 0.1.11-rc.0

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.
Files changed (42) hide show
  1. package/.eslintrc +6 -2
  2. package/admin/src/modules/@common/models/supported-content-type-fields.js +8 -0
  3. package/admin/src/modules/plugin-settings/components/Tree/index.js +2 -0
  4. package/admin/src/modules/plugin-settings/utils/get-filtered-models-schemas.js +4 -4
  5. package/admin/src/modules/plugin-settings/utils/get-models-tree.js +3 -1
  6. package/package.json +1 -1
  7. package/server/bootstrap.js +15 -1
  8. package/server/controllers/localazy-transfer-controller.js +41 -46
  9. package/server/functions/should-set-downloaded-property.js +16 -0
  10. package/server/models/supported-content-type-fields.js +8 -0
  11. package/server/services/index.js +2 -0
  12. package/server/services/strapi-i18n-service.js +4 -3
  13. package/server/services/strapi-localazy-i18n-service.js +104 -0
  14. package/server/tests/fixtures/parsed-localazy-entry-to-create-entry-cookbook.js +5761 -0
  15. package/server/tests/fixtures/parsed-localazy-entry-to-create-entry-restaurant-simple-menu.js +536 -0
  16. package/server/tests/fixtures/parsed-localazy-entry-to-update-entry.js +35157 -0
  17. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-cookbook-empty-recipes.js +202 -0
  18. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-cookbook.js +2700 -0
  19. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-flat-simple.js +47 -0
  20. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-flat-with-media.js +169 -0
  21. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-menu-empty.js +3003 -0
  22. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-menu-with-media.js +2057 -0
  23. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-sample-json.js +46 -0
  24. package/server/tests/fixtures/{all-models-with-multimedia.js → strapi-plugin-all-models.js} +717 -540
  25. package/server/utils/__tests__/get-models-tree.test.js +1 -1
  26. package/server/utils/__tests__/parsed-localazy-entry-to-create-entry.test.js +90 -93
  27. package/server/utils/__tests__/parsed-localazy-entry-to-update-entry.test.js +417 -101
  28. package/server/utils/__tests__/populate-create-update-entry-with-base-entry.test.js +852 -0
  29. package/server/utils/get-full-populate-object.js +56 -0
  30. package/server/utils/get-models-tree.js +3 -1
  31. package/server/utils/model-utils.js +38 -0
  32. package/server/utils/parsed-localazy-entry-to-create-entry.js +1 -18
  33. package/server/utils/parsed-localazy-entry-to-update-entry.js +38 -3
  34. package/server/utils/populate-create-update-entry-with-base-entry.js +222 -0
  35. package/server/utils/transfer-setup-utils.js +14 -0
  36. package/server/tests/fixtures/restaurant-model.js +0 -230
  37. package/server/tests/fixtures/restaurants-entries.js +0 -152
  38. package/server/tests/fixtures/strapi-book-with-multimedia-components-cs.js +0 -31
  39. package/server/tests/fixtures/stringified-book-cs.js +0 -3
  40. package/server/tests/fixtures/stringified-book-with-multimedia-components-cs.js +0 -3
  41. package/server/tests/fixtures/stringified-restaurant-cs.js +0 -3
  42. package/server/tests/fixtures/stringified-restaurant-de.js +0 -5
@@ -0,0 +1,852 @@
1
+ "use strict";
2
+
3
+ const allModels = require("../../tests/fixtures/strapi-plugin-all-models");
4
+ const simpleFlatSimpleModel = require("../../tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-flat-simple");
5
+ const simpleFlatWithMediaModel = require("../../tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-flat-with-media");
6
+ const simpleMenuWithMediaModel = require("../../tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-menu-with-media");
7
+ const simpleMenuEmptyModel = require("../../tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-menu-empty");
8
+ const sampleJSONModel = require("../../tests/fixtures/populate-create-update-entry-with-base-entry-sample-json");
9
+ const cookbookModel = require("../../tests/fixtures/populate-create-update-entry-with-base-entry-cookbook");
10
+ const cookbookEmptyRecipesModel = require("../../tests/fixtures/populate-create-update-entry-with-base-entry-cookbook-empty-recipes");
11
+
12
+ const populateCreateUpdateEntryWithBaseEntry = require("../populate-create-update-entry-with-base-entry");
13
+
14
+ describe("populate-create-update-entry-with-base-entry.js", () => {
15
+ it("should populate a 'restaurant-simple-flat' correctly", async () => {
16
+ const populatedEntry = await populateCreateUpdateEntryWithBaseEntry(
17
+ allModels,
18
+ simpleFlatSimpleModel.updateEntry,
19
+ simpleFlatSimpleModel.baseEntry,
20
+ simpleFlatSimpleModel.fullyPopulatedLocalizedEntry,
21
+ simpleFlatSimpleModel.uid,
22
+ simpleFlatSimpleModel.locale,
23
+ );
24
+
25
+ const expected = {
26
+ id: 47,
27
+ name: "hlad, okno",
28
+ description: "Orientální pouliční jídlo v ústech rychlé a snadné!",
29
+ established_at: "2022-10-01",
30
+ is_franchise: false,
31
+ contact_email: "david@localazy.com",
32
+ cuisine: "Thai",
33
+ featured_image: null,
34
+ };
35
+
36
+ expect(populatedEntry).toEqual(expected);
37
+ });
38
+
39
+ it("should populate a 'restaurant-simple-flat' with media correctly", async () => {
40
+ const populatedEntry = await populateCreateUpdateEntryWithBaseEntry(
41
+ allModels,
42
+ simpleFlatWithMediaModel.updateEntry,
43
+ simpleFlatWithMediaModel.baseEntry,
44
+ simpleFlatWithMediaModel.fullyPopulatedLocalizedEntry,
45
+ simpleFlatWithMediaModel.uid,
46
+ simpleFlatWithMediaModel.locale,
47
+ );
48
+
49
+ const expected = {
50
+ id: 52,
51
+ name: "Michelin",
52
+ description: "Najbardziej wyszukana restauracja w Układzie Słonecznym. Sprawdź nasze menu stworzone przez jedynego Gordona Ramsaya.",
53
+ established_at: "2002-06-23",
54
+ is_franchise: true,
55
+ contact_email: "david@localazy.com",
56
+ cuisine: "French",
57
+ featured_image: {
58
+ id: 1,
59
+ name: "jason-leung-poI7DelFiVA-unsplash.jpg",
60
+ alternativeText: "jason-leung-poI7DelFiVA-unsplash.jpg",
61
+ caption: "jason-leung-poI7DelFiVA-unsplash.jpg",
62
+ width: 5596,
63
+ height: 3731,
64
+ formats: {
65
+ thumbnail: {
66
+ name: "thumbnail_jason-leung-poI7DelFiVA-unsplash.jpg",
67
+ hash: "thumbnail_jason_leung_po_I7_Del_Fi_VA_unsplash_508d22c55b",
68
+ ext: ".jpg",
69
+ mime: "image/jpeg",
70
+ path: null,
71
+ width: 234,
72
+ height: 156,
73
+ size: 11.74,
74
+ url: "/uploads/thumbnail_jason_leung_po_I7_Del_Fi_VA_unsplash_508d22c55b.jpg",
75
+ },
76
+ large: {
77
+ name: "large_jason-leung-poI7DelFiVA-unsplash.jpg",
78
+ hash: "large_jason_leung_po_I7_Del_Fi_VA_unsplash_508d22c55b",
79
+ ext: ".jpg",
80
+ mime: "image/jpeg",
81
+ path: null,
82
+ width: 1000,
83
+ height: 666,
84
+ size: 140.2,
85
+ url: "/uploads/large_jason_leung_po_I7_Del_Fi_VA_unsplash_508d22c55b.jpg",
86
+ },
87
+ medium: {
88
+ name: "medium_jason-leung-poI7DelFiVA-unsplash.jpg",
89
+ hash: "medium_jason_leung_po_I7_Del_Fi_VA_unsplash_508d22c55b",
90
+ ext: ".jpg",
91
+ mime: "image/jpeg",
92
+ path: null,
93
+ width: 750,
94
+ height: 500,
95
+ size: 86.32,
96
+ url: "/uploads/medium_jason_leung_po_I7_Del_Fi_VA_unsplash_508d22c55b.jpg",
97
+ },
98
+ small: {
99
+ name: "small_jason-leung-poI7DelFiVA-unsplash.jpg",
100
+ hash: "small_jason_leung_po_I7_Del_Fi_VA_unsplash_508d22c55b",
101
+ ext: ".jpg",
102
+ mime: "image/jpeg",
103
+ path: null,
104
+ width: 500,
105
+ height: 333,
106
+ size: 42.51,
107
+ url: "/uploads/small_jason_leung_po_I7_Del_Fi_VA_unsplash_508d22c55b.jpg",
108
+ },
109
+ },
110
+ hash: "jason_leung_po_I7_Del_Fi_VA_unsplash_508d22c55b",
111
+ ext: ".jpg",
112
+ mime: "image/jpeg",
113
+ size: 3461.64,
114
+ url: "/uploads/jason_leung_po_I7_Del_Fi_VA_unsplash_508d22c55b.jpg",
115
+ previewUrl: null,
116
+ provider: "local",
117
+ provider_metadata: null,
118
+ },
119
+ };
120
+
121
+ expect(populatedEntry).toEqual(expected);
122
+ });
123
+
124
+ // with menu
125
+ it("should populate a 'restaurant-simple-menu' with menu and media correctly", async () => {
126
+ const populatedEntry = await populateCreateUpdateEntryWithBaseEntry(
127
+ allModels,
128
+ simpleMenuWithMediaModel.updateEntry,
129
+ simpleMenuWithMediaModel.baseEntry,
130
+ simpleMenuWithMediaModel.fullyPopulatedLocalizedEntry,
131
+ simpleMenuWithMediaModel.uid,
132
+ simpleMenuWithMediaModel.locale,
133
+ );
134
+
135
+ const expected = {
136
+ id: 37,
137
+ name: "Głodne okno",
138
+ description: "Orientalne jedzenie uliczne w ustach szybko i łatwo!",
139
+ established_at: "2022-10-01",
140
+ is_franchise: false,
141
+ contact_email: "david@localazy.com",
142
+ cuisine: "Thai",
143
+ capacity: 68,
144
+ our_story: "Za nami jest więcej**! Sprawdź naszą historię na [Localazy] (https://localazy.com).\n\n! [Logo_sq-01.png] (/uploads/Logo_sq_01_08b9bb6be1.png)",
145
+ menu: [
146
+ {
147
+ id: 40,
148
+ name: "Zupa Curry",
149
+ price: 5,
150
+ currency: "$",
151
+ description: "_Super pyszna zupa. _\n\n<u>Ostrzeżenie: Ostre jak diabli! </u>",
152
+ is_available: true,
153
+ food_gallery: [
154
+ {
155
+ id: 3,
156
+ name: "emy-XoByiBymX20-unsplash.jpg",
157
+ alternativeText: "emy-XoByiBymX20-unsplash.jpg",
158
+ caption: "emy-XoByiBymX20-unsplash.jpg",
159
+ width: 5184,
160
+ height: 3456,
161
+ formats: {
162
+ thumbnail: {
163
+ name: "thumbnail_emy-XoByiBymX20-unsplash.jpg",
164
+ hash: "thumbnail_emy_Xo_Byi_Bym_X20_unsplash_a5d1373d3a",
165
+ ext: ".jpg",
166
+ mime: "image/jpeg",
167
+ path: null,
168
+ width: 234,
169
+ height: 156,
170
+ size: 11.04,
171
+ url: "/uploads/thumbnail_emy_Xo_Byi_Bym_X20_unsplash_a5d1373d3a.jpg",
172
+ },
173
+ large: {
174
+ name: "large_emy-XoByiBymX20-unsplash.jpg",
175
+ hash: "large_emy_Xo_Byi_Bym_X20_unsplash_a5d1373d3a",
176
+ ext: ".jpg",
177
+ mime: "image/jpeg",
178
+ path: null,
179
+ width: 1000,
180
+ height: 667,
181
+ size: 97.59,
182
+ url: "/uploads/large_emy_Xo_Byi_Bym_X20_unsplash_a5d1373d3a.jpg",
183
+ },
184
+ medium: {
185
+ name: "medium_emy-XoByiBymX20-unsplash.jpg",
186
+ hash: "medium_emy_Xo_Byi_Bym_X20_unsplash_a5d1373d3a",
187
+ ext: ".jpg",
188
+ mime: "image/jpeg",
189
+ path: null,
190
+ width: 750,
191
+ height: 500,
192
+ size: 63.15,
193
+ url: "/uploads/medium_emy_Xo_Byi_Bym_X20_unsplash_a5d1373d3a.jpg",
194
+ },
195
+ small: {
196
+ name: "small_emy-XoByiBymX20-unsplash.jpg",
197
+ hash: "small_emy_Xo_Byi_Bym_X20_unsplash_a5d1373d3a",
198
+ ext: ".jpg",
199
+ mime: "image/jpeg",
200
+ path: null,
201
+ width: 500,
202
+ height: 333,
203
+ size: 33.98,
204
+ url: "/uploads/small_emy_Xo_Byi_Bym_X20_unsplash_a5d1373d3a.jpg",
205
+ },
206
+ },
207
+ hash: "emy_Xo_Byi_Bym_X20_unsplash_a5d1373d3a",
208
+ ext: ".jpg",
209
+ mime: "image/jpeg",
210
+ size: 1411.68,
211
+ url: "/uploads/emy_Xo_Byi_Bym_X20_unsplash_a5d1373d3a.jpg",
212
+ previewUrl: null,
213
+ provider: "local",
214
+ provider_metadata: null,
215
+ },
216
+ {
217
+ id: 4,
218
+ name: "ting-tian-al9eh9QkdPA-unsplash.jpg",
219
+ alternativeText: "ting-tian-al9eh9QkdPA-unsplash.jpg",
220
+ caption: "ting-tian-al9eh9QkdPA-unsplash.jpg",
221
+ width: 3840,
222
+ height: 5760,
223
+ formats: {
224
+ thumbnail: {
225
+ name: "thumbnail_ting-tian-al9eh9QkdPA-unsplash.jpg",
226
+ hash: "thumbnail_ting_tian_al9eh9_Qkd_PA_unsplash_d5132e8a85",
227
+ ext: ".jpg",
228
+ mime: "image/jpeg",
229
+ path: null,
230
+ width: 104,
231
+ height: 156,
232
+ size: 6.06,
233
+ url: "/uploads/thumbnail_ting_tian_al9eh9_Qkd_PA_unsplash_d5132e8a85.jpg",
234
+ },
235
+ large: {
236
+ name: "large_ting-tian-al9eh9QkdPA-unsplash.jpg",
237
+ hash: "large_ting_tian_al9eh9_Qkd_PA_unsplash_d5132e8a85",
238
+ ext: ".jpg",
239
+ mime: "image/jpeg",
240
+ path: null,
241
+ width: 667,
242
+ height: 1000,
243
+ size: 202.98,
244
+ url: "/uploads/large_ting_tian_al9eh9_Qkd_PA_unsplash_d5132e8a85.jpg",
245
+ },
246
+ medium: {
247
+ name: "medium_ting-tian-al9eh9QkdPA-unsplash.jpg",
248
+ hash: "medium_ting_tian_al9eh9_Qkd_PA_unsplash_d5132e8a85",
249
+ ext: ".jpg",
250
+ mime: "image/jpeg",
251
+ path: null,
252
+ width: 500,
253
+ height: 750,
254
+ size: 120.06,
255
+ url: "/uploads/medium_ting_tian_al9eh9_Qkd_PA_unsplash_d5132e8a85.jpg",
256
+ },
257
+ small: {
258
+ name: "small_ting-tian-al9eh9QkdPA-unsplash.jpg",
259
+ hash: "small_ting_tian_al9eh9_Qkd_PA_unsplash_d5132e8a85",
260
+ ext: ".jpg",
261
+ mime: "image/jpeg",
262
+ path: null,
263
+ width: 333,
264
+ height: 500,
265
+ size: 54.32,
266
+ url: "/uploads/small_ting_tian_al9eh9_Qkd_PA_unsplash_d5132e8a85.jpg",
267
+ },
268
+ },
269
+ hash: "ting_tian_al9eh9_Qkd_PA_unsplash_d5132e8a85",
270
+ ext: ".jpg",
271
+ mime: "image/jpeg",
272
+ size: 5952.03,
273
+ url: "/uploads/ting_tian_al9eh9_Qkd_PA_unsplash_d5132e8a85.jpg",
274
+ previewUrl: null,
275
+ provider: "local",
276
+ provider_metadata: null,
277
+ },
278
+ ],
279
+ },
280
+ ],
281
+ featured_image: null,
282
+ };
283
+
284
+ expect(populatedEntry).toEqual(expected);
285
+ });
286
+
287
+ it("should populate a 'restaurant-simple-menu' without menu correctly", async () => {
288
+ const populatedEntry = await populateCreateUpdateEntryWithBaseEntry(
289
+ allModels,
290
+ simpleMenuEmptyModel.updateEntry,
291
+ simpleMenuEmptyModel.baseEntry,
292
+ simpleMenuEmptyModel.fullyPopulatedLocalizedEntry,
293
+ simpleMenuEmptyModel.uid,
294
+ simpleMenuEmptyModel.locale,
295
+ );
296
+
297
+ const expected = {
298
+ id: 39,
299
+ name: "Niebieska ostryga",
300
+ description: "Widzisz jedzenie? Lepiej powiedzmy, że owoce morza!",
301
+ established_at: "1822-07-09",
302
+ is_franchise: null,
303
+ contact_email: "david@localazy.com",
304
+ cuisine: "Italian",
305
+ capacity: 16,
306
+ our_story: "Długa tradycja, mądrość przekazywana z pokolenia na pokolenie... Od 1822 roku.",
307
+ menu: [
308
+ ],
309
+ featured_image: null,
310
+ };
311
+
312
+ expect(populatedEntry).toEqual(expected);
313
+ });
314
+
315
+ it("should populate a 'sample-json' correctly", async () => {
316
+ const populatedEntry = await populateCreateUpdateEntryWithBaseEntry(
317
+ allModels,
318
+ sampleJSONModel.updateEntry,
319
+ sampleJSONModel.baseEntry,
320
+ sampleJSONModel.fullyPopulatedLocalizedEntry,
321
+ sampleJSONModel.uid,
322
+ sampleJSONModel.locale,
323
+ );
324
+
325
+ const expected = {
326
+ id: 17,
327
+ purpose: "Foo CZ",
328
+ data: {
329
+ foo: "bar",
330
+ bar: {
331
+ foo: "baz",
332
+ },
333
+ },
334
+ };
335
+
336
+ expect(populatedEntry).toEqual(expected);
337
+ });
338
+
339
+ it("should populate a 'cookbook' correctly", async () => {
340
+ const populatedEntry = await populateCreateUpdateEntryWithBaseEntry(
341
+ allModels,
342
+ cookbookModel.updateEntry,
343
+ cookbookModel.baseEntry,
344
+ cookbookModel.fullyPopulatedLocalizedEntry,
345
+ cookbookModel.uid,
346
+ cookbookModel.locale,
347
+ );
348
+
349
+ const expected = {
350
+ id: 24,
351
+ title: "Pro každý den v roce",
352
+ author_name: "David V.",
353
+ pages: 365,
354
+ recipes: [
355
+ {
356
+ id: 20,
357
+ name: "Bramborový salát",
358
+ recipe: "Oloupejte brambory, smíchejte je se všemi ingrediencemi a máte hotovo. Bon apetit!",
359
+ estimated_cook_time: "00:30:00.000",
360
+ difficulty: "easy",
361
+ author_name: "Mr. Bramborová hlava",
362
+ gallery: [
363
+ {
364
+ id: 100,
365
+ image_title: "Syrové brambory",
366
+ image_description: "Čerstvý!",
367
+ image: {
368
+ id: 6,
369
+ name: "rodrigo-dos-reis-h3AkzboxK4Q-unsplash.jpg",
370
+ alternativeText: "rodrigo-dos-reis-h3AkzboxK4Q-unsplash.jpg",
371
+ caption: "rodrigo-dos-reis-h3AkzboxK4Q-unsplash.jpg",
372
+ width: 2268,
373
+ height: 4032,
374
+ formats: {
375
+ thumbnail: {
376
+ name: "thumbnail_rodrigo-dos-reis-h3AkzboxK4Q-unsplash.jpg",
377
+ hash: "thumbnail_rodrigo_dos_reis_h3_Akzbox_K4_Q_unsplash_d17e795cea",
378
+ ext: ".jpg",
379
+ mime: "image/jpeg",
380
+ path: null,
381
+ width: 88,
382
+ height: 156,
383
+ size: 5.35,
384
+ url: "/uploads/thumbnail_rodrigo_dos_reis_h3_Akzbox_K4_Q_unsplash_d17e795cea.jpg",
385
+ },
386
+ large: {
387
+ name: "large_rodrigo-dos-reis-h3AkzboxK4Q-unsplash.jpg",
388
+ hash: "large_rodrigo_dos_reis_h3_Akzbox_K4_Q_unsplash_d17e795cea",
389
+ ext: ".jpg",
390
+ mime: "image/jpeg",
391
+ path: null,
392
+ width: 563,
393
+ height: 1000,
394
+ size: 108.15,
395
+ url: "/uploads/large_rodrigo_dos_reis_h3_Akzbox_K4_Q_unsplash_d17e795cea.jpg",
396
+ },
397
+ medium: {
398
+ name: "medium_rodrigo-dos-reis-h3AkzboxK4Q-unsplash.jpg",
399
+ hash: "medium_rodrigo_dos_reis_h3_Akzbox_K4_Q_unsplash_d17e795cea",
400
+ ext: ".jpg",
401
+ mime: "image/jpeg",
402
+ path: null,
403
+ width: 422,
404
+ height: 750,
405
+ size: 65.52,
406
+ url: "/uploads/medium_rodrigo_dos_reis_h3_Akzbox_K4_Q_unsplash_d17e795cea.jpg",
407
+ },
408
+ small: {
409
+ name: "small_rodrigo-dos-reis-h3AkzboxK4Q-unsplash.jpg",
410
+ hash: "small_rodrigo_dos_reis_h3_Akzbox_K4_Q_unsplash_d17e795cea",
411
+ ext: ".jpg",
412
+ mime: "image/jpeg",
413
+ path: null,
414
+ width: 281,
415
+ height: 500,
416
+ size: 34.23,
417
+ url: "/uploads/small_rodrigo_dos_reis_h3_Akzbox_K4_Q_unsplash_d17e795cea.jpg",
418
+ },
419
+ },
420
+ hash: "rodrigo_dos_reis_h3_Akzbox_K4_Q_unsplash_d17e795cea",
421
+ ext: ".jpg",
422
+ mime: "image/jpeg",
423
+ size: 1081.59,
424
+ url: "/uploads/rodrigo_dos_reis_h3_Akzbox_K4_Q_unsplash_d17e795cea.jpg",
425
+ previewUrl: null,
426
+ provider: "local",
427
+ provider_metadata: null,
428
+ },
429
+ },
430
+ {
431
+ id: 101,
432
+ image_title: "Salát",
433
+ image_description: "Mňam!",
434
+ image: {
435
+ id: 7,
436
+ name: "jeffrey-betts-PeyzQt7tMk0-unsplash.jpg",
437
+ alternativeText: "jeffrey-betts-PeyzQt7tMk0-unsplash.jpg",
438
+ caption: "jeffrey-betts-PeyzQt7tMk0-unsplash.jpg",
439
+ width: 4608,
440
+ height: 3456,
441
+ formats: {
442
+ thumbnail: {
443
+ name: "thumbnail_jeffrey-betts-PeyzQt7tMk0-unsplash.jpg",
444
+ hash: "thumbnail_jeffrey_betts_Peyz_Qt7t_Mk0_unsplash_9650d628db",
445
+ ext: ".jpg",
446
+ mime: "image/jpeg",
447
+ path: null,
448
+ width: 208,
449
+ height: 156,
450
+ size: 9.03,
451
+ url: "/uploads/thumbnail_jeffrey_betts_Peyz_Qt7t_Mk0_unsplash_9650d628db.jpg",
452
+ },
453
+ large: {
454
+ name: "large_jeffrey-betts-PeyzQt7tMk0-unsplash.jpg",
455
+ hash: "large_jeffrey_betts_Peyz_Qt7t_Mk0_unsplash_9650d628db",
456
+ ext: ".jpg",
457
+ mime: "image/jpeg",
458
+ path: null,
459
+ width: 1000,
460
+ height: 750,
461
+ size: 102.77,
462
+ url: "/uploads/large_jeffrey_betts_Peyz_Qt7t_Mk0_unsplash_9650d628db.jpg",
463
+ },
464
+ medium: {
465
+ name: "medium_jeffrey-betts-PeyzQt7tMk0-unsplash.jpg",
466
+ hash: "medium_jeffrey_betts_Peyz_Qt7t_Mk0_unsplash_9650d628db",
467
+ ext: ".jpg",
468
+ mime: "image/jpeg",
469
+ path: null,
470
+ width: 750,
471
+ height: 563,
472
+ size: 66.26,
473
+ url: "/uploads/medium_jeffrey_betts_Peyz_Qt7t_Mk0_unsplash_9650d628db.jpg",
474
+ },
475
+ small: {
476
+ name: "small_jeffrey-betts-PeyzQt7tMk0-unsplash.jpg",
477
+ hash: "small_jeffrey_betts_Peyz_Qt7t_Mk0_unsplash_9650d628db",
478
+ ext: ".jpg",
479
+ mime: "image/jpeg",
480
+ path: null,
481
+ width: 500,
482
+ height: 375,
483
+ size: 35.17,
484
+ url: "/uploads/small_jeffrey_betts_Peyz_Qt7t_Mk0_unsplash_9650d628db.jpg",
485
+ },
486
+ },
487
+ hash: "jeffrey_betts_Peyz_Qt7t_Mk0_unsplash_9650d628db",
488
+ ext: ".jpg",
489
+ mime: "image/jpeg",
490
+ size: 1664.79,
491
+ url: "/uploads/jeffrey_betts_Peyz_Qt7t_Mk0_unsplash_9650d628db.jpg",
492
+ previewUrl: null,
493
+ provider: "local",
494
+ provider_metadata: null,
495
+ },
496
+ },
497
+ ],
498
+ ingredients: [
499
+ {
500
+ id: 115,
501
+ name: "Brambory",
502
+ amount: 2,
503
+ unit: "kg",
504
+ is_required: true,
505
+ },
506
+ {
507
+ id: 116,
508
+ name: "Hrášek",
509
+ amount: 0.5,
510
+ unit: "plechovka",
511
+ is_required: true,
512
+ },
513
+ {
514
+ id: 117,
515
+ name: "Kukuřice",
516
+ amount: 0.5,
517
+ unit: "plechovka",
518
+ is_required: true,
519
+ },
520
+ {
521
+ id: 118,
522
+ name: "Majonéza",
523
+ amount: 4,
524
+ unit: "1",
525
+ is_required: true,
526
+ },
527
+ {
528
+ id: 119,
529
+ name: "Sýr",
530
+ amount: 1,
531
+ unit: "1",
532
+ is_required: true,
533
+ },
534
+ {
535
+ id: 120,
536
+ name: "Jablko",
537
+ amount: 1,
538
+ unit: "ks",
539
+ is_required: true,
540
+ },
541
+ ],
542
+ },
543
+ ],
544
+ gallery: {
545
+ id: 24,
546
+ optional_title: null,
547
+ annotation: "Podívejte se na naše chutné jídlo, pak čtěte dál a ponořte se do kulinářského nebe!",
548
+ main_image: {
549
+ id: 102,
550
+ image_title: "Kuchařka",
551
+ image_description: "Booklet",
552
+ image: {
553
+ id: 9,
554
+ name: "dan-gold-5O1ddenSM4g-unsplash.jpg",
555
+ alternativeText: "dan-gold-5O1ddenSM4g-unsplash.jpg",
556
+ caption: "dan-gold-5O1ddenSM4g-unsplash.jpg",
557
+ width: 6000,
558
+ height: 3376,
559
+ formats: {
560
+ thumbnail: {
561
+ name: "thumbnail_dan-gold-5O1ddenSM4g-unsplash.jpg",
562
+ hash: "thumbnail_dan_gold_5_O1dden_SM_4g_unsplash_5adef7d907",
563
+ ext: ".jpg",
564
+ mime: "image/jpeg",
565
+ path: null,
566
+ width: 245,
567
+ height: 138,
568
+ size: 7.44,
569
+ url: "/uploads/thumbnail_dan_gold_5_O1dden_SM_4g_unsplash_5adef7d907.jpg",
570
+ },
571
+ large: {
572
+ name: "large_dan-gold-5O1ddenSM4g-unsplash.jpg",
573
+ hash: "large_dan_gold_5_O1dden_SM_4g_unsplash_5adef7d907",
574
+ ext: ".jpg",
575
+ mime: "image/jpeg",
576
+ path: null,
577
+ width: 1000,
578
+ height: 563,
579
+ size: 52.67,
580
+ url: "/uploads/large_dan_gold_5_O1dden_SM_4g_unsplash_5adef7d907.jpg",
581
+ },
582
+ medium: {
583
+ name: "medium_dan-gold-5O1ddenSM4g-unsplash.jpg",
584
+ hash: "medium_dan_gold_5_O1dden_SM_4g_unsplash_5adef7d907",
585
+ ext: ".jpg",
586
+ mime: "image/jpeg",
587
+ path: null,
588
+ width: 750,
589
+ height: 422,
590
+ size: 35.15,
591
+ url: "/uploads/medium_dan_gold_5_O1dden_SM_4g_unsplash_5adef7d907.jpg",
592
+ },
593
+ small: {
594
+ name: "small_dan-gold-5O1ddenSM4g-unsplash.jpg",
595
+ hash: "small_dan_gold_5_O1dden_SM_4g_unsplash_5adef7d907",
596
+ ext: ".jpg",
597
+ mime: "image/jpeg",
598
+ path: null,
599
+ width: 500,
600
+ height: 281,
601
+ size: 19.95,
602
+ url: "/uploads/small_dan_gold_5_O1dden_SM_4g_unsplash_5adef7d907.jpg",
603
+ },
604
+ },
605
+ hash: "dan_gold_5_O1dden_SM_4g_unsplash_5adef7d907",
606
+ ext: ".jpg",
607
+ mime: "image/jpeg",
608
+ size: 972.68,
609
+ url: "/uploads/dan_gold_5_O1dden_SM_4g_unsplash_5adef7d907.jpg",
610
+ previewUrl: null,
611
+ provider: "local",
612
+ provider_metadata: null,
613
+ },
614
+ },
615
+ gallery: [
616
+ {
617
+ id: 103,
618
+ image_title: null,
619
+ image_description: "Brožura, listy a vidlička.",
620
+ image: {
621
+ id: 11,
622
+ name: "heather-ford-G4LFhuLXhLE-unsplash.jpg",
623
+ alternativeText: "heather-ford-G4LFhuLXhLE-unsplash.jpg",
624
+ caption: "heather-ford-G4LFhuLXhLE-unsplash.jpg",
625
+ width: 6127,
626
+ height: 3844,
627
+ formats: {
628
+ thumbnail: {
629
+ name: "thumbnail_heather-ford-G4LFhuLXhLE-unsplash.jpg",
630
+ hash: "thumbnail_heather_ford_G4_L_Fhu_L_Xh_LE_unsplash_7a2c2cac8f",
631
+ ext: ".jpg",
632
+ mime: "image/jpeg",
633
+ path: null,
634
+ width: 245,
635
+ height: 154,
636
+ size: 9.54,
637
+ url: "/uploads/thumbnail_heather_ford_G4_L_Fhu_L_Xh_LE_unsplash_7a2c2cac8f.jpg",
638
+ },
639
+ large: {
640
+ name: "large_heather-ford-G4LFhuLXhLE-unsplash.jpg",
641
+ hash: "large_heather_ford_G4_L_Fhu_L_Xh_LE_unsplash_7a2c2cac8f",
642
+ ext: ".jpg",
643
+ mime: "image/jpeg",
644
+ path: null,
645
+ width: 1000,
646
+ height: 628,
647
+ size: 117.56,
648
+ url: "/uploads/large_heather_ford_G4_L_Fhu_L_Xh_LE_unsplash_7a2c2cac8f.jpg",
649
+ },
650
+ medium: {
651
+ name: "medium_heather-ford-G4LFhuLXhLE-unsplash.jpg",
652
+ hash: "medium_heather_ford_G4_L_Fhu_L_Xh_LE_unsplash_7a2c2cac8f",
653
+ ext: ".jpg",
654
+ mime: "image/jpeg",
655
+ path: null,
656
+ width: 750,
657
+ height: 471,
658
+ size: 66.32,
659
+ url: "/uploads/medium_heather_ford_G4_L_Fhu_L_Xh_LE_unsplash_7a2c2cac8f.jpg",
660
+ },
661
+ small: {
662
+ name: "small_heather-ford-G4LFhuLXhLE-unsplash.jpg",
663
+ hash: "small_heather_ford_G4_L_Fhu_L_Xh_LE_unsplash_7a2c2cac8f",
664
+ ext: ".jpg",
665
+ mime: "image/jpeg",
666
+ path: null,
667
+ width: 500,
668
+ height: 314,
669
+ size: 31.42,
670
+ url: "/uploads/small_heather_ford_G4_L_Fhu_L_Xh_LE_unsplash_7a2c2cac8f.jpg",
671
+ },
672
+ },
673
+ hash: "heather_ford_G4_L_Fhu_L_Xh_LE_unsplash_7a2c2cac8f",
674
+ ext: ".jpg",
675
+ mime: "image/jpeg",
676
+ size: 6971.47,
677
+ url: "/uploads/heather_ford_G4_L_Fhu_L_Xh_LE_unsplash_7a2c2cac8f.jpg",
678
+ previewUrl: null,
679
+ provider: "local",
680
+ provider_metadata: null,
681
+ },
682
+ },
683
+ {
684
+ id: 104,
685
+ image_title: "Koření",
686
+ image_description: null,
687
+ image: {
688
+ id: 10,
689
+ name: "calum-lewis-vA1L1jRTM70-unsplash.jpg",
690
+ alternativeText: "calum-lewis-vA1L1jRTM70-unsplash.jpg",
691
+ caption: "calum-lewis-vA1L1jRTM70-unsplash.jpg",
692
+ width: 3569,
693
+ height: 5353,
694
+ formats: {
695
+ thumbnail: {
696
+ name: "thumbnail_calum-lewis-vA1L1jRTM70-unsplash.jpg",
697
+ hash: "thumbnail_calum_lewis_v_A1_L1j_RTM_70_unsplash_5aff3a8997",
698
+ ext: ".jpg",
699
+ mime: "image/jpeg",
700
+ path: null,
701
+ width: 104,
702
+ height: 156,
703
+ size: 5.55,
704
+ url: "/uploads/thumbnail_calum_lewis_v_A1_L1j_RTM_70_unsplash_5aff3a8997.jpg",
705
+ },
706
+ large: {
707
+ name: "large_calum-lewis-vA1L1jRTM70-unsplash.jpg",
708
+ hash: "large_calum_lewis_v_A1_L1j_RTM_70_unsplash_5aff3a8997",
709
+ ext: ".jpg",
710
+ mime: "image/jpeg",
711
+ path: null,
712
+ width: 667,
713
+ height: 1000,
714
+ size: 116.32,
715
+ url: "/uploads/large_calum_lewis_v_A1_L1j_RTM_70_unsplash_5aff3a8997.jpg",
716
+ },
717
+ medium: {
718
+ name: "medium_calum-lewis-vA1L1jRTM70-unsplash.jpg",
719
+ hash: "medium_calum_lewis_v_A1_L1j_RTM_70_unsplash_5aff3a8997",
720
+ ext: ".jpg",
721
+ mime: "image/jpeg",
722
+ path: null,
723
+ width: 500,
724
+ height: 750,
725
+ size: 72.75,
726
+ url: "/uploads/medium_calum_lewis_v_A1_L1j_RTM_70_unsplash_5aff3a8997.jpg",
727
+ },
728
+ small: {
729
+ name: "small_calum-lewis-vA1L1jRTM70-unsplash.jpg",
730
+ hash: "small_calum_lewis_v_A1_L1j_RTM_70_unsplash_5aff3a8997",
731
+ ext: ".jpg",
732
+ mime: "image/jpeg",
733
+ path: null,
734
+ width: 333,
735
+ height: 500,
736
+ size: 36.52,
737
+ url: "/uploads/small_calum_lewis_v_A1_L1j_RTM_70_unsplash_5aff3a8997.jpg",
738
+ },
739
+ },
740
+ hash: "calum_lewis_v_A1_L1j_RTM_70_unsplash_5aff3a8997",
741
+ ext: ".jpg",
742
+ mime: "image/jpeg",
743
+ size: 2305.97,
744
+ url: "/uploads/calum_lewis_v_A1_L1j_RTM_70_unsplash_5aff3a8997.jpg",
745
+ previewUrl: null,
746
+ provider: "local",
747
+ provider_metadata: null,
748
+ },
749
+ },
750
+ ],
751
+ },
752
+ };
753
+
754
+ expect(populatedEntry).toEqual(expected);
755
+ });
756
+
757
+ it("should populate a 'cookbook' without recipes correctly", async () => {
758
+ const populatedEntry = await populateCreateUpdateEntryWithBaseEntry(
759
+ allModels,
760
+ cookbookEmptyRecipesModel.updateEntry,
761
+ cookbookEmptyRecipesModel.baseEntry,
762
+ cookbookEmptyRecipesModel.fullyPopulatedLocalizedEntry,
763
+ cookbookEmptyRecipesModel.uid,
764
+ cookbookEmptyRecipesModel.locale,
765
+ );
766
+
767
+ const expected = {
768
+ id: 34,
769
+ title: "Jedna cholernie pusta książka kucharska",
770
+ author_name: "Jamie Oliver",
771
+ pages: 0,
772
+ recipes: [
773
+ ],
774
+ gallery: {
775
+ id: 34,
776
+ optional_title: "Jamie's cookbook",
777
+ annotation: "Zupełnie nowy, zawiera zero przepisów. Stwórz własne!",
778
+ main_image: {
779
+ id: 140,
780
+ image_title: "Knajpa",
781
+ image_description: "Pub",
782
+ image: {
783
+ id: 12,
784
+ name: "rishabh-modi-ubEMIKHv9Jk-unsplash.jpg",
785
+ alternativeText: "rishabh-modi-ubEMIKHv9Jk-unsplash.jpg",
786
+ caption: "rishabh-modi-ubEMIKHv9Jk-unsplash.jpg",
787
+ width: 2839,
788
+ height: 3785,
789
+ formats: {
790
+ thumbnail: {
791
+ name: "thumbnail_rishabh-modi-ubEMIKHv9Jk-unsplash.jpg",
792
+ hash: "thumbnail_rishabh_modi_ub_EMIK_Hv9_Jk_unsplash_68bba86c28",
793
+ ext: ".jpg",
794
+ mime: "image/jpeg",
795
+ path: null,
796
+ width: 117,
797
+ height: 156,
798
+ size: 5.26,
799
+ url: "/uploads/thumbnail_rishabh_modi_ub_EMIK_Hv9_Jk_unsplash_68bba86c28.jpg",
800
+ },
801
+ large: {
802
+ name: "large_rishabh-modi-ubEMIKHv9Jk-unsplash.jpg",
803
+ hash: "large_rishabh_modi_ub_EMIK_Hv9_Jk_unsplash_68bba86c28",
804
+ ext: ".jpg",
805
+ mime: "image/jpeg",
806
+ path: null,
807
+ width: 750,
808
+ height: 1000,
809
+ size: 114.8,
810
+ url: "/uploads/large_rishabh_modi_ub_EMIK_Hv9_Jk_unsplash_68bba86c28.jpg",
811
+ },
812
+ medium: {
813
+ name: "medium_rishabh-modi-ubEMIKHv9Jk-unsplash.jpg",
814
+ hash: "medium_rishabh_modi_ub_EMIK_Hv9_Jk_unsplash_68bba86c28",
815
+ ext: ".jpg",
816
+ mime: "image/jpeg",
817
+ path: null,
818
+ width: 562,
819
+ height: 750,
820
+ size: 69.07,
821
+ url: "/uploads/medium_rishabh_modi_ub_EMIK_Hv9_Jk_unsplash_68bba86c28.jpg",
822
+ },
823
+ small: {
824
+ name: "small_rishabh-modi-ubEMIKHv9Jk-unsplash.jpg",
825
+ hash: "small_rishabh_modi_ub_EMIK_Hv9_Jk_unsplash_68bba86c28",
826
+ ext: ".jpg",
827
+ mime: "image/jpeg",
828
+ path: null,
829
+ width: 375,
830
+ height: 500,
831
+ size: 35.47,
832
+ url: "/uploads/small_rishabh_modi_ub_EMIK_Hv9_Jk_unsplash_68bba86c28.jpg",
833
+ },
834
+ },
835
+ hash: "rishabh_modi_ub_EMIK_Hv9_Jk_unsplash_68bba86c28",
836
+ ext: ".jpg",
837
+ mime: "image/jpeg",
838
+ size: 1736.7,
839
+ url: "/uploads/rishabh_modi_ub_EMIK_Hv9_Jk_unsplash_68bba86c28.jpg",
840
+ previewUrl: null,
841
+ provider: "local",
842
+ provider_metadata: null,
843
+ },
844
+ },
845
+ gallery: [
846
+ ],
847
+ },
848
+ };
849
+
850
+ expect(populatedEntry).toEqual(expected);
851
+ });
852
+ });