@plone/volto 18.0.0-alpha.14 → 18.0.0-alpha.15

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 (150) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/jest-setup-afterenv.js +2 -0
  3. package/package.json +24 -20
  4. package/src/components/manage/Add/Add.jsx +9 -11
  5. package/src/components/manage/Add/Add.test.jsx +11 -13
  6. package/src/components/manage/Aliases/Aliases.jsx +6 -6
  7. package/src/components/manage/Aliases/Aliases.test.jsx +7 -7
  8. package/src/components/manage/BlockChooser/BlockChooser.test.jsx +0 -1
  9. package/src/components/manage/BlockChooser/BlockChooserButton.jsx +6 -6
  10. package/src/components/manage/BlockChooser/BlockChooserSearch.test.jsx +0 -1
  11. package/src/components/manage/Blocks/Block/Settings.test.jsx +0 -1
  12. package/src/components/manage/Blocks/Container/NewBlockAddButton.jsx +20 -19
  13. package/src/components/manage/Blocks/Image/View.test.jsx +0 -1
  14. package/src/components/manage/Blocks/Table/Edit.jsx +7 -6
  15. package/src/components/manage/Contents/Contents.jsx +6 -6
  16. package/src/components/manage/Contents/Contents.test.jsx +7 -7
  17. package/src/components/manage/Contents/ContentsPropertiesModal.test.jsx +4 -4
  18. package/src/components/manage/Controlpanels/AddonsControlpanel.jsx +6 -6
  19. package/src/components/manage/Controlpanels/AddonsControlpanel.test.jsx +6 -7
  20. package/src/components/manage/Controlpanels/Aliases.jsx +6 -6
  21. package/src/components/manage/Controlpanels/Aliases.test.jsx +6 -7
  22. package/src/components/manage/Controlpanels/ContentType.jsx +6 -6
  23. package/src/components/manage/Controlpanels/ContentType.test.jsx +7 -7
  24. package/src/components/manage/Controlpanels/ContentTypeLayout.jsx +93 -85
  25. package/src/components/manage/Controlpanels/ContentTypeLayout.test.jsx +7 -7
  26. package/src/components/manage/Controlpanels/ContentTypeSchema.jsx +6 -6
  27. package/src/components/manage/Controlpanels/ContentTypes.jsx +6 -6
  28. package/src/components/manage/Controlpanels/ContentTypes.test.jsx +7 -7
  29. package/src/components/manage/Controlpanels/Controlpanel.jsx +6 -6
  30. package/src/components/manage/Controlpanels/Controlpanel.test.jsx +7 -7
  31. package/src/components/manage/Controlpanels/Controlpanels.jsx +6 -6
  32. package/src/components/manage/Controlpanels/Controlpanels.test.jsx +10 -10
  33. package/src/components/manage/Controlpanels/DatabaseInformation.jsx +6 -6
  34. package/src/components/manage/Controlpanels/Groups/GroupsControlpanel.jsx +6 -6
  35. package/src/components/manage/Controlpanels/Groups/GroupsControlpanel.test.jsx +7 -7
  36. package/src/components/manage/Controlpanels/ModerateComments.jsx +6 -6
  37. package/src/components/manage/Controlpanels/ModerateComments.test.jsx +7 -7
  38. package/src/components/manage/Controlpanels/Relations/Relations.jsx +13 -7
  39. package/src/components/manage/Controlpanels/Rules/AddRule.jsx +6 -6
  40. package/src/components/manage/Controlpanels/Rules/AddRule.test.jsx +6 -7
  41. package/src/components/manage/Controlpanels/Rules/ConfigureRule.jsx +6 -6
  42. package/src/components/manage/Controlpanels/Rules/ConfigureRule.test.jsx +6 -7
  43. package/src/components/manage/Controlpanels/Rules/EditRule.jsx +6 -6
  44. package/src/components/manage/Controlpanels/Rules/EditRule.test.jsx +6 -7
  45. package/src/components/manage/Controlpanels/Rules/Rules.jsx +6 -6
  46. package/src/components/manage/Controlpanels/Rules/Rules.test.jsx +6 -7
  47. package/src/components/manage/Controlpanels/Rules/components/{VariableModal.test.jsx → VariableModal.test.jsx.removed} +6 -7
  48. package/src/components/manage/Controlpanels/UndoControlpanel.jsx +6 -6
  49. package/src/components/manage/Controlpanels/UndoControlpanel.test.jsx +7 -7
  50. package/src/components/manage/Controlpanels/UpgradeControlPanel.jsx +6 -6
  51. package/src/components/manage/Controlpanels/Users/UserGroupMembershipControlPanel.jsx +14 -8
  52. package/src/components/manage/Controlpanels/Users/UserGroupMembershipControlPanel.test.jsx +7 -7
  53. package/src/components/manage/Controlpanels/Users/UsersControlpanel.jsx +6 -6
  54. package/src/components/manage/Controlpanels/Users/UsersControlpanel.test.jsx +7 -7
  55. package/src/components/manage/Delete/Delete.jsx +6 -6
  56. package/src/components/manage/Delete/Delete.test.jsx +10 -10
  57. package/src/components/manage/Diff/Diff.jsx +6 -6
  58. package/src/components/manage/Diff/Diff.test.jsx +2 -3
  59. package/src/components/manage/Edit/Edit.jsx +10 -11
  60. package/src/components/manage/Edit/Edit.test.jsx +14 -10
  61. package/src/components/manage/Form/BlockDataForm.test.jsx +0 -1
  62. package/src/components/manage/Form/Form.jsx +16 -8
  63. package/src/components/manage/Form/ModalForm.test.jsx +0 -1
  64. package/src/components/manage/History/History.jsx +6 -6
  65. package/src/components/manage/History/History.test.jsx +14 -13
  66. package/src/components/manage/LinksToItem/LinksToItem.jsx +78 -49
  67. package/src/components/manage/LinksToItem/LinksToItem.test.jsx +7 -7
  68. package/src/components/manage/Multilingual/ManageTranslations.jsx +13 -7
  69. package/src/components/manage/Multilingual/ManageTranslations.test.jsx +6 -7
  70. package/src/components/manage/Preferences/ChangePassword.jsx +6 -6
  71. package/src/components/manage/Preferences/ChangePassword.test.jsx +6 -7
  72. package/src/components/manage/Preferences/PersonalInformation.test.jsx +1 -3
  73. package/src/components/manage/Preferences/PersonalPreferences.test.jsx +1 -3
  74. package/src/components/manage/Rules/Rules.jsx +6 -6
  75. package/src/components/manage/Rules/Rules.test.jsx +7 -7
  76. package/src/components/manage/Sharing/Sharing.jsx +6 -6
  77. package/src/components/manage/Sharing/Sharing.test.jsx +7 -7
  78. package/src/components/manage/Sidebar/ObjectBrowser.jsx +1 -1
  79. package/src/components/manage/Sidebar/Sidebar.jsx +2 -0
  80. package/src/components/manage/Sidebar/SidebarPopup.jsx +28 -21
  81. package/src/components/manage/Sidebar/SidebarPortal.jsx +7 -6
  82. package/src/components/manage/Widgets/FileWidget.jsx +1 -1
  83. package/src/components/manage/Widgets/ObjectBrowserWidget.test.jsx +4 -4
  84. package/src/components/manage/Widgets/ObjectListWidget.test.js +0 -1
  85. package/src/components/manage/Widgets/ObjectWidget.test.jsx +0 -1
  86. package/src/components/manage/Widgets/SchemaWidget.test.jsx +4 -4
  87. package/src/components/manage/Widgets/SchemaWidgetFieldset.test.jsx +5 -5
  88. package/src/components/manage/Widgets/UrlWidget.test.jsx +4 -4
  89. package/src/components/manage/Widgets/VocabularyTermsWidget.test.jsx +4 -4
  90. package/src/components/theme/Comments/Comments.jsx +7 -8
  91. package/src/components/theme/Component/Component.test.jsx +0 -1
  92. package/src/components/theme/ContactForm/ContactForm.jsx +6 -6
  93. package/src/components/theme/ContactForm/ContactForm.test.jsx +12 -10
  94. package/src/components/theme/Footer/Footer.test.jsx +0 -1
  95. package/src/components/theme/Logout/Logout.test.jsx +8 -5
  96. package/src/components/theme/Search/Search.jsx +6 -6
  97. package/src/components/theme/Search/Search.test.jsx +13 -10
  98. package/src/components/theme/SlotRenderer/SlotRenderer.test.jsx +0 -1
  99. package/src/components/theme/View/View.jsx +6 -6
  100. package/src/components/theme/View/View.test.jsx +25 -18
  101. package/src/helpers/AsyncConnect/AsyncConnect.test.js +0 -2
  102. package/src/helpers/Utils/UseDetectClickOutside.stories.jsx +8 -8
  103. package/src/start-client.jsx +3 -3
  104. package/types/components/manage/Add/Add.d.ts +1 -4
  105. package/types/components/manage/Aliases/Aliases.d.ts +1 -4
  106. package/types/components/manage/Blocks/Block/Edit.d.ts +1 -3
  107. package/types/components/manage/Blocks/HeroImageLeft/Edit.d.ts +1 -4
  108. package/types/components/manage/Blocks/Image/Edit.d.ts +1 -4
  109. package/types/components/manage/Contents/Contents.d.ts +2 -7
  110. package/types/components/manage/Contents/ContentsUploadModal.d.ts +1 -4
  111. package/types/components/manage/Controlpanels/AddonsControlpanel.d.ts +1 -4
  112. package/types/components/manage/Controlpanels/Aliases.d.ts +1 -4
  113. package/types/components/manage/Controlpanels/ContentType.d.ts +1 -4
  114. package/types/components/manage/Controlpanels/ContentTypeLayout.d.ts +1 -4
  115. package/types/components/manage/Controlpanels/ContentTypeSchema.d.ts +1 -4
  116. package/types/components/manage/Controlpanels/ContentTypes.d.ts +1 -4
  117. package/types/components/manage/Controlpanels/DatabaseInformation.d.ts +1 -4
  118. package/types/components/manage/Controlpanels/Groups/GroupsControlpanel.d.ts +1 -4
  119. package/types/components/manage/Controlpanels/ModerateComments.d.ts +1 -4
  120. package/types/components/manage/Controlpanels/Rules/AddRule.d.ts +1 -4
  121. package/types/components/manage/Controlpanels/Rules/ConfigureRule.d.ts +1 -4
  122. package/types/components/manage/Controlpanels/Rules/EditRule.d.ts +1 -4
  123. package/types/components/manage/Controlpanels/Rules/Rules.d.ts +1 -4
  124. package/types/components/manage/Controlpanels/Rules/components/VariableModal.d.ts +1 -4
  125. package/types/components/manage/Controlpanels/UndoControlpanel.d.ts +1 -4
  126. package/types/components/manage/Controlpanels/UpgradeControlPanel.d.ts +1 -4
  127. package/types/components/manage/Controlpanels/Users/RenderUsers.d.ts +1 -4
  128. package/types/components/manage/Controlpanels/Users/UsersControlpanel.d.ts +1 -4
  129. package/types/components/manage/Display/Display.d.ts +1 -4
  130. package/types/components/manage/Edit/Edit.d.ts +2 -7
  131. package/types/components/manage/Form/BlocksToolbar.d.ts +1 -3
  132. package/types/components/manage/History/History.d.ts +1 -4
  133. package/types/components/manage/Preferences/PersonalPreferences.d.ts +1 -4
  134. package/types/components/manage/Rules/Rules.d.ts +1 -4
  135. package/types/components/manage/Sidebar/ObjectBrowserBody.d.ts +1 -4
  136. package/types/components/manage/Toolbar/Toolbar.d.ts +1 -4
  137. package/types/components/manage/Widgets/ArrayWidget.d.ts +1 -3
  138. package/types/components/manage/Widgets/IdWidget.d.ts +1 -4
  139. package/types/components/manage/Widgets/QueryWidget.d.ts +1 -3
  140. package/types/components/manage/Widgets/ReferenceWidget.d.ts +1 -4
  141. package/types/components/manage/Widgets/SchemaWidget.d.ts +1 -4
  142. package/types/components/manage/Widgets/SelectAutoComplete.d.ts +1 -3
  143. package/types/components/manage/Widgets/TokenWidget.d.ts +1 -4
  144. package/types/components/manage/Widgets/WysiwygWidget.d.ts +1 -4
  145. package/types/components/theme/Search/Search.d.ts +2 -7
  146. package/types/components/theme/Sitemap/Sitemap.d.ts +2 -6
  147. package/types/components/theme/View/View.d.ts +1 -4
  148. package/types/config/Widgets.d.ts +1 -3
  149. package/src/components/manage/Multilingual/CreateTranslation.test.jsx +0 -46
  150. package/src/helpers/Utils/usePagination.test.js +0 -115
