@eeacms/volto-tableau 1.3.0 → 3.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.
@@ -2,7 +2,7 @@ const defaultBabel = require('@plone/volto/babel');
2
2
 
3
3
  function applyDefault(api) {
4
4
  const voltoBabel = defaultBabel(api);
5
- voltoBabel.plugins.push('@babel/plugin-transform-modules-commonjs', 'transform-class-properties', 'istanbul');
5
+ voltoBabel.plugins.push('istanbul');
6
6
  return voltoBabel;
7
7
  }
8
8
 
@@ -0,0 +1 @@
1
+ module.exports = require('@plone/volto/babel');
@@ -0,0 +1,47 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ const projectRootPath = fs.existsSync('./project')
5
+ ? fs.realpathSync('./project')
6
+ : fs.realpathSync('./../../../');
7
+ const packageJson = require(path.join(projectRootPath, 'package.json'));
8
+ const jsConfig = require(path.join(projectRootPath, 'jsconfig.json'))
9
+ .compilerOptions;
10
+
11
+ const pathsConfig = jsConfig.paths;
12
+
13
+ let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto');
14
+
15
+ Object.keys(pathsConfig).forEach((pkg) => {
16
+ if (pkg === '@plone/volto') {
17
+ voltoPath = `./${jsConfig.baseUrl}/${pathsConfig[pkg][0]}`;
18
+ }
19
+ });
20
+ const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`);
21
+ const reg = new AddonConfigurationRegistry(projectRootPath);
22
+
23
+ // Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
24
+ const addonAliases = Object.keys(reg.packages).map((o) => [
25
+ o,
26
+ reg.packages[o].modulePath,
27
+ ]);
28
+
29
+ module.exports = {
30
+ extends: `${projectRootPath}/node_modules/@plone/volto/.eslintrc`,
31
+ settings: {
32
+ 'import/resolver': {
33
+ alias: {
34
+ map: [
35
+ ['@plone/volto', '@plone/volto/src'],
36
+ ...addonAliases,
37
+ ['@package', `${__dirname}/src`],
38
+ ['~', `${__dirname}/src`],
39
+ ],
40
+ extensions: ['.js', '.jsx', '.json'],
41
+ },
42
+ 'babel-plugin-root-import': {
43
+ rootPathSuffix: 'src',
44
+ },
45
+ },
46
+ },
47
+ };
package/CHANGELOG.md CHANGED
@@ -4,11 +4,45 @@ 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
+ ### [3.0.0](https://github.com/eea/volto-tableau/compare/2.0.0...3.0.0) - 12 January 2023
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - Remove sources from schema [dana-cfc4 - [`0d2b862`](https://github.com/eea/volto-tableau/commit/0d2b86212b72e06d4ab81804395eda0c2919aeb8)]
12
+ - setup the loader, script loading, data provenance, error catching [andreiggr - [`bc65898`](https://github.com/eea/volto-tableau/commit/bc65898edf878f8d011573f91fb72fb1a956d8e9)]
13
+ - merge with better_tableau_import [andreiggr - [`2d8f314`](https://github.com/eea/volto-tableau/commit/2d8f314a939f1122c0307ccfebf4215bcea2c148)]
14
+ - better loader response [andreiggr - [`d6f3c86`](https://github.com/eea/volto-tableau/commit/d6f3c86cc97475819db71a99108e4da739d66576)]
15
+ - Add ConnectedTableau [dana-cfc4 - [`d83417d`](https://github.com/eea/volto-tableau/commit/d83417d1b9ea454ded0b6f24e581ac2a85c32780)]
16
+ - lint [andreiggr - [`f268b10`](https://github.com/eea/volto-tableau/commit/f268b10710a77cd19d9cc110d60447d495a747ed)]
17
+ - fix crashing sources && better getContent [andreiggr - [`a202967`](https://github.com/eea/volto-tableau/commit/a202967340bcb8e366868193d236d9f49b563bfc)]
18
+ - somewhat better import [andreiggr - [`48219a3`](https://github.com/eea/volto-tableau/commit/48219a368b7165ef9e9df3cf65e643be72f5f8b0)]
19
+ - Fix style lint errors [dana-cfc4 - [`ed1873c`](https://github.com/eea/volto-tableau/commit/ed1873ce27c81e6f2a2459f38bc4cd10d65b559b)]
20
+ - Fix initValue not initialized [dana-cfc4 - [`bbe5802`](https://github.com/eea/volto-tableau/commit/bbe5802c8e2ee794b15570959a00307531b32d96)]
21
+ - Add placeholder in case of errors [dana-cfc4 - [`1af2d0d`](https://github.com/eea/volto-tableau/commit/1af2d0da04635716f4aef320c5f84694a59435e7)]
22
+ - importmap for versions of tableau [Andrei Grigore - [`4e03cb2`](https://github.com/eea/volto-tableau/commit/4e03cb2c3a3bf11d186462067d12c2685b9bf607)]
23
+ - Increase addon version [danac - [`26b58c5`](https://github.com/eea/volto-tableau/commit/26b58c57b6cb4be4eed23fe3343c65250e6d593a)]
24
+ - Add data provenance [danac - [`bd46995`](https://github.com/eea/volto-tableau/commit/bd4699547be72b2d9dad292ee3681b937e741239)]
25
+ - Add eslint config [danac - [`394e5d1`](https://github.com/eea/volto-tableau/commit/394e5d11591610a97cb5b57d882da818b0128b7e)]
26
+ - Fix formatting issues [danac - [`2ef1bae`](https://github.com/eea/volto-tableau/commit/2ef1bae5caf44fb144f8251aed2895df2e03de7d)]
27
+ - Add Embed EEA Tableau block [danac - [`54e45b2`](https://github.com/eea/volto-tableau/commit/54e45b2b0b29d01173315ffe47e74938e43cdf23)]
28
+ ## [2.0.0](https://github.com/eea/volto-tableau/compare/1.3.0...2.0.0) - 1 November 2022
29
+
30
+ #### :bug: Bug Fixes
31
+
32
+ - fix(cypress): fix silly test [Nilesh - [`d53131a`](https://github.com/eea/volto-tableau/commit/d53131adc4a38252727a6202860e258fbc4d899c)]
33
+
34
+ #### :hammer_and_wrench: Others
35
+
36
+ - Update block-basics.cy.js [Nilesh - [`e4f7ca4`](https://github.com/eea/volto-tableau/commit/e4f7ca45969d379fa373bb4b88a1680945b5ca7e)]
37
+ - prepare 2.0 [Nilesh - [`e60db00`](https://github.com/eea/volto-tableau/commit/e60db002471ca193a446edbbfc3d015ad88bbc8c)]
38
+ - Update block-basics.cy.js [Nilesh - [`65b6419`](https://github.com/eea/volto-tableau/commit/65b64190af746d24e87276d397db2ad6473e9883)]
39
+ - Update commands.js [Nilesh - [`7c48437`](https://github.com/eea/volto-tableau/commit/7c4843780efb9b85a4728de73c00d831c1d8fdcf)]
40
+ - Update e2e.js [Nilesh - [`f67b45c`](https://github.com/eea/volto-tableau/commit/f67b45c170f58f8d0301192994226f173e4cb00a)]
41
+ - latest volto compatibility refs #154757 [nileshgulia1 - [`881ba48`](https://github.com/eea/volto-tableau/commit/881ba482dc9b82e7fdac16549d41e80a6d26b3de)]
7
42
  ### [1.3.0](https://github.com/eea/volto-tableau/compare/1.2.5...1.3.0) - 28 September 2022
8
43
 
9
44
  #### :hammer_and_wrench: Others
10
45
 
11
- - refactor script set tableau [andreiggr - [`d78328e`](https://github.com/eea/volto-tableau/commit/d78328e74d67d685390ca0671a44a1bfe9b21e97)]
12
46
  - Bump version [Miu Razvan - [`837f8a7`](https://github.com/eea/volto-tableau/commit/837f8a70257660253b70b818977693101d6576e9)]
13
47
  - clear lint [andreiggr - [`69d83b8`](https://github.com/eea/volto-tableau/commit/69d83b806aa48a6a696e01b6e026de07e6a34dfe)]
14
48
  ### [1.2.5](https://github.com/eea/volto-tableau/compare/1.2.4...1.2.5) - 2 September 2022
package/Jenkinsfile CHANGED
@@ -4,9 +4,9 @@ pipeline {
4
4
  environment {
5
5
  GIT_NAME = "volto-tableau"
6
6
  NAMESPACE = "@eeacms"
7
- SONARQUBE_TAGS = "volto.eea.europa.eu,climate-energy.eea.europa.eu,forest.eea.europa.eu,biodiversity.europa.eu,water.europa.eu-freshwater"
7
+ SONARQUBE_TAGS = "volto.eea.europa.eu,climate-energy.eea.europa.eu,forest.eea.europa.eu,biodiversity.europa.eu,water.europa.eu-freshwater,water.europa.eu-marine"
8
8
  DEPENDENCIES = ""
9
- VOLTO = "16.0.0-alpha.14"
9
+ VOLTO = "alpha"
10
10
  }
11
11
 
12
12
  stages {
@@ -41,19 +41,19 @@ pipeline {
41
41
 
42
42
  "ES lint": {
43
43
  node(label: 'docker') {
44
- sh '''docker run -i --rm --name="$BUILD_TAG-eslint" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" plone/volto-addon-ci eslint'''
44
+ sh '''docker run -i --rm --name="$BUILD_TAG-eslint" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci:alpha eslint'''
45
45
  }
46
46
  },
47
47
 
48
48
  "Style lint": {
49
49
  node(label: 'docker') {
50
- sh '''docker run -i --rm --name="$BUILD_TAG-stylelint" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" plone/volto-addon-ci stylelint'''
50
+ sh '''docker run -i --rm --name="$BUILD_TAG-stylelint" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci:alpha stylelint'''
51
51
  }
52
52
  },
53
53
 
54
54
  "Prettier": {
55
55
  node(label: 'docker') {
56
- sh '''docker run -i --rm --name="$BUILD_TAG-prettier" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" plone/volto-addon-ci prettier'''
56
+ sh '''docker run -i --rm --name="$BUILD_TAG-prettier" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci:alpha prettier'''
57
57
  }
58
58
  }
59
59
  )
@@ -77,8 +77,8 @@ pipeline {
77
77
  node(label: 'docker') {
78
78
  script {
79
79
  try {
80
- sh '''docker pull plone/volto-addon-ci'''
81
- sh '''docker run -i --name="$BUILD_TAG-volto" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" plone/volto-addon-ci'''
80
+ sh '''docker pull plone/volto-addon-ci:alpha'''
81
+ sh '''docker run -i --name="$BUILD_TAG-volto" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci:alpha'''
82
82
  sh '''rm -rf xunit-reports'''
83
83
  sh '''mkdir -p xunit-reports'''
84
84
  sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/coverage xunit-reports/'''
@@ -125,8 +125,8 @@ pipeline {
125
125
  node(label: 'docker') {
126
126
  script {
127
127
  try {
128
- sh '''docker pull eeacms/plone-backend; docker run -d --rm --name="$BUILD_TAG-plone" -e SITE="Plone" -e PROFILES="eea.kitkat:testing" eeacms/plone-backend'''
129
- sh '''docker pull plone/volto-addon-ci; docker run -i --name="$BUILD_TAG-cypress" --link $BUILD_TAG-plone:plone -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e DEPENDENCIES="$DEPENDENCIES" -e NODE_ENV=development -e VOLTO="$VOLTO" plone/volto-addon-ci cypress'''
128
+ sh '''docker pull eeacms/plone-backend; docker run --rm -d --name="$BUILD_TAG-plone" -e SITE="Plone" -e PROFILES="eea.kitkat:testing" eeacms/plone-backend'''
129
+ sh '''docker pull plone/volto-addon-ci:alpha; docker run -i --name="$BUILD_TAG-cypress" --link $BUILD_TAG-plone:plone -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e DEPENDENCIES="$DEPENDENCIES" -e NODE_ENV=development -e VOLTO=$VOLTO plone/volto-addon-ci:alpha cypress'''
130
130
  } finally {
131
131
  try {
132
132
  sh '''rm -rf cypress-reports cypress-results cypress-coverage'''
@@ -239,4 +239,4 @@ pipeline {
239
239
  }
240
240
  }
241
241
  }
242
- }
242
+ }
@@ -0,0 +1,17 @@
1
+ module.exports = function (api) {
2
+ api.cache(true);
3
+ const presets = ['razzle'];
4
+ const plugins = [
5
+ [
6
+ 'react-intl', // React Intl extractor, required for the whole i18n infrastructure to work
7
+ {
8
+ messagesDir: './build/messages/',
9
+ },
10
+ ],
11
+ ];
12
+
13
+ return {
14
+ plugins,
15
+ presets,
16
+ };
17
+ };
@@ -1,20 +1,17 @@
1
- import { setupBeforeEach, tearDownAfterEach } from '../support';
1
+ import { slateBeforeEach, slateAfterEach } from '../support/e2e';
2
2
 
3
3
  describe('Blocks Tests', () => {
4
- beforeEach(setupBeforeEach);
5
- afterEach(tearDownAfterEach);
4
+ beforeEach(slateBeforeEach);
5
+ afterEach(slateAfterEach);
6
6
 
7
7
  it('Add Block: Empty', () => {
8
8
  // Change page title
9
- cy.get('.documentFirstHeading > .public-DraftStyleDefault-block')
10
- .clear()
11
- .type('My Add-on Page')
12
- .get('.documentFirstHeading span[data-text]')
13
- .contains('My Add-on Page');
9
+ cy.clearSlateTitle();
10
+ cy.getSlateTitle().type('My Add-on Page');
14
11
 
15
- cy.get('.documentFirstHeading > .public-DraftStyleDefault-block').type(
16
- '{enter}',
17
- );
12
+ cy.get('.documentFirstHeading').contains('My Add-on Page');
13
+
14
+ cy.getSlate().click();
18
15
 
19
16
  // Add block
20
17
  cy.get('.ui.basic.icon.button.block-add-button').first().click();
@@ -1,5 +1,8 @@
1
1
  /* eslint no-console: ["error", { allow: ["log"] }] */
2
2
 
3
+ const SLATE_SELECTOR = '.content-area .slate-editor [contenteditable=true]';
4
+ const SLATE_TITLE_SELECTOR = '.block.inner.title [contenteditable="true"]';
5
+
3
6
  // --- AUTOLOGIN -------------------------------------------------------------
4
7
  Cypress.Commands.add('autologin', () => {
5
8
  let api_url, user, password;
@@ -92,7 +95,7 @@ Cypress.Commands.add(
92
95
  title: contentTitle,
93
96
  blocks: {
94
97
  'd3f1c443-583f-4e8e-a682-3bf25752a300': { '@type': 'title' },
95
- '7624cf59-05d0-4055-8f55-5fd6597d84b0': { '@type': 'text' },
98
+ '7624cf59-05d0-4055-8f55-5fd6597d84b0': { '@type': 'slate' },
96
99
  },
97
100
  blocks_layout: {
98
101
  items: [
@@ -125,6 +128,100 @@ Cypress.Commands.add(
125
128
  },
126
129
  );
127
130
 
131
+ // --- Add DX Content-Type ----------------------------------------------------------
132
+ Cypress.Commands.add('addContentType', (name) => {
133
+ let api_url, auth;
134
+ api_url = Cypress.env('API_PATH') || 'http://localhost:8080/Plone';
135
+ auth = {
136
+ user: 'admin',
137
+ pass: 'admin',
138
+ };
139
+ return cy
140
+ .request({
141
+ method: 'POST',
142
+ url: `${api_url}/@controlpanels/dexterity-types/${name}`,
143
+ headers: {
144
+ Accept: 'application/json',
145
+ },
146
+ auth: auth,
147
+ body: {
148
+ title: name,
149
+ },
150
+ })
151
+ .then(() => console.log(`${name} content-type added.`));
152
+ });
153
+
154
+ // --- Remove DX behavior ----------------------------------------------------------
155
+ Cypress.Commands.add('removeContentType', (name) => {
156
+ let api_url, auth;
157
+ api_url = Cypress.env('API_PATH') || 'http://localhost:8080/Plone';
158
+ auth = {
159
+ user: 'admin',
160
+ pass: 'admin',
161
+ };
162
+ return cy
163
+ .request({
164
+ method: 'DELETE',
165
+ url: `${api_url}/@controlpanels/dexterity-types/${name}`,
166
+ headers: {
167
+ Accept: 'application/json',
168
+ },
169
+ auth: auth,
170
+ body: {},
171
+ })
172
+ .then(() => console.log(`${name} content-type removed.`));
173
+ });
174
+
175
+ // --- Add DX field ----------------------------------------------------------
176
+ Cypress.Commands.add('addSlateJSONField', (type, name) => {
177
+ let api_url, auth;
178
+ api_url = Cypress.env('API_PATH') || 'http://localhost:8080/Plone';
179
+ auth = {
180
+ user: 'admin',
181
+ pass: 'admin',
182
+ };
183
+ return cy
184
+ .request({
185
+ method: 'POST',
186
+ url: `${api_url}/@types/${type}`,
187
+ headers: {
188
+ Accept: 'application/json',
189
+ },
190
+ auth: auth,
191
+ body: {
192
+ id: name,
193
+ title: name,
194
+ description: 'Slate JSON Field',
195
+ factory: 'SlateJSONField',
196
+ required: false,
197
+ },
198
+ })
199
+ .then(() => console.log(`${name} SlateJSONField field added to ${type}`));
200
+ });
201
+
202
+ // --- Remove DX field ----------------------------------------------------------
203
+ Cypress.Commands.add('removeSlateJSONField', (type, name) => {
204
+ let api_url, auth;
205
+ api_url = Cypress.env('API_PATH') || 'http://localhost:8080/Plone';
206
+ auth = {
207
+ user: 'admin',
208
+ pass: 'admin',
209
+ };
210
+ return cy
211
+ .request({
212
+ method: 'DELETE',
213
+ url: `${api_url}/@types/${type}/${name}`,
214
+ headers: {
215
+ Accept: 'application/json',
216
+ },
217
+ auth: auth,
218
+ body: {},
219
+ })
220
+ .then(() =>
221
+ console.log(`${name} SlateJSONField field removed from ${type}`),
222
+ );
223
+ });
224
+
128
225
  // --- REMOVE CONTENT --------------------------------------------------------
129
226
  Cypress.Commands.add('removeContent', (path) => {
130
227
  let api_url, auth;
@@ -146,6 +243,41 @@ Cypress.Commands.add('removeContent', (path) => {
146
243
  .then(() => console.log(`${path} removed`));
147
244
  });
148
245
 
246
+ Cypress.Commands.add('typeInSlate', { prevSubject: true }, (subject, text) => {
247
+ return (
248
+ cy
249
+ .wrap(subject)
250
+ .then((subject) => {
251
+ subject[0].dispatchEvent(
252
+ new InputEvent('beforeinput', {
253
+ inputType: 'insertText',
254
+ data: text,
255
+ }),
256
+ );
257
+ return subject;
258
+ })
259
+ // TODO: do this only for Electron-based browser which does not understand instantaneously
260
+ // that the user inserted some text in the block
261
+ .wait(1000)
262
+ );
263
+ });
264
+
265
+ Cypress.Commands.add('lineBreakInSlate', { prevSubject: true }, (subject) => {
266
+ return (
267
+ cy
268
+ .wrap(subject)
269
+ .then((subject) => {
270
+ subject[0].dispatchEvent(
271
+ new InputEvent('beforeinput', { inputType: 'insertLineBreak' }),
272
+ );
273
+ return subject;
274
+ })
275
+ // TODO: do this only for Electron-based browser which does not understand instantaneously
276
+ // that the block was split
277
+ .wait(1000)
278
+ );
279
+ });
280
+
149
281
  // --- SET WORKFLOW ----------------------------------------------------------
150
282
  Cypress.Commands.add(
151
283
  'setWorkflow',
@@ -247,6 +379,83 @@ Cypress.Commands.add(
247
379
  },
248
380
  );
249
381
 
382
+ Cypress.Commands.add('getSlate', ({ createNewSlate = true } = {}) => {
383
+ let slate;
384
+ cy.getIfExists(
385
+ SLATE_SELECTOR,
386
+ () => {
387
+ slate = cy.get(SLATE_SELECTOR).last();
388
+ },
389
+ () => {
390
+ if (createNewSlate) {
391
+ cy.get('.block.inner').last().type('{moveToEnd}{enter}');
392
+ }
393
+ slate = cy.get(SLATE_SELECTOR, { timeout: 10000 }).last();
394
+ },
395
+ );
396
+ return slate;
397
+ });
398
+
399
+ Cypress.Commands.add('clearSlate', (selector) => {
400
+ return cy
401
+ .get(selector)
402
+ .focus()
403
+ .click()
404
+ .wait(1000)
405
+ .type('{selectAll}')
406
+ .wait(1000)
407
+ .type('{backspace}');
408
+ });
409
+
410
+ Cypress.Commands.add('getSlateTitle', () => {
411
+ return cy.get(SLATE_TITLE_SELECTOR, {
412
+ timeout: 10000,
413
+ });
414
+ });
415
+
416
+ Cypress.Commands.add('clearSlateTitle', () => {
417
+ return cy.clearSlate(SLATE_TITLE_SELECTOR);
418
+ });
419
+
420
+ Cypress.Commands.add('setSlateSelection', (subject, query, endQuery) => {
421
+ cy.get('.slate-editor.selected [contenteditable=true]')
422
+ .focus()
423
+ .click()
424
+ .setSelection(subject, query, endQuery)
425
+ .wait(1000); // this wait is needed for the selection change to be detected after
426
+ });
427
+
428
+ Cypress.Commands.add('getSlateEditorAndType', (type) => {
429
+ cy.getSlate().focus().click().type(type);
430
+ });
431
+
432
+ Cypress.Commands.add('setSlateCursor', (subject, query, endQuery) => {
433
+ cy.get('.slate-editor.selected [contenteditable=true]')
434
+ .focus()
435
+ .click()
436
+ .setCursor(subject, query, endQuery)
437
+ .wait(1000);
438
+ });
439
+
440
+ Cypress.Commands.add('clickSlateButton', (button) => {
441
+ cy.get(`.slate-inline-toolbar .button-wrapper a[title="${button}"]`, {
442
+ timeout: 10000,
443
+ }).click({ force: true }); //force click is needed to ensure the button in visible in view.
444
+ });
445
+
446
+ Cypress.Commands.add('toolbarSave', () => {
447
+ cy.wait(1000);
448
+
449
+ // Save
450
+ cy.get('#toolbar-save').click();
451
+ cy.waitForResourceToLoad('@navigation');
452
+ cy.waitForResourceToLoad('@breadcrumbs');
453
+ cy.waitForResourceToLoad('@actions');
454
+ cy.waitForResourceToLoad('@types');
455
+ cy.waitForResourceToLoad('my-page');
456
+ cy.url().should('eq', Cypress.config().baseUrl + '/cypress/my-page');
457
+ });
458
+
250
459
  // Low level command reused by `setCursorBefore` and `setCursorAfter`, equal to `setCursorAfter`
251
460
  Cypress.Commands.add(
252
461
  'setCursor',
@@ -313,3 +522,16 @@ Cypress.Commands.add('store', () => {
313
522
  Cypress.Commands.add('settings', (key, value) => {
314
523
  return cy.window().its('settings');
315
524
  });
525
+
526
+ Cypress.Commands.add(
527
+ 'getIfExists',
528
+ (selector, successAction = () => {}, failAction = () => {}) => {
529
+ cy.get('body').then((body) => {
530
+ if (body.find(selector).length > 0 && successAction) {
531
+ successAction();
532
+ } else if (failAction) {
533
+ failAction();
534
+ }
535
+ });
536
+ },
537
+ );
@@ -0,0 +1,125 @@
1
+ // ***********************************************************
2
+ // This example support/index.js is processed and
3
+ // loaded automatically before your test files.
4
+ //
5
+ // This is a great place to put global configuration and
6
+ // behavior that modifies Cypress.
7
+ //
8
+ // You can change the location of this file or turn off
9
+ // automatically serving support files with the
10
+ // 'supportFile' configuration option.
11
+ //
12
+ // You can read more here:
13
+ // https://on.cypress.io/configuration
14
+ // ***********************************************************
15
+
16
+ // Import commands.js using ES2015 syntax:
17
+ import './commands';
18
+ // Alternatively you can use CommonJS syntax:
19
+ // require('./commands')
20
+
21
+ //Generate code-coverage
22
+ import '@cypress/code-coverage/support';
23
+
24
+ export const slateBeforeEach = (contentType = 'Document') => {
25
+ cy.autologin();
26
+ cy.createContent({
27
+ contentType: 'Document',
28
+ contentId: 'cypress',
29
+ contentTitle: 'Cypress',
30
+ });
31
+ cy.createContent({
32
+ contentType: contentType,
33
+ contentId: 'my-page',
34
+ contentTitle: 'My Page',
35
+ path: 'cypress',
36
+ });
37
+ cy.visit('/cypress/my-page');
38
+ cy.waitForResourceToLoad('@navigation');
39
+ cy.waitForResourceToLoad('@breadcrumbs');
40
+ cy.waitForResourceToLoad('@actions');
41
+ cy.waitForResourceToLoad('@types');
42
+ cy.waitForResourceToLoad('my-page');
43
+ cy.navigate('/cypress/my-page/edit');
44
+ };
45
+
46
+ export const slateAfterEach = () => {
47
+ cy.autologin();
48
+ cy.removeContent('cypress');
49
+ };
50
+
51
+ export const slateJsonBeforeEach = (contentType = 'slate') => {
52
+ cy.autologin();
53
+ cy.addContentType(contentType);
54
+ cy.addSlateJSONField(contentType, 'slate');
55
+ slateBeforeEach(contentType);
56
+ };
57
+
58
+ export const slateJsonAfterEach = (contentType = 'slate') => {
59
+ cy.autologin();
60
+ cy.removeContentType(contentType);
61
+ slateAfterEach();
62
+ };
63
+
64
+ export const getSelectedSlateEditor = () => {
65
+ return cy.get('.slate-editor.selected [contenteditable=true]').click();
66
+ };
67
+
68
+ export const createSlateBlock = () => {
69
+ cy.get('.ui.basic.icon.button.block-add-button').first().click();
70
+ cy.get('.blocks-chooser .title').contains('Text').click();
71
+ cy.get('.ui.basic.icon.button.slate').contains('Text').click();
72
+ return getSelectedSlateEditor();
73
+ };
74
+
75
+ export const getSlateBlockValue = (sb) => {
76
+ return sb.invoke('attr', 'data-slate-value').then((str) => {
77
+ return typeof str === 'undefined' ? [] : JSON.parse(str);
78
+ });
79
+ };
80
+
81
+ export const createSlateBlockWithList = ({
82
+ numbered,
83
+ firstItemText,
84
+ secondItemText,
85
+ }) => {
86
+ let s1 = createSlateBlock();
87
+
88
+ s1.typeInSlate(firstItemText + secondItemText);
89
+
90
+ // select all contents of slate block
91
+ // - this opens hovering toolbar
92
+ cy.contains(firstItemText + secondItemText).then((el) => {
93
+ selectSlateNodeOfWord(el);
94
+ });
95
+
96
+ // TODO: do not hardcode these selectors:
97
+ if (numbered) {
98
+ // this is the numbered list option in the hovering toolbar
99
+ cy.get('.slate-inline-toolbar > :nth-child(9)').click();
100
+ } else {
101
+ // this is the bulleted list option in the hovering toolbar
102
+ cy.get('.slate-inline-toolbar > :nth-child(10)').click();
103
+ }
104
+
105
+ // move the text cursor
106
+ const sse = getSelectedSlateEditor();
107
+ sse.type('{leftarrow}');
108
+ for (let i = 0; i < firstItemText.length; ++i) {
109
+ sse.type('{rightarrow}');
110
+ }
111
+
112
+ // simulate pressing Enter
113
+ getSelectedSlateEditor().lineBreakInSlate();
114
+
115
+ return s1;
116
+ };
117
+
118
+ export const selectSlateNodeOfWord = (el) => {
119
+ return cy.window().then((win) => {
120
+ var event = new CustomEvent('Test_SelectWord', {
121
+ detail: el[0],
122
+ });
123
+ win.document.dispatchEvent(event);
124
+ });
125
+ };
@@ -0,0 +1,26 @@
1
+ const { defineConfig } = require('cypress');
2
+
3
+ module.exports = defineConfig({
4
+ viewportWidth: 1280,
5
+ defaultCommandTimeout: 8888,
6
+ chromeWebSecurity: false,
7
+ reporter: 'junit',
8
+ video: true,
9
+ retries: {
10
+ runMode: 8,
11
+ openMode: 0,
12
+ },
13
+ reporterOptions: {
14
+ mochaFile: 'cypress/reports/cypress-[hash].xml',
15
+ jenkinsMode: true,
16
+ toConsole: true,
17
+ },
18
+ e2e: {
19
+ setupNodeEvents(on, config) {
20
+ // e2e testing node events setup code
21
+ require('@cypress/code-coverage/task')(on, config);
22
+ return config;
23
+ },
24
+ baseUrl: 'http://localhost:3000',
25
+ },
26
+ });
@@ -11,16 +11,15 @@ module.exports = {
11
11
  '@package/(.*)$': '<rootDir>/src/$1',
12
12
  '@plone/volto-quanta/(.*)$': '<rootDir>/src/addons/volto-quanta/src/$1',
13
13
  '@eeacms/(.*?)/(.*)$': '<rootDir>/src/addons/$1/src/$2',
14
- 'volto-slate/(.*)$': '<rootDir>/src/addons/volto-slate/src/$1',
14
+ '@plone/volto-slate':
15
+ '<rootDir>/node_modules/@plone/volto/packages/volto-slate/src',
15
16
  '~/(.*)$': '<rootDir>/src/$1',
16
17
  'load-volto-addons':
17
18
  '<rootDir>/node_modules/@plone/volto/jest-addons-loader.js',
19
+ '\\.(css|less|scss|sass)$': 'identity-obj-proxy',
18
20
  },
19
21
  transform: {
20
22
  '^.+\\.js(x)?$': 'babel-jest',
21
- '^.+\\.css$': 'jest-css-modules',
22
- '^.+\\.less$': 'jest-css-modules',
23
- '^.+\\.scss$': 'jest-css-modules',
24
23
  '^.+\\.(png)$': 'jest-file',
25
24
  '^.+\\.(jpg)$': 'jest-file',
26
25
  '^.+\\.(svg)$': './node_modules/@plone/volto/jest-svgsystem-transform.js',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-tableau",
3
- "version": "1.3.0",
3
+ "version": "3.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",
@@ -24,7 +24,9 @@
24
24
  },
25
25
  "devDependencies": {
26
26
  "@cypress/code-coverage": "^3.9.5",
27
- "babel-plugin-transform-class-properties": "^6.24.1"
27
+ "@plone/scripts": "*",
28
+ "babel-plugin-transform-class-properties": "^6.24.1",
29
+ "md5": "^2.3.0"
28
30
  },
29
31
  "scripts": {
30
32
  "release": "release-it",