diff --git a/examples/getstarted/components/default/openingtimes.json b/examples/getstarted/components/default/openingtimes.json index a197ceba32..9d38e81ac0 100644 --- a/examples/getstarted/components/default/openingtimes.json +++ b/examples/getstarted/components/default/openingtimes.json @@ -13,6 +13,7 @@ }, "time": { "type": "string" - } + }, + "dishrep": { "type": "component", "repeatable": true, "component": "default.dish" } } } diff --git a/packages/strapi-plugin-content-manager/admin/src/containers/EditView/utils/getDraftRelations.js b/packages/strapi-plugin-content-manager/admin/src/containers/EditView/utils/getDraftRelations.js new file mode 100644 index 0000000000..43e02205dd --- /dev/null +++ b/packages/strapi-plugin-content-manager/admin/src/containers/EditView/utils/getDraftRelations.js @@ -0,0 +1,74 @@ +import { get, has, isEmpty } from 'lodash'; + +const getDraftRelations = (data, ctSchema, components) => { + const getDraftRelationsCount = (data, schema) => + Object.keys(data).reduce((acc, current) => { + const type = get(schema, ['schema', 'attributes', current, 'type'], 'string'); + const relationType = get(schema, ['schema', 'attributes', current, 'relationType'], ''); + const isMorph = relationType.toLowerCase().includes('morph'); + const oneWayTypes = ['oneWay', 'oneToOne', 'manyToOne']; + const currentData = data[current]; + + if (type === 'dynamiczone') { + const dzDraftCount = currentData.reduce((acc2, curr) => { + const compoSchema = get(components, curr.__component, {}); + + acc2 += getDraftRelationsCount(curr, compoSchema); + + return acc2; + }, 0); + + acc += dzDraftCount; + } + + if (type === 'component') { + const isRepeatable = get(schema, ['schema', 'attributes', current, 'repeatable'], false); + const compoUID = get(schema, ['schema', 'attributes', current, 'component'], ''); + const compoSchema = get(components, compoUID, {}); + + if (isRepeatable) { + const compoCount = currentData.reduce((acc2, curr) => { + acc2 += getDraftRelationsCount(curr, compoSchema); + + return acc2; + }, 0); + + acc += compoCount; + } else { + acc += getDraftRelationsCount(currentData, compoSchema); + } + } + + if (type === 'relation' && !isMorph) { + if (oneWayTypes.includes(relationType)) { + const hasDraftAndPublish = has(currentData, 'published_at'); + + if (hasDraftAndPublish && isEmpty(currentData.published_at)) { + acc += 1; + } + } else { + const hasDraftAndPublish = currentData.some(value => has(value, 'published_at')); + + if (hasDraftAndPublish) { + const count = currentData.reduce((acc, current) => { + if (isEmpty(current.published_at)) { + acc += 1; + } + + return acc; + }, 0); + + acc += count; + } + } + } + + return acc; + }, 0); + + const count = getDraftRelationsCount(data, ctSchema, components); + + return count; +}; + +export default getDraftRelations; diff --git a/packages/strapi-plugin-content-manager/admin/src/containers/EditView/utils/tests/data/compos-schema.json b/packages/strapi-plugin-content-manager/admin/src/containers/EditView/utils/tests/data/compos-schema.json new file mode 100644 index 0000000000..2d47d0f950 --- /dev/null +++ b/packages/strapi-plugin-content-manager/admin/src/containers/EditView/utils/tests/data/compos-schema.json @@ -0,0 +1,103 @@ +{ + "default.closingperiod": { + "category": "default", + "uid": "default.closingperiod", + "name": "closingperiod", + "apiID": "closingperiod", + "label": "Closingperiods", + "isDisplayed": true, + "schema": { + "modelType": "component", + "connection": "default", + "collectionName": "components_closingperiods", + "info": { "name": "closingperiod", "description": "", "icon": "angry" }, + "options": { "timestamps": false }, + "attributes": { + "id": { "type": "integer" }, + "label": { "type": "string" }, + "start_date": { "type": "date", "required": true }, + "end_date": { "type": "date", "required": true }, + "media": { "type": "media", "multiple": false, "required": false }, + "dish": { "component": "default.dish", "type": "component" } + }, + "kind": "collectionType" + } + }, + "default.dish": { + "category": "default", + "uid": "default.dish", + "name": "dish", + "apiID": "dish", + "label": "Dishes", + "isDisplayed": true, + "schema": { + "modelType": "component", + "connection": "default", + "collectionName": "components_dishes", + "info": { "name": "dish", "description": "", "icon": "address-book" }, + "options": { "timestamps": false }, + "attributes": { + "id": { "type": "integer" }, + "name": { "type": "string", "required": false, "default": "My super dish" }, + "description": { "type": "text" }, + "price": { "type": "float" }, + "picture": { "type": "media", "multiple": false, "required": false }, + "very_long_description": { "type": "richtext" }, + "categories": { + "collection": "category", + "attribute": "category", + "column": "id", + "isVirtual": true, + "type": "relation", + "targetModel": "application::category.category", + "relationType": "manyWay" + } + }, + "kind": "collectionType" + } + }, + "default.openingtimes": { + "category": "default", + "uid": "default.openingtimes", + "name": "openingtimes", + "apiID": "openingtimes", + "label": "Openingtimes", + "isDisplayed": true, + "schema": { + "modelType": "component", + "connection": "default", + "collectionName": "components_openingtimes", + "info": { "name": "openingtimes", "description": "", "icon": "calendar" }, + "options": { "timestamps": false }, + "attributes": { + "id": { "type": "integer" }, + "label": { "type": "string", "required": true, "default": "something" }, + "time": { "type": "string" }, + "dishrep": { "type": "component", "repeatable": true, "component": "default.dish" } + }, + "kind": "collectionType" + } + }, + "default.restaurantservice": { + "category": "default", + "uid": "default.restaurantservice", + "name": "restaurantservice", + "apiID": "restaurantservice", + "label": "Restaurantservices", + "isDisplayed": true, + "schema": { + "modelType": "component", + "connection": "default", + "collectionName": "components_restaurantservices", + "info": { "name": "restaurantservice", "description": "", "icon": "cannabis" }, + "options": { "timestamps": false }, + "attributes": { + "id": { "type": "integer" }, + "name": { "type": "string", "required": true, "default": "something" }, + "media": { "type": "media", "multiple": false, "required": false }, + "is_available": { "type": "boolean", "required": true, "default": true } + }, + "kind": "collectionType" + } + } +} diff --git a/packages/strapi-plugin-content-manager/admin/src/containers/EditView/utils/tests/data/ct-schema.json b/packages/strapi-plugin-content-manager/admin/src/containers/EditView/utils/tests/data/ct-schema.json new file mode 100644 index 0000000000..ff659cf6bc --- /dev/null +++ b/packages/strapi-plugin-content-manager/admin/src/containers/EditView/utils/tests/data/ct-schema.json @@ -0,0 +1,84 @@ +{ + "uid": "application::restaurant.restaurant", + "name": "restaurant", + "apiID": "restaurant", + "label": "Restaurants", + "isDisplayed": true, + "schema": { + "modelType": "contentType", + "connection": "default", + "collectionName": "restaurants", + "info": { "name": "restaurant", "description": "" }, + "options": { + "draftAndPublish": false, + "increments": true, + "timestamps": ["created_at", "updated_at"], + "comment": "" + }, + "attributes": { + "id": { "type": "integer" }, + "name": { "maxLength": 50, "required": true, "minLength": 5, "type": "string" }, + "slug": { "type": "uid", "targetField": "name" }, + "price_range": { + "enum": ["very_cheap", "cheap", "average", "expensive", "very_expensive"], + "type": "enumeration" + }, + "closing_period": { "component": "default.closingperiod", "type": "component" }, + "contact_email": { "type": "email" }, + "stars": { "required": true, "type": "integer", "min": 0, "max": 3 }, + "averagePrice": { "type": "float", "min": 0, "max": 35.12 }, + "address": { + "model": "address", + "type": "relation", + "targetModel": "application::address.address", + "relationType": "oneWay" + }, + "cover": { "type": "media", "multiple": false, "required": false }, + "timestamp": { "type": "timestamp" }, + "images": { "type": "media", "multiple": true, "required": false }, + "short_description": { "type": "text" }, + "since": { "type": "date" }, + "categories": { + "collection": "category", + "attribute": "category", + "column": "id", + "isVirtual": true, + "type": "relation", + "targetModel": "application::category.category", + "relationType": "manyWay" + }, + "description": { "type": "richtext", "required": true, "minLength": 10 }, + "services": { + "component": "default.restaurantservice", + "repeatable": true, + "type": "component" + }, + "menu": { + "model": "menu", + "via": "restaurant", + "type": "relation", + "targetModel": "application::menu.menu", + "relationType": "oneToOne" + }, + "opening_times": { + "component": "default.openingtimes", + "type": "component", + "repeatable": true, + "min": 1, + "max": 10 + }, + "dz": { + "type": "dynamiczone", + "components": [ + "default.openingtimes", + "default.restaurantservice", + "default.closingperiod", + "default.dish" + ] + }, + "created_at": { "type": "timestamp" }, + "updated_at": { "type": "timestamp" } + }, + "kind": "collectionType" + } +} diff --git a/packages/strapi-plugin-content-manager/admin/src/containers/EditView/utils/tests/data/entry-compos.json b/packages/strapi-plugin-content-manager/admin/src/containers/EditView/utils/tests/data/entry-compos.json new file mode 100644 index 0000000000..2282ad9e48 --- /dev/null +++ b/packages/strapi-plugin-content-manager/admin/src/containers/EditView/utils/tests/data/entry-compos.json @@ -0,0 +1,462 @@ +{ + "id": 1, + "name": "teststest", + "slug": "teststest", + "price_range": "very_cheap", + "contact_email": "contact@email.com", + "stars": 1, + "averagePrice": 1, + "timestamp": null, + "short_description": "test test", + "since": "2020-09-02", + "description": "test test test test ", + "created_by": { "id": 1, "firstname": "cyril", "lastname": "lopez", "username": null }, + "updated_by": { "id": 1, "firstname": "cyril", "lastname": "lopez", "username": null }, + "created_at": "2020-09-01T14:47:53.257Z", + "updated_at": "2020-09-01T14:47:53.627Z", + "closing_period": { + "id": 1, + "label": "closing labe", + "start_date": "2020-09-02", + "end_date": "2020-09-02", + "dish": { + "id": 1, + "name": "My super dish", + "description": "gdfg", + "price": 0.02, + "very_long_description": "test test test", + "picture": { + "id": 1, + "name": "Screenshot 2020-07-15 at 18.54.56.png", + "alternativeText": "", + "caption": "", + "width": 1996, + "height": 1124, + "formats": { + "thumbnail": { + "name": "thumbnail_Screenshot 2020-07-15 at 18.54.56.png", + "hash": "thumbnail_Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "width": 245, + "height": 138, + "size": 5.27, + "path": null, + "url": "/uploads/thumbnail_Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png" + }, + "large": { + "name": "large_Screenshot 2020-07-15 at 18.54.56.png", + "hash": "large_Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "width": 1000, + "height": 563, + "size": 40.75, + "path": null, + "url": "/uploads/large_Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png" + }, + "medium": { + "name": "medium_Screenshot 2020-07-15 at 18.54.56.png", + "hash": "medium_Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "width": 750, + "height": 422, + "size": 27.2, + "path": null, + "url": "/uploads/medium_Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png" + }, + "small": { + "name": "small_Screenshot 2020-07-15 at 18.54.56.png", + "hash": "small_Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "width": 500, + "height": 282, + "size": 15.17, + "path": null, + "url": "/uploads/small_Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png" + } + }, + "hash": "Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "size": 69.06, + "url": "/uploads/Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png", + "previewUrl": null, + "provider": "local", + "provider_metadata": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T14:35:21.346Z", + "updated_at": "2020-09-01T14:35:21.358Z" + }, + "categories": [ + { + "id": 1, + "name": "cat1", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T08:37:15.012Z", + "updated_at": "2020-09-01T12:37:33.249Z" + }, + { + "id": 2, + "name": "cat2", + "published_at": "2020-09-01T13:07:04.235Z", + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:46.798Z", + "updated_at": "2020-09-01T13:07:04.253Z" + }, + { + "id": 3, + "name": "cat3", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:51.438Z", + "updated_at": "2020-09-01T12:05:51.444Z" + } + ] + }, + "media": { + "id": 2, + "name": "Screenshot 2020-07-23 at 23.28.41.png", + "alternativeText": "", + "caption": "", + "width": 1084, + "height": 1312, + "formats": { + "thumbnail": { + "name": "thumbnail_Screenshot 2020-07-23 at 23.28.41.png", + "hash": "thumbnail_Screenshot_2020_07_23_at_23_28_41_68575e6313", + "ext": ".png", + "mime": "image/png", + "width": 129, + "height": 156, + "size": 44.23, + "path": null, + "url": "/uploads/thumbnail_Screenshot_2020_07_23_at_23_28_41_68575e6313.png" + }, + "large": { + "name": "large_Screenshot 2020-07-23 at 23.28.41.png", + "hash": "large_Screenshot_2020_07_23_at_23_28_41_68575e6313", + "ext": ".png", + "mime": "image/png", + "width": 826, + "height": 1000, + "size": 1415.04, + "path": null, + "url": "/uploads/large_Screenshot_2020_07_23_at_23_28_41_68575e6313.png" + }, + "medium": { + "name": "medium_Screenshot 2020-07-23 at 23.28.41.png", + "hash": "medium_Screenshot_2020_07_23_at_23_28_41_68575e6313", + "ext": ".png", + "mime": "image/png", + "width": 620, + "height": 750, + "size": 831.52, + "path": null, + "url": "/uploads/medium_Screenshot_2020_07_23_at_23_28_41_68575e6313.png" + }, + "small": { + "name": "small_Screenshot 2020-07-23 at 23.28.41.png", + "hash": "small_Screenshot_2020_07_23_at_23_28_41_68575e6313", + "ext": ".png", + "mime": "image/png", + "width": 413, + "height": 500, + "size": 390.82, + "path": null, + "url": "/uploads/small_Screenshot_2020_07_23_at_23_28_41_68575e6313.png" + } + }, + "hash": "Screenshot_2020_07_23_at_23_28_41_68575e6313", + "ext": ".png", + "mime": "image/png", + "size": 2065.3, + "url": "/uploads/Screenshot_2020_07_23_at_23_28_41_68575e6313.png", + "previewUrl": null, + "provider": "local", + "provider_metadata": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T14:35:38.706Z", + "updated_at": "2020-09-01T14:35:38.715Z" + } + }, + "services": [ + { + "id": 1, + "name": "something test", + "is_available": true, + "media": { + "id": 2, + "name": "Screenshot 2020-07-23 at 23.28.41.png", + "alternativeText": "", + "caption": "", + "width": 1084, + "height": 1312, + "formats": { + "thumbnail": { + "name": "thumbnail_Screenshot 2020-07-23 at 23.28.41.png", + "hash": "thumbnail_Screenshot_2020_07_23_at_23_28_41_68575e6313", + "ext": ".png", + "mime": "image/png", + "width": 129, + "height": 156, + "size": 44.23, + "path": null, + "url": "/uploads/thumbnail_Screenshot_2020_07_23_at_23_28_41_68575e6313.png" + }, + "large": { + "name": "large_Screenshot 2020-07-23 at 23.28.41.png", + "hash": "large_Screenshot_2020_07_23_at_23_28_41_68575e6313", + "ext": ".png", + "mime": "image/png", + "width": 826, + "height": 1000, + "size": 1415.04, + "path": null, + "url": "/uploads/large_Screenshot_2020_07_23_at_23_28_41_68575e6313.png" + }, + "medium": { + "name": "medium_Screenshot 2020-07-23 at 23.28.41.png", + "hash": "medium_Screenshot_2020_07_23_at_23_28_41_68575e6313", + "ext": ".png", + "mime": "image/png", + "width": 620, + "height": 750, + "size": 831.52, + "path": null, + "url": "/uploads/medium_Screenshot_2020_07_23_at_23_28_41_68575e6313.png" + }, + "small": { + "name": "small_Screenshot 2020-07-23 at 23.28.41.png", + "hash": "small_Screenshot_2020_07_23_at_23_28_41_68575e6313", + "ext": ".png", + "mime": "image/png", + "width": 413, + "height": 500, + "size": 390.82, + "path": null, + "url": "/uploads/small_Screenshot_2020_07_23_at_23_28_41_68575e6313.png" + } + }, + "hash": "Screenshot_2020_07_23_at_23_28_41_68575e6313", + "ext": ".png", + "mime": "image/png", + "size": 2065.3, + "url": "/uploads/Screenshot_2020_07_23_at_23_28_41_68575e6313.png", + "previewUrl": null, + "provider": "local", + "provider_metadata": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T14:35:38.706Z", + "updated_at": "2020-09-01T14:35:38.715Z" + } + }, + { + "id": 2, + "name": "something", + "is_available": true, + "media": { + "id": 1, + "name": "Screenshot 2020-07-15 at 18.54.56.png", + "alternativeText": "", + "caption": "", + "width": 1996, + "height": 1124, + "formats": { + "thumbnail": { + "name": "thumbnail_Screenshot 2020-07-15 at 18.54.56.png", + "hash": "thumbnail_Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "width": 245, + "height": 138, + "size": 5.27, + "path": null, + "url": "/uploads/thumbnail_Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png" + }, + "large": { + "name": "large_Screenshot 2020-07-15 at 18.54.56.png", + "hash": "large_Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "width": 1000, + "height": 563, + "size": 40.75, + "path": null, + "url": "/uploads/large_Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png" + }, + "medium": { + "name": "medium_Screenshot 2020-07-15 at 18.54.56.png", + "hash": "medium_Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "width": 750, + "height": 422, + "size": 27.2, + "path": null, + "url": "/uploads/medium_Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png" + }, + "small": { + "name": "small_Screenshot 2020-07-15 at 18.54.56.png", + "hash": "small_Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "width": 500, + "height": 282, + "size": 15.17, + "path": null, + "url": "/uploads/small_Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png" + } + }, + "hash": "Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "size": 69.06, + "url": "/uploads/Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png", + "previewUrl": null, + "provider": "local", + "provider_metadata": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T14:35:21.346Z", + "updated_at": "2020-09-01T14:35:21.358Z" + } + } + ], + "opening_times": [ + { + "id": 1, + "label": "something", + "time": "rrr", + "dishrep": [ + { + "id": 3, + "name": "My super dish", + "description": "test ", + "price": 0.1, + "very_long_description": "test test test test test ", + "picture": null, + "categories": [ + { + "id": 2, + "name": "cat2", + "published_at": "2020-09-01T13:07:04.235Z", + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:46.798Z", + "updated_at": "2020-09-01T13:07:04.253Z" + }, + { + "id": 1, + "name": "cat1", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T08:37:15.012Z", + "updated_at": "2020-09-01T12:37:33.249Z" + }, + { + "id": 3, + "name": "cat3", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:51.438Z", + "updated_at": "2020-09-01T12:05:51.444Z" + } + ] + }, + { + "id": 4, + "name": "My super dish", + "description": "test test ", + "price": 0.04, + "very_long_description": "test test test test test test test test ", + "picture": null, + "categories": [ + { + "id": 1, + "name": "cat1", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T08:37:15.012Z", + "updated_at": "2020-09-01T12:37:33.249Z" + }, + { + "id": 2, + "name": "cat2", + "published_at": "2020-09-01T13:07:04.235Z", + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:46.798Z", + "updated_at": "2020-09-01T13:07:04.253Z" + }, + { + "id": 3, + "name": "cat3", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:51.438Z", + "updated_at": "2020-09-01T12:05:51.444Z" + } + ] + } + ] + }, + { + "id": 2, + "label": "somethingtest test ", + "time": "test v", + "dishrep": [ + { + "id": 2, + "name": "My super dish", + "description": null, + "price": null, + "very_long_description": "test test test test test test ", + "picture": null, + "categories": [ + { + "id": 1, + "name": "cat1", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T08:37:15.012Z", + "updated_at": "2020-09-01T12:37:33.249Z" + }, + { + "id": 2, + "name": "cat2", + "published_at": "2020-09-01T13:07:04.235Z", + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:46.798Z", + "updated_at": "2020-09-01T13:07:04.253Z" + }, + { + "id": 3, + "name": "cat3", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:51.438Z", + "updated_at": "2020-09-01T12:05:51.444Z" + } + ] + } + ] + } + ] +} diff --git a/packages/strapi-plugin-content-manager/admin/src/containers/EditView/utils/tests/data/entry-dz.json b/packages/strapi-plugin-content-manager/admin/src/containers/EditView/utils/tests/data/entry-dz.json new file mode 100644 index 0000000000..cb9a586584 --- /dev/null +++ b/packages/strapi-plugin-content-manager/admin/src/containers/EditView/utils/tests/data/entry-dz.json @@ -0,0 +1,141 @@ +{ + "id": 1, + "name": "teststest", + "slug": "teststest", + "price_range": "very_cheap", + "contact_email": "contact@email.com", + "stars": 1, + "averagePrice": 1, + + "timestamp": null, + "short_description": "test test", + "since": "2020-09-02", + "description": "test test test test ", + "menu": { + "id": 1, + "description": "menu1", + "restaurant": 1, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T14:47:10.654Z", + "updated_at": "2020-09-01T14:47:53.568Z" + }, + "created_by": { "id": 1, "firstname": "cyril", "lastname": "lopez", "username": null }, + "updated_by": { "id": 1, "firstname": "cyril", "lastname": "lopez", "username": null }, + "created_at": "2020-09-01T14:47:53.257Z", + "updated_at": "2020-09-01T14:47:53.627Z", + + "dz": [ + { + "__component": "default.openingtimes", + "id": 3, + "label": "something", + "time": "test ", + "dishrep": [ + { + "id": 6, + "name": "My super dish", + "description": "test test ", + "price": 0.01, + "very_long_description": "\ntest test test test ", + "picture": null, + "categories": [ + { + "id": 1, + "name": "cat1", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T08:37:15.012Z", + "updated_at": "2020-09-01T12:37:33.249Z" + }, + { + "id": 2, + "name": "cat2", + "published_at": "2020-09-01T13:07:04.235Z", + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:46.798Z", + "updated_at": "2020-09-01T13:07:04.253Z" + }, + { + "id": 3, + "name": "cat3", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:51.438Z", + "updated_at": "2020-09-01T12:05:51.444Z" + } + ] + }, + { + "id": 7, + "name": "My super dish", + "description": "test test test ", + "price": 0.04, + "very_long_description": "test test test ", + "picture": null, + "categories": [ + { + "id": 3, + "name": "cat3", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:51.438Z", + "updated_at": "2020-09-01T12:05:51.444Z" + }, + { + "id": 1, + "name": "cat1", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T08:37:15.012Z", + "updated_at": "2020-09-01T12:37:33.249Z" + } + ] + } + ] + }, + { + "__component": "default.dish", + "id": 5, + "name": "My super dish", + "description": "test test test ", + "price": 0.02, + "very_long_description": "test test test ", + "picture": null, + "categories": [ + { + "id": 2, + "name": "cat2", + "published_at": "2020-09-01T13:07:04.235Z", + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:46.798Z", + "updated_at": "2020-09-01T13:07:04.253Z" + }, + { + "id": 1, + "name": "cat1", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T08:37:15.012Z", + "updated_at": "2020-09-01T12:37:33.249Z" + }, + { + "id": 3, + "name": "cat3", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:51.438Z", + "updated_at": "2020-09-01T12:05:51.444Z" + } + ] + } + ] +} diff --git a/packages/strapi-plugin-content-manager/admin/src/containers/EditView/utils/tests/data/entry-simple.json b/packages/strapi-plugin-content-manager/admin/src/containers/EditView/utils/tests/data/entry-simple.json new file mode 100644 index 0000000000..69b122712c --- /dev/null +++ b/packages/strapi-plugin-content-manager/admin/src/containers/EditView/utils/tests/data/entry-simple.json @@ -0,0 +1,68 @@ +{ + "id": 1, + "name": "teststest", + "slug": "teststest", + "price_range": "very_cheap", + "contact_email": "contact@email.com", + "stars": 1, + "averagePrice": 1, + "address": { + "id": 9, + "postal_coder": "rzerz", + "city": "rzzerze", + "published_at": "2020-08-31T13:29:02.118Z", + "created_by": 1, + "updated_by": 1, + "created_at": "2020-08-31T12:35:46.553Z", + "updated_at": "2020-08-31T13:29:02.136Z", + "cover": null, + "images": [] + }, + "timestamp": null, + "short_description": "test test", + "since": "2020-09-02", + "description": "test test test test ", + "menu": { + "id": 1, + "description": "menu1", + "restaurant": 1, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T14:47:10.654Z", + "updated_at": "2020-09-01T14:47:53.568Z" + }, + "created_by": { "id": 1, "firstname": "cyril", "lastname": "lopez", "username": null }, + "updated_by": { "id": 1, "firstname": "cyril", "lastname": "lopez", "username": null }, + "created_at": "2020-09-01T14:47:53.257Z", + "updated_at": "2020-09-01T14:47:53.627Z", + + "categories": [ + { + "id": 3, + "name": "cat3", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:51.438Z", + "updated_at": "2020-09-01T12:05:51.444Z" + }, + { + "id": 1, + "name": "cat1", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T08:37:15.012Z", + "updated_at": "2020-09-01T12:37:33.249Z" + }, + { + "id": 2, + "name": "cat2", + "published_at": "2020-09-01T13:07:04.235Z", + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:46.798Z", + "updated_at": "2020-09-01T13:07:04.253Z" + } + ] +} diff --git a/packages/strapi-plugin-content-manager/admin/src/containers/EditView/utils/tests/data/entry.json b/packages/strapi-plugin-content-manager/admin/src/containers/EditView/utils/tests/data/entry.json new file mode 100644 index 0000000000..ce069b29e2 --- /dev/null +++ b/packages/strapi-plugin-content-manager/admin/src/containers/EditView/utils/tests/data/entry.json @@ -0,0 +1,825 @@ +{ + "id": 1, + "name": "teststest", + "slug": "teststest", + "price_range": "very_cheap", + "contact_email": "contact@email.com", + "stars": 1, + "averagePrice": 1, + "address": { + "id": 9, + "postal_coder": "rzerz", + "city": "rzzerze", + "published_at": "2020-08-31T13:29:02.118Z", + "created_by": 1, + "updated_by": 1, + "created_at": "2020-08-31T12:35:46.553Z", + "updated_at": "2020-08-31T13:29:02.136Z", + "cover": null, + "images": [] + }, + "timestamp": null, + "short_description": "test test", + "since": "2020-09-02", + "description": "test test test test ", + "menu": { + "id": 1, + "description": "menu1", + "restaurant": 1, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T14:47:10.654Z", + "updated_at": "2020-09-01T14:47:53.568Z" + }, + "created_by": { "id": 1, "firstname": "cyril", "lastname": "lopez", "username": null }, + "updated_by": { "id": 1, "firstname": "cyril", "lastname": "lopez", "username": null }, + "created_at": "2020-09-01T14:47:53.257Z", + "updated_at": "2020-09-01T14:47:53.627Z", + "closing_period": { + "id": 1, + "label": "closing labe", + "start_date": "2020-09-02", + "end_date": "2020-09-02", + "dish": { + "id": 1, + "name": "My super dish", + "description": "gdfg", + "price": 0.02, + "very_long_description": "test test test", + "picture": { + "id": 1, + "name": "Screenshot 2020-07-15 at 18.54.56.png", + "alternativeText": "", + "caption": "", + "width": 1996, + "height": 1124, + "formats": { + "thumbnail": { + "name": "thumbnail_Screenshot 2020-07-15 at 18.54.56.png", + "hash": "thumbnail_Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "width": 245, + "height": 138, + "size": 5.27, + "path": null, + "url": "/uploads/thumbnail_Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png" + }, + "large": { + "name": "large_Screenshot 2020-07-15 at 18.54.56.png", + "hash": "large_Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "width": 1000, + "height": 563, + "size": 40.75, + "path": null, + "url": "/uploads/large_Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png" + }, + "medium": { + "name": "medium_Screenshot 2020-07-15 at 18.54.56.png", + "hash": "medium_Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "width": 750, + "height": 422, + "size": 27.2, + "path": null, + "url": "/uploads/medium_Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png" + }, + "small": { + "name": "small_Screenshot 2020-07-15 at 18.54.56.png", + "hash": "small_Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "width": 500, + "height": 282, + "size": 15.17, + "path": null, + "url": "/uploads/small_Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png" + } + }, + "hash": "Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "size": 69.06, + "url": "/uploads/Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png", + "previewUrl": null, + "provider": "local", + "provider_metadata": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T14:35:21.346Z", + "updated_at": "2020-09-01T14:35:21.358Z" + }, + "categories": [ + { + "id": 1, + "name": "cat1", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T08:37:15.012Z", + "updated_at": "2020-09-01T12:37:33.249Z" + }, + { + "id": 2, + "name": "cat2", + "published_at": "2020-09-01T13:07:04.235Z", + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:46.798Z", + "updated_at": "2020-09-01T13:07:04.253Z" + }, + { + "id": 3, + "name": "cat3", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:51.438Z", + "updated_at": "2020-09-01T12:05:51.444Z" + } + ] + }, + "media": { + "id": 2, + "name": "Screenshot 2020-07-23 at 23.28.41.png", + "alternativeText": "", + "caption": "", + "width": 1084, + "height": 1312, + "formats": { + "thumbnail": { + "name": "thumbnail_Screenshot 2020-07-23 at 23.28.41.png", + "hash": "thumbnail_Screenshot_2020_07_23_at_23_28_41_68575e6313", + "ext": ".png", + "mime": "image/png", + "width": 129, + "height": 156, + "size": 44.23, + "path": null, + "url": "/uploads/thumbnail_Screenshot_2020_07_23_at_23_28_41_68575e6313.png" + }, + "large": { + "name": "large_Screenshot 2020-07-23 at 23.28.41.png", + "hash": "large_Screenshot_2020_07_23_at_23_28_41_68575e6313", + "ext": ".png", + "mime": "image/png", + "width": 826, + "height": 1000, + "size": 1415.04, + "path": null, + "url": "/uploads/large_Screenshot_2020_07_23_at_23_28_41_68575e6313.png" + }, + "medium": { + "name": "medium_Screenshot 2020-07-23 at 23.28.41.png", + "hash": "medium_Screenshot_2020_07_23_at_23_28_41_68575e6313", + "ext": ".png", + "mime": "image/png", + "width": 620, + "height": 750, + "size": 831.52, + "path": null, + "url": "/uploads/medium_Screenshot_2020_07_23_at_23_28_41_68575e6313.png" + }, + "small": { + "name": "small_Screenshot 2020-07-23 at 23.28.41.png", + "hash": "small_Screenshot_2020_07_23_at_23_28_41_68575e6313", + "ext": ".png", + "mime": "image/png", + "width": 413, + "height": 500, + "size": 390.82, + "path": null, + "url": "/uploads/small_Screenshot_2020_07_23_at_23_28_41_68575e6313.png" + } + }, + "hash": "Screenshot_2020_07_23_at_23_28_41_68575e6313", + "ext": ".png", + "mime": "image/png", + "size": 2065.3, + "url": "/uploads/Screenshot_2020_07_23_at_23_28_41_68575e6313.png", + "previewUrl": null, + "provider": "local", + "provider_metadata": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T14:35:38.706Z", + "updated_at": "2020-09-01T14:35:38.715Z" + } + }, + "services": [ + { + "id": 1, + "name": "something test", + "is_available": true, + "media": { + "id": 2, + "name": "Screenshot 2020-07-23 at 23.28.41.png", + "alternativeText": "", + "caption": "", + "width": 1084, + "height": 1312, + "formats": { + "thumbnail": { + "name": "thumbnail_Screenshot 2020-07-23 at 23.28.41.png", + "hash": "thumbnail_Screenshot_2020_07_23_at_23_28_41_68575e6313", + "ext": ".png", + "mime": "image/png", + "width": 129, + "height": 156, + "size": 44.23, + "path": null, + "url": "/uploads/thumbnail_Screenshot_2020_07_23_at_23_28_41_68575e6313.png" + }, + "large": { + "name": "large_Screenshot 2020-07-23 at 23.28.41.png", + "hash": "large_Screenshot_2020_07_23_at_23_28_41_68575e6313", + "ext": ".png", + "mime": "image/png", + "width": 826, + "height": 1000, + "size": 1415.04, + "path": null, + "url": "/uploads/large_Screenshot_2020_07_23_at_23_28_41_68575e6313.png" + }, + "medium": { + "name": "medium_Screenshot 2020-07-23 at 23.28.41.png", + "hash": "medium_Screenshot_2020_07_23_at_23_28_41_68575e6313", + "ext": ".png", + "mime": "image/png", + "width": 620, + "height": 750, + "size": 831.52, + "path": null, + "url": "/uploads/medium_Screenshot_2020_07_23_at_23_28_41_68575e6313.png" + }, + "small": { + "name": "small_Screenshot 2020-07-23 at 23.28.41.png", + "hash": "small_Screenshot_2020_07_23_at_23_28_41_68575e6313", + "ext": ".png", + "mime": "image/png", + "width": 413, + "height": 500, + "size": 390.82, + "path": null, + "url": "/uploads/small_Screenshot_2020_07_23_at_23_28_41_68575e6313.png" + } + }, + "hash": "Screenshot_2020_07_23_at_23_28_41_68575e6313", + "ext": ".png", + "mime": "image/png", + "size": 2065.3, + "url": "/uploads/Screenshot_2020_07_23_at_23_28_41_68575e6313.png", + "previewUrl": null, + "provider": "local", + "provider_metadata": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T14:35:38.706Z", + "updated_at": "2020-09-01T14:35:38.715Z" + } + }, + { + "id": 2, + "name": "something", + "is_available": true, + "media": { + "id": 1, + "name": "Screenshot 2020-07-15 at 18.54.56.png", + "alternativeText": "", + "caption": "", + "width": 1996, + "height": 1124, + "formats": { + "thumbnail": { + "name": "thumbnail_Screenshot 2020-07-15 at 18.54.56.png", + "hash": "thumbnail_Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "width": 245, + "height": 138, + "size": 5.27, + "path": null, + "url": "/uploads/thumbnail_Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png" + }, + "large": { + "name": "large_Screenshot 2020-07-15 at 18.54.56.png", + "hash": "large_Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "width": 1000, + "height": 563, + "size": 40.75, + "path": null, + "url": "/uploads/large_Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png" + }, + "medium": { + "name": "medium_Screenshot 2020-07-15 at 18.54.56.png", + "hash": "medium_Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "width": 750, + "height": 422, + "size": 27.2, + "path": null, + "url": "/uploads/medium_Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png" + }, + "small": { + "name": "small_Screenshot 2020-07-15 at 18.54.56.png", + "hash": "small_Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "width": 500, + "height": 282, + "size": 15.17, + "path": null, + "url": "/uploads/small_Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png" + } + }, + "hash": "Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "size": 69.06, + "url": "/uploads/Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png", + "previewUrl": null, + "provider": "local", + "provider_metadata": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T14:35:21.346Z", + "updated_at": "2020-09-01T14:35:21.358Z" + } + } + ], + "opening_times": [ + { + "id": 1, + "label": "something", + "time": "rrr", + "dishrep": [ + { + "id": 3, + "name": "My super dish", + "description": "test ", + "price": 0.1, + "very_long_description": "test test test test test ", + "picture": null, + "categories": [ + { + "id": 2, + "name": "cat2", + "published_at": "2020-09-01T13:07:04.235Z", + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:46.798Z", + "updated_at": "2020-09-01T13:07:04.253Z" + }, + { + "id": 1, + "name": "cat1", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T08:37:15.012Z", + "updated_at": "2020-09-01T12:37:33.249Z" + }, + { + "id": 3, + "name": "cat3", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:51.438Z", + "updated_at": "2020-09-01T12:05:51.444Z" + } + ] + }, + { + "id": 4, + "name": "My super dish", + "description": "test test ", + "price": 0.04, + "very_long_description": "test test test test test test test test ", + "picture": null, + "categories": [ + { + "id": 1, + "name": "cat1", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T08:37:15.012Z", + "updated_at": "2020-09-01T12:37:33.249Z" + }, + { + "id": 2, + "name": "cat2", + "published_at": "2020-09-01T13:07:04.235Z", + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:46.798Z", + "updated_at": "2020-09-01T13:07:04.253Z" + }, + { + "id": 3, + "name": "cat3", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:51.438Z", + "updated_at": "2020-09-01T12:05:51.444Z" + } + ] + } + ] + }, + { + "id": 2, + "label": "somethingtest test ", + "time": "test v", + "dishrep": [ + { + "id": 2, + "name": "My super dish", + "description": null, + "price": null, + "very_long_description": "test test test test test test ", + "picture": null, + "categories": [ + { + "id": 1, + "name": "cat1", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T08:37:15.012Z", + "updated_at": "2020-09-01T12:37:33.249Z" + }, + { + "id": 2, + "name": "cat2", + "published_at": "2020-09-01T13:07:04.235Z", + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:46.798Z", + "updated_at": "2020-09-01T13:07:04.253Z" + }, + { + "id": 3, + "name": "cat3", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:51.438Z", + "updated_at": "2020-09-01T12:05:51.444Z" + } + ] + } + ] + } + ], + "dz": [ + { + "__component": "default.openingtimes", + "id": 3, + "label": "something", + "time": "test ", + "dishrep": [ + { + "id": 6, + "name": "My super dish", + "description": "test test ", + "price": 0.01, + "very_long_description": "\ntest test test test ", + "picture": null, + "categories": [ + { + "id": 1, + "name": "cat1", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T08:37:15.012Z", + "updated_at": "2020-09-01T12:37:33.249Z" + }, + { + "id": 2, + "name": "cat2", + "published_at": "2020-09-01T13:07:04.235Z", + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:46.798Z", + "updated_at": "2020-09-01T13:07:04.253Z" + }, + { + "id": 3, + "name": "cat3", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:51.438Z", + "updated_at": "2020-09-01T12:05:51.444Z" + } + ] + }, + { + "id": 7, + "name": "My super dish", + "description": "test test test ", + "price": 0.04, + "very_long_description": "test test test ", + "picture": null, + "categories": [ + { + "id": 3, + "name": "cat3", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:51.438Z", + "updated_at": "2020-09-01T12:05:51.444Z" + }, + { + "id": 1, + "name": "cat1", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T08:37:15.012Z", + "updated_at": "2020-09-01T12:37:33.249Z" + } + ] + } + ] + }, + { + "__component": "default.dish", + "id": 5, + "name": "My super dish", + "description": "test test test ", + "price": 0.02, + "very_long_description": "test test test ", + "picture": null, + "categories": [ + { + "id": 2, + "name": "cat2", + "published_at": "2020-09-01T13:07:04.235Z", + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:46.798Z", + "updated_at": "2020-09-01T13:07:04.253Z" + }, + { + "id": 1, + "name": "cat1", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T08:37:15.012Z", + "updated_at": "2020-09-01T12:37:33.249Z" + }, + { + "id": 3, + "name": "cat3", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:51.438Z", + "updated_at": "2020-09-01T12:05:51.444Z" + } + ] + } + ], + "cover": { + "id": 1, + "name": "Screenshot 2020-07-15 at 18.54.56.png", + "alternativeText": "", + "caption": "", + "width": 1996, + "height": 1124, + "formats": { + "thumbnail": { + "name": "thumbnail_Screenshot 2020-07-15 at 18.54.56.png", + "hash": "thumbnail_Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "width": 245, + "height": 138, + "size": 5.27, + "path": null, + "url": "/uploads/thumbnail_Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png" + }, + "large": { + "name": "large_Screenshot 2020-07-15 at 18.54.56.png", + "hash": "large_Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "width": 1000, + "height": 563, + "size": 40.75, + "path": null, + "url": "/uploads/large_Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png" + }, + "medium": { + "name": "medium_Screenshot 2020-07-15 at 18.54.56.png", + "hash": "medium_Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "width": 750, + "height": 422, + "size": 27.2, + "path": null, + "url": "/uploads/medium_Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png" + }, + "small": { + "name": "small_Screenshot 2020-07-15 at 18.54.56.png", + "hash": "small_Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "width": 500, + "height": 282, + "size": 15.17, + "path": null, + "url": "/uploads/small_Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png" + } + }, + "hash": "Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "size": 69.06, + "url": "/uploads/Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png", + "previewUrl": null, + "provider": "local", + "provider_metadata": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T14:35:21.346Z", + "updated_at": "2020-09-01T14:35:21.358Z" + }, + "images": [ + { + "id": 2, + "name": "Screenshot 2020-07-23 at 23.28.41.png", + "alternativeText": "", + "caption": "", + "width": 1084, + "height": 1312, + "formats": { + "thumbnail": { + "name": "thumbnail_Screenshot 2020-07-23 at 23.28.41.png", + "hash": "thumbnail_Screenshot_2020_07_23_at_23_28_41_68575e6313", + "ext": ".png", + "mime": "image/png", + "width": 129, + "height": 156, + "size": 44.23, + "path": null, + "url": "/uploads/thumbnail_Screenshot_2020_07_23_at_23_28_41_68575e6313.png" + }, + "large": { + "name": "large_Screenshot 2020-07-23 at 23.28.41.png", + "hash": "large_Screenshot_2020_07_23_at_23_28_41_68575e6313", + "ext": ".png", + "mime": "image/png", + "width": 826, + "height": 1000, + "size": 1415.04, + "path": null, + "url": "/uploads/large_Screenshot_2020_07_23_at_23_28_41_68575e6313.png" + }, + "medium": { + "name": "medium_Screenshot 2020-07-23 at 23.28.41.png", + "hash": "medium_Screenshot_2020_07_23_at_23_28_41_68575e6313", + "ext": ".png", + "mime": "image/png", + "width": 620, + "height": 750, + "size": 831.52, + "path": null, + "url": "/uploads/medium_Screenshot_2020_07_23_at_23_28_41_68575e6313.png" + }, + "small": { + "name": "small_Screenshot 2020-07-23 at 23.28.41.png", + "hash": "small_Screenshot_2020_07_23_at_23_28_41_68575e6313", + "ext": ".png", + "mime": "image/png", + "width": 413, + "height": 500, + "size": 390.82, + "path": null, + "url": "/uploads/small_Screenshot_2020_07_23_at_23_28_41_68575e6313.png" + } + }, + "hash": "Screenshot_2020_07_23_at_23_28_41_68575e6313", + "ext": ".png", + "mime": "image/png", + "size": 2065.3, + "url": "/uploads/Screenshot_2020_07_23_at_23_28_41_68575e6313.png", + "previewUrl": null, + "provider": "local", + "provider_metadata": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T14:35:38.706Z", + "updated_at": "2020-09-01T14:35:38.715Z" + }, + { + "id": 1, + "name": "Screenshot 2020-07-15 at 18.54.56.png", + "alternativeText": "", + "caption": "", + "width": 1996, + "height": 1124, + "formats": { + "thumbnail": { + "name": "thumbnail_Screenshot 2020-07-15 at 18.54.56.png", + "hash": "thumbnail_Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "width": 245, + "height": 138, + "size": 5.27, + "path": null, + "url": "/uploads/thumbnail_Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png" + }, + "large": { + "name": "large_Screenshot 2020-07-15 at 18.54.56.png", + "hash": "large_Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "width": 1000, + "height": 563, + "size": 40.75, + "path": null, + "url": "/uploads/large_Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png" + }, + "medium": { + "name": "medium_Screenshot 2020-07-15 at 18.54.56.png", + "hash": "medium_Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "width": 750, + "height": 422, + "size": 27.2, + "path": null, + "url": "/uploads/medium_Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png" + }, + "small": { + "name": "small_Screenshot 2020-07-15 at 18.54.56.png", + "hash": "small_Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "width": 500, + "height": 282, + "size": 15.17, + "path": null, + "url": "/uploads/small_Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png" + } + }, + "hash": "Screenshot_2020_07_15_at_18_54_56_5250e5a68e", + "ext": ".png", + "mime": "image/png", + "size": 69.06, + "url": "/uploads/Screenshot_2020_07_15_at_18_54_56_5250e5a68e.png", + "previewUrl": null, + "provider": "local", + "provider_metadata": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T14:35:21.346Z", + "updated_at": "2020-09-01T14:35:21.358Z" + } + ], + "categories": [ + { + "id": 3, + "name": "cat3", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:51.438Z", + "updated_at": "2020-09-01T12:05:51.444Z" + }, + { + "id": 1, + "name": "cat1", + "published_at": null, + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T08:37:15.012Z", + "updated_at": "2020-09-01T12:37:33.249Z" + }, + { + "id": 2, + "name": "cat2", + "published_at": "2020-09-01T13:07:04.235Z", + "created_by": 1, + "updated_by": 1, + "created_at": "2020-09-01T12:05:46.798Z", + "updated_at": "2020-09-01T13:07:04.253Z" + } + ] +} diff --git a/packages/strapi-plugin-content-manager/admin/src/containers/EditView/utils/tests/getDraftRelations.test.js b/packages/strapi-plugin-content-manager/admin/src/containers/EditView/utils/tests/getDraftRelations.test.js new file mode 100644 index 0000000000..49460fc53f --- /dev/null +++ b/packages/strapi-plugin-content-manager/admin/src/containers/EditView/utils/tests/getDraftRelations.test.js @@ -0,0 +1,31 @@ +import getDraftRelations from '../getDraftRelations'; +import components from './data/compos-schema.json'; +import ct from './data/ct-schema.json'; +import data from './data/entry.json'; +import dataCompo from './data/entry-compos.json'; +import dataDZ from './data/entry-dz.json'; +import dataSimple from './data/entry-simple.json'; + +describe('CONTENT MANAGER | CONTAINERS | EditView | utils | getDraftRelations', () => { + it('should return the number of not published relations', () => { + expect(getDraftRelations(dataSimple, ct, components)).toEqual(2); + expect(getDraftRelations(dataDZ, ct, components)).toEqual(6); + expect(getDraftRelations(dataCompo, ct, components)).toEqual(8); + expect(getDraftRelations(data, ct, components)).toEqual(16); + expect( + getDraftRelations( + { + id: 1, + name: 'teststest', + slug: 'teststest', + price_range: 'very_cheap', + contact_email: 'contact@email.com', + stars: 1, + averagePrice: 1, + }, + ct, + components + ) + ).toEqual(0); + }); +});