package/CHANGELOG.md CHANGED
@@ -17,6 +17,12 @@ myst:
17
17
 
18
18
  <!-- towncrier release notes start -->
19
19
 
20
+ ## 18.0.0-alpha.15 (2024-03-01)
21
+
22
+ ### Breaking
23
+
24
+ - Upgrade Volto core to use React 18.2.0 @sneridagh [#3221](https://github.com/plone/volto/issues/3221)
25
+
20
26
  ## 18.0.0-alpha.14 (2024-03-01)
21
27
 
22
28
  ### Breaking
@@ -0,0 +1,2 @@
1
+ // Jest-crap setup after env T_T
2
+ import '@testing-library/jest-dom';
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "license": "MIT",
12
- "version": "18.0.0-alpha.14",
12
+ "version": "18.0.0-alpha.15",
13
13
  "repository": {
14
14
  "type": "git",
15
15
  "url": "git@github.com:plone/volto.git"
@@ -80,6 +80,9 @@
80
80
  "./test-setup-config.js"
81
81
  ],
82
82
  "globalSetup": "./global-test-setup.js",
83
+ "setupFilesAfterEnv": [
84
+ "<rootDir>/jest-setup-afterenv.js"
85
+ ],
83
86
  "globals": {
84
87
  "__DEV__": true
85
88
  },
@@ -243,7 +246,7 @@
243
246
  "razzle-dev-utils": "4.2.18",
244
247
  "razzle-plugin-scss": "4.2.18",
245
248
  "rc-time-picker": "3.7.3",
246
- "react": "17.0.2",
249
+ "react": "18.2.0",
247
250
  "react-anchor-link-smooth-scroll": "1.0.12",
248
251
  "react-animate-height": "2.0.17",
249
252
  "react-beautiful-dnd": "13.0.0",
@@ -252,17 +255,16 @@
252
255
  "react-detect-click-outside": "1.1.1",
253
256
  "react-dnd": "5.0.0",
254
257
  "react-dnd-html5-backend": "5.0.1",
255
- "react-dom": "17.0.2",
258
+ "react-dom": "18.2.0",
256
259
  "react-dropzone": "11.1.0",
257
260
  "react-fast-compare": "2.0.4",
258
261
  "react-image-gallery": "1.2.7",
259
262
  "react-intersection-observer": "9.1.0",
260
263
  "react-intl": "3.8.0",
261
- "react-intl-redux": "2.2.0",
264
+ "react-intl-redux": "2.3.0",
262
265
  "react-medium-image-zoom": "3.0.15",
263
266
  "react-popper": "^2.3.0",
264
- "react-portal": "4.2.1",
265
- "react-redux": "7.2.4",
267
+ "react-redux": "8.1.2",
266
268
  "react-router": "5.2.0",
267
269
  "react-router-config": "5.1.1",
268
270
  "react-router-dom": "5.2.0",
@@ -270,21 +272,21 @@
270
272
  "react-select": "4.3.1",
271
273
  "react-select-async-paginate": "0.5.3",
272
274
  "react-share": "2.3.1",
273
- "react-side-effect": "2.1.0",
275
+ "react-side-effect": "2.1.2",
274
276
  "react-simple-code-editor": "0.7.1",
275
277
  "react-sortable-hoc": "2.0.0",
276
- "react-test-renderer": "17.0.2",
278
+ "react-test-renderer": "18.2.0",
277
279
  "react-toastify": "5.4.1",
278
280
  "react-transition-group": "4.4.5",
279
281
  "react-virtualized": "9.22.3",
280
282
  "redraft": "0.10.2",
281
- "redux": "4.1.0",
282
- "redux-actions": "2.6.5",
283
+ "redux": "4.2.1",
284
+ "redux-actions": "3.0.0",
283
285
  "redux-connect": "10.0.0",
284
- "redux-devtools-extension": "2.13.8",
285
- "redux-localstorage-simple": "2.3.1",
286
+ "redux-devtools-extension": "2.13.9",
287
+ "redux-localstorage-simple": "2.5.1",
286
288
  "redux-mock-store": "1.5.4",
287
- "redux-thunk": "2.3.0",
289
+ "redux-thunk": "2.4.2",
288
290
  "rrule": "2.7.1",
289
291
  "semantic-ui-less": "2.4.1",
290
292
  "semantic-ui-react": "2.1.5",
@@ -314,8 +316,8 @@
314
316
  "webpack-node-externals": "3.0.0",
315
317
  "xmlrpc": "1.3.2",
316
318
  "yarnhook": "0.5.1",
317
- "@plone/registry": "1.4.0",
318
- "@plone/volto-slate": "18.0.0-alpha.7",
319
+ "@plone/registry": "1.5.0",
320
+ "@plone/volto-slate": "18.0.0-alpha.8",
319
321
  "@plone/scripts": "3.3.2"
320
322
  },
