forked from plone/volto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-setup-config.js
172 lines (165 loc) · 4.49 KB
/
test-setup-config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*
* This is the mocked config registry loader for tests.
* It uses some of the default (real) configuration,
* (mainly) DraftJS one, to not differ too much from reality
* Ideally, we should mock this ones as well at some point.
* Views, Widgets and Blocks are mocked already, to keep
* snapshot consistency and readability.
*/
import React from 'react';
import config from '@plone/volto/registry';
import { loadables } from '@plone/volto/config/Loadables';
import { nonContentRoutes } from '@plone/volto/config/NonContentRoutes';
import ToHTMLRenderers, {
options as ToHTMLOptions,
} from '@plone/volto/config/RichTextEditor/ToHTML';
import {
extendedBlockRenderMap,
blockStyleFn,
listBlockTypes,
} from '@plone/volto/config/RichTextEditor/Blocks';
import FromHTMLCustomBlockFn from '@plone/volto/config/RichTextEditor/FromHTML';
import { contentIcons } from '@plone/volto/config/ContentIcons';
import { styleClassNameConverters } from '@plone/volto/config/Style';
import {
controlPanelsIcons,
filterControlPanels,
filterControlPanelsSchema,
} from '@plone/volto/config/ControlPanels';
// we need to do a redefinition here because of circular import issues
// because draftjs-based components are not really tested, this is basically
// dummy code.
const richtextEditorSettings = (props) => {
return {
extendedBlockRenderMap,
blockStyleFn,
listBlockTypes,
FromHTMLCustomBlockFn,
// richTextEditorPlugins: plugins,
// richTextEditorInlineToolbarButtons: inlineToolbarButtons,
};
};
const richtextViewSettings = {
ToHTMLRenderers,
ToHTMLOptions,
};
config.set('settings', {
apiPath: 'http://localhost:8080/Plone',
defaultLanguage: 'en',
supportedLanguages: ['en'],
defaultPageSize: 25,
isMultilingual: false,
nonContentRoutes,
richtextEditorSettings,
richtextViewSettings,
contentIcons: contentIcons,
loadables,
lazyBundles: {
cms: [
'prettierStandalone',
'prettierParserHtml',
'prismCore',
'toastify',
'reactSelect',
'reactSortableHOC',
// 'diffLib',
],
},
controlPanelsIcons,
filterControlPanels,
filterControlPanelsSchema,
apiExpanders: [],
downloadableObjects: ['File'],
viewableInBrowserObjects: [],
styleClassNameConverters,
});
config.set('blocks', {
blocksConfig: {
listing: {
variations: [
{
id: 'default',
isDefault: true,
title: 'Default',
template: () => (
<div className="mocked-default-listing-template"></div>
),
},
{
id: 'imageGallery',
title: 'Image gallery',
template: () => <div className="mocked-image-listing-template"></div>,
},
{
id: 'summary',
title: 'Summary',
template: () => (
<div className="mocked-summary-listing-template"></div>
),
},
],
},
},
requiredBlocks: [],
groupBlocksOrder: [
{ id: 'mostUsed', title: 'Most used' },
{ id: 'text', title: 'Text' },
{ id: 'media', title: 'Media' },
{ id: 'common', title: 'Common' },
],
initialBlocks: {},
});
config.set('views', {
layoutViews: {},
contentTypesViews: {},
defaultView: {},
errorViews: {},
});
function BaseWidget(name) {
return (props) => (
<div id={`mocked-field-${props.id}`} className={`mocked-${name}-widget`}>
{props.title || 'No title'} - {props.description || 'No description'}
</div>
);
}
config.set('widgets', {
id: {
schema: BaseWidget('schema'),
subjects: BaseWidget('subjects'),
query: BaseWidget('query'),
recurrence: BaseWidget('recurrence'),
remoteUrl: BaseWidget('remoteurl'),
},
widget: {
richtext: BaseWidget('richtext'),
textarea: BaseWidget('textarea'),
datetime: BaseWidget('datetime'),
date: BaseWidget('date'),
password: BaseWidget('password'),
file: BaseWidget('file'),
align: BaseWidget('align'),
url: BaseWidget('url'),
email: BaseWidget('email'),
object_browser: BaseWidget('object_browser'),
},
vocabulary: {},
factory: {},
choices: BaseWidget('choices'),
type: {
boolean: BaseWidget('boolean'),
array: BaseWidget('array'),
object: BaseWidget('object'),
datetime: BaseWidget('datetime'),
date: BaseWidget('date'),
password: BaseWidget('password'),
number: BaseWidget('number'),
integer: BaseWidget('integer'),
},
default: BaseWidget('default'),
});
config.set('components', {});
config.set('experimental', {
addBlockButton: {
enabled: false,
},
});