@eeacms/volto-editing-progress 0.1.8 → 0.2.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');
@@ -1,7 +1,9 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
3
 
4
- const projectRootPath = fs.realpathSync('./project'); // __dirname
4
+ const projectRootPath = fs.existsSync('./project')
5
+ ? fs.realpathSync('./project')
6
+ : fs.realpathSync('./../../../');
5
7
  const packageJson = require(path.join(projectRootPath, 'package.json'));
6
8
  const jsConfig = require(path.join(projectRootPath, 'jsconfig.json')).compilerOptions;
7
9
 
package/CHANGELOG.md CHANGED
@@ -4,64 +4,63 @@ 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
- #### [0.1.8](https://github.com/eea/volto-editing-progress/compare/0.1.7...0.1.8)
7
+ ### [0.2.0](https://github.com/eea/volto-editing-progress/compare/0.1.8...0.2.0) - 9 June 2023
8
8
 
9
+ #### :rocket: New Features
9
10
 
10
- #### [0.1.7](https://github.com/eea/volto-editing-progress/compare/0.1.6...0.1.7)
11
+ - feat: add a JSON.stringify TextArea widget for controlpanel process editing - refs #253821 [rexalex - [`ac240d2`](https://github.com/eea/volto-editing-progress/commit/ac240d2c515b7e18482d9a530ae3bce16632e8a1)]
11
12
 
12
- > 23 December 2021
13
+ #### :bug: Bug Fixes
13
14
 
