@eeacms/volto-tableau 6.0.6 → 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 CHANGED
@@ -4,17 +4,33 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
- ### [6.0.6](https://github.com/eea/volto-tableau/compare/6.0.5...6.0.6) - 17 November 2023
7
+ ### [7.0.0](https://github.com/eea/volto-tableau/compare/6.0.6...7.0.0) - 23 November 2023
8
8
 
9
- #### :rocket: New Features
9
+ #### :bug: Bug Fixes
10
+
11
+ - fix: unittests [Miu Razvan - [`ce983d2`](https://github.com/eea/volto-tableau/commit/ce983d26d18fc2ed6d24f3fa64999e85c3b90051)]
10
12
 
11
- - feat: clean up [Miu Razvan - [`73ff5c0`](https://github.com/eea/volto-tableau/commit/73ff5c0f61c947067006cecf3bd3ad003249d78c)]
13
+ #### :hammer_and_wrench: Others
14
+
15
+ - update [Miu Razvan - [`a7a6f1f`](https://github.com/eea/volto-tableau/commit/a7a6f1f8f0f2ed727a13d386fd30396f80418130)]
16
+ - bump version [Miu Razvan - [`192c7ae`](https://github.com/eea/volto-tableau/commit/192c7ae64e6c659a1f676a3506aa87563cb715e7)]
17
+ - tests [Miu Razvan - [`94aeb23`](https://github.com/eea/volto-tableau/commit/94aeb2332fa98088b0da456df692368163d01221)]
18
+ - update [Miu Razvan - [`daaeeb5`](https://github.com/eea/volto-tableau/commit/daaeeb51876276909d506c9f1851b83089ff9124)]
19
+ - update [Miu Razvan - [`48e976f`](https://github.com/eea/volto-tableau/commit/48e976f0e9ff6d11dd18a61f6d17bd6c0de11e5a)]
20
+ - update [Miu Razvan - [`fcc702a`](https://github.com/eea/volto-tableau/commit/fcc702a38cc3942d84282443d5de543f0e361389)]
21
+ - update [Miu Razvan - [`ef9abd3`](https://github.com/eea/volto-tableau/commit/ef9abd3617bde7148fe2ac6d33079f3d5f82a302)]
22
+ - update snapshot [Dobricean Ioan Dorian - [`baaeccf`](https://github.com/eea/volto-tableau/commit/baaeccf8c589c7a6bac6a5522a0a23b90b9fda1d)]
23
+ - unify view and edit [Dobricean Ioan Dorian - [`1159da9`](https://github.com/eea/volto-tableau/commit/1159da96057dc78a1ac46371c57f55e7786aab34)]
24
+ - fix tests [Dobricean Ioan Dorian - [`33bff4b`](https://github.com/eea/volto-tableau/commit/33bff4b8e9060548610990c6817b49cb06be79ae)]
25
+ - test [Dobricean Ioan Dorian - [`48505ca`](https://github.com/eea/volto-tableau/commit/48505caef84d12091035fdd79cf64067e7f819e2)]
26
+ - split the view and edit [Dobricean Ioan Dorian - [`7227bb1`](https://github.com/eea/volto-tableau/commit/7227bb1fb70e5d895f15872ed6533e089be99836)]
27
+ - update embed tableau so it can work with serialized data [Dobricean Ioan Dorian - [`59d958c`](https://github.com/eea/volto-tableau/commit/59d958c7a1a5055ea62e04abcbf34ee93f52e23a)]
28
+ ### [6.0.6](https://github.com/eea/volto-tableau/compare/6.0.5...6.0.6) - 17 November 2023
12
29
 
13
30
  #### :hammer_and_wrench: Others
14
31
 
15
32
  - tests: add cypress for tableau [nileshgulia1 - [`6eca683`](https://github.com/eea/volto-tableau/commit/6eca6834b85cdab4ed82367fee32fdbbb35b0f5e)]
16
33
  - tests: update unit tests [nileshgulia1 - [`96cae09`](https://github.com/eea/volto-tableau/commit/96cae09eab2e737f032c97eb401a3efa88e68ec6)]
17
- - test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`c7e81cb`](https://github.com/eea/volto-tableau/commit/c7e81cb0768f755dd4107a4998253d9bccc33809)]
18
34
  - comment test [Miu Razvan - [`a459525`](https://github.com/eea/volto-tableau/commit/a459525fdccf8ee61651d4cb2e04eb253e841c61)]
19
35
  ### [6.0.5](https://github.com/eea/volto-tableau/compare/6.0.4...6.0.5) - 15 November 2023
20
36
 
@@ -41,7 +57,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
41
57
 
42
58
  #### :house: Internal changes
43
59
 
44
- - chore: [JENKINS] Refactor automated testing [valentinab25 - [`903b90a`](https://github.com/eea/volto-tableau/commit/903b90a2df0abc183aa68d99a89bb688de3a0c73)]
45
60
 
46
61
  #### :hammer_and_wrench: Others
47
62
 
@@ -51,9 +66,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
51
66
  - tests: increase coverage [kreafox - [`ecb9262`](https://github.com/eea/volto-tableau/commit/ecb92625a44365faf4c39f0ff3f02ccc4ca21656)]
52
67
  - Fix tableau height [kreafox - [`6194c24`](https://github.com/eea/volto-tableau/commit/6194c2405e2bd93aba9865caed76292cd55193d3)]
53
68
  - Show share & download button on widget view [kreafox - [`a66e253`](https://github.com/eea/volto-tableau/commit/a66e2537d08dc7129e249c28e1daa27246c88815)]
54
- - test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`9d2189d`](https://github.com/eea/volto-tableau/commit/9d2189d4edb13dd449d75cd6dd9052bbed67304d)]
55
- - test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`f2fa3f9`](https://github.com/eea/volto-tableau/commit/f2fa3f9ccabab918586179ac16ead44e2eba8498)]
56
- - test: [JENKINS] Improve cypress time [valentinab25 - [`5748183`](https://github.com/eea/volto-tableau/commit/5748183c27dae18a4ebbc067d659cbc24cad8f71)]
57
69
  - use toolbar from volto-embed [Miu Razvan - [`1a232a1`](https://github.com/eea/volto-tableau/commit/1a232a15f2bbe05da75307800590d0a0a1c4996b)]
58
70
  ## [6.0.0](https://github.com/eea/volto-tableau/compare/5.0.2...6.0.0) - 30 October 2023
59
71
 
@@ -111,7 +123,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
111
123
  - test: change volto version in Jenkinsfile [ana-oprea - [`347aceb`](https://github.com/eea/volto-tableau/commit/347aceb07d152fddeebbf3a7e7a6ac9c55dc21ba)]
112
124
  - test: increase cypress timeout [ana-oprea - [`bdf4408`](https://github.com/eea/volto-tableau/commit/bdf44083cd84c96b4914d3f8a3bb17c5187f191c)]
113
125
  - test: EN locales, pre-commit fix, feature PRs checks Refs #257193 [valentinab25 - [`caff974`](https://github.com/eea/volto-tableau/commit/caff9742a703b224133a8dd2a969629e70c9fd33)]
114
- - test: Fix eslint and yarn i18n [Alin Voinea - [`b8be7fb`](https://github.com/eea/volto-tableau/commit/b8be7fb9ab10faed0a1be8ce7e3d4e7c78ebe020)]
115
126
  - i18n: Add en [Alin Voinea - [`c5e20dd`](https://github.com/eea/volto-tableau/commit/c5e20ddea25c830ac80665ee9a71e557e8cd117d)]
116
127
  - test: Update Makefile and docker-compose to align it with Jenkinsfile [valentinab25 - [`2116ff9`](https://github.com/eea/volto-tableau/commit/2116ff95c6454e813bdca44e6c3aa81fa0a916b8)]
117
128
  ## [5.0.0](https://github.com/eea/volto-tableau/compare/4.1.1...5.0.0) - 25 July 2023
@@ -123,21 +134,17 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
123
134
  #### :hammer_and_wrench: Others
124
135
 
125
136
  - Release 5.0.0 [Alin Voinea - [`97c98e9`](https://github.com/eea/volto-tableau/commit/97c98e98b1295a4ad45756326dc20cd59517515f)]
126
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`2acb3a5`](https://github.com/eea/volto-tableau/commit/2acb3a5490f62ce0a95ebbd03c32874ac3a42603)]
127
137
  ### [4.1.1](https://github.com/eea/volto-tableau/compare/4.1.0...4.1.1) - 21 July 2023
128
138
 
129
139
  #### :hammer_and_wrench: Others
130
140
 
131
141
  - Add VisualizationViewWidget [Tiberiu Ichim - [`fa881cb`](https://github.com/eea/volto-tableau/commit/fa881cbc3643a46697fb16d1c86ada1d4121a46a)]
132
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`cbcbad2`](https://github.com/eea/volto-tableau/commit/cbcbad26f7aa3683122199c8d5cbd142903df93b)]
133
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`51abe6d`](https://github.com/eea/volto-tableau/commit/51abe6d4db80825fe2e396e04c7003c6ad79b480)]
134
142
  ### [4.1.0](https://github.com/eea/volto-tableau/compare/4.0.0...4.1.0) - 15 June 2023
135
143
 
136
144
  ## [4.0.0](https://github.com/eea/volto-tableau/compare/3.0.8...4.0.0) - 13 June 2023
137
145
 
138
146
  #### :house: Internal changes
139
147
 
140
- - chore: [JENKINS] Remove alpha testing version [valentinab25 - [`e33bb21`](https://github.com/eea/volto-tableau/commit/e33bb21eb429c33e3a15d771487a1c9af8ccb0d5)]
141
148
 
142
149
  #### :hammer_and_wrench: Others
143
150
 
@@ -169,7 +176,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
169
176
 
170
177
  #### :hammer_and_wrench: Others
171
178
 
172
- - Add Sonarqube tag using industry-frontend addons list [EEA Jenkins - [`f5deccd`](https://github.com/eea/volto-tableau/commit/f5deccd84372752908b300c5cfd78134818e5ce4)]
173
179
  ### [3.0.6](https://github.com/eea/volto-tableau/compare/3.0.5...3.0.6) - 30 January 2023
174
180
 
175
181
  ### [3.0.5](https://github.com/eea/volto-tableau/compare/3.0.4...3.0.5) - 26 January 2023
@@ -241,7 +247,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
241
247
  - Update commands.js [Nilesh - [`7c48437`](https://github.com/eea/volto-tableau/commit/7c4843780efb9b85a4728de73c00d831c1d8fdcf)]
242
248
  - Update e2e.js [Nilesh - [`f67b45c`](https://github.com/eea/volto-tableau/commit/f67b45c170f58f8d0301192994226f173e4cb00a)]
243
249
  - latest volto compatibility refs #154757 [nileshgulia1 - [`881ba48`](https://github.com/eea/volto-tableau/commit/881ba482dc9b82e7fdac16549d41e80a6d26b3de)]
244
- - Add Sonarqube tag using marine-frontend addons list [EEA Jenkins - [`58e25df`](https://github.com/eea/volto-tableau/commit/58e25df2291add09670143bee54cde103ee835b9)]
245
250
  ### [1.3.0](https://github.com/eea/volto-tableau/compare/1.2.5...1.3.0) - 28 September 2022
246
251
 
247
252
  #### :hammer_and_wrench: Others
@@ -255,15 +260,11 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
255
260
  - Use volto 16 alpha 14 [Miu Razvan - [`93641be`](https://github.com/eea/volto-tableau/commit/93641be4c2393f49008aff789400cf7c947949fd)]
256
261
  - Revert volto-tableau group to common [Andrei Grigore - [`9d24c6d`](https://github.com/eea/volto-tableau/commit/9d24c6d2767fed6a840cddaee55dbd5cecb544b5)]
257
262
  - Tableaugroup typo fix [Andrei Grigore - [`b0b5378`](https://github.com/eea/volto-tableau/commit/b0b5378a437043120a96c9e5e8802584145daa22)]
258
- - Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`3234347`](https://github.com/eea/volto-tableau/commit/3234347e524cc0ed4918242f503fe9e7dba266b2)]
259
263
  - Refs #142010 - Optimize Volto-addons gitflow pipelines [valentinab25 - [`d237e1c`](https://github.com/eea/volto-tableau/commit/d237e1c72817d7e68a3eb698563674d1514db24f)]
260
264
  ### [1.2.4](https://github.com/eea/volto-tableau/compare/1.2.3...1.2.4) - 25 October 2021
261
265
 
262
266
  #### :hammer_and_wrench: Others
263
267
 
264
- - Add Sonarqube tag using frontend addons list [EEA Jenkins - [`2b19679`](https://github.com/eea/volto-tableau/commit/2b19679e2c7bcdc83082d1c73a595eea8b86d14f)]
265
- - Add Sonarqube tag using frontend addons list [EEA Jenkins - [`384ccae`](https://github.com/eea/volto-tableau/commit/384ccaebed8c414a5c90eb96c6ce0a2b091f249c)]
266
- - Add Sonarqube tag using frontend addons list [EEA Jenkins - [`589258e`](https://github.com/eea/volto-tableau/commit/589258e9b3cbba9cee37c57bb85ca5b707bc65d7)]
267
268
  ### [1.2.3](https://github.com/eea/volto-tableau/compare/1.2.2...1.2.3) - 14 June 2021
268
269
 
269
270
  #### :hammer_and_wrench: Others
package/Jenkinsfile CHANGED
@@ -1,4 +1,7 @@
1
1
  pipeline {
2
+ tools {
3
+ jdk 'Java17'
4
+ }
2
5
  agent {
3
6
  node { label 'docker-host' }
4
7
  }
package/README.md CHANGED
@@ -24,6 +24,10 @@ Registers a VisualizationView component for a content type named 'tableau_visual
24
24
 
25
25
  ## Getting started
26
26
 
27
+ ### Upgrade
28
+
29
+ #### 7.x.x -> requires >= eea.api.dataconnector@7.0
30
+
27
31
  ### Try volto-tableau with Docker
28
32
 
29
33
  git clone https://github.com/eea/volto-tableau.git
@@ -43,25 +47,25 @@ Go to http://localhost:3000
43
47
 
44
48
  1. Start Volto frontend
45
49
 
46
- * If you already have a volto project, just update `package.json`:
50
+ - If you already have a volto project, just update `package.json`:
47
51
 
48
- ```JSON
49
- "addons": [
50
- "@eeacms/volto-tableau"
51
- ],
52
+ ```JSON
53
+ "addons": [
54
+ "@eeacms/volto-tableau"
55
+ ],
52
56
 
53
- "dependencies": {
54
- "@eeacms/volto-tableau": "*"
55
- }
56
- ```
57
+ "dependencies": {
58
+ "@eeacms/volto-tableau": "*"
59
+ }
60
+ ```
57
61
 
58
- * If not, create one:
62
+ - If not, create one:
59
63
 
60
- ```
61
- npm install -g yo @plone/generator-volto
62
- yo @plone/volto my-volto-project --canary --addon @eeacms/volto-tableau
63
- cd my-volto-project
64
- ```
64
+ ```
65
+ npm install -g yo @plone/generator-volto
66
+ yo @plone/volto my-volto-project --canary --addon @eeacms/volto-tableau
67
+ cd my-volto-project
68
+ ```
65
69
 
66
70
  1. Install new add-ons and restart Volto:
67
71
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-tableau",
3
- "version": "6.0.6",
3
+ "version": "7.0.0",
4
4
  "description": "@eeacms/volto-tableau: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -75,4 +75,4 @@
75
75
  "cypress:open": "make cypress-open",
76
76
  "prepare": "husky install"
77
77
  }
78
- }
78
+ }
@@ -1,15 +1,16 @@
1
1
  import React from 'react';
2
2
  import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm';
3
3
  import { SidebarPortal } from '@plone/volto/components';
4
- import View from './View';
5
4
  import getSchema from './schema';
6
5
 
6
+ import View from './View';
7
+
7
8
  const Edit = (props) => {
8
9
  const schema = React.useMemo(() => getSchema(props), [props]);
9
10
 
10
11
  return (
11
12
  <React.Fragment>
12
- <View {...props} mode="edit" />
13
+ <View mode="edit" {...props} />
13
14
  <SidebarPortal selected={props.selected}>
14
15
  <BlockDataForm
15
16
  block={props.block}
@@ -0,0 +1,87 @@
1
+ import React from 'react';
2
+ import renderer from 'react-test-renderer';
3
+ import configureStore from 'redux-mock-store';
4
+ import { Provider } from 'react-intl-redux';
5
+ import config from '@plone/volto/registry';
6
+
7
+ import Edit from './Edit';
8
+ import installEmbedTableau from '.';
9
+
10
+ installEmbedTableau(config);
11
+
12
+ const mockStore = configureStore([]);
13
+
14
+ window.URL.createObjectURL = jest.fn(() => 'test');
15
+
16
+ jest.mock('@plone/volto/components', () => ({
17
+ Icon: ({ children }) => <img alt="incon">{children}</img>,
18
+ Toast: ({ children }) => <p>{children}</p>,
19
+ SidebarPortal: jest.requireActual(
20
+ '@plone/volto/components/manage/Sidebar/SidebarPortal',
21
+ ).default,
22
+ }));
23
+
24
+ jest.mock('@eeacms/volto-matomo/utils', () => ({
25
+ trackLink: jest.fn(),
26
+ }));
27
+
28
+ jest.mock(
29
+ '@eeacms/volto-embed/PrivacyProtection/PrivacyProtection',
30
+ () => ({ children }) => {
31
+ return children;
32
+ },
33
+ );
34
+
35
+ jest.mock('@eeacms/volto-embed/helpers', () => ({
36
+ pickMetadata: (data) => data,
37
+ }));
38
+
39
+ const store = mockStore({
40
+ intl: {
41
+ locale: 'en',
42
+ messages: {},
43
+ },
44
+ content: {
45
+ create: {},
46
+ subrequests: [],
47
+ },
48
+ connected_data_parameters: {},
49
+ });
50
+
51
+ describe('Edit', () => {
52
+ const data = {
53
+ '@type': 'embed_tableau_visualization',
54
+ dataprotection: {
55
+ enabled: false,
56
+ },
57
+ tableau_vis_url: 'http://localhost:3000/tableau-ct',
58
+ with_download: true,
59
+ with_more_info: true,
60
+ with_notes: true,
61
+ with_share: true,
62
+ };
63
+
64
+ it('should render the component', () => {
65
+ const component = renderer.create(
66
+ <Provider store={store}>
67
+ <Edit
68
+ id="my-tableau"
69
+ data={data}
70
+ pathname="/news"
71
+ selected={false}
72
+ block="1234"
73
+ index={1}
74
+ onChangeBlock={() => {}}
75
+ onSelectBlock={() => {}}
76
+ onDeleteBlock={() => {}}
77
+ onFocusPreviousBlock={() => {}}
78
+ onFocusNextBlock={() => {}}
79
+ handleKeyDown={() => {}}
80
+ content={{}}
81
+ />
82
+ </Provider>,
83
+ );
84
+ const json = component.toJSON();
85
+ expect(json).toMatchSnapshot();
86
+ });
87
+ });
@@ -1,14 +1,30 @@
1
- import React from 'react';
2
- import { connect } from 'react-redux';
3
- import { compose } from 'redux';
1
+ import React, { useEffect } from 'react';
4
2
  import { Message } from 'semantic-ui-react';
5
3
  import { flattenToAppURL } from '@plone/volto/helpers';
4
+ import { connect } from 'react-redux';
5
+ import { compose } from 'redux';
6
6
  import { getContent } from '@plone/volto/actions';
7
- import { PrivacyProtection } from '@eeacms/volto-embed';
7
+ import PrivacyProtection from '@eeacms/volto-embed/PrivacyProtection/PrivacyProtection';
8
+ import { pickMetadata } from '@eeacms/volto-embed/helpers';
8
9
  import Tableau from '@eeacms/volto-tableau/Tableau/Tableau';
9
10
 
11
+ function getTableauVisualization(props) {
12
+ const { isBlock } = props;
13
+ const content = (isBlock ? props.tableauContent : props.content) || {};
14
+ const tableau_visualization =
15
+ (isBlock
16
+ ? props.tableauContent?.tableau_visualization
17
+ : props.content?.tableau_visualization) ||
18
+ props.data.tableau_visualization ||
19
+ {};
20
+ return {
21
+ ...pickMetadata(content),
22
+ ...tableau_visualization,
23
+ };
24
+ }
25
+
10
26
  const View = (props) => {
11
- const data = props.data;
27
+ const { isBlock, id, mode, data, getContent } = props;
12
28
  const {
13
29
  with_notes = true,
14
30
  with_sources = true,
@@ -18,32 +34,27 @@ const View = (props) => {
18
34
  with_enlarge = true,
19
35
  tableau_height = 700,
20
36
  } = data;
21
- const { figure_note = [], data_provenance = {}, tableau_visualization } =
22
- props.tableau_visualization_data || {};
23
37
 
24
38
  const tableau_vis_url = flattenToAppURL(data.tableau_vis_url || '');
25
39
 
26
- React.useEffect(() => {
27
- if (tableau_vis_url) {
28
- props.getContent(tableau_vis_url, null, props.id);
29
- }
30
- // eslint-disable-next-line
31
- }, [tableau_vis_url]);
40
+ const tableau_visualization = getTableauVisualization(props);
32
41
 
33
- if (props.mode === 'edit' && !tableau_vis_url) {
34
- return (
35
- <Message>
36
- Please select a tableau visualization from block editor.
37
- </Message>
38
- );
39
- }
42
+ useEffect(() => {
43
+ const tableauVisId = flattenToAppURL(tableau_visualization['@id'] || '');
44
+ if (
45
+ isBlock &&
46
+ mode === 'edit' &&
47
+ tableau_vis_url &&
48
+ tableau_vis_url !== tableauVisId
49
+ ) {
50
+ getContent(tableau_vis_url, null, id);
51
+ }
52
+ }, [id, isBlock, getContent, mode, tableau_vis_url, tableau_visualization]);
40
53
 
41
- if (props.mode === 'edit' && !tableau_visualization?.url) {
42
- return <Message>Url is not set in the visualization</Message>;
43
- }
54
+ const { figure_note = [], data_provenance = {} } = tableau_visualization;
44
55
 
45
- if (!tableau_visualization?.url) {
46
- return null;
56
+ if (props.mode === 'edit' && !tableau_vis_url) {
57
+ return <Message>Please select a tableau from block editor.</Message>;
47
58
  }
48
59
 
49
60
  return (
@@ -65,7 +76,7 @@ const View = (props) => {
65
76
  tableau_vis_url,
66
77
  }}
67
78
  figure_note={figure_note}
68
- sources={data_provenance.data || []}
79
+ sources={data_provenance?.data || []}
69
80
  />
70
81
  </PrivacyProtection>
71
82
  </div>
@@ -75,7 +86,8 @@ const View = (props) => {
75
86
  export default compose(
76
87
  connect(
77
88
  (state, props) => ({
78
- tableau_visualization_data: state.content.subrequests?.[props.id]?.data,
89
+ tableauContent: state.content.subrequests?.[props.id]?.data,
90
+ isBlock: !!props.data?.['@type'],
79
91
  }),
80
92
  {
81
93
  getContent,
@@ -1,31 +1,51 @@
1
1
  import React from 'react';
2
- import { render } from '@testing-library/react';
3
- import '@testing-library/jest-dom/extend-expect';
4
- import { Provider } from 'react-redux';
2
+ import renderer from 'react-test-renderer';
5
3
  import configureStore from 'redux-mock-store';
4
+ import { Provider } from 'react-intl-redux';
6
5
  import View from './View';
7
6
 
8
7
  const mockStore = configureStore([]);
9
- const store = mockStore({ content: { subrequests: [] } });
10
8
 
11
9
  window.URL.createObjectURL = jest.fn(() => 'test');
12
10
 
13
- jest.mock('@eeacms/volto-embed', () => ({
14
- PrivacyProtection: ({ children }) => <div>{children}</div>,
15
- }));
16
-
17
11
  jest.mock('@plone/volto/components', () => ({
18
12
  Icon: ({ children }) => <img alt="incon">{children}</img>,
13
+ Toast: ({ children }) => <p>{children}</p>,
19
14
  }));
20
15
 
21
- jest.mock('@plone/volto/components', () => ({
22
- Toast: ({ children }) => <p>{children}</p>,
16
+ jest.mock('@eeacms/volto-matomo/utils', () => ({
17
+ trackLink: jest.fn(),
23
18
  }));
24
19
 
20
+ jest.mock(
21
+ '@eeacms/volto-embed/PrivacyProtection/PrivacyProtection',
22
+ () => ({ children }) => {
23
+ return children;
24
+ },
25
+ );
26
+
27
+ jest.mock('@eeacms/volto-embed/helpers', () => ({
28
+ pickMetadata: (data) => data,
29
+ }));
30
+
31
+ const store = mockStore({
32
+ intl: {
33
+ locale: 'en',
34
+ messages: {},
35
+ },
36
+ content: {
37
+ create: {},
38
+ subrequests: [],
39
+ },
40
+ connected_data_parameters: {},
41
+ });
42
+
25
43
  describe('View', () => {
26
44
  const data = {
27
45
  '@type': 'embed_tableau_visualization',
28
- dataprotection: {},
46
+ dataprotection: {
47
+ enabled: false,
48
+ },
29
49
  tableau_vis_url: 'http://localhost:3000/tableau-ct',
30
50
  with_download: true,
31
51
  with_more_info: true,
@@ -34,12 +54,12 @@ describe('View', () => {
34
54
  };
35
55
 
36
56
  it('should render the component', () => {
37
- const { asFragment } = render(
57
+ const component = renderer.create(
38
58
  <Provider store={store}>
39
59
  <View data={data} />
40
60
  </Provider>,
41
61
  );
42
- expect(asFragment()).toMatchSnapshot();
43
- //expect(container.querySelector('.embed-tableau')).toBeInTheDocument();
62
+ const json = component.toJSON();
63
+ expect(json).toMatchSnapshot();
44
64
  });
45
65
  });
@@ -0,0 +1,20 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Edit should render the component 1`] = `
4
+ <div
5
+ className="embed-tableau"
6
+ >
7
+ <div
8
+ className="tableau-wrapper"
9
+ >
10
+ <div
11
+ className="tableau tableau-2.8.0"
12
+ style={
13
+ Object {
14
+ "height": "700px",
15
+ }
16
+ }
17
+ />
18
+ </div>
19
+ </div>
20
+ `;
@@ -1,3 +1,20 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`View should render the component 1`] = `<DocumentFragment />`;
3
+ exports[`View should render the component 1`] = `
4
+ <div
5
+ className="embed-tableau"
6
+ >
7
+ <div
8
+ className="tableau-wrapper"
9
+ >
10
+ <div
11
+ className="tableau tableau-2.8.0"
12
+ style={
13
+ Object {
14
+ "height": "700px",
15
+ }
16
+ }
17
+ />
18
+ </div>
19
+ </div>
20
+ `;
@@ -0,0 +1,44 @@
1
+ import React from 'react';
2
+ import renderer from 'react-test-renderer';
3
+ import configureStore from 'redux-mock-store';
4
+ import { Provider } from 'react-intl-redux';
5
+
6
+ import Download from './Download';
7
+
8
+ const mockStore = configureStore([]);
9
+
10
+ window.URL.createObjectURL = jest.fn(() => 'test');
11
+
12
+ jest.mock('semantic-ui-react', () => ({
13
+ Popup: ({ content, trigger }) => {
14
+ return (
15
+ <div className="popup">
16
+ <div className="trigger">{trigger}</div>
17
+ <div className="content">{content}</div>
18
+ </div>
19
+ );
20
+ },
21
+ }));
22
+
23
+ const store = mockStore({
24
+ intl: {
25
+ locale: 'en',
26
+ messages: {},
27
+ },
28
+ content: {
29
+ create: {},
30
+ subrequests: [],
31
+ },
32
+ });
33
+
34
+ describe('Edit', () => {
35
+ it('should render the component', () => {
36
+ const component = renderer.create(
37
+ <Provider store={store}>
38
+ <Download />
39
+ </Provider>,
40
+ );
41
+ const json = component.toJSON();
42
+ expect(json).toMatchSnapshot();
43
+ });
44
+ });
@@ -0,0 +1,111 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Edit should render the component 1`] = `
4
+ <div
5
+ className="popup"
6
+ >
7
+ <div
8
+ className="trigger"
9
+ >
10
+ <div
11
+ className="tableau-download-container"
12
+ >
13
+ <button
14
+ className="trigger-button"
15
+ >
16
+ <i
17
+ className="ri-download-fill"
18
+ />
19
+ Download
20
+ </button>
21
+ </div>
22
+ </div>
23
+ <div
24
+ className="content"
25
+ >
26
+ <div
27
+ className="item"
28
+ >
29
+ <span
30
+ className="label"
31
+ >
32
+ Data formats
33
+ </span>
34
+ <div
35
+ className="types"
36
+ >
37
+ <div
38
+ className="type"
39
+ >
40
+ <button
41
+ onClick={[Function]}
42
+ >
43
+ <span>
44
+ CSV
45
+ </span>
46
+ </button>
47
+ </div>
48
+ <div
49
+ className="type"
50
+ >
51
+ <button
52
+ onClick={[Function]}
53
+ >
54
+ <span>
55
+ Excel
56
+ </span>
57
+ </button>
58
+ </div>
59
+ </div>
60
+ </div>
61
+ <div
62
+ className="item"
63
+ >
64
+ <span
65
+ className="label"
66
+ >
67
+ Image formats
68
+ </span>
69
+ <div
70
+ className="types"
71
+ >
72
+ <div
73
+ className="type"
74
+ >
75
+ <button
76
+ onClick={[Function]}
77
+ >
78
+ <span>
79
+ PNG
80
+ </span>
81
+ </button>
82
+ </div>
83
+ </div>
84
+ </div>
85
+ <div
86
+ className="item"
87
+ >
88
+ <span
89
+ className="label"
90
+ >
91
+ Other formats
92
+ </span>
93
+ <div
94
+ className="types"
95
+ >
96
+ <div
97
+ className="type"
98
+ >
99
+ <button
100
+ onClick={[Function]}
101
+ >
102
+ <span>
103
+ PDF
104
+ </span>
105
+ </button>
106
+ </div>
107
+ </div>
108
+ </div>
109
+ </div>
110
+ </div>
111
+ `;