@eeacms/volto-embed 6.0.1 → 7.0.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.
- package/CHANGELOG.md +20 -0
- package/cypress.config.js +3 -3
- package/package.json +4 -4
- package/src/{Iframe/EditIframe.jsx → Blocks/Maps/Edit.jsx} +30 -22
- package/src/Blocks/Maps/Edit.test.jsx +119 -0
- package/src/Blocks/Maps/MapsSidebar.jsx +52 -0
- package/src/{Iframe/ViewIframe.jsx → Blocks/Maps/View.jsx} +7 -11
- package/src/Blocks/Maps/index.js +12 -0
- package/src/Blocks/Maps/schema.js +67 -0
- package/src/Blocks/index.js +5 -0
- package/src/PrivacyProtection/PrivacyProtection.jsx +3 -1
- package/src/PrivacyProtection/styles.less +0 -5
- package/src/Toolbar/Enlarge.jsx +29 -0
- package/src/Toolbar/FigureNote.jsx +45 -0
- package/src/Toolbar/MoreInfo.jsx +20 -0
- package/src/Toolbar/Share.jsx +89 -0
- package/src/Toolbar/Sources.jsx +74 -0
- package/src/Toolbar/index.jsx +5 -0
- package/src/Toolbar/styles.less +209 -0
- package/src/index.js +4 -10
- package/src/Iframe/EditIframe.test.jsx +0 -88
- package/src/Iframe/index.js +0 -4
- package/src/Iframe/schema.js +0 -39
- package/src/PrivacyProtection/PrivacyProtection.test.jsx +0 -340
- package/src/PrivacyProtection/helpers.test.js +0 -19
|
@@ -1,340 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, fireEvent, act } from '@testing-library/react';
|
|
3
|
-
import { CookiesProvider } from 'react-cookie';
|
|
4
|
-
import { Provider } from 'react-intl-redux';
|
|
5
|
-
import configureStore from 'redux-mock-store';
|
|
6
|
-
import PrivacyProtection from './PrivacyProtection';
|
|
7
|
-
import config from '@plone/volto/registry';
|
|
8
|
-
import '@testing-library/jest-dom/extend-expect';
|
|
9
|
-
|
|
10
|
-
const mockStore = configureStore();
|
|
11
|
-
|
|
12
|
-
const store = mockStore(() => ({
|
|
13
|
-
connected_data_parameters: {},
|
|
14
|
-
router: {
|
|
15
|
-
location: {
|
|
16
|
-
pathname: '',
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
intl: {
|
|
20
|
-
locale: 'en',
|
|
21
|
-
messages: {},
|
|
22
|
-
},
|
|
23
|
-
}));
|
|
24
|
-
|
|
25
|
-
jest.mock('@plone/volto-slate/editor/render', () => ({
|
|
26
|
-
serializeNodes: jest.fn(() => 'serialized nodes'),
|
|
27
|
-
}));
|
|
28
|
-
|
|
29
|
-
jest.mock('@eeacms/volto-datablocks/helpers', () => ({
|
|
30
|
-
getFilteredURL: jest.fn(() => 'filtered url'),
|
|
31
|
-
getConnectedDataParametersForContext: jest.fn(() => 'connected data params'),
|
|
32
|
-
}));
|
|
33
|
-
|
|
34
|
-
global.fetch = jest.fn(() =>
|
|
35
|
-
Promise.resolve({
|
|
36
|
-
blob: () => Promise.resolve(new Blob(['test'])),
|
|
37
|
-
}),
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
jest.mock('react-toastify', () => ({
|
|
41
|
-
toast: {
|
|
42
|
-
success: jest.fn(),
|
|
43
|
-
},
|
|
44
|
-
}));
|
|
45
|
-
|
|
46
|
-
jest.mock('./helpers', () => ({
|
|
47
|
-
createImageUrl: () => 'test',
|
|
48
|
-
}));
|
|
49
|
-
|
|
50
|
-
global.URL.createObjectURL = jest.fn(() => 'test');
|
|
51
|
-
|
|
52
|
-
jest.mock('react-visibility-sensor', () => ({
|
|
53
|
-
__esModule: true,
|
|
54
|
-
default: (props) => {
|
|
55
|
-
return <div onChange={props.onChange(true)}>{props.children}</div>;
|
|
56
|
-
},
|
|
57
|
-
}));
|
|
58
|
-
|
|
59
|
-
describe('PrivacyProtection', () => {
|
|
60
|
-
it('renders without crashing', () => {
|
|
61
|
-
render(
|
|
62
|
-
<Provider store={store}>
|
|
63
|
-
<CookiesProvider>
|
|
64
|
-
<PrivacyProtection />
|
|
65
|
-
</CookiesProvider>
|
|
66
|
-
</Provider>,
|
|
67
|
-
);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('renders loader', async () => {
|
|
71
|
-
const props = {
|
|
72
|
-
data: {
|
|
73
|
-
dataprotection: {
|
|
74
|
-
enabled: true,
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
cookies: {
|
|
78
|
-
get: () => 'false',
|
|
79
|
-
getAll: () => {},
|
|
80
|
-
addChangeListener: () => {},
|
|
81
|
-
removeChangeListener: () => {},
|
|
82
|
-
},
|
|
83
|
-
editable: true,
|
|
84
|
-
};
|
|
85
|
-
const { container } = render(
|
|
86
|
-
<Provider store={store}>
|
|
87
|
-
<CookiesProvider>
|
|
88
|
-
<PrivacyProtection {...props} />
|
|
89
|
-
</CookiesProvider>
|
|
90
|
-
</Provider>,
|
|
91
|
-
);
|
|
92
|
-
expect(container.querySelector('.ui.loader')).toBeInTheDocument();
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('renders loader', async () => {
|
|
96
|
-
const props = {
|
|
97
|
-
data: {
|
|
98
|
-
dataprotection: {
|
|
99
|
-
enabled: true,
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
cookies: {
|
|
103
|
-
get: () => 'false',
|
|
104
|
-
getAll: () => {},
|
|
105
|
-
addChangeListener: () => {},
|
|
106
|
-
removeChangeListener: () => {},
|
|
107
|
-
},
|
|
108
|
-
editable: false,
|
|
109
|
-
};
|
|
110
|
-
const { container } = render(
|
|
111
|
-
<Provider store={store}>
|
|
112
|
-
<CookiesProvider>
|
|
113
|
-
<PrivacyProtection {...props} />
|
|
114
|
-
</CookiesProvider>
|
|
115
|
-
</Provider>,
|
|
116
|
-
);
|
|
117
|
-
expect(container.querySelector('.ui.loader')).toBeInTheDocument();
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it('renders the wrapper and children', async () => {
|
|
121
|
-
const props = {
|
|
122
|
-
data: {
|
|
123
|
-
dataprotection: {
|
|
124
|
-
enabled: false,
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
cookies: {
|
|
128
|
-
get: () => 'true',
|
|
129
|
-
getAll: () => {},
|
|
130
|
-
addChangeListener: () => {},
|
|
131
|
-
removeChangeListener: () => {},
|
|
132
|
-
},
|
|
133
|
-
editable: false,
|
|
134
|
-
};
|
|
135
|
-
const { container, getByText } = render(
|
|
136
|
-
<Provider store={store}>
|
|
137
|
-
<CookiesProvider>
|
|
138
|
-
<PrivacyProtection {...props}>
|
|
139
|
-
<div>test test</div>
|
|
140
|
-
</PrivacyProtection>
|
|
141
|
-
</CookiesProvider>
|
|
142
|
-
</Provider>,
|
|
143
|
-
);
|
|
144
|
-
expect(getByText('test test')).toBeInTheDocument();
|
|
145
|
-
expect(
|
|
146
|
-
container.querySelector('.privacy-protection-wrapper'),
|
|
147
|
-
).toBeInTheDocument();
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
it('renders the wrapper and children', async () => {
|
|
151
|
-
config.settings = {
|
|
152
|
-
embedCookieExpirationDays: 30,
|
|
153
|
-
};
|
|
154
|
-
const props = {
|
|
155
|
-
data: {
|
|
156
|
-
dataprotection: {
|
|
157
|
-
enabled: true,
|
|
158
|
-
},
|
|
159
|
-
},
|
|
160
|
-
cookies: {
|
|
161
|
-
get: () => 'true',
|
|
162
|
-
getAll: () => {},
|
|
163
|
-
addChangeListener: () => {},
|
|
164
|
-
removeChangeListener: () => {},
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
const { container, getByText } = render(
|
|
168
|
-
<Provider store={store}>
|
|
169
|
-
<CookiesProvider>
|
|
170
|
-
<PrivacyProtection {...props}>
|
|
171
|
-
<div>test test</div>
|
|
172
|
-
</PrivacyProtection>
|
|
173
|
-
</CookiesProvider>
|
|
174
|
-
</Provider>,
|
|
175
|
-
);
|
|
176
|
-
expect(getByText('test test')).toBeInTheDocument();
|
|
177
|
-
expect(
|
|
178
|
-
container.querySelector('.privacy-protection-wrapper'),
|
|
179
|
-
).toBeInTheDocument();
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it('renders popup with external content, button', async () => {
|
|
183
|
-
const props = {
|
|
184
|
-
data: {
|
|
185
|
-
dataprotection: {
|
|
186
|
-
enabled: true,
|
|
187
|
-
background_image: 'test',
|
|
188
|
-
privacy_statement: {
|
|
189
|
-
nodes: [],
|
|
190
|
-
getAttributes: () => {},
|
|
191
|
-
},
|
|
192
|
-
},
|
|
193
|
-
},
|
|
194
|
-
cookies: {
|
|
195
|
-
get: () => false,
|
|
196
|
-
set: () => {},
|
|
197
|
-
getAll: () => {},
|
|
198
|
-
addChangeListener: () => {},
|
|
199
|
-
removeChangeListener: () => {},
|
|
200
|
-
},
|
|
201
|
-
};
|
|
202
|
-
const { container, queryByText, getByText } = render(
|
|
203
|
-
<Provider store={store}>
|
|
204
|
-
<CookiesProvider>
|
|
205
|
-
<PrivacyProtection {...props}>
|
|
206
|
-
<div>test test</div>
|
|
207
|
-
</PrivacyProtection>
|
|
208
|
-
</CookiesProvider>
|
|
209
|
-
</Provider>,
|
|
210
|
-
);
|
|
211
|
-
expect(
|
|
212
|
-
container.querySelector('.privacy-protection-wrapper'),
|
|
213
|
-
).toBeInTheDocument();
|
|
214
|
-
expect(container.querySelector('.privacy-protection')).toBeInTheDocument();
|
|
215
|
-
|
|
216
|
-
expect(
|
|
217
|
-
container.querySelector(
|
|
218
|
-
'.overlay .wrapped .privacy-button .primary.button',
|
|
219
|
-
),
|
|
220
|
-
).toBeInTheDocument();
|
|
221
|
-
expect(
|
|
222
|
-
container.querySelector(
|
|
223
|
-
'.overlay .wrapped .privacy-toggle .ui.toggle.checkbox input',
|
|
224
|
-
),
|
|
225
|
-
).toBeInTheDocument();
|
|
226
|
-
|
|
227
|
-
expect(getByText('Show external content')).toBeInTheDocument();
|
|
228
|
-
expect(getByText('Remember my choice')).toBeInTheDocument();
|
|
229
|
-
expect(getByText('serialized nodes')).toBeInTheDocument();
|
|
230
|
-
fireEvent.click(getByText('Show external content'));
|
|
231
|
-
await act(() => Promise.resolve());
|
|
232
|
-
expect(queryByText('Show external content')).toBe(null);
|
|
233
|
-
expect(getByText('test test')).toBeInTheDocument();
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
it('renders popup with external content, button', async () => {
|
|
237
|
-
const props = {
|
|
238
|
-
data: {
|
|
239
|
-
dataprotection: {
|
|
240
|
-
enabled: true,
|
|
241
|
-
background_image: 'test',
|
|
242
|
-
privacy_statement: {
|
|
243
|
-
nodes: [],
|
|
244
|
-
getAttributes: () => {},
|
|
245
|
-
},
|
|
246
|
-
},
|
|
247
|
-
},
|
|
248
|
-
cookies: {
|
|
249
|
-
get: () => 'false',
|
|
250
|
-
set: () => {},
|
|
251
|
-
getAll: () => {},
|
|
252
|
-
addChangeListener: () => {},
|
|
253
|
-
removeChangeListener: () => {},
|
|
254
|
-
},
|
|
255
|
-
};
|
|
256
|
-
const { container, queryByText, getByText } = render(
|
|
257
|
-
<Provider store={store}>
|
|
258
|
-
<CookiesProvider>
|
|
259
|
-
<PrivacyProtection {...props}>
|
|
260
|
-
<div>test test</div>
|
|
261
|
-
</PrivacyProtection>
|
|
262
|
-
</CookiesProvider>
|
|
263
|
-
</Provider>,
|
|
264
|
-
);
|
|
265
|
-
expect(
|
|
266
|
-
container.querySelector('.privacy-protection-wrapper'),
|
|
267
|
-
).toBeInTheDocument();
|
|
268
|
-
expect(container.querySelector('.privacy-protection')).toBeInTheDocument();
|
|
269
|
-
|
|
270
|
-
expect(
|
|
271
|
-
container.querySelector(
|
|
272
|
-
'.overlay .wrapped .privacy-button .primary.button',
|
|
273
|
-
),
|
|
274
|
-
).toBeInTheDocument();
|
|
275
|
-
expect(
|
|
276
|
-
container.querySelector(
|
|
277
|
-
'.overlay .wrapped .privacy-toggle .ui.toggle.checkbox input',
|
|
278
|
-
),
|
|
279
|
-
).toBeInTheDocument();
|
|
280
|
-
|
|
281
|
-
expect(getByText('Show external content')).toBeInTheDocument();
|
|
282
|
-
expect(getByText('Remember my choice')).toBeInTheDocument();
|
|
283
|
-
expect(getByText('serialized nodes')).toBeInTheDocument();
|
|
284
|
-
fireEvent.click(getByText('Show external content'));
|
|
285
|
-
await act(() => Promise.resolve());
|
|
286
|
-
expect(queryByText('Show external content')).toBe(null);
|
|
287
|
-
expect(getByText('test test')).toBeInTheDocument();
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
it('renders popup with external content, button', () => {
|
|
291
|
-
const props = {
|
|
292
|
-
data: {
|
|
293
|
-
dataprotection: {
|
|
294
|
-
enabled: true,
|
|
295
|
-
background_image: 'test',
|
|
296
|
-
privacy_statement: {
|
|
297
|
-
nodes: [],
|
|
298
|
-
getAttributes: () => {},
|
|
299
|
-
},
|
|
300
|
-
},
|
|
301
|
-
},
|
|
302
|
-
cookies: {
|
|
303
|
-
get: () => 'false',
|
|
304
|
-
set: () => {},
|
|
305
|
-
getAll: () => {},
|
|
306
|
-
addChangeListener: () => {},
|
|
307
|
-
removeChangeListener: () => {},
|
|
308
|
-
},
|
|
309
|
-
};
|
|
310
|
-
const { container, getByText } = render(
|
|
311
|
-
<Provider store={store}>
|
|
312
|
-
<CookiesProvider>
|
|
313
|
-
<PrivacyProtection {...props}>
|
|
314
|
-
<div>test test</div>
|
|
315
|
-
</PrivacyProtection>
|
|
316
|
-
</CookiesProvider>
|
|
317
|
-
</Provider>,
|
|
318
|
-
);
|
|
319
|
-
expect(
|
|
320
|
-
container.querySelector('.privacy-protection-wrapper'),
|
|
321
|
-
).toBeInTheDocument();
|
|
322
|
-
expect(container.querySelector('.privacy-protection')).toBeInTheDocument();
|
|
323
|
-
|
|
324
|
-
expect(
|
|
325
|
-
container.querySelector(
|
|
326
|
-
'.overlay .wrapped .privacy-button .primary.button',
|
|
327
|
-
),
|
|
328
|
-
).toBeInTheDocument();
|
|
329
|
-
expect(
|
|
330
|
-
container.querySelector(
|
|
331
|
-
'.overlay .wrapped .privacy-toggle .ui.toggle.checkbox input',
|
|
332
|
-
),
|
|
333
|
-
).toBeInTheDocument();
|
|
334
|
-
|
|
335
|
-
expect(getByText('Show external content')).toBeInTheDocument();
|
|
336
|
-
expect(getByText('Remember my choice')).toBeInTheDocument();
|
|
337
|
-
expect(getByText('serialized nodes')).toBeInTheDocument();
|
|
338
|
-
fireEvent.click(getByText('Remember my choice'));
|
|
339
|
-
});
|
|
340
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { createImageUrl } from './helpers';
|
|
2
|
-
import '@testing-library/jest-dom/extend-expect';
|
|
3
|
-
|
|
4
|
-
global.window.atob = jest.fn();
|
|
5
|
-
|
|
6
|
-
global.URL.createObjectURL = jest.fn(() => 'mocked-url');
|
|
7
|
-
|
|
8
|
-
describe('createImageUrl', () => {
|
|
9
|
-
it('should return a valid image URL', () => {
|
|
10
|
-
const result = {
|
|
11
|
-
data: 'VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGluZyB0byBkZWNvZGU=',
|
|
12
|
-
'content-type': 'image/jpeg',
|
|
13
|
-
};
|
|
14
|
-
global.window.atob.mockReturnValue('This is a base64 encoding to decode');
|
|
15
|
-
const imageUrl = createImageUrl(result);
|
|
16
|
-
|
|
17
|
-
expect(typeof imageUrl).toBe('string');
|
|
18
|
-
});
|
|
19
|
-
});
|