@eeacms/volto-eea-website-theme 1.22.1 → 1.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,343 @@
1
+ import applyConfig from './index';
2
+ import * as eea from './config';
3
+ import BaseTag from './components/theme/BaseTag';
4
+
5
+ jest.mock(
6
+ '@eeacms/volto-eea-design-system/ui/InpageNavigation/InpageNavigation',
7
+ () => 'MockedInpageNavigation',
8
+ );
9
+ jest.mock('@eeacms/volto-eea-website-theme/helpers/schema-utils', () => ({
10
+ addStylingFieldsetSchemaEnhancer: jest.fn(),
11
+ }));
12
+ jest.mock(
13
+ '@eeacms/volto-eea-website-theme/components/theme/CustomCSS/CustomCSS',
14
+ () => 'MockedCustomCSS',
15
+ );
16
+ jest.mock(
17
+ '@eeacms/volto-eea-website-theme/components/theme/NotFound/NotFound',
18
+ () => 'MockedNotFound',
19
+ );
20
+ jest.mock(
21
+ '@eeacms/volto-eea-website-theme/components/theme/DraftBackground/DraftBackground',
22
+ () => 'MockedDraftBackground',
23
+ );
24
+ jest.mock(
25
+ '@eeacms/volto-eea-website-theme/components/theme/Widgets/TokenWidget',
26
+ () => ({
27
+ TokenWidget: 'MockedTokenWidget',
28
+ }),
29
+ );
30
+ jest.mock(
31
+ '@eeacms/volto-eea-website-theme/components/theme/Widgets/TopicsWidget',
32
+ () => ({
33
+ TopicsWidget: 'MockedThemesWidget',
34
+ }),
35
+ );
36
+ jest.mock('./components/theme/SubsiteClass', () => 'MockedSubsiteClass');
37
+ jest.mock(
38
+ '@eeacms/volto-eea-website-theme/components/theme/Homepage/HomePageView',
39
+ () => 'MockedHomePageView',
40
+ );
41
+ jest.mock(
42
+ '@eeacms/volto-eea-website-theme/components/theme/Homepage/HomePageInverseView',
43
+ () => 'MockedHomePageInverseView',
44
+ );
45
+ jest.mock('@plone/volto/components', () => ({
46
+ Icon: 'MockedIcon',
47
+ }));
48
+
49
+ global.__SERVER__ = true;
50
+
51
+ describe('applyConfig', () => {
52
+ it('should update the config settings with EEA specific settings', () => {
53
+ const originalConfig = {
54
+ blocks: {
55
+ blocksConfig: {
56
+ title: {
57
+ restricted: undefined,
58
+ },
59
+ description: {
60
+ restricted: undefined,
61
+ },
62
+ image: {},
63
+ video: {},
64
+ teaser: {
65
+ restricted: undefined,
66
+ },
67
+ nextCloudVideo: {
68
+ subtitlesLanguages: [],
69
+ },
70
+ accordion: undefined,
71
+ tabs_block: undefined,
72
+ columnsBlock: undefined,
73
+ hero: undefined,
74
+ group: undefined,
75
+ listing: undefined,
76
+ dividerBlock: undefined,
77
+ callToActionBlock: undefined,
78
+ },
79
+ },
80
+ views: {
81
+ layoutViews: undefined,
82
+ errorViews: {},
83
+ },
84
+ widgets: {
85
+ views: {
86
+ id: {
87
+ taxonomy_themes: undefined,
88
+ },
89
+ widget: {
90
+ tags: undefined,
91
+ },
92
+ },
93
+ },
94
+ settings: {
95
+ eea: {
96
+ languages: [{ code: 'en', name: 'English' }],
97
+ },
98
+ contactForm: '',
99
+ serverConfig: undefined,
100
+ showTags: true,
101
+ dateLocale: '',
102
+ available_colors: [],
103
+ expressMiddleware: [],
104
+ appExtras: undefined,
105
+
106
+ pluggableStyles: undefined,
107
+ apiExpanders: [],
108
+ hasLanguageDropdown: true,
109
+ themeColors: [],
110
+ previewText: '',
111
+ requiredBlocks: [],
112
+ },
113
+ };
114
+ const config = applyConfig(originalConfig);
115
+
116
+ expect(config.settings.contactForm).toBe('/contact');
117
+ expect(config.settings.showTags).toBe(false);
118
+ expect(config.blocks.blocksConfig['teaser'].restricted).toBe(true);
119
+ expect(config.blocks.blocksConfig['title'].restricted).toBe(false);
120
+ expect(config.blocks.blocksConfig['description'].restricted).toBe(false);
121
+ expect(config.settings.dateLocale).toBe('en-gb');
122
+ expect(config.views.layoutViews['homepage_view']).toBe(
123
+ 'MockedHomePageView',
124
+ );
125
+ expect(config.views.layoutViews['homepage_inverse_view']).toBe(
126
+ 'MockedHomePageInverseView',
127
+ );
128
+ expect(config.views.errorViews['404']).toBe('MockedNotFound');
129
+
130
+ expect(config.blocks.blocksConfig['description'].className).toBe(
131
+ 'documentDescription eea callout',
132
+ );
133
+
134
+ expect(config.widgets.views.id.subjects).toBe('MockedTokenWidget');
135
+ expect(config.settings.expressMiddleware.length).toEqual(2);
136
+ expect(config.settings.appExtras).toEqual([
137
+ { match: '/**', component: 'MockedInpageNavigation' },
138
+ { match: '', component: 'MockedCustomCSS' },
139
+ { match: '', component: 'MockedDraftBackground' },
140
+ { match: '', component: 'MockedSubsiteClass' },
141
+ { match: '', component: BaseTag },
142
+ ]);
143
+ expect(config.settings.available_colors).toEqual(eea.colors);
144
+ expect(config.settings.hasLanguageDropdown).toBe(false);
145
+ expect(config.settings.themeColors).toEqual([
146
+ { value: undefined, title: 'No theme' },
147
+ { value: 'primary', title: 'Primary' },
148
+ { value: 'secondary', title: 'Secondary' },
149
+ { value: 'tertiary', title: 'Tertiary' },
150
+ ]);
151
+ expect(config.settings.pluggableStyles).toEqual([
152
+ {
153
+ id: 'content-box-gray',
154
+ title: 'Default',
155
+ previewComponent: expect.any(Function),
156
+ viewComponent: expect.any(Function),
157
+ },
158
+ {
159
+ id: 'content-box-primary',
160
+ title: 'Primary',
161
+ previewComponent: expect.any(Function),
162
+ viewComponent: expect.any(Function),
163
+ },
164
+ {
165
+ id: 'content-box-secondary',
166
+ title: 'Secondary',
167
+ previewComponent: expect.any(Function),
168
+ viewComponent: expect.any(Function),
169
+ },
170
+ {
171
+ id: 'content-box-tertiary',
172
+ title: 'Tertiary',
173
+ previewComponent: expect.any(Function),
174
+ viewComponent: expect.any(Function),
175
+ },
176
+ ]);
177
+ expect(config.blocks.blocksConfig.image.mostUsed).toBe(false);
178
+ expect(config.blocks.blocksConfig.video.mostUsed).toBe(false);
179
+ expect(config.settings.apiExpanders).toEqual([
180
+ { match: '', GET_CONTENT: ['breadcrumbs'] },
181
+ ]);
182
+ });
183
+
184
+ it('should update the config settings with EEA specific settings', () => {
185
+ const originalConfig = {
186
+ blocks: {
187
+ blocksConfig: {
188
+ title: {
189
+ restricted: undefined,
190
+ },
191
+ description: {
192
+ restricted: undefined,
193
+ },
194
+ image: {},
195
+ video: {},
196
+ teaser: {
197
+ restricted: undefined,
198
+ },
199
+ nextCloudVideo: {
200
+ subtitlesLanguages: undefined,
201
+ },
202
+ accordion: {
203
+ defaults: {},
204
+ },
205
+ tabs_block: {
206
+ templates: {
207
+ accordion: {},
208
+ },
209
+ variations: [
210
+ { id: 'default', title: 'Default', isDefault: true },
211
+ {
212
+ id: 'horizontal-responsive',
213
+ title: 'Horizontal',
214
+ isDefault: false,
215
+ },
216
+ ],
217
+ },
218
+ columnsBlock: {},
219
+ hero: {},
220
+ group: {},
221
+ listing: {},
222
+ dividerBlock: {},
223
+ callToActionBlock: {},
224
+ },
225
+ },
226
+ views: {
227
+ layoutViews: {},
228
+ errorViews: {},
229
+ },
230
+ widgets: {
231
+ views: {
232
+ id: {
233
+ taxonomy_themes: undefined,
234
+ },
235
+ widget: {
236
+ tags: undefined,
237
+ },
238
+ },
239
+ },
240
+ settings: {
241
+ eea: {},
242
+ contactForm: '',
243
+ serverConfig: {
244
+ extractScripts: {},
245
+ },
246
+ showTags: true,
247
+ dateLocale: '',
248
+ available_colors: [],
249
+ expressMiddleware: [],
250
+ appExtras: [],
251
+
252
+ pluggableStyles: [],
253
+ apiExpanders: [],
254
+ hasLanguageDropdown: true,
255
+ themeColors: [],
256
+ previewText: '',
257
+ requiredBlocks: [],
258
+ },
259
+ };
260
+ const config = applyConfig(originalConfig);
261
+
262
+ expect(config.settings.eea).toEqual(eea);
263
+ expect(config.settings.contactForm).toBe('/contact');
264
+ expect(config.settings.serverConfig.extractScripts.errorPages).toBe(true);
265
+ expect(config.settings.showTags).toBe(false);
266
+ expect(config.blocks.blocksConfig['teaser'].restricted).toBe(true);
267
+ expect(config.blocks.blocksConfig['title'].restricted).toBe(false);
268
+ expect(config.blocks.blocksConfig['description'].restricted).toBe(false);
269
+ expect(config.settings.dateLocale).toBe('en-gb');
270
+ expect(config.views.layoutViews['homepage_view']).toBe(
271
+ 'MockedHomePageView',
272
+ );
273
+ expect(config.views.layoutViews['homepage_inverse_view']).toBe(
274
+ 'MockedHomePageInverseView',
275
+ );
276
+ expect(config.views.errorViews['404']).toBe('MockedNotFound');
277
+
278
+ expect(config.blocks.blocksConfig['accordion'].options).toEqual({});
279
+ expect(config.blocks.blocksConfig['accordion'].defaults.theme).toBe(
280
+ 'secondary',
281
+ );
282
+
283
+ expect(config.blocks.blocksConfig['columnsBlock'].available_colors).toEqual(
284
+ eea.colors,
285
+ );
286
+ expect(config.blocks.blocksConfig['description'].className).toBe(
287
+ 'documentDescription eea callout',
288
+ );
289
+ expect(config.blocks.blocksConfig['hero'].copyrightPrefix).toBe('Image');
290
+
291
+ expect(config.widgets.views.id.subjects).toBe('MockedTokenWidget');
292
+ expect(config.settings.expressMiddleware.length).toEqual(2);
293
+ expect(config.settings.appExtras).toEqual([
294
+ { match: '/**', component: 'MockedInpageNavigation' },
295
+ { match: '', component: 'MockedCustomCSS' },
296
+ { match: '', component: 'MockedDraftBackground' },
297
+ { match: '', component: 'MockedSubsiteClass' },
298
+ { match: '', component: BaseTag },
299
+ ]);
300
+ expect(config.settings.available_colors).toEqual(eea.colors);
301
+ expect(config.settings.hasLanguageDropdown).toBe(false);
302
+ expect(config.settings.themeColors).toEqual([
303
+ { value: undefined, title: 'No theme' },
304
+ { value: 'primary', title: 'Primary' },
305
+ { value: 'secondary', title: 'Secondary' },
306
+ { value: 'tertiary', title: 'Tertiary' },
307
+ ]);
308
+ expect(config.settings.pluggableStyles).toEqual([
309
+ {
310
+ id: 'content-box-gray',
311
+ title: 'Default',
312
+ previewComponent: expect.any(Function),
313
+ viewComponent: expect.any(Function),
314
+ },
315
+ {
316
+ id: 'content-box-primary',
317
+ title: 'Primary',
318
+ previewComponent: expect.any(Function),
319
+ viewComponent: expect.any(Function),
320
+ },
321
+ {
322
+ id: 'content-box-secondary',
323
+ title: 'Secondary',
324
+ previewComponent: expect.any(Function),
325
+ viewComponent: expect.any(Function),
326
+ },
327
+ {
328
+ id: 'content-box-tertiary',
329
+ title: 'Tertiary',
330
+ previewComponent: expect.any(Function),
331
+ viewComponent: expect.any(Function),
332
+ },
333
+ ]);
334
+ expect(config.blocks.blocksConfig.image.mostUsed).toBe(false);
335
+ expect(config.blocks.blocksConfig.video.mostUsed).toBe(false);
336
+ expect(config.blocks.blocksConfig.dividerBlock.mostUsed).toBe(true);
337
+ expect(config.blocks.blocksConfig.callToActionBlock.mostUsed).toBe(true);
338
+ expect(config.blocks.blocksConfig.accordion.mostUsed).toBe(true);
339
+ expect(config.settings.apiExpanders).toEqual([
340
+ { match: '', GET_CONTENT: ['breadcrumbs'] },
341
+ ]);
342
+ });
343
+ });
@@ -1,109 +0,0 @@
1
- export default () => ({
2
- title: 'Default tabs block',
3
- fieldsets: [
4
- {
5
- id: 'default',
6
- title: 'Default',
7
- fields: ['description'],
8
- },
9
- {
10
- id: 'menu',
11
- title: 'Menu',
12
- fields: ['menuAlign', 'menuPosition', 'menuColor', 'menuInverted'],
13
- },
14
- ],
15
- properties: {
16
- description: {
17
- title: 'Description',
18
- },
19
- menuPosition: {
20
- title: 'Position',
21
- choices: [
22
- ['top', 'Top'],
23
- ['bottom', 'Bottom'],
24
- ['left side', 'Left side'],
25
- ['right side', 'Right side'],
26
- ],
27
- },
28
- menuAlign: {
29
- title: 'Alignment',
30
- type: 'array',
31
- choices: [
32
- ['left', 'Left'],
33
- ['center', 'Center'],
34
- ['right', 'Right'],
35
- ['space-between', 'Space between'],
36
- ],
37
- },
38
- menuSize: {
39
- title: 'Size',
40
- choices: [
41
- ['mini', 'Mini'],
42
- ['tiny', 'Tiny'],
43
- ['small', 'Small'],
44
- ['large', 'Large'],
45
- ['huge', 'Huge'],
46
- ['massive', 'Masive'],
47
- ],
48
- },
49
- menuColor: {
50
- title: 'Color',
51
- defaultValue: 'green',
52
- choices: [
53
- ['red', 'Red'],
54
- ['orange', 'Orange'],
55
- ['yellow', 'Yellow'],
56
- ['olive', 'Olive'],
57
- ['green', 'Green'],
58
- ['teal', 'Teal'],
59
- ['blue', 'Blue'],
60
- ['violet', 'Violet'],
61
- ['purple', 'Purple'],
62
- ['pink', 'Pink'],
63
- ['brown', 'Brown'],
64
- ['grey', 'Grey'],
65
- ['black', 'Black'],
66
- ],
67
- },
68
- menuBorderless: {
69
- title: 'Borderless',
70
- type: 'boolean',
71
- },
72
- menuCompact: {
73
- title: 'Compact',
74
- type: 'boolean',
75
- },
76
- menuFluid: {
77
- title: 'Fluid',
78
- type: 'boolean',
79
- value: true,
80
- },
81
- menuInverted: {
82
- title: 'Inverted',
83
- type: 'boolean',
84
- },
85
- menuPointing: {
86
- title: 'Pointing',
87
- type: 'boolean',
88
- value: true,
89
- },
90
- menuSecondary: {
91
- title: 'Secondary',
92
- type: 'boolean',
93
- value: true,
94
- },
95
- menuStackable: {
96
- title: 'Stackable',
97
- type: 'boolean',
98
- },
99
- menuTabular: {
100
- title: 'Tabular',
101
- type: 'boolean',
102
- },
103
- menuText: {
104
- title: 'Text',
105
- type: 'boolean',
106
- },
107
- },
108
- required: [],
109
- });
@@ -1,109 +0,0 @@
1
- export default () => ({
2
- title: 'Default tabs block',
3
- fieldsets: [
4
- {
5
- id: 'default',
6
- title: 'Default',
7
- fields: ['description'],
8
- },
9
- {
10
- id: 'menu',
11
- title: 'Menu',
12
- fields: ['menuAlign', 'menuPosition', 'menuColor', 'menuInverted'],
13
- },
14
- ],
15
- properties: {
16
- description: {
17
- title: 'Description',
18
- },
19
- menuPosition: {
20
- title: 'Position',
21
- choices: [
22
- ['top', 'Top'],
23
- ['bottom', 'Bottom'],
24
- ['left side', 'Left side'],
25
- ['right side', 'Right side'],
26
- ],
27
- },
28
- menuAlign: {
29
- title: 'Alignment',
30
- type: 'array',
31
- choices: [
32
- ['left', 'Left'],
33
- ['center', 'Center'],
34
- ['right', 'Right'],
35
- ['space-between', 'Space between'],
36
- ],
37
- },
38
- menuSize: {
39
- title: 'Size',
40
- choices: [
41
- ['mini', 'Mini'],
42
- ['tiny', 'Tiny'],
43
- ['small', 'Small'],
44
- ['large', 'Large'],
45
- ['huge', 'Huge'],
46
- ['massive', 'Masive'],
47
- ],
48
- },
49
- menuColor: {
50
- title: 'Color',
51
- defaultValue: 'green',
52
- choices: [
53
- ['red', 'Red'],
54
- ['orange', 'Orange'],
55
- ['yellow', 'Yellow'],
56
- ['olive', 'Olive'],
57
- ['green', 'Green'],
58
- ['teal', 'Teal'],
59
- ['blue', 'Blue'],
60
- ['violet', 'Violet'],
61
- ['purple', 'Purple'],
62
- ['pink', 'Pink'],
63
- ['brown', 'Brown'],
64
- ['grey', 'Grey'],
65
- ['black', 'Black'],
66
- ],
67
- },
68
- menuBorderless: {
69
- title: 'Borderless',
70
- type: 'boolean',
71
- },
72
- menuCompact: {
73
- title: 'Compact',
74
- type: 'boolean',
75
- },
76
- menuFluid: {
77
- title: 'Fluid',
78
- type: 'boolean',
79
- value: true,
80
- },
81
- menuInverted: {
82
- title: 'Inverted',
83
- type: 'boolean',
84
- },
85
- menuPointing: {
86
- title: 'Pointing',
87
- type: 'boolean',
88
- value: true,
89
- },
90
- menuSecondary: {
91
- title: 'Secondary',
92
- type: 'boolean',
93
- value: true,
94
- },
95
- menuStackable: {
96
- title: 'Stackable',
97
- type: 'boolean',
98
- },
99
- menuTabular: {
100
- title: 'Tabular',
101
- type: 'boolean',
102
- },
103
- menuText: {
104
- title: 'Text',
105
- type: 'boolean',
106
- },
107
- },
108
- required: [],
109
- });