321
323
  "devDependencies": {
@@ -330,13 +332,15 @@
330
332
  "@storybook/manager-webpack5": "^6.5.15",
331
333
  "@storybook/react": "^6.5.15",
332
334
  "@testing-library/cypress": "9.0.0",
333
- "@testing-library/jest-dom": "5.16.4",
334
- "@testing-library/react": "12.1.5",
335
+ "@testing-library/jest-dom": "6.4.1",
336
+ "@testing-library/react": "14.2.0",
335
337
  "@testing-library/react-hooks": "8.0.1",
336
338
  "@types/jest": "^29.5.8",
337
339
  "@types/lodash": "^4.14.201",
340
+ "@types/react": "^18",
341
+ "@types/react-dom": "^18",
338
342
  "@types/react-router-dom": "^5.3.3",
339
- "@types/react-test-renderer": "18.0.1",
343
+ "@types/react-test-renderer": "18.0.7",
340
344
  "@types/uuid": "^9.0.2",
341
345
  "@typescript-eslint/eslint-plugin": "6.7.0",
342
346
  "@typescript-eslint/parser": "6.7.0",
@@ -353,7 +357,7 @@
353
357
  "jsonwebtoken": "9.0.0",
354
358
  "react-docgen-typescript-plugin": "^1.0.5",
355
359
  "react-error-overlay": "6.0.9",
356
- "react-is": "^16.13.1",
360
+ "react-is": "^18.2.0",
357
361
  "release-it": "^16.2.1",
358
362
  "semver": "^7.5.4",
359
363
  "tmp": "0.2.1",
@@ -363,7 +367,7 @@
363
367
  "use-trace-update": "1.3.2",
364
368
  "wait-on": "6.0.0",
365
369
  "why": "0.6.2",
366
- "@plone/types": "1.0.0-alpha.4",
370
+ "@plone/types": "1.0.0-alpha.5",
367
371
  "@plone/volto-coresandbox": "1.0.0"
368
372
  },
