@localazy/strapi-plugin 0.1.10 → 0.1.11-rc.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/.eslintrc +6 -2
- package/admin/src/modules/@common/models/supported-content-type-fields.js +8 -0
- package/admin/src/modules/plugin-settings/components/ContentTransferSetup/index.js +5 -0
- package/admin/src/modules/plugin-settings/components/Tree/index.js +22 -5
- package/admin/src/modules/plugin-settings/functions/build-content-transfer-setup-schema.js +1 -1
- package/admin/src/modules/plugin-settings/functions/has-model-changed.js +1 -1
- package/admin/src/modules/plugin-settings/locale/en.js +1 -1
- package/admin/src/modules/plugin-settings/utils/get-filtered-models-schemas.js +1 -7
- package/admin/src/modules/plugin-settings/utils/get-models-tree.js +21 -3
- package/package.json +4 -4
- package/server/bootstrap.js +15 -1
- package/server/controllers/localazy-transfer-controller.js +67 -52
- package/server/functions/should-set-downloaded-property.js +61 -0
- package/server/models/supported-content-type-fields.js +8 -0
- package/server/services/index.js +2 -0
- package/server/services/strapi-i18n-service.js +5 -4
- package/server/services/strapi-localazy-i18n-service.js +104 -0
- package/server/tests/fixtures/parsed-localazy-entry-to-create-entry-cookbook.js +5761 -0
- package/server/tests/fixtures/parsed-localazy-entry-to-create-entry-lesson-dz.js +392 -0
- package/server/tests/fixtures/parsed-localazy-entry-to-create-entry-restaurant-simple-menu.js +536 -0
- package/server/tests/fixtures/parsed-localazy-entry-to-create-entry-sample-json-dz.js +4675 -0
- package/server/tests/fixtures/parsed-localazy-entry-to-update-entry.js +35157 -0
- package/server/tests/fixtures/populate-create-update-entry-with-base-entry-cookbook-empty-recipes.js +202 -0
- package/server/tests/fixtures/populate-create-update-entry-with-base-entry-cookbook.js +2700 -0
- package/server/tests/fixtures/populate-create-update-entry-with-base-entry-lesson-dz.js +309 -0
- package/server/tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-flat-simple.js +47 -0
- package/server/tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-flat-with-media.js +169 -0
- package/server/tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-menu-empty.js +3003 -0
- package/server/tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-menu-with-media.js +2057 -0
- package/server/tests/fixtures/populate-create-update-entry-with-base-entry-sample-json-dz.js +884 -0
- package/server/tests/fixtures/populate-create-update-entry-with-base-entry-sample-json.js +46 -0
- package/server/tests/fixtures/strapi-plugin-all-models.js +2048 -0
- package/server/utils/__tests__/get-models-tree.test.js +1 -1
- package/server/utils/__tests__/parsed-localazy-entry-to-create-entry.test.js +237 -91
- package/server/utils/__tests__/parsed-localazy-entry-to-update-entry.test.js +417 -101
- package/server/utils/__tests__/pick-entries.test.js +936 -56
- package/server/utils/__tests__/populate-create-update-entry-with-base-entry.test.js +1139 -0
- package/server/utils/build-populate.js +5 -0
- package/server/utils/get-full-populate-object.js +56 -0
- package/server/utils/get-models-tree.js +3 -1
- package/server/utils/model-utils.js +43 -0
- package/server/utils/omit-deep.js +7 -0
- package/server/utils/parsed-localazy-entry-to-create-entry.js +58 -21
- package/server/utils/parsed-localazy-entry-to-update-entry.js +44 -4
- package/server/utils/pick-deep.js +22 -0
- package/server/utils/pick-entries.js +90 -5
- package/server/utils/populate-create-update-entry-with-base-entry.js +270 -0
- package/server/utils/transfer-setup-utils.js +14 -0
- package/server/tests/fixtures/all-models-with-multimedia.js +0 -1064
- package/server/tests/fixtures/collection-flattened.js +0 -76
- package/server/tests/fixtures/restaurant-flattened.js +0 -46
- package/server/tests/fixtures/restaurant-model.js +0 -230
- package/server/tests/fixtures/restaurants-entries.js +0 -152
- package/server/tests/fixtures/restaurants-pick-paths.js +0 -15
- package/server/tests/fixtures/strapi-book-with-multimedia-components-cs.js +0 -31
- package/server/tests/fixtures/stringified-book-cs.js +0 -3
- package/server/tests/fixtures/stringified-book-with-multimedia-components-cs.js +0 -3
- package/server/tests/fixtures/stringified-restaurant-cs.js +0 -3
- package/server/tests/fixtures/stringified-restaurant-de.js +0 -5
|
@@ -1,121 +1,267 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const parsedLocalazyEntryToCreateEntry = require("../parsed-localazy-entry-to-create-entry");
|
|
4
|
-
const allModels = require("../../tests/fixtures/all-models");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
4
|
+
const allModels = require("../../tests/fixtures/strapi-plugin-all-models");
|
|
5
|
+
const simpleMenuWithMediaModel = require("../../tests/fixtures/parsed-localazy-entry-to-create-entry-restaurant-simple-menu");
|
|
6
|
+
const cookbookModel = require("../../tests/fixtures/parsed-localazy-entry-to-create-entry-cookbook");
|
|
7
|
+
const lessonDZModel = require("../../tests/fixtures/parsed-localazy-entry-to-create-entry-lesson-dz");
|
|
8
|
+
const sampleJSONDZModel = require("../../tests/fixtures/parsed-localazy-entry-to-create-entry-sample-json-dz");
|
|
7
9
|
|
|
8
10
|
describe("parsed-localazy-entry-to-create-entry.js", () => {
|
|
9
|
-
it("should return transformed restaurant entry to strapi create entry structure", () => {
|
|
10
|
-
//
|
|
11
|
-
const
|
|
12
|
-
|
|
11
|
+
it("should return transformed 'restaurant-simple-menu' entry to strapi create entry structure", () => {
|
|
12
|
+
// EXECUTE
|
|
13
|
+
const result = parsedLocalazyEntryToCreateEntry(
|
|
14
|
+
allModels,
|
|
15
|
+
simpleMenuWithMediaModel.parsedLocalazyEntry,
|
|
16
|
+
simpleMenuWithMediaModel.baseEntry,
|
|
17
|
+
simpleMenuWithMediaModel.uid,
|
|
18
|
+
simpleMenuWithMediaModel.locale
|
|
19
|
+
);
|
|
13
20
|
|
|
14
|
-
|
|
21
|
+
// VERIFY
|
|
22
|
+
const expected = {
|
|
23
|
+
createEntry: {
|
|
24
|
+
name: "hlad, okno",
|
|
25
|
+
description: "Orientální pouliční jídlo v ústech rychlé a snadné!",
|
|
26
|
+
locale: "cs",
|
|
27
|
+
},
|
|
28
|
+
dynamicZoneComponentKeys: []
|
|
29
|
+
};
|
|
15
30
|
|
|
31
|
+
expect(result).toEqual(expected);
|
|
32
|
+
});
|
|
33
|
+
it("should return transformed 'cookbook' entry to strapi create entry structure", () => {
|
|
16
34
|
// EXECUTE
|
|
17
35
|
const result = parsedLocalazyEntryToCreateEntry(
|
|
18
|
-
JSON.parse("[{\"kind\":\"singleType\",\"collectionName\":\"a_first_positioned_some_test_single_types\",\"info\":{\"singularName\":\"a-first-positioned-some-test-single-type\",\"pluralName\":\"a-first-positioned-some-test-single-types\",\"displayName\":\"a_first_positioned_some_test_single_type\"},\"options\":{\"draftAndPublish\":true},\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"attributes\":{\"label\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"createdAt\":{\"type\":\"datetime\"},\"updatedAt\":{\"type\":\"datetime\"},\"publishedAt\":{\"type\":\"datetime\",\"configurable\":false,\"writable\":true,\"visible\":false},\"createdBy\":{\"type\":\"relation\",\"relation\":\"oneToOne\",\"target\":\"admin::user\",\"configurable\":false,\"writable\":false,\"visible\":false,\"useJoinTable\":false,\"private\":true},\"updatedBy\":{\"type\":\"relation\",\"relation\":\"oneToOne\",\"target\":\"admin::user\",\"configurable\":false,\"writable\":false,\"visible\":false,\"useJoinTable\":false,\"private\":true},\"localizations\":{\"writable\":true,\"private\":false,\"configurable\":false,\"visible\":false,\"type\":\"relation\",\"relation\":\"oneToMany\",\"target\":\"api::a-first-positioned-some-test-single-type.a-first-positioned-some-test-single-type\"},\"locale\":{\"writable\":true,\"private\":false,\"configurable\":false,\"visible\":false,\"type\":\"string\"}},\"__schema__\":{\"collectionName\":\"a_first_positioned_some_test_single_types\",\"info\":{\"singularName\":\"a-first-positioned-some-test-single-type\",\"pluralName\":\"a-first-positioned-some-test-single-types\",\"displayName\":\"a_first_positioned_some_test_single_type\"},\"options\":{\"draftAndPublish\":true},\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"attributes\":{\"label\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"}},\"kind\":\"singleType\"},\"modelType\":\"contentType\",\"modelName\":\"a-first-positioned-some-test-single-type\",\"connection\":\"default\",\"uid\":\"api::a-first-positioned-some-test-single-type.a-first-positioned-some-test-single-type\",\"apiName\":\"a-first-positioned-some-test-single-type\",\"globalId\":\"AFirstPositionedSomeTestSingleType\",\"actions\":{},\"lifecycles\":{},\"singularName\":\"a-first-positioned-some-test-single-type\",\"tableName\":\"a_first_positioned_some_test_single_types\"},{\"kind\":\"collectionType\",\"collectionName\":\"books\",\"info\":{\"singularName\":\"book\",\"pluralName\":\"books\",\"displayName\":\"Book\",\"description\":\"\"},\"options\":{\"draftAndPublish\":true},\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"attributes\":{\"Title\":{\"type\":\"string\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"Author\":{\"type\":\"string\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"Pages\":{\"type\":\"integer\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"additional_info\":{\"type\":\"component\",\"repeatable\":false,\"component\":\"food.pub-component-1\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"cover\":{\"type\":\"relation\",\"relation\":\"morphOne\",\"target\":\"plugin::upload.file\",\"morphBy\":\"related\"},\"presentations\":{\"type\":\"relation\",\"relation\":\"morphMany\",\"target\":\"plugin::upload.file\",\"morphBy\":\"related\"},\"seo_setup\":{\"type\":\"component\",\"repeatable\":true,\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"component\":\"seo.gallery\"},\"non_localizable_name\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"createdAt\":{\"type\":\"datetime\"},\"updatedAt\":{\"type\":\"datetime\"},\"publishedAt\":{\"type\":\"datetime\",\"configurable\":false,\"writable\":true,\"visible\":false},\"createdBy\":{\"type\":\"relation\",\"relation\":\"oneToOne\",\"target\":\"admin::user\",\"configurable\":false,\"writable\":false,\"visible\":false,\"useJoinTable\":false,\"private\":true},\"updatedBy\":{\"type\":\"relation\",\"relation\":\"oneToOne\",\"target\":\"admin::user\",\"configurable\":false,\"writable\":false,\"visible\":false,\"useJoinTable\":false,\"private\":true},\"localizations\":{\"writable\":true,\"private\":false,\"configurable\":false,\"visible\":false,\"type\":\"relation\",\"relation\":\"oneToMany\",\"target\":\"api::book.book\"},\"locale\":{\"writable\":true,\"private\":false,\"configurable\":false,\"visible\":false,\"type\":\"string\"}},\"__schema__\":{\"collectionName\":\"books\",\"info\":{\"singularName\":\"book\",\"pluralName\":\"books\",\"displayName\":\"Book\",\"description\":\"\"},\"options\":{\"draftAndPublish\":true},\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"attributes\":{\"Title\":{\"type\":\"string\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"Author\":{\"type\":\"string\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"Pages\":{\"type\":\"integer\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"additional_info\":{\"type\":\"component\",\"repeatable\":false,\"component\":\"food.pub-component-1\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"cover\":{\"type\":\"media\",\"multiple\":false,\"required\":false,\"allowedTypes\":[\"images\",\"files\",\"videos\",\"audios\"],\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"presentations\":{\"type\":\"media\",\"multiple\":true,\"required\":false,\"allowedTypes\":[\"images\",\"files\",\"videos\",\"audios\"],\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"seo_setup\":{\"type\":\"component\",\"repeatable\":true,\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"component\":\"seo.gallery\"},\"non_localizable_name\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"}},\"kind\":\"collectionType\"},\"modelType\":\"contentType\",\"modelName\":\"book\",\"connection\":\"default\",\"uid\":\"api::book.book\",\"apiName\":\"book\",\"globalId\":\"Book\",\"actions\":{},\"lifecycles\":{},\"singularName\":\"book\",\"tableName\":\"books\"},{\"kind\":\"collectionType\",\"collectionName\":\"loc_5087s\",\"info\":{\"singularName\":\"loc-5087\",\"pluralName\":\"loc-5087s\",\"displayName\":\"LOC-5087\",\"description\":\"\"},\"options\":{\"draftAndPublish\":true},\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"attributes\":{\"ingredients\":{\"type\":\"component\",\"repeatable\":true,\"component\":\"food.ingredients\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"createdAt\":{\"type\":\"datetime\"},\"updatedAt\":{\"type\":\"datetime\"},\"publishedAt\":{\"type\":\"datetime\",\"configurable\":false,\"writable\":true,\"visible\":false},\"createdBy\":{\"type\":\"relation\",\"relation\":\"oneToOne\",\"target\":\"admin::user\",\"configurable\":false,\"writable\":false,\"visible\":false,\"useJoinTable\":false,\"private\":true},\"updatedBy\":{\"type\":\"relation\",\"relation\":\"oneToOne\",\"target\":\"admin::user\",\"configurable\":false,\"writable\":false,\"visible\":false,\"useJoinTable\":false,\"private\":true},\"localizations\":{\"writable\":true,\"private\":false,\"configurable\":false,\"visible\":false,\"type\":\"relation\",\"relation\":\"oneToMany\",\"target\":\"api::loc-5087.loc-5087\"},\"locale\":{\"writable\":true,\"private\":false,\"configurable\":false,\"visible\":false,\"type\":\"string\"}},\"__schema__\":{\"collectionName\":\"loc_5087s\",\"info\":{\"singularName\":\"loc-5087\",\"pluralName\":\"loc-5087s\",\"displayName\":\"LOC-5087\",\"description\":\"\"},\"options\":{\"draftAndPublish\":true},\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"attributes\":{\"ingredients\":{\"type\":\"component\",\"repeatable\":true,\"component\":\"food.ingredients\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}}},\"kind\":\"collectionType\"},\"modelType\":\"contentType\",\"modelName\":\"loc-5087\",\"connection\":\"default\",\"uid\":\"api::loc-5087.loc-5087\",\"apiName\":\"loc-5087\",\"globalId\":\"Loc5087\",\"actions\":{},\"lifecycles\":{},\"singularName\":\"loc-5087\",\"tableName\":\"loc_5087s\"},{\"kind\":\"collectionType\",\"collectionName\":\"restaurants\",\"info\":{\"singularName\":\"restaurant\",\"pluralName\":\"restaurants\",\"displayName\":\"Restaurant\",\"description\":\"\"},\"options\":{\"draftAndPublish\":true},\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"attributes\":{\"title\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\",\"required\":true},\"description\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"text\"},\"books\":{\"type\":\"relation\",\"relation\":\"oneToMany\",\"target\":\"api::book.book\"},\"recipes\":{\"type\":\"component\",\"repeatable\":true,\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"component\":\"food.recipe\"},\"descs\":{\"type\":\"component\",\"repeatable\":false,\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"component\":\"food.pub-component-1\"},\"street\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"city\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"country\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"Motto\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"motto_2\":{\"pluginOptions\":{\"i18n\":{\"localized\":false}},\"type\":\"string\"},\"title_2\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"createdAt\":{\"type\":\"datetime\"},\"updatedAt\":{\"type\":\"datetime\"},\"publishedAt\":{\"type\":\"datetime\",\"configurable\":false,\"writable\":true,\"visible\":false},\"createdBy\":{\"type\":\"relation\",\"relation\":\"oneToOne\",\"target\":\"admin::user\",\"configurable\":false,\"writable\":false,\"visible\":false,\"useJoinTable\":false,\"private\":true},\"updatedBy\":{\"type\":\"relation\",\"relation\":\"oneToOne\",\"target\":\"admin::user\",\"configurable\":false,\"writable\":false,\"visible\":false,\"useJoinTable\":false,\"private\":true},\"localizations\":{\"writable\":true,\"private\":false,\"configurable\":false,\"visible\":false,\"type\":\"relation\",\"relation\":\"oneToMany\",\"target\":\"api::restaurant.restaurant\"},\"locale\":{\"writable\":true,\"private\":false,\"configurable\":false,\"visible\":false,\"type\":\"string\"}},\"__schema__\":{\"collectionName\":\"restaurants\",\"info\":{\"singularName\":\"restaurant\",\"pluralName\":\"restaurants\",\"displayName\":\"Restaurant\",\"description\":\"\"},\"options\":{\"draftAndPublish\":true},\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"attributes\":{\"title\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\",\"required\":true},\"description\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"text\"},\"books\":{\"type\":\"relation\",\"relation\":\"oneToMany\",\"target\":\"api::book.book\"},\"recipes\":{\"type\":\"component\",\"repeatable\":true,\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"component\":\"food.recipe\"},\"descs\":{\"type\":\"component\",\"repeatable\":false,\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"component\":\"food.pub-component-1\"},\"street\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"city\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"country\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"Motto\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"motto_2\":{\"pluginOptions\":{\"i18n\":{\"localized\":false}},\"type\":\"string\"},\"title_2\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"}},\"kind\":\"collectionType\"},\"modelType\":\"contentType\",\"modelName\":\"restaurant\",\"connection\":\"default\",\"uid\":\"api::restaurant.restaurant\",\"apiName\":\"restaurant\",\"globalId\":\"Restaurant\",\"actions\":{},\"lifecycles\":{},\"singularName\":\"restaurant\",\"tableName\":\"restaurants\"},{\"collectionName\":\"components_food_ingredient_variants\",\"info\":{\"displayName\":\"ingredient_variants\",\"icon\":\"atlas\"},\"options\":{},\"attributes\":{\"name\":{\"type\":\"string\"}},\"__filename__\":\"ingredient-variants.json\",\"__schema__\":{\"collectionName\":\"components_food_ingredient_variants\",\"info\":{\"displayName\":\"ingredient_variants\",\"icon\":\"atlas\"},\"options\":{},\"attributes\":{\"name\":{\"type\":\"string\"}},\"__filename__\":\"ingredient-variants.json\"},\"uid\":\"food.ingredient-variants\",\"category\":\"food\",\"modelType\":\"component\",\"modelName\":\"ingredient-variants\",\"globalId\":\"ComponentFoodIngredientVariants\",\"singularName\":\"ingredient-variants\",\"tableName\":\"components_food_ingredient_variants\"},{\"collectionName\":\"components_food_ingredients\",\"info\":{\"displayName\":\"ingredients\",\"icon\":\"atom\",\"description\":\"\"},\"options\":{},\"attributes\":{\"name\":{\"type\":\"string\",\"required\":true},\"pcs\":{\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"}},\"__filename__\":\"ingredients.json\",\"__schema__\":{\"collectionName\":\"components_food_ingredients\",\"info\":{\"displayName\":\"ingredients\",\"icon\":\"atom\",\"description\":\"\"},\"options\":{},\"attributes\":{\"name\":{\"type\":\"string\",\"required\":true},\"pcs\":{\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"}},\"__filename__\":\"ingredients.json\"},\"uid\":\"food.ingredients\",\"category\":\"food\",\"modelType\":\"component\",\"modelName\":\"ingredients\",\"globalId\":\"ComponentFoodIngredients\",\"singularName\":\"ingredients\",\"tableName\":\"components_food_ingredients\"},{\"collectionName\":\"components_food_pub_component_1s\",\"info\":{\"displayName\":\"Pub Component 1\",\"icon\":\"american-sign-language-interpreting\",\"description\":\"\"},\"options\":{},\"attributes\":{\"rich_description\":{\"type\":\"richtext\"},\"history\":{\"type\":\"text\"},\"excerpt\":{\"type\":\"string\"},\"test_variants\":{\"type\":\"component\",\"repeatable\":false,\"component\":\"food.ingredient-variants\"}},\"__filename__\":\"pub-component-1.json\",\"__schema__\":{\"collectionName\":\"components_food_pub_component_1s\",\"info\":{\"displayName\":\"Pub Component 1\",\"icon\":\"american-sign-language-interpreting\",\"description\":\"\"},\"options\":{},\"attributes\":{\"rich_description\":{\"type\":\"richtext\"},\"history\":{\"type\":\"text\"},\"excerpt\":{\"type\":\"string\"},\"test_variants\":{\"type\":\"component\",\"repeatable\":false,\"component\":\"food.ingredient-variants\"}},\"__filename__\":\"pub-component-1.json\"},\"uid\":\"food.pub-component-1\",\"category\":\"food\",\"modelType\":\"component\",\"modelName\":\"pub-component-1\",\"globalId\":\"ComponentFoodPubComponent1\",\"singularName\":\"pub-component-1\",\"tableName\":\"components_food_pub_component_1s\"},{\"collectionName\":\"components_food_recipes\",\"info\":{\"displayName\":\"recipe\",\"icon\":\"ad\",\"description\":\"\"},\"options\":{},\"attributes\":{\"name\":{\"type\":\"string\",\"required\":true},\"ingredients\":{\"type\":\"component\",\"repeatable\":true,\"component\":\"food.ingredients\"},\"variants\":{\"type\":\"component\",\"repeatable\":false,\"component\":\"food.ingredient-variants\"}},\"__filename__\":\"recipe.json\",\"__schema__\":{\"collectionName\":\"components_food_recipes\",\"info\":{\"displayName\":\"recipe\",\"icon\":\"ad\",\"description\":\"\"},\"options\":{},\"attributes\":{\"name\":{\"type\":\"string\",\"required\":true},\"ingredients\":{\"type\":\"component\",\"repeatable\":true,\"component\":\"food.ingredients\"},\"variants\":{\"type\":\"component\",\"repeatable\":false,\"component\":\"food.ingredient-variants\"}},\"__filename__\":\"recipe.json\"},\"uid\":\"food.recipe\",\"category\":\"food\",\"modelType\":\"component\",\"modelName\":\"recipe\",\"globalId\":\"ComponentFoodRecipe\",\"singularName\":\"recipe\",\"tableName\":\"components_food_recipes\"},{\"collectionName\":\"components_seo_galleries\",\"info\":{\"displayName\":\"Gallery\",\"icon\":\"address-card\",\"description\":\"\"},\"options\":{},\"attributes\":{\"main_image\":{\"type\":\"relation\",\"relation\":\"morphOne\",\"target\":\"plugin::upload.file\",\"morphBy\":\"related\"},\"rest\":{\"type\":\"relation\",\"relation\":\"morphMany\",\"target\":\"plugin::upload.file\",\"morphBy\":\"related\"},\"seo_desc\":{\"type\":\"string\"}},\"__filename__\":\"gallery.json\",\"__schema__\":{\"collectionName\":\"components_seo_galleries\",\"info\":{\"displayName\":\"Gallery\",\"icon\":\"address-card\",\"description\":\"\"},\"options\":{},\"attributes\":{\"main_image\":{\"type\":\"media\",\"multiple\":false,\"required\":false,\"allowedTypes\":[\"images\",\"files\",\"videos\",\"audios\"]},\"rest\":{\"type\":\"media\",\"multiple\":true,\"required\":false,\"allowedTypes\":[\"images\",\"videos\",\"audios\",\"files\"]},\"seo_desc\":{\"type\":\"string\"}},\"__filename__\":\"gallery.json\"},\"uid\":\"seo.gallery\",\"category\":\"seo\",\"modelType\":\"component\",\"modelName\":\"gallery\",\"globalId\":\"ComponentSeoGallery\",\"singularName\":\"gallery\",\"tableName\":\"components_seo_galleries\"}]"),
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
36
|
+
allModels,
|
|
37
|
+
cookbookModel.parsedLocalazyEntry,
|
|
38
|
+
cookbookModel.baseEntry,
|
|
39
|
+
cookbookModel.uid,
|
|
40
|
+
cookbookModel.locale
|
|
23
41
|
);
|
|
24
42
|
|
|
25
43
|
// VERIFY
|
|
26
44
|
const expected = {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
45
|
+
createEntry: {
|
|
46
|
+
title: "Pro každý den v roce",
|
|
47
|
+
recipes: [
|
|
48
|
+
{
|
|
49
|
+
name: "Bramborový salát",
|
|
50
|
+
__component: "food.cookbook-item",
|
|
51
|
+
recipe: "Oloupejte brambory, smíchejte je se všemi ingrediencemi a máte hotovo. Bon apetit!",
|
|
52
|
+
author_name: "Mr. Bramborová hlava",
|
|
53
|
+
gallery: [
|
|
54
|
+
{
|
|
55
|
+
image_title: "Syrové brambory",
|
|
56
|
+
__component: "food.gallery-item",
|
|
57
|
+
image_description: "Čerstvý!",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
image_title: "Salát",
|
|
61
|
+
__component: "food.gallery-item",
|
|
62
|
+
image_description: "Mňam!",
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
ingredients: [
|
|
66
|
+
{
|
|
67
|
+
name: "Brambory",
|
|
68
|
+
__component: "food.recipe-ingredient",
|
|
69
|
+
unit: "kg",
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "Hrášek",
|
|
73
|
+
__component: "food.recipe-ingredient",
|
|
74
|
+
unit: "plechovka",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "Kukuřice",
|
|
78
|
+
__component: "food.recipe-ingredient",
|
|
79
|
+
unit: "plechovka",
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: "Mayo",
|
|
83
|
+
__component: "food.recipe-ingredient",
|
|
84
|
+
unit: "lžíce",
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: "Sýr",
|
|
88
|
+
__component: "food.recipe-ingredient",
|
|
89
|
+
unit: "blok",
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "Apple",
|
|
93
|
+
__component: "food.recipe-ingredient",
|
|
94
|
+
unit: "ks",
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
gallery: {
|
|
100
|
+
__component: "food.gallery",
|
|
101
|
+
annotation: "Podívejte se na naše chutné jídlo, pak čtěte dál a ponořte se do kulinářského nebe!",
|
|
102
|
+
main_image: {
|
|
103
|
+
__component: "food.gallery-item",
|
|
104
|
+
image_title: "Kuchařka",
|
|
105
|
+
image_description: "Brožura II",
|
|
106
|
+
},
|
|
107
|
+
gallery: [
|
|
108
|
+
{
|
|
109
|
+
image_description: "Brožura a listy a vidlice.",
|
|
110
|
+
__component: "food.gallery-item",
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
image_title: "Koření",
|
|
114
|
+
__component: "food.gallery-item",
|
|
115
|
+
},
|
|
116
|
+
],
|
|
79
117
|
},
|
|
118
|
+
locale: "cs",
|
|
119
|
+
},
|
|
120
|
+
dynamicZoneComponentKeys: [],
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
expect(result).toEqual(expected);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("should return transformed 'lesson' entry including Dynamic Zones to strapi create entry structure", () => {
|
|
127
|
+
// EXECUTE
|
|
128
|
+
const result = parsedLocalazyEntryToCreateEntry(
|
|
129
|
+
allModels,
|
|
130
|
+
lessonDZModel.parsedLocalazyEntry,
|
|
131
|
+
lessonDZModel.baseEntry,
|
|
132
|
+
lessonDZModel.uid,
|
|
133
|
+
lessonDZModel.locale
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
// VERIFY
|
|
137
|
+
const expected = {
|
|
138
|
+
createEntry: {
|
|
139
|
+
title: "Test: Sčítání",
|
|
140
|
+
description: "Otestujte si své dovednosti, které jsme se naučili v předchozí lekci.",
|
|
141
|
+
lesson_type: [
|
|
142
|
+
{
|
|
143
|
+
title: "Vyberte správnou odpověď",
|
|
144
|
+
__component: "lesson.quiz",
|
|
145
|
+
questions: [
|
|
146
|
+
{
|
|
147
|
+
question: "1 + 1 = ",
|
|
148
|
+
__component: "lesson.survey-question",
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
question: "5 + 15 = ",
|
|
152
|
+
__component: "lesson.survey-question",
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
question: "Kolik pohárů je na fotce?",
|
|
156
|
+
__component: "lesson.survey-question",
|
|
157
|
+
},
|
|
158
|
+
],
|
|
159
|
+
answers: [
|
|
160
|
+
{
|
|
161
|
+
correct_answer: "2",
|
|
162
|
+
__component: "lesson.answers",
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
correct_answer: "20",
|
|
166
|
+
__component: "lesson.answers",
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
correct_answer: "15",
|
|
170
|
+
__component: "lesson.answers",
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
},
|
|
174
|
+
],
|
|
175
|
+
locale: "cs",
|
|
176
|
+
},
|
|
177
|
+
dynamicZoneComponentKeys: [
|
|
80
178
|
{
|
|
81
|
-
|
|
82
|
-
|
|
179
|
+
key: "lesson_type.0.__component",
|
|
180
|
+
component: "lesson.quiz",
|
|
83
181
|
},
|
|
84
|
-
]
|
|
85
|
-
}
|
|
182
|
+
]
|
|
183
|
+
};
|
|
184
|
+
|
|
86
185
|
expect(result).toEqual(expected);
|
|
87
186
|
});
|
|
88
|
-
it("should return transformed book entry to strapi create entry structure", () => {
|
|
89
|
-
// SETUP
|
|
90
|
-
const uid = "api::book.book";
|
|
91
|
-
const entry = JSON.parse(stringifiedBookCs);
|
|
92
|
-
|
|
93
|
-
const locale = "cs";
|
|
94
187
|
|
|
188
|
+
it("should return transformed 'sample-json' entry including Dynamic Zones to strapi create entry structure", () => {
|
|
95
189
|
// EXECUTE
|
|
96
190
|
const result = parsedLocalazyEntryToCreateEntry(
|
|
97
191
|
allModels,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
uid,
|
|
101
|
-
locale
|
|
192
|
+
sampleJSONDZModel.parsedLocalazyEntry,
|
|
193
|
+
sampleJSONDZModel.baseEntry,
|
|
194
|
+
sampleJSONDZModel.uid,
|
|
102
195
|
);
|
|
103
196
|
|
|
104
197
|
// VERIFY
|
|
105
198
|
const expected = {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
199
|
+
createEntry: {
|
|
200
|
+
purpose: "Bar",
|
|
201
|
+
repeatable_component_property: [
|
|
202
|
+
{
|
|
203
|
+
name: "Položka 1",
|
|
204
|
+
__component: "restaurant.menu-item",
|
|
205
|
+
description: "Nějaký popis",
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
name: "Položka 2",
|
|
209
|
+
__component: "restaurant.menu-item",
|
|
210
|
+
description: "Nějaký další popis",
|
|
211
|
+
},
|
|
212
|
+
],
|
|
213
|
+
dynamic_property: [
|
|
214
|
+
{
|
|
215
|
+
image_title: "Nějaký název obrázku",
|
|
216
|
+
__component: "food.gallery-item",
|
|
217
|
+
image_description: "Nějaký popis obrázku",
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
name: "Přísada I",
|
|
221
|
+
__component: "food.recipe-ingredient",
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
name: "První položka CB",
|
|
225
|
+
__component: "food.cookbook-item",
|
|
226
|
+
author_name: "Já",
|
|
227
|
+
ingredients: [
|
|
228
|
+
{
|
|
229
|
+
name: "První Ingr DZ",
|
|
230
|
+
__component: "food.recipe-ingredient",
|
|
231
|
+
},
|
|
232
|
+
],
|
|
233
|
+
gallery: [
|
|
234
|
+
{
|
|
235
|
+
image_title: "Obrázek G Jedna",
|
|
236
|
+
__component: "food.gallery-item",
|
|
237
|
+
image_description: "Obrázek G Popis Jedna",
|
|
238
|
+
},
|
|
239
|
+
],
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
name: "Druhá přísada",
|
|
243
|
+
__component: "food.recipe-ingredient",
|
|
244
|
+
},
|
|
245
|
+
],
|
|
118
246
|
},
|
|
247
|
+
dynamicZoneComponentKeys: [
|
|
248
|
+
{
|
|
249
|
+
key: "dynamic_property.2.__component",
|
|
250
|
+
component: "food.cookbook-item",
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
key: "dynamic_property.0.__component",
|
|
254
|
+
component: "food.gallery-item",
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
key: "dynamic_property.1.__component",
|
|
258
|
+
component: "food.recipe-ingredient",
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
key: "dynamic_property.3.__component",
|
|
262
|
+
component: "food.recipe-ingredient",
|
|
263
|
+
},
|
|
264
|
+
]
|
|
119
265
|
};
|
|
120
266
|
|
|
121
267
|
expect(result).toEqual(expected);
|