14
- - Update cypress tests to work also with slate [`#7`](https://github.com/eea/volto-editing-progress/pull/7)
15
+ - fix: fix class to avoid override from workflowProgress - refs #253798 [rexalex - [`86e138b`](https://github.com/eea/volto-editing-progress/commit/86e138b3e2b14c569f2db6dc0c6b67d28cb6e1e9)]
15
16
 
16
- #### [0.1.6](https://github.com/eea/volto-editing-progress/compare/0.1.5...0.1.6)
17
+ #### :house: Internal changes
17
18
 
18
- > 18 December 2021
19
19
 
20
- - Add SonarQube badges [`#6`](https://github.com/eea/volto-editing-progress/pull/6)
21
- - Refs #142010 - Optimize Volto-addons gitflow pipelines [`ecaea55`](https://github.com/eea/volto-editing-progress/commit/ecaea55e1987fdcf4228075fa05414f71922ba0c)
20
+ #### :hammer_and_wrench: Others
22
21
 
23
- #### [0.1.5](https://github.com/eea/volto-editing-progress/compare/0.1.4...0.1.5)
22
+ - Release 0.2.0 [Alin Voinea - [`8380466`](https://github.com/eea/volto-editing-progress/commit/8380466e0f3a25e00a56f37071b08062a29a0fd7)]
23
+ - test: Fix test config, coverage Refs #253277 [valentinab25 - [`206e055`](https://github.com/eea/volto-editing-progress/commit/206e0556c70598664997cafa14293f6caf49ac30)]
24
+ - Avoid fatal errors on null states [Alin Voinea - [`571d00b`](https://github.com/eea/volto-editing-progress/commit/571d00bddd7ee5ace272a4e324870c9f4eeb9948)]
25
+ ### [0.1.8](https://github.com/eea/volto-editing-progress/compare/0.1.7...0.1.8) - 3 January 2022
24
26
 
25
- > 24 June 2021
27
+ ### [0.1.7](https://github.com/eea/volto-editing-progress/compare/0.1.6...0.1.7) - 23 December 2021
26
28
 
27
- - Refs #124587 ensure we have document sidebar active on edit: [`#5`](https://github.com/eea/volto-editing-progress/pull/5)
28
- - Refs #124587 lint fix: [`1fdaf0a`](https://github.com/eea/volto-editing-progress/commit/1fdaf0a2b7d003bc4c153b33f3d42dc02ed0359b)
29
+ ### [0.1.6](https://github.com/eea/volto-editing-progress/compare/0.1.5...0.1.6) - 18 December 2021
29
30
 
30
- #### [0.1.4](https://github.com/eea/volto-editing-progress/compare/0.1.3...0.1.4)
31
+ #### :hammer_and_wrench: Others
31
32
 
32
- > 18 June 2021
33
+ - Refs #142010 - Optimize Volto-addons gitflow pipelines [valentinab25 - [`ecaea55`](https://github.com/eea/volto-editing-progress/commit/ecaea55e1987fdcf4228075fa05414f71922ba0c)]
34
+ ### [0.1.5](https://github.com/eea/volto-editing-progress/compare/0.1.4...0.1.5) - 24 June 2021
33
35
 
34
- - Refs #124587 ensure that the scroll to hash flashes everytime it's sc… [`#4`](https://github.com/eea/volto-editing-progress/pull/4)
35
- - Refs #124587 ensure that the scroll to hash flashes everytime it's scrolled into view [`4052cf2`](https://github.com/eea/volto-editing-progress/commit/4052cf212e74690ca5f43adf79b679aef2167358)
36
+ #### :hammer_and_wrench: Others
36
37
 
37
- #### [0.1.3](https://github.com/eea/volto-editing-progress/compare/0.1.2...0.1.3)
38
+ - Refs #124587 lint fix: [David Ichim - [`1fdaf0a`](https://github.com/eea/volto-editing-progress/commit/1fdaf0a2b7d003bc4c153b33f3d42dc02ed0359b)]
39
+ ### [0.1.4](https://github.com/eea/volto-editing-progress/compare/0.1.3...0.1.4) - 18 June 2021
38
40
 
39
- > 18 June 2021
41
+ #### :hammer_and_wrench: Others
40
42
 
41
- - Refs #124587 fixed use object if it's found and we have no field div: [`#3`](https://github.com/eea/volto-editing-progress/pull/3)
43
+ - Refs #124587 ensure that the scroll to hash flashes everytime it's scrolled into view [David Ichim - [`4052cf2`](https://github.com/eea/volto-editing-progress/commit/4052cf212e74690ca5f43adf79b679aef2167358)]
44
+ ### [0.1.3](https://github.com/eea/volto-editing-progress/compare/0.1.2...0.1.3) - 18 June 2021
42
45
 
43
- #### [0.1.2](https://github.com/eea/volto-editing-progress/compare/0.1.1...0.1.2)
46
+ ### [0.1.2](https://github.com/eea/volto-editing-progress/compare/0.1.1...0.1.2) - 15 June 2021
44
47
 
45
- > 15 June 2021
48
+ #### :hammer_and_wrench: Others
46
49
 
47
- - Refs #124587 implemented scroll to field with a flash effect [`#2`](https://github.com/eea/volto-editing-progress/pull/2)
48
- - Refs #124587 fixed linting and removed marking of soft required from edit: [`d1e9deb`](https://github.com/eea/volto-editing-progress/commit/d1e9debedb5ca0d0b78570e188ed0df81211588f)
49
- - Refs #124587 added scroll into view when we have a hash in view [`901c66b`](https://github.com/eea/volto-editing-progress/commit/901c66bd90f8050a6664ca85770de6b709d48d29)
50
+ - Refs #124587 fixed linting and removed marking of soft required from edit: [David Ichim - [`d1e9deb`](https://github.com/eea/volto-editing-progress/commit/d1e9debedb5ca0d0b78570e188ed0df81211588f)]
51
+ - Refs #124587 added scroll into view when we have a hash in view [David Ichim - [`901c66b`](https://github.com/eea/volto-editing-progress/commit/901c66bd90f8050a6664ca85770de6b709d48d29)]
52
+ ### [0.1.1](https://github.com/eea/volto-editing-progress/compare/0.1.0...0.1.1) - 10 June 2021
50
53
 
51
- #### [0.1.1](https://github.com/eea/volto-editing-progress/compare/0.1.0...0.1.1)
54
+ #### :hammer_and_wrench: Others
52
55
 
53
- > 10 June 2021
56
+ - Refs #124587 lint fixing [David Ichim - [`2bc7ffa`](https://github.com/eea/volto-editing-progress/commit/2bc7ffa48535a1f032bfbfa242f0d0f9c09ad9b2)]
57
+ - Refs #124587 wip setting bullets for soft required fields on edit [David Ichim - [`5d0cd54`](https://github.com/eea/volto-editing-progress/commit/5d0cd54200117bda9b2fb9bb1ec56f270b6d3c33)]
58
+ - Refs #124587 changed the following: [David Ichim - [`5ac614f`](https://github.com/eea/volto-editing-progress/commit/5ac614f89fd9bef5775052f5ec1a171256235d1e)]
59
+ - Cypress coverage [valentinab25 - [`88de55f`](https://github.com/eea/volto-editing-progress/commit/88de55fc070dc902cec92d2511d0748d5ce32d1f)]
60
+ - Refs #124587 added the basic hook up to the active-progress-workflow pluggable: [David Ichim - [`8efc3b1`](https://github.com/eea/volto-editing-progress/commit/8efc3b1973a31a59af7ba528abb418516c324ede)]
61
+ ### 0.1.0 - 26 May 2021
54
62
 
55
- - Cypress code coverage [`#1`](https://github.com/eea/volto-editing-progress/pull/1)
56
- - Refs #124587 lint fixing [`2bc7ffa`](https://github.com/eea/volto-editing-progress/commit/2bc7ffa48535a1f032bfbfa242f0d0f9c09ad9b2)
57
- - Refs #124587 wip setting bullets for soft required fields on edit [`5d0cd54`](https://github.com/eea/volto-editing-progress/commit/5d0cd54200117bda9b2fb9bb1ec56f270b6d3c33)
58
- - Refs #124587 changed the following: [`5ac614f`](https://github.com/eea/volto-editing-progress/commit/5ac614f89fd9bef5775052f5ec1a171256235d1e)
59
- - Cypress coverage [`88de55f`](https://github.com/eea/volto-editing-progress/commit/88de55fc070dc902cec92d2511d0748d5ce32d1f)
60
- - Refs #124587 added the basic hook up to the active-progress-workflow pluggable: [`8efc3b1`](https://github.com/eea/volto-editing-progress/commit/8efc3b1973a31a59af7ba528abb418516c324ede)
63
+ #### :hammer_and_wrench: Others
61
64
 
62
- #### 0.1.0
63
-
64
- > 26 May 2021
65
-
66
- - Refs #124587 renamed addon-template to editing-progress: [`2bd0b1b`](https://github.com/eea/volto-editing-progress/commit/2bd0b1b61398131bbdc12c01f9d47ed5b74862bf)
67
- - Initial commit [`82c7e96`](https://github.com/eea/volto-editing-progress/commit/82c7e96c4b63a9a164c0dbae0908fceb52c213d6)
65
+ - Refs #124587 renamed addon-template to editing-progress: [David Ichim - [`2bd0b1b`](https://github.com/eea/volto-editing-progress/commit/2bd0b1b61398131bbdc12c01f9d47ed5b74862bf)]
66
+ - Initial commit [ichim-david - [`82c7e96`](https://github.com/eea/volto-editing-progress/commit/82c7e96c4b63a9a164c0dbae0908fceb52c213d6)]
@@ -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
+ };
@@ -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
+ });
@@ -5,22 +5,22 @@ module.exports = {
5
5
  '!src/**/*.d.ts',
6
6
  ],
7
7
  moduleNameMapper: {
8
+ '\\.(css|less|scss|sass)$': 'identity-obj-proxy',
8
9
  '@plone/volto/cypress': '<rootDir>/node_modules/@plone/volto/cypress',
9
10
  '@plone/volto/babel': '<rootDir>/node_modules/@plone/volto/babel',
10
11
  '@plone/volto/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
11
12
  '@package/(.*)$': '<rootDir>/src/$1',
13
+ '@root/(.*)$': '<rootDir>/src/$1',
12
14
  '@plone/volto-quanta/(.*)$': '<rootDir>/src/addons/volto-quanta/src/$1',
13
15
  '@eeacms/(.*?)/(.*)$': '<rootDir>/src/addons/$1/src/$2',
14
- 'volto-slate/(.*)$': '<rootDir>/src/addons/volto-slate/src/$1',
16
+ '@plone/volto-slate':
17
+ '<rootDir>/node_modules/@plone/volto/packages/volto-slate/src',
15
18
  '~/(.*)$': '<rootDir>/src/$1',
16
19
  'load-volto-addons':
17
20
  '<rootDir>/node_modules/@plone/volto/jest-addons-loader.js',
18
21
  },
19
22
  transform: {
20
23
  '^.+\\.js(x)?$': 'babel-jest',
21
- '^.+\\.css$': 'jest-css-modules',
22
- '^.+\\.less$': 'jest-css-modules',
23
- '^.+\\.scss$': 'jest-css-modules',
24
24
  '^.+\\.(png)$': 'jest-file',
25
25
  '^.+\\.(jpg)$': 'jest-file',
26
26
  '^.+\\.(svg)$': './node_modules/@plone/volto/jest-svgsystem-transform.js',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-editing-progress",
3
- "version": "0.1.8",
3
+ "version": "0.2.0",
4
4
  "description": "@eeacms/volto-editing-progress: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -16,10 +16,10 @@
16
16
  "type": "git",
17
17
  "url": "git@github.com:eea/volto-editing-progress.git"
18
18
  },
19
- "dependencies": {},
20
19
  "devDependencies": {
21
20
  "@cypress/code-coverage": "^3.9.5",
22
- "babel-plugin-transform-class-properties": "^6.24.1"
21
+ "babel-plugin-transform-class-properties": "^6.24.1",
22
+ "md5": "^2.3.0"
23
23
  },
24
24
  "scripts": {
25
25
  "release": "release-it",
@@ -14,10 +14,10 @@ const filter_remaining_steps = (values, key) => {
14
14
  return false;
15
15
  }
16
16
  const states = value.states;
17
- const required_for_all = states.indexOf('all') !== -1;
17
+ const required_for_all = states?.indexOf('all') !== -1;
18
18
  return (
19
19
  (is_not_ready && required_for_all) ||
20
- (is_not_ready && states.indexOf(key) !== -1)
20
+ (is_not_ready && states?.indexOf(key) !== -1)
21
21
  );
22
22
  });
23
23
  };
@@ -84,7 +84,7 @@ const EditingProgress = (props) => {
84
84
  {remaining_steps.length} fields missing
85
85
  </Button>
86
86
  <ul
87
- className={'sidenav-ol ep-sidenav is-hidden'}
87
+ className={'sidenav-ol sidenav-ol--ep is-hidden'}
88
88
  ref={sideMenuRef}
89
89
  >
90
90
  {remaining_steps.map((step, index) => {
@@ -0,0 +1,107 @@
1
+ /**
2
+ * TextAreaJSONWidget component.
3
+ * @module components/manage/Widgets/TextAreaJSONWidget
4
+ */
5
+
6
+ import React, { useState } from 'react';
7
+ import PropTypes from 'prop-types';
8
+ import { TextArea } from 'semantic-ui-react';
9
+
10
+ import { defineMessages, injectIntl } from 'react-intl';
11
+ import { FormFieldWrapper } from '@plone/volto/components';
12
+
13
+ const messages = defineMessages({
14
+ invalidJSONError: {
15
+ id: 'Please enter valid JSON!',
16
+ defaultMessage: 'Please enter valid JSON!',
17
+ },
18
+ });
19
+
20
+ function isValidJson(json) {
21
+ try {
22
+ JSON.parse(json);
23
+ return true;
24
+ } catch (e) {
25
+ return false;
26
+ }
27
+ }
28
+
29
+ const TextAreaJSONWidget = (props) => {
30
+ const { id, value = '', onChange, placeholder, isDisabled, intl } = props;
31
+ const [invalidJSONError, setInvalidJSONError] = useState([]);
32
+ const [prevValue, setPrevValue] = useState(value);
33
+
34
+ /**
35
+ * will update Textarea to current value only if JSON is valid
36
+ * otherwise it will keep the previous value to avoid invalid JSON errors
37
+ * value is stringified, prevValue is object
38
+ * @param {string} id
39
+ * @param {string} value
40
+ */
41
+ const onhandleChange = (id, value) => {
42
+ if (!isValidJson(value)) {
43
+ setInvalidJSONError([intl.formatMessage(messages.invalidJSONError)]);
44
+ // remove error message after 1.5 seconds, since serves an informative role:
45
+ // in case of invalidation attempt the last valid JSON is shown
46
+ setTimeout(() => setInvalidJSONError([]), 1500);
47
+ onChange(id, prevValue);
48
+ } else {
49
+ setPrevValue(JSON.parse(value));
50
+ setInvalidJSONError([]);
51
+ onChange(id, JSON.parse(value));
52
+ }
53
+ };
54
+
55
+ return (
56
+ <FormFieldWrapper {...props} className="textarea" error={invalidJSONError}>
57
+ <TextArea
58
+ id={`field-${id}`}
59
+ name={id}
60
+ value={prevValue ? JSON.stringify(prevValue, undefined, 2) : ''}
61
+ disabled={isDisabled}
62
+ placeholder={placeholder}
63
+ rows="10"
64
+ style={{ height: '400px', maxWidth: 'none' }}
65
+ onChange={({ target }) =>
66
+ onhandleChange(id, target.value === '' ? undefined : target.value)
67
+ }
68
+ />
69
+ </FormFieldWrapper>
70
+ );
71
+ };
72
+
73
+ /**
74
+ * Property types.
75
+ * @property {Object} propTypes Property types.
76
+ * @static
77
+ */
78
+ TextAreaJSONWidget.propTypes = {
79
+ id: PropTypes.string.isRequired,
80
+ title: PropTypes.string.isRequired,
81
+ description: PropTypes.string,
82
+ required: PropTypes.bool,
83
+ error: PropTypes.arrayOf(PropTypes.string),
84
+ value: PropTypes.object,
85
+ onChange: PropTypes.func,
86
+ onEdit: PropTypes.func,
87
+ onDelete: PropTypes.func,
88
+ wrapped: PropTypes.bool,
89
+ placeholder: PropTypes.string,
90
+ };
91
+
92
+ /**
93
+ * Default properties.
94
+ * @property {Object} defaultProps Default properties.
95
+ * @static
96
+ */
97
+ TextAreaJSONWidget.defaultProps = {
98
+ description: null,
99
+ required: false,
100
+ error: [],
101
+ value: null,
102
+ onChange: null,
103
+ onEdit: null,
104
+ onDelete: null,
105
+ };
106
+
107
+ export default injectIntl(TextAreaJSONWidget);
package/src/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import EditingProgress from './EditingProgress';
2
2
  import ScrollIntoView from './ScrollIntoView';
3
3
  import { editingProgress } from './reducers';
4
+ import TextareaJSONWidget from './TextareaJSONWidget';
4
5
 
5
6
  const applyConfig = (config) => {
6
7
  config.addonReducers = {
@@ -10,6 +11,8 @@ const applyConfig = (config) => {
10
11
 
11
12
  const appExtras = config.settings.appExtras || [];
12
13
 
14
+ config.widgets.id.progress = TextareaJSONWidget;
15
+
13
16
  config.settings.appExtras = [
14
17
  ...appExtras,
15
18
  {
@@ -1,8 +1,11 @@
1
1
  @orange: orange;
2
+ @progress-wf-sidebar-width: 280px;
2
3
 
3
- .ep-sidenav {
4
- left: 280px;
5
- padding: 1.5rem;
4
+ .sidenav-ol {
5
+ &.sidenav-ol--ep {
6
+ left: @progress-wf-sidebar-width;
7
+ padding: 1.5rem;
8
+ }
6
9
  }
7
10
 
8
11
  .soft-required .wrapper {
package/Jenkinsfile DELETED
@@ -1,241 +0,0 @@
1
- pipeline {
2
- agent any
3
-
4
- environment {
5
- GIT_NAME = "volto-editing-progress"
6
- NAMESPACE = "@eeacms"
7
- SONARQUBE_TAGS = "volto.eea.europa.eu,www.eea.europa.eu-ims"
8
- DEPENDENCIES = ""
9
- }
10
-
11
- stages {
12
-
13
- stage('Release') {
14
- when {
15
- allOf {
16
- environment name: 'CHANGE_ID', value: ''
17
- branch 'master'
18
- }
19
- }
20
- steps {
21
- node(label: 'docker') {
22
- withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN'),string(credentialsId: 'eea-jenkins-npm-token', variable: 'NPM_TOKEN')]) {
23
- sh '''docker pull eeacms/gitflow'''
24
- sh '''docker run -i --rm --name="$BUILD_TAG-gitflow-master" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_NAME="$GIT_NAME" -e GIT_TOKEN="$GITHUB_TOKEN" -e NPM_TOKEN="$NPM_TOKEN" -e LANGUAGE=javascript eeacms/gitflow'''
25
- }
26
- }
27
- }
28
- }
29
-
30
- stage('Code') {
31
- when {
32
- allOf {
33
- environment name: 'CHANGE_ID', value: ''
34
- not { changelog '.*^Automated release [0-9\\.]+$' }
35
- not { branch 'master' }
36
- }
37
- }
38
- steps {
39
- parallel(
40
-
41
- "ES lint": {
42
- node(label: 'docker') {
43
- 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
- }
45
- },
46
-
47
- "Style lint": {
48
- node(label: 'docker') {
49
- 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
- }
51
- },
52
-
53
- "Prettier": {
54
- node(label: 'docker') {
55
- 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
- }
57
- }
58
- )
59
- }
60
- }
61
-
62
- stage('Tests') {
63
- when {
64
- allOf {
65
- environment name: 'CHANGE_ID', value: ''
66
- anyOf {
67
- not { changelog '.*^Automated release [0-9\\.]+$' }
68
- branch 'master'
69
- }
70
- }
71
- }
72
- steps {
73
- parallel(
74
-
75
- "Volto": {
76
- node(label: 'docker') {
77
- script {
78
- try {
79
- sh '''docker pull plone/volto-addon-ci'''
80
- 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'''
81
- sh '''rm -rf xunit-reports'''
82
- sh '''mkdir -p xunit-reports'''
83
- sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/coverage xunit-reports/'''
84
- sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/junit.xml xunit-reports/'''
85
- sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/unit_tests_log.txt xunit-reports/'''
86
- stash name: "xunit-reports", includes: "xunit-reports/**"
87
- archiveArtifacts artifacts: "xunit-reports/unit_tests_log.txt", fingerprint: true
88
- publishHTML (target : [
89
- allowMissing: false,
90
- alwaysLinkToLastBuild: true,
91
- keepAll: true,
92
- reportDir: 'xunit-reports/coverage/lcov-report',
93
- reportFiles: 'index.html',
94
- reportName: 'UTCoverage',
95
- reportTitles: 'Unit Tests Code Coverage'
96
- ])
97
- } finally {
98
- catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
99
- junit testResults: 'xunit-reports/junit.xml', allowEmptyResults: true
100
- }
101
- sh script: '''docker rm -v $BUILD_TAG-volto''', returnStatus: true
102
- }
103
- }
104
- }
105
- }
106
- )
107
- }
108
- }
109
-
110
- stage('Integration tests') {
111
- when {
112
- allOf {
113
- environment name: 'CHANGE_ID', value: ''
114
- anyOf {
115
- not { changelog '.*^Automated release [0-9\\.]+$' }
116
- branch 'master'
117
- }
118
- }
119
- }
120
- steps {
121
- parallel(
122
-
123
- "Cypress": {
124
- node(label: 'docker') {
125
- script {
126
- try {
127
- sh '''docker pull plone; docker run -d --rm --name="$BUILD_TAG-plone" -e SITE="Plone" -e PROFILES="profile-plone.restapi:blocks" plone fg'''
128
- 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" plone/volto-addon-ci cypress'''
129
- } finally {
130
- try {
131
- sh '''rm -rf cypress-reports cypress-results cypress-coverage'''
132
- sh '''mkdir -p cypress-reports cypress-results cypress-coverage'''
133
- sh '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/src/addons/$GIT_NAME/cypress/videos cypress-reports/'''
134
- sh '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/src/addons/$GIT_NAME/cypress/reports cypress-results/'''
135
- coverage = sh script: '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/src/addons/$GIT_NAME/coverage cypress-coverage/''', returnStatus: true
136
- if ( coverage == 0 ) {
137
- publishHTML (target : [allowMissing: false,
138
- alwaysLinkToLastBuild: true,
139
- keepAll: true,
140
- reportDir: 'cypress-coverage/coverage/lcov-report',
141
- reportFiles: 'index.html',
142
- reportName: 'CypressCoverage',
143
- reportTitles: 'Integration Tests Code Coverage'])
144
- }
145
- sh '''touch empty_file; for ok_test in $(grep -E 'file=.*failures="0"' $(grep 'testsuites .*failures="0"' $(find cypress-results -name *.xml) empty_file | awk -F: '{print $1}') empty_file | sed 's/.* file="\\(.*\\)" time.*/\\1/' | sed 's#^cypress/integration/##g' | sed 's#^../../../node_modules/@eeacms/##g'); do rm -f cypress-reports/videos/$ok_test.mp4; rm -f cypress-reports/$ok_test.mp4; done'''
146
- archiveArtifacts artifacts: 'cypress-reports/**/*.mp4', fingerprint: true, allowEmptyArchive: true
147
- stash name: "cypress-coverage", includes: "cypress-coverage/**", allowEmpty: true
148
- }
149
- finally {
150
- catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
151
- junit testResults: 'cypress-results/**/*.xml', allowEmptyResults: true
152
- }
153
- sh script: "docker stop $BUILD_TAG-plone", returnStatus: true
154
- sh script: "docker rm -v $BUILD_TAG-plone", returnStatus: true
155
- sh script: "docker rm -v $BUILD_TAG-cypress", returnStatus: true
156
-
157
- }
158
- }
159
- }
160
- }
161
- }
162
-
163
- )
164
- }
165
- }
166
-
167
- stage('Report to SonarQube') {
168
- when {
169
- allOf {
170
- environment name: 'CHANGE_ID', value: ''
171
- anyOf {
172
- branch 'master'
173
- allOf {
174
- branch 'develop'
175
- not { changelog '.*^Automated release [0-9\\.]+$' }
176
- }
177
- }
178
- }
179
- }
180
- steps {
181
- node(label: 'swarm') {
182
- script{
183
- checkout scm
184
- unstash "xunit-reports"
185
- unstash "cypress-coverage"
186
- def scannerHome = tool 'SonarQubeScanner';
187
- def nodeJS = tool 'NodeJS11';
188
- withSonarQubeEnv('Sonarqube') {
189
- sh '''sed -i "s#/opt/frontend/my-volto-project/src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info'''
190
- sh "export PATH=$PATH:${scannerHome}/bin:${nodeJS}/bin; sonar-scanner -Dsonar.javascript.lcov.reportPaths=./xunit-reports/coverage/lcov.info,./cypress-coverage/coverage/lcov.info -Dsonar.sources=./src -Dsonar.projectKey=$GIT_NAME-$BRANCH_NAME -Dsonar.projectVersion=$BRANCH_NAME-$BUILD_NUMBER"
191
- sh '''try=2; while [ \$try -gt 0 ]; do curl -s -XPOST -u "${SONAR_AUTH_TOKEN}:" "${SONAR_HOST_URL}api/project_tags/set?project=${GIT_NAME}-${BRANCH_NAME}&tags=${SONARQUBE_TAGS},${BRANCH_NAME}" > set_tags_result; if [ \$(grep -ic error set_tags_result ) -eq 0 ]; then try=0; else cat set_tags_result; echo "... Will retry"; sleep 60; try=\$(( \$try - 1 )); fi; done'''
192
- }
193
- }
194
- }
195
- }
196
- }
197
-
198
- stage('Pull Request') {
199
- when {
200
- not {
201
- environment name: 'CHANGE_ID', value: ''
202
- }
203
- environment name: 'CHANGE_TARGET', value: 'master'
204
- }
205
- steps {
206
- node(label: 'docker') {
207
- script {
208
- if ( env.CHANGE_BRANCH != "develop" ) {
209
- error "Pipeline aborted due to PR not made from develop branch"
210
- }
211
- withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) {
212
- sh '''docker pull eeacms/gitflow'''
213
- sh '''docker run -i --rm --name="$BUILD_TAG-gitflow-pr" -e GIT_CHANGE_TARGET="$CHANGE_TARGET" -e GIT_CHANGE_BRANCH="$CHANGE_BRANCH" -e GIT_CHANGE_AUTHOR="$CHANGE_AUTHOR" -e GIT_CHANGE_TITLE="$CHANGE_TITLE" -e GIT_TOKEN="$GITHUB_TOKEN" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e GIT_ORG="$GIT_ORG" -e GIT_NAME="$GIT_NAME" -e LANGUAGE=javascript eeacms/gitflow'''
214
- }
215
- }
216
- }
217
- }
218
- }
219
-
220
- }
221
-
222
- post {
223
- always {
224
- cleanWs(cleanWhenAborted: true, cleanWhenFailure: true, cleanWhenNotBuilt: true, cleanWhenSuccess: true, cleanWhenUnstable: true, deleteDirs: true)
225
- }
226
- changed {
227
- script {
228
- def details = """<h1>${env.JOB_NAME} - Build #${env.BUILD_NUMBER} - ${currentBuild.currentResult}</h1>
229
- <p>Check console output at <a href="${env.BUILD_URL}/display/redirect">${env.JOB_BASE_NAME} - #${env.BUILD_NUMBER}</a></p>
230
- """
231
- emailext(
232
- subject: '$DEFAULT_SUBJECT',
233
- body: details,
234
- attachLog: true,
235
- compressLog: true,
236
- recipientProviders: [[$class: 'DevelopersRecipientProvider'], [$class: 'CulpritsRecipientProvider']]
237
- )
238
- }
239
- }
240
- }
241
- }
package/Makefile DELETED
@@ -1,39 +0,0 @@
1
- SHELL=/bin/bash
2
-
3
- DIR=$(shell basename $$(pwd))
4
- ADDON ?= "@eeacms/volto-editing-progress"
5
-
6
- # We like colors
7
- # From: https://coderwall.com/p/izxssa/colored-makefile-for-golang-projects
8
- RED=`tput setaf 1`
9
- GREEN=`tput setaf 2`
10
- RESET=`tput sgr0`
11
- YELLOW=`tput setaf 3`
12
-
13
- project:
14
- npm install -g yo
15
- npm install -g @plone/generator-volto
16
- npm install -g mrs-developer
17
- yo @plone/volto project --addon ${ADDON} --workspace "src/addons/${DIR}" --no-interactive
18
- ln -sf $$(pwd) project/src/addons/
19
- cp .project.eslintrc.js .eslintrc.js
20
- cd project && yarn
21
- @echo "-------------------"
22
- @echo "$(GREEN)Volto project is ready!$(RESET)"
23
- @echo "$(RED)Now run: cd project && yarn start$(RESET)"
24
-
25
- all: project
26
-
27
- .PHONY: start-test-backend
28
- start-test-backend: ## Start Test Plone Backend
29
- @echo "$(GREEN)==> Start Test Plone Backend$(RESET)"
30
- docker run -i --rm -e ZSERVER_HOST=0.0.0.0 -e ZSERVER_PORT=55001 -p 55001:55001 -e SITE=plone -e APPLY_PROFILES=plone.app.contenttypes:plone-content,plone.restapi:default,kitconcept.volto:default-homepage -e CONFIGURE_PACKAGES=plone.app.contenttypes,plone.restapi,kitconcept.volto,kitconcept.volto.cors -e ADDONS='plone.app.robotframework plone.app.contenttypes plone.restapi kitconcept.volto' plone ./bin/robot-server plone.app.robotframework.testing.PLONE_ROBOT_TESTING
31
-
32
- .PHONY: start-backend-docker
33
- start-backend-docker: ## Starts a Docker-based backend
34
- @echo "$(GREEN)==> Start Docker-based Plone Backend$(RESET)"
35
- docker run -it --rm --name=plone -p 8080:8080 -e SITE=Plone -e ADDONS="kitconcept.volto" -e ZCML="kitconcept.volto.cors" plone
36
-
37
- .PHONY: help
38
- help: ## Show this help.
39
- @echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)"
@@ -1,5 +0,0 @@
1
- {
2
- "name": "Using fixtures to represent data",
3
- "email": "hello@cypress.io",
4
- "body": "Fixtures are a great way to mock data for responses to routes"
5
- }
@@ -1,30 +0,0 @@
1
- import { setupBeforeEach, tearDownAfterEach } from '../support';
2
-
3
- describe('Blocks Tests', () => {
4
- beforeEach(setupBeforeEach);
5
- afterEach(tearDownAfterEach);
6
-
7
- it('Add Block: Empty', () => {
8
- // Change page title
9
- cy.get('[contenteditable=true]').first().clear();
10
-
11
- cy.get('[contenteditable=true]').first().type('My Add-on Page');
12
-
13
- cy.get('.documentFirstHeading').contains('My Add-on Page');
14
-
15
- cy.get('[contenteditable=true]').first().type('{enter}');
16
-
17
- // Add block
18
- cy.get('.ui.basic.icon.button.block-add-button').first().click();
19
- cy.get('.blocks-chooser .title').contains('Media').click();
20
- cy.get('.content.active.media .button.image').contains('Image').click();
21
-
22
- // Save
23
- cy.get('#toolbar-save').click();
24
- cy.url().should('eq', Cypress.config().baseUrl + '/cypress/my-page');
25
-
26
- // then the page view should contain our changes
27
- cy.contains('My Add-on Page');
28
- cy.get('.block.image');
29
- });
30
- });
@@ -1,26 +0,0 @@
1
- /// <reference types="cypress" />
2
- // ***********************************************************
3
- // This example plugins/index.js can be used to load plugins
4
- //
5
- // You can change the location of this file or turn off loading
6
- // the plugins file with the 'pluginsFile' configuration option.
7
- //
8
- // You can read more here:
9
- // https://on.cypress.io/plugins-guide
10
- // ***********************************************************
11
-
12
- // This function is called when a project is opened or re-opened (e.g. due to
13
- // the project's config changing)
14
-
15
- /**
16
- * @type {Cypress.PluginConfig}
17
- */
18
- module.exports = (on, config) => {
19
- // `on` is used to hook into various events Cypress emits
20
- // `config` is the resolved Cypress config
21
- /* coverage-start
22
- require('@cypress/code-coverage/task')(on, config)
23
- on('file:preprocessor', require('@cypress/code-coverage/use-babelrc'))
24
- return config
25
- coverage-end */
26
- };
@@ -1,315 +0,0 @@
1
- /* eslint no-console: ["error", { allow: ["log"] }] */
2
-
3
- // --- AUTOLOGIN -------------------------------------------------------------
4
- Cypress.Commands.add('autologin', () => {
5
- let api_url, user, password;
6
- api_url = Cypress.env('API_PATH') || 'http://localhost:8080/Plone';
7
- user = 'admin';
8
- password = 'admin';
9
-
10
- return cy
11
- .request({
12
- method: 'POST',
13
- url: `${api_url}/@login`,
14
- headers: { Accept: 'application/json' },
15
- body: { login: user, password: password },
16
- })
17
- .then((response) => cy.setCookie('auth_token', response.body.token));
18
- });
19
-
20
- // --- CREATE CONTENT --------------------------------------------------------
21
- Cypress.Commands.add(
22
- 'createContent',
23
- ({
24
- contentType,
25
- contentId,
26
- contentTitle,
27
- path = '',
28
- allow_discussion = false,
29
- }) => {
30
- let api_url, auth;
31
- api_url = Cypress.env('API_PATH') || 'http://localhost:8080/Plone';
32
- auth = {
33
- user: 'admin',
34
- pass: 'admin',
35
- };
36
- if (contentType === 'File') {
37
- return cy.request({
38
- method: 'POST',
39
- url: `${api_url}/${path}`,
40
- headers: {
41
- Accept: 'application/json',
42
- },
43
- auth: auth,
44
- body: {
45
- '@type': contentType,
46
- id: contentId,
47
- title: contentTitle,
48
- file: {
49
- data: 'dGVzdGZpbGUK',
50
- encoding: 'base64',
51
- filename: 'lorem.txt',
52
- 'content-type': 'text/plain',
53
- },
54
- allow_discussion: allow_discussion,
55
- },
56
- });
57
- }
58
- if (contentType === 'Image') {
59
- return cy.request({
60
- method: 'POST',
61
- url: `${api_url}/${path}`,
62
- headers: {
63
- Accept: 'application/json',
64
- },
65
- auth: auth,
66
- body: {
67
- '@type': contentType,
68
- id: contentId,
69
- title: contentTitle,
70
- image: {
71
- data:
72
- 'iVBORw0KGgoAAAANSUhEUgAAANcAAAA4CAMAAABZsZ3QAAAAM1BMVEX29fK42OU+oMvn7u9drtIPisHI4OhstdWZyt4fkcXX5+sAg74umMhNp86p0eJ7vNiKw9v/UV4wAAAAAXRSTlMAQObYZgAABBxJREFUeF7tmuty4yAMhZG4X2zn/Z92J5tsBJwWXG/i3XR6frW2Y/SBLIRAfaQUDNt8E5tLUt9BycfcKfq3R6Mlfyimtx4rzp+K3dtibXkor99zsEqLYZltblTecciogoh+TXfY1Ve4dn07rCDGG9dHSEEOg/GmXl0U1XDxTKxNK5De7BxsyyBr6gGm2/vPxKJ8F6f7BXKfRMp1xIWK9A+5ks25alSb353dWnDJN1k35EL5f8dVGifTf/4tjUuuFq7u4srmXC60yAmldLXIWbg65RKU87lcGxJCFqUPv0IacW0PmSivOZFLE908inPToMmii/roG+MRV/O8FU88i8tFsxV3a06MFUw0Qu7RmAtdV5/HVVaOVMTWNOWSwMljLhzhcB6XIS7OK5V6AvRDNN7t5VJWQs1J40UmalbK56usBG/CuCHSYuc+rkUGeMCViNRARPrzW52N3oQLe6WifNliSuuGaH3czbVNudI9s7ZLUCLHVwWlyES522o1t14uvmbblmVTKqFjaZYJFSTPP4dLL1kU1z7p0lzdbRulmEWLxoQX+z9ce7A8GqEEucllLxePuZwdJl1Lezu0hoswvTPt61DrFcRuujV/2cmlxaGBC7Aw6cpovGANwRiSdOAWJ5AGy4gLL64dl0QhUEAuEUNws+XxV+OKGPdw/hESGYF9XEGaFC7sNLMSXWJjHsnanYi87VK428N2uxpOjOFANcagLM5l+7mSycM8KknZpKLcGi6jmzWGr/vLurZ/0g4u9AZuAoeb5r1ceQhyiTPY1E4wUR6u/F3H2ojSpXMMriBPT9cezTto8Cx+MsglHL4fv1Rxrb1LVw9yvyQpJ3AhFnLZfuRLH2QsOG3FGGD20X/th/u5bFAt16Bt308KjF+MNOXgl/SquIEySX3GhaZvc67KZbDxcCDORz2N8yCWPaY5lyQZO7lQ29fnZbt3Xu6qoge4+DjXl/MocySPOp9rlvdyznahRyHEYd77v3LhugOXDv4J65QXfl803BDAdaWBEDhfVx7nKofjoVCgxnUAqw/UAUDPn788BDvQuG4TDtdtUPvzjSlXAB8DvaDOhhrmhwbywylXAm8CvaouikJTL93gs3y7Yy4VYbIxOHrcMizPqWOjqO9l3Uz52kibQy4xxOgqhJvD+w5rvokOcAlGvNCfeqCv1ste1stzLm0f71Iq3ZfTrPfuE5nhPtF+LvQE2lffQC7pYtQy3tdzdrKvd5TLVVzDetScS3nEKmmwDyt1Cev1kX3YfbvzNK4fzrlw+cB6vm+uiUgf2zdXI62241LawCb7Pi5FXFPF8KpzDoF/Sw2lg+GrHNbno1mhPu+VCF/vfMnw06PnUl6j48dVHD3jHNHPua+fc3o/5yp/zsGi0vYtzi3Pz5mHd4T6BWMIlewacd63AAAAAElFTkSuQmCC',
73
- encoding: 'base64',
74
- filename: 'image.png',
75
- 'content-type': 'image/png',
76
- },
77
- },
78
- });
79
- }
80
- if (['Document', 'Folder', 'CMSFolder'].includes(contentType)) {
81
- return cy
82
- .request({
83
- method: 'POST',
84
- url: `${api_url}/${path}`,
85
- headers: {
86
- Accept: 'application/json',
87
- },
88
- auth: auth,
89
- body: {
90
- '@type': contentType,
91
- id: contentId,
92
- title: contentTitle,
93
- blocks: {
94
- 'd3f1c443-583f-4e8e-a682-3bf25752a300': { '@type': 'title' },
95
- '7624cf59-05d0-4055-8f55-5fd6597d84b0': { '@type': 'text' },
96
- },
97
- blocks_layout: {
98
- items: [
99
- 'd3f1c443-583f-4e8e-a682-3bf25752a300',
100
- '7624cf59-05d0-4055-8f55-5fd6597d84b0',
101
- ],
102
- },
103
- allow_discussion: allow_discussion,
104
- },
105
- })
106
- .then(() => console.log(`${contentType} created`));
107
- } else {
108
- return cy
109
- .request({
110
- method: 'POST',
111
- url: `${api_url}/${path}`,
112
- headers: {
113
- Accept: 'application/json',
114
- },
115
- auth: auth,
116
- body: {
117
- '@type': contentType,
118
- id: contentId,
119
- title: contentTitle,
120
- allow_discussion: allow_discussion,
121
- },
122
- })
123
- .then(() => console.log(`${contentType} created`));
124
- }
125
- },
126
- );
127
-
128
- // --- REMOVE CONTENT --------------------------------------------------------
129
- Cypress.Commands.add('removeContent', (path) => {
130
- let api_url, auth;
131
- api_url = Cypress.env('API_PATH') || 'http://localhost:8080/Plone';
132
- auth = {
133
- user: 'admin',
134
- pass: 'admin',
135
- };
136
- return cy
137
- .request({
138
- method: 'DELETE',
139
- url: `${api_url}/${path}`,
140
- headers: {
141
- Accept: 'application/json',
142
- },
143
- auth: auth,
144
- body: {},
145
- })
146
- .then(() => console.log(`${path} removed`));
147
- });
148
-
149
- // --- SET WORKFLOW ----------------------------------------------------------
150
- Cypress.Commands.add(
151
- 'setWorkflow',
152
- ({
153
- path = '/',
154
- actor = 'admin',
155
- review_state = 'publish',
156
- time = '1995-07-31T18:30:00',
157
- title = '',
158
- comment = '',
159
- effective = '2018-01-21T08:00:00',
160
- expires = '2019-01-21T08:00:00',
161
- include_children = true,
162
- }) => {
163
- let api_url, auth;
164
- api_url = Cypress.env('API_PATH') || 'http://localhost:8080/Plone';
165
- auth = {
166
- user: 'admin',
167
- pass: 'admin',
168
- };
169
- return cy.request({
170
- method: 'POST',
171
- url: `${api_url}/${path}/@workflow/${review_state}`,
172
- headers: {
173
- Accept: 'application/json',
174
- },
175
- auth: auth,
176
- body: {
177
- actor: actor,
178
- review_state: review_state,
179
- time: time,
180
- title: title,
181
- comment: comment,
182
- effective: effective,
183
- expires: expires,
184
- include_children: include_children,
185
- },
186
- });
187
- },
188
- );
189
-
190
- // --- waitForResourceToLoad ----------------------------------------------------------
191
- Cypress.Commands.add('waitForResourceToLoad', (fileName, type) => {
192
- const resourceCheckInterval = 40;
193
-
194
- return new Cypress.Promise((resolve) => {
195
- const checkIfResourceHasBeenLoaded = () => {
196
- const resource = cy
197
- .state('window')
198
- .performance.getEntriesByType('resource')
199
- .filter((entry) => !type || entry.initiatorType === type)
200
- .find((entry) => entry.name.includes(fileName));
201
-
202
- if (resource) {
203
- resolve();
204
-
205
- return;
206
- }
207
-
208
- setTimeout(checkIfResourceHasBeenLoaded, resourceCheckInterval);
209
- };
210
-
211
- checkIfResourceHasBeenLoaded();
212
- });
213
- });
214
-
215
- // Low level command reused by `setSelection` and low level command `setCursor`
216
- Cypress.Commands.add('selection', { prevSubject: true }, (subject, fn) => {
217
- cy.wrap(subject).trigger('mousedown').then(fn).trigger('mouseup');
218
-
219
- cy.document().trigger('selectionchange');
220
- return cy.wrap(subject);
221
- });
222
-
223
- Cypress.Commands.add(
224
- 'setSelection',
225
- { prevSubject: true },
226
- (subject, query, endQuery) => {
227
- return cy.wrap(subject).selection(($el) => {
228
- if (typeof query === 'string') {
229
- const anchorNode = getTextNode($el[0], query);
230
- const focusNode = endQuery ? getTextNode($el[0], endQuery) : anchorNode;
231
- const anchorOffset = anchorNode.wholeText.indexOf(query);
232
- const focusOffset = endQuery
233
- ? focusNode.wholeText.indexOf(endQuery) + endQuery.length
234
- : anchorOffset + query.length;
235
- setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);
236
- } else if (typeof query === 'object') {
237
- const el = $el[0];
238
- const anchorNode = getTextNode(el.querySelector(query.anchorQuery));
239
- const anchorOffset = query.anchorOffset || 0;
240
- const focusNode = query.focusQuery
241
- ? getTextNode(el.querySelector(query.focusQuery))
242
- : anchorNode;
243
- const focusOffset = query.focusOffset || 0;
244
- setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);
245
- }
246
- });
247
- },
248
- );
249
-
250
- // Low level command reused by `setCursorBefore` and `setCursorAfter`, equal to `setCursorAfter`
251
- Cypress.Commands.add(
252
- 'setCursor',
253
- { prevSubject: true },
254
- (subject, query, atStart) => {
255
- return cy.wrap(subject).selection(($el) => {
256
- const node = getTextNode($el[0], query);
257
- const offset =
258
- node.wholeText.indexOf(query) + (atStart ? 0 : query.length);
259
- const document = node.ownerDocument;
260
- document.getSelection().removeAllRanges();
261
- document.getSelection().collapse(node, offset);
262
- });
263
- // Depending on what you're testing, you may need to chain a `.click()` here to ensure
264
- // further commands are picked up by whatever you're testing (this was required for Slate, for example).
265
- },
266
- );
267
-
268
- Cypress.Commands.add(
269
- 'setCursorBefore',
270
- { prevSubject: true },
271
- (subject, query) => {
272
- cy.wrap(subject).setCursor(query, true);
273
- },
274
- );
275
-
276
- Cypress.Commands.add(
277
- 'setCursorAfter',
278
- { prevSubject: true },
279
- (subject, query) => {
280
- cy.wrap(subject).setCursor(query);
281
- },
282
- );
283
-
284
- // Helper functions
285
- function getTextNode(el, match) {
286
- const walk = document.createTreeWalker(el, NodeFilter.SHOW_TEXT, null, false);
287
- if (!match) {
288
- return walk.nextNode();
289
- }
290
-
291
- let node;
292
- while ((node = walk.nextNode())) {
293
- if (node.wholeText.includes(match)) {
294
- return node;
295
- }
296
- }
297
- }
298
-
299
- function setBaseAndExtent(...args) {
300
- const document = args[0].ownerDocument;
301
- document.getSelection().removeAllRanges();
302
- document.getSelection().setBaseAndExtent(...args);
303
- }
304
-
305
- Cypress.Commands.add('navigate', (route = '') => {
306
- return cy.window().its('appHistory').invoke('push', route);
307
- });
308
-
309
- Cypress.Commands.add('store', () => {
310
- return cy.window().its('store').invoke('getStore', '');
311
- });
312
-
313
- Cypress.Commands.add('settings', (key, value) => {
314
- return cy.window().its('settings');
315
- });
@@ -1,53 +0,0 @@
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
-
19
- // Alternatively you can use CommonJS syntax:
20
- // require('./commands')
21
-
22
- /* coverage-start
23
- //Generate code-coverage
24
- import '@cypress/code-coverage/support';
25
- coverage-end */
26
-
27
- export const setupBeforeEach = () => {
28
- cy.autologin();
29
- cy.createContent({
30
- contentType: 'Folder',
31
- contentId: 'cypress',
32
- contentTitle: 'Cypress',
33
- });
34
- cy.createContent({
35
- contentType: 'Document',
36
- contentId: 'my-page',
37
- contentTitle: 'My Page',
38
- path: 'cypress',
39
- });
40
- cy.visit('/cypress/my-page');
41
- cy.waitForResourceToLoad('@navigation');
42
- cy.waitForResourceToLoad('@breadcrumbs');
43
- cy.waitForResourceToLoad('@actions');
44
- cy.waitForResourceToLoad('@types');
45
- cy.waitForResourceToLoad('my-page');
46
- cy.navigate('/cypress/my-page/edit');
47
- cy.get(`.block.title h1`);
48
- };
49
-
50
- export const tearDownAfterEach = () => {
51
- cy.autologin();
52
- cy.removeContent('cypress');
53
- };
package/cypress.json DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "baseUrl": "http://localhost:3000",
3
- "viewportWidth": 1280,
4
- "defaultCommandTimeout": 15000,
5
- "reporter": "junit",
6
- "video": true,
7
- "reporterOptions": {
8
- "mochaFile": "cypress/reports/cypress-[hash].xml",
9
- "jenkinsMode": true,
10
- "toConsole": true
11
- }
12
- }