369
373
  "volta": {
@@ -11,7 +11,7 @@ import { compose } from 'redux';
11
11
  import { keys, isEmpty } from 'lodash';
12
12
  import { defineMessages, injectIntl } from 'react-intl';
13
13
  import { Button, Grid, Menu } from 'semantic-ui-react';
14
- import { Portal } from 'react-portal';
14
+ import { createPortal } from 'react-dom';
15
15
  import { v4 as uuid } from 'uuid';
16
16
  import qs from 'query-string';
17
17
  import { toast } from 'react-toastify';
@@ -366,8 +366,8 @@ class Add extends Component {
366
366
  }}
367
367
  global
368
368
  />
369
- {this.state.isClient && (
370
- <Portal node={document.getElementById('toolbar')}>
369
+ {this.state.isClient &&
370
+ createPortal(
371
371
  <Toolbar
372
372
  pathname={this.props.pathname}
373
373
  hideDefaultViewButtons
@@ -400,14 +400,12 @@ class Add extends Component {
400
400
  </Button>
401
401
  </>
402
402
  }
403
- />
404
- </Portal>
405
- )}
406
- {visual && this.state.isClient && (
407
- <Portal node={document.getElementById('sidebar')}>
408
- <Sidebar />
409
- </Portal>
410
- )}
403
+ />,
404
+ document.getElementById('toolbar'),
405
+ )}
406
+ {visual &&
407
+ this.state.isClient &&
408
+ createPortal(<Sidebar />, document.getElementById('sidebar'))}
411
409
  </div>
