@plone/volto 17.0.0-alpha.4 → 17.0.0-alpha.6
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/.changelog.draft +20 -20
- package/.yarn/install-state.gz +0 -0
- package/CHANGELOG.md +98 -13
- package/CONTRIBUTING.md +1 -1
- package/README.md +9 -12
- package/locales/de/LC_MESSAGES/volto.po +17 -17
- package/locales/de.json +1 -1
- package/package.json +3 -2
- package/packages/volto-slate/package.json +1 -1
- package/src/components/manage/Blocks/Listing/Edit.jsx +0 -14
- package/src/components/manage/Blocks/Listing/ListingBody.test.jsx +0 -20
- package/src/components/manage/Blocks/Listing/getAsyncData.js +10 -2
- package/src/components/manage/Blocks/Listing/withQuerystringResults.jsx +20 -14
- package/src/components/manage/Blocks/Search/SearchBlockEdit.jsx +5 -4
- package/src/components/manage/Blocks/Search/SearchBlockView.jsx +2 -1
- package/src/components/manage/Blocks/Search/hocs/withSearch.jsx +28 -19
- package/src/components/manage/Contents/Contents.jsx +29 -24
- package/src/components/manage/Controlpanels/Controlpanels.jsx +190 -224
- package/src/components/manage/Controlpanels/Controlpanels.test.jsx +46 -7
- package/src/components/manage/Form/InlineForm.jsx +39 -9
- package/src/components/manage/Form/InlineFormState.js +8 -0
- package/src/components/manage/Widgets/ObjectListWidget.jsx +3 -8
- package/src/components/theme/Icon/Icon.jsx +2 -2
- package/src/components/theme/Login/Login.jsx +1 -0
- package/src/config/index.js +1 -0
- package/src/express-middleware/sitemap.js +36 -3
- package/src/helpers/Robots/Robots.js +24 -6
- package/src/helpers/Sitemap/Sitemap.js +44 -2
- package/src/helpers/Url/Url.js +8 -3
- package/src/helpers/Url/Url.test.js +14 -0
- package/src/helpers/Utils/Utils.js +17 -4
- package/src/helpers/Utils/usePagination.js +14 -48
- package/src/helpers/index.js +2 -0
- package/src/middleware/Api.test.js +54 -0
- package/src/middleware/api.js +1 -1
- package/test-setup-config.js +1 -0
- package/theme/themes/pastanaga/extras/sidebar.less +4 -0
- package/src/helpers/Utils/usePagination.test.js +0 -115
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { renderHook } from '@testing-library/react-hooks';
|
|
2
|
-
import { usePagination } from './usePagination';
|
|
3
|
-
import * as redux from 'react-redux';
|
|
4
|
-
import routeData from 'react-router';
|
|
5
|
-
import { slugify } from '@plone/volto/helpers/Utils/Utils';
|
|
6
|
-
|
|
7
|
-
const searchBlockId = '545b33de-92cf-4747-969d-68851837b317';
|
|
8
|
-
const searchBlockId2 = '454b33de-92cf-4747-969d-68851837b713';
|
|
9
|
-
const searchBlock = {
|
|
10
|
-
'@type': 'search',
|
|
11
|
-
query: {
|
|
12
|
-
b_size: '4',
|
|
13
|
-
query: [
|
|
14
|
-
{
|
|
15
|
-
i: 'path',
|
|
16
|
-
o: 'plone.app.querystring.operation.string.relativePath',
|
|
17
|
-
v: '',
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
|
-
sort_order: 'ascending',
|
|
21
|
-
},
|
|
22
|
-
showSearchInput: true,
|
|
23
|
-
showTotalResults: true,
|
|
24
|
-
};
|
|
25
|
-
let state = {
|
|
26
|
-
content: {
|
|
27
|
-
data: {
|
|
28
|
-
blocks: {
|
|
29
|
-
[searchBlockId]: searchBlock,
|
|
30
|
-
},
|
|
31
|
-
blocks_layout: {
|
|
32
|
-
items: [searchBlockId],
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
let mockUseLocationValue = {
|
|
39
|
-
pathname: '/testroute',
|
|
40
|
-
search: '',
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const setUp = (searchParam, numberOfSearches) => {
|
|
44
|
-
mockUseLocationValue.search = searchParam;
|
|
45
|
-
if (numberOfSearches > 1) {
|
|
46
|
-
state.content.data.blocks[searchBlockId2] = searchBlock;
|
|
47
|
-
state.content.data.blocks_layout.items.push(searchBlockId2);
|
|
48
|
-
}
|
|
49
|
-
return renderHook(({ id, defaultPage }) => usePagination(id, defaultPage), {
|
|
50
|
-
initialProps: {
|
|
51
|
-
id: searchBlockId,
|
|
52
|
-
defaultPage: 1,
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
describe(`Tests for usePagination, for the block ${searchBlockId}`, () => {
|
|
58
|
-
const useLocation = jest.spyOn(routeData, 'useLocation');
|
|
59
|
-
const useHistory = jest.spyOn(routeData, 'useHistory');
|
|
60
|
-
const useSelector = jest.spyOn(redux, 'useSelector');
|
|
61
|
-
beforeEach(() => {
|
|
62
|
-
useLocation.mockReturnValue(mockUseLocationValue);
|
|
63
|
-
useHistory.mockReturnValue({ replace: jest.fn() });
|
|
64
|
-
useSelector.mockImplementation((cb) => cb(state));
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('1 paginated block with id and defaultPage 1 - shoud be 1', () => {
|
|
68
|
-
const { result } = setUp();
|
|
69
|
-
expect(result.current.currentPage).toBe(1);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('1 paginated block without params - shoud be 1', () => {
|
|
73
|
-
const { result } = setUp();
|
|
74
|
-
expect(result.current.currentPage).toBe(1);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
const param1 = '?page=2';
|
|
78
|
-
it(`1 paginated block with params: ${param1} - shoud be 2`, () => {
|
|
79
|
-
const { result } = setUp(param1);
|
|
80
|
-
expect(result.current.currentPage).toBe(2);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
const param2 = `?${slugify(`page-${searchBlockId}`)}=2`;
|
|
84
|
-
it(`2 paginated blocks with current block in the params: ${param2} - shoud be 2`, () => {
|
|
85
|
-
const { result } = setUp(param2, 2);
|
|
86
|
-
expect(result.current.currentPage).toBe(2);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
const param3 = `?${slugify(`page-${searchBlockId2}`)}=2`;
|
|
90
|
-
it(`2 paginated blocks with the other block in the params: ${param3} - shoud be 1`, () => {
|
|
91
|
-
const { result } = setUp(param3, 2);
|
|
92
|
-
expect(result.current.currentPage).toBe(1);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
const param4 = `?${slugify(`page-${searchBlockId}`)}=2&${slugify(
|
|
96
|
-
`page-${searchBlockId2}`,
|
|
97
|
-
)}=1`;
|
|
98
|
-
it(`2 paginated blocks with both blocks in the params, current 2: ${param4} - shoud be 2`, () => {
|
|
99
|
-
const { result } = setUp(param4, 2);
|
|
100
|
-
expect(result.current.currentPage).toBe(2);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
const param5 = `?${slugify(`page-${searchBlockId}`)}=1&${slugify(
|
|
104
|
-
`page-${searchBlockId2}`,
|
|
105
|
-
)}=2`;
|
|
106
|
-
it(`2 paginated blocks with both blocks in the params, current 1: ${param5} - shoud be 1`, () => {
|
|
107
|
-
const { result } = setUp(param5, 2);
|
|
108
|
-
expect(result.current.currentPage).toBe(1);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it(`2 paginated blocks with wrong page param: ${param1} - shoud be 1`, () => {
|
|
112
|
-
const { result } = setUp(param1, 2);
|
|
113
|
-
expect(result.current.currentPage).toBe(1);
|
|
114
|
-
});
|
|
115
|
-
});
|