412
410
  );
413
411
 
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import renderer from 'react-test-renderer';
2
+ import { render } from '@testing-library/react';
3
3
  import configureStore from 'redux-mock-store';
4
4
  import { Provider } from 'react-intl-redux';
5
5
  import config from '@plone/volto/registry';
@@ -16,9 +16,8 @@ beforeAll(() => {
16
16
  config.settings.loadables = {};
17
17
  });
18
18
 
19
- jest.mock('react-portal', () => ({
20
- Portal: jest.fn(() => <div id="Portal" />),
21
- }));
19
+ jest.mock('../Toolbar/Toolbar', () => jest.fn(() => <div id="Portal" />));
20
+
22
21
  jest.mock('../Form/Form', () => jest.fn(() => <div className="Form" />));
23
22
 
24
23
  describe('Add', () => {
@@ -39,13 +38,12 @@ describe('Add', () => {
39
38
  messages: {},
40
39
  },
41
40
  });
42
- const component = renderer.create(
41
+ const { container } = render(
43
42
  <Provider store={store}>
44
43
  <Add location={{ pathname: '/blog', search: { type: 'Document' } }} />
45
44
  </Provider>,
46
45
  );
47
- const json = component.toJSON();
48
- expect(json).toMatchSnapshot();
46
+ expect(container).toMatchSnapshot();
49
47
  });
50
48
 
51
49
  it('renders an add component', () => {
@@ -67,13 +65,13 @@ describe('Add', () => {
67
65
  messages: {},
68
66
  },
69
67
  });
70
- const component = renderer.create(
68
+ const { container } = render(
71
69
  <Provider store={store}>
72
70
  <Add location={{ pathname: '/blog', search: { type: 'Document' } }} />
73
71
  </Provider>,
74
72
  );
75
- const json = component.toJSON();
76
- expect(json).toMatchSnapshot();
73
+
74
+ expect(container).toMatchSnapshot();
77
75
  });
78
76
 
79
77
  it('renders an add component with schema', () => {
@@ -106,12 +104,12 @@ describe('Add', () => {
106
104
  messages: {},
107
105
  },
108
106
  });
109
- const component = renderer.create(
107
+ const { container } = render(
110
108
  <Provider store={store}>
111
109
  <Add location={{ pathname: '/blog', search: { type: 'Document' } }} />
112
110
  </Provider>,
113
111
  );
114
- const json = component.toJSON();
115
- expect(json).toMatchSnapshot();
112
+
113
+ expect(container).toMatchSnapshot();
116
114
  });
117
115
  });
@@ -8,7 +8,7 @@ import { Helmet } from '@plone/volto/helpers';
8
8
  import { connect } from 'react-redux';
9
9
  import { compose } from 'redux';
10
10
  import { Link } from 'react-router-dom';
11
- import { Portal } from 'react-portal';
11
+ import { createPortal } from 'react-dom';
12
12
  import {
13
13
  Button,
14
14
  Checkbox,
@@ -317,8 +317,8 @@ class Aliases extends Component {
317
317
  </Segment>
318
318
  </Form>
319
319
  </Segment.Group>
320
- {this.state.isClient && (
321
- <Portal node={document.getElementById('toolbar')}>
320
+ {this.state.isClient &&
321
+ createPortal(
322
322
  <Toolbar
323
323
  pathname={this.props.pathname}
324
324
  hideDefaultViewButtons
@@ -335,9 +335,9 @@ class Aliases extends Component {
335
335
  />
336
336
  </Link>
337
337
  }
338
- />
339
- </Portal>
340
- )}
338
+ />,
339
+ document.getElementById('toolbar'),
340
+ )}
341
341
  </Container>
342
342
  );
343
343
  }
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import renderer from 'react-test-renderer';
2
+ import { render } from '@testing-library/react';
3
3
  import { Provider } from 'react-intl-redux';
4
4
  import configureMockStore from 'redux-mock-store';
5
5
  import thunk from 'redux-thunk';
@@ -9,9 +9,8 @@ import Aliases from './Aliases';
9
9
  const middlewares = [thunk];
10
10
  const mockStore = configureMockStore(middlewares);
11
11
 
12
- jest.mock('react-portal', () => ({
13
- Portal: jest.fn(() => <div id="Portal" />),
14
- }));
12
+ jest.mock('../Toolbar/Toolbar', () => jest.fn(() => <div id="Portal" />));
13
+
15
14
  jest.mock('../Toolbar/More', () => jest.fn(() => <div className="More" />));
16
15
 
17
16
  describe('Aliases', () => {
@@ -45,12 +44,13 @@ describe('Aliases', () => {
45
44
  messages: {},
46
45
  },
47
46
  });
48
- const component = renderer.create(
47
+ const { container } = render(
49
48
  <Provider store={store}>
50
49
  <Aliases location={{ pathname: '/blog/aliases' }} />
50
+ <div id="toolbar"></div>
51
51
  </Provider>,
52
52
  );
53
- const json = component.toJSON();
54
- expect(json).toMatchSnapshot();
53
+
54
+ expect(container).toMatchSnapshot();
55
55
  });
56
56
  });
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import '@testing-library/jest-dom/extend-expect';
3
2
  import { render, screen } from '@testing-library/react';
4
3
  import { Provider } from 'react-intl-redux';
5
4
  import configureStore from 'redux-mock-store';
@@ -7,7 +7,7 @@ import config from '@plone/volto/registry';
7
7
  import { Button, Ref } from 'semantic-ui-react';
8
8
  import { defineMessages, useIntl } from 'react-intl';
9
9
  import { usePopper } from 'react-popper';
10
- import { Portal } from 'react-portal';
10
+ import { createPortal } from 'react-dom';
11
11
 
12
12
  const messages = defineMessages({
13
13
  addBlock: {
@@ -115,8 +115,8 @@ const BlockChooserButton = (props) => {
115
115
  />
116
116
  </Ref>
117
117
  )}
118
- {addNewBlockOpened && (
119
- <Portal node={document.getElementById('body')}>
118
+ {addNewBlockOpened &&
119
+ createPortal(
120
120
  <div
121
121
  ref={setPopperElement}
122
122
  style={styles.popper}
@@ -148,9 +148,9 @@ const BlockChooserButton = (props) => {
148
148
  navRoot={navRoot}
149
149
  contentType={contentType}
150
150
  />
151
- </div>
152
- </Portal>
153
- )}
151
+ </div>,
152
+ document.body,
153
+ )}
154
154
  </>
155
155
  );
156
156
  };
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import '@testing-library/jest-dom/extend-expect';
3
2
  import { render } from '@testing-library/react';
4
3
  import BlockChooserSearch from './BlockChooserSearch';
5
4
  import { Provider } from 'react-intl-redux';
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
  import Settings from './Settings';
3
3
  import { render } from '@testing-library/react';
4
- import '@testing-library/jest-dom/extend-expect';
5
4
  import configureStore from 'redux-mock-store';
6
5
  import config from '@plone/volto/registry';
7
6
  import { Provider } from 'react-intl-redux';
@@ -5,7 +5,7 @@ import { BlockChooser, Icon } from '@plone/volto/components';
5
5
  import { useDetectClickOutside } from '@plone/volto/helpers';
6
6
  import addSVG from '@plone/volto/icons/add.svg';
7
7
  import { usePopper } from 'react-popper';
8
- import { Portal } from 'react-portal';
8
+ import { createPortal } from 'react-dom';
9
9
 
10
10
  const messages = defineMessages({
11
11
  addBlock: {
@@ -59,24 +59,25 @@ const NewBlockAddButton = (props) => {
59
59
  <Icon name={addSVG} className="circled" size="24px" />
60
60
  </Button>
61
61
  </Ref>
62
- {isOpenMenu ? (
63
- <Portal node={document.getElementById('body')}>
64
- <div
65
- ref={setPopperElement}
66
- style={styles.popper}
67
- {...attributes.popper}
68
- className="container-chooser-wrapper"
69
- >
70
- <BlockChooser
71
- onMutateBlock={onMutateBlock}
72
- currentBlock={block}
73
- showRestricted
74
- blocksConfig={blocksConfig}
75
- ref={blockChooserRef}
76
- />
77
- </div>
78
- </Portal>
79
- ) : null}
62
+ {isOpenMenu
63
+ ? createPortal(
64
+ <div
65
+ ref={setPopperElement}
66
+ style={styles.popper}
67
+ {...attributes.popper}
68
+ className="container-chooser-wrapper"
69
+ >
70
+ <BlockChooser
71
+ onMutateBlock={onMutateBlock}
72
+ currentBlock={block}
73
+ showRestricted
74
+ blocksConfig={blocksConfig}
75
+ ref={blockChooserRef}
76
+ />
77
+ </div>,
78
+ document.body,
79
+ )
80
+ : null}
80
81
  </>
81
82
  );
82
83
  };
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import '@testing-library/jest-dom/extend-expect';
3
2
  import { render } from '@testing-library/react';
4
3
  import { MemoryRouter } from 'react-router-dom';
5
4
  import { Provider } from 'react-intl-redux';
@@ -8,7 +8,7 @@ import PropTypes from 'prop-types';
8
8
  import { compose } from 'redux';
9
9
  import { map, remove } from 'lodash';
10
10
  import { Button, Segment, Table, Form } from 'semantic-ui-react';
11
- import { Portal } from 'react-portal';
11
+ import { createPortal } from 'react-dom';
12
12
  import cx from 'classnames';
13
13
  import { FormattedMessage, defineMessages, injectIntl } from 'react-intl';
14
14
 
@@ -670,8 +670,9 @@ class Edit extends Component {
670
670
  </Table.Body>
671
671
  </Table>
672
672
  )}
673
- {this.props.selected && this.state.isClient && (
674
- <Portal node={document.getElementById('sidebar-properties')}>
673
+ {this.props.selected &&
674
+ this.state.isClient &&
675
+ createPortal(
675
676
  <Form
676
677
  method="post"
677
678
  onSubmit={(event) => {
@@ -736,9 +737,9 @@ class Edit extends Component {
736
737
  onChange={this.toggleCellType}
737
738
  />
738
739
  </Segment>
739
- </Form>
740
- </Portal>
741
- )}
740
+ </Form>,
741
+ document.getElementById('sidebar-properties'),
742
+ )}
742
743
  </div>
743
744
  );
744
745
  }
@@ -7,7 +7,7 @@ import React, { Component } from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import { connect } from 'react-redux';
9
9
  import { compose } from 'redux';
10
- import { Portal } from 'react-portal';
10
+ import { createPortal } from 'react-dom';
11
11
  import { Link } from 'react-router-dom';
12
12
  import {
13
13
  Button,
@@ -2159,8 +2159,8 @@ class Contents extends Component {
2159
2159
  </section>
2160
2160
  </article>
2161
2161
  </div>
2162
- {this.state.isClient && (
2163
- <Portal node={document.getElementById('toolbar')}>
2162
+ {this.state.isClient &&
2163
+ createPortal(
2164
2164
  <Toolbar
2165
2165
  pathname={this.props.pathname}
2166
2166
  inner={
@@ -2178,9 +2178,9 @@ class Contents extends Component {
2178
2178
  />
2179
2179
  </Link>
2180
2180
  }
2181
- />
2182
- </Portal>
2183
- )}
2181
+ />,
2182
+ document.getElementById('toolbar'),
2183
+ )}
2184
2184
  </Dimmer.Dimmable>
2185
2185
  </Container>
2186
2186
  ) : (
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import renderer from 'react-test-renderer';
2
+ import { render } from '@testing-library/react';
3
3
  import configureStore from 'redux-mock-store';
4
4
  import { Provider } from 'react-intl-redux';
5
5
  import { MemoryRouter } from 'react-router-dom';
@@ -14,9 +14,8 @@ beforeAll(
14
14
  await require('@plone/volto/helpers/Loadable/Loadable').__setLoadables(),
15
15
  );
16
16
 
17
- jest.mock('react-portal', () => ({
18
- Portal: jest.fn(() => <div id="Portal" />),
19
- }));
17
+ jest.mock('../Toolbar/Toolbar', () => jest.fn(() => <div id="Portal" />));
18
+
20
19
  jest.mock('../../theme/Pagination/Pagination', () =>
21
20
  jest.fn(() => <div className="Pagination" />),
22
21
  );
@@ -91,14 +90,15 @@ describe('Contents', () => {
91
90
  messages: {},
92
91
  },
93
92
  });
94
- const component = renderer.create(
93
+ const { container } = render(
95
94
  <Provider store={store}>
96
95
  <MemoryRouter>
97
96
  <Contents location={{ pathname: '/blog' }} />
97
+ <div id="toolbar"></div>
98
98
  </MemoryRouter>
99
99
  </Provider>,
100
100
  );
101
- const json = component.toJSON();
102
- expect(json).toMatchSnapshot();
101
+
102
+ expect(container).toMatchSnapshot();
103
103
  });
104
104
  });
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import renderer from 'react-test-renderer';
2
+ import { render } from '@testing-library/react';
3
3
  import configureStore from 'redux-mock-store';
4
4
  import { Provider } from 'react-intl-redux';
5
5
 
@@ -23,7 +23,7 @@ describe('ContentsPropertiesModal', () => {
23
23
  messages: {},
24
24
  },
25
25
  });
26
- const component = renderer.create(
26
+ const { container } = render(
27
27
  <Provider store={store}>
28
28
  <ContentsPropertiesModal
29
29
  open
@@ -33,7 +33,7 @@ describe('ContentsPropertiesModal', () => {
33
33
  />
34
34
  </Provider>,
35
35
  );
36
- const json = component.toJSON();
37
- expect(json).toMatchSnapshot();
36
+
37
+ expect(container).toMatchSnapshot();
38
38
  });
39
39
  });
@@ -7,7 +7,7 @@ import PropTypes from 'prop-types';
7
7
  import { connect } from 'react-redux';
8
8
  import { compose } from 'redux';
9
9
  import { Link } from 'react-router-dom';
10
- import { Portal } from 'react-portal';
10
+ import { createPortal } from 'react-dom';
11
11
  import {
12
12
  Accordion,
13
13
  Button,
@@ -550,8 +550,8 @@ class AddonsControlpanel extends Component {
550
550
  )}
551
551
  </Segment.Group>
552
552
 
553
- {this.state.isClient && (
554
- <Portal node={document.getElementById('toolbar')}>
553
+ {this.state.isClient &&
554
+ createPortal(
555
555
  <Toolbar
556
556
  pathname={this.props.pathname}
557
557
  hideDefaultViewButtons
@@ -568,9 +568,9 @@ class AddonsControlpanel extends Component {
568
568
  </Link>
569
569
  </>
570
570
  }
571
- />
572
- </Portal>
573
- )}
571
+ />,
572
+ document.getElementById('toolbar'),
573
+ )}
574
574
  </Container>
575
575
  );
576
576
  }
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import renderer from 'react-test-renderer';
2
+ import { render } from '@testing-library/react';
3
3
  import configureStore from 'redux-mock-store';
4
4
  import { Provider } from 'react-intl-redux';
5
5
 
@@ -7,9 +7,7 @@ import AddonsControlpanel from './AddonsControlpanel';
7
7
 
8
8
  const mockStore = configureStore();
9
9
 
10
- jest.mock('react-portal', () => ({
11
- Portal: jest.fn(() => <div id="Portal" />),
12
- }));
10
+ jest.mock('../Toolbar/Toolbar', () => jest.fn(() => <div id="Portal" />));
13
11
 
14
12
  describe('AddonsControlpanel', () => {
15
13
  it('renders an addon control component', () => {
@@ -57,12 +55,13 @@ describe('AddonsControlpanel', () => {
57
55
  messages: {},
58
56
  },
59
57
  });
60
- const component = renderer.create(
58
+ const { container } = render(
61
59
  <Provider store={store}>
62
60
  <AddonsControlpanel location={{ pathname: '/blog' }} />
61
+ <div id="toolbar"></div>
63
62
  </Provider>,
64
63
  );
65
- const json = component.toJSON();
66
- expect(json).toMatchSnapshot();
64
+
65
+ expect(container).toMatchSnapshot();
67
66
  });
68
67
  });