Skip to content

Commit

Permalink
Merge pull request #97 from eea/develop
Browse files Browse the repository at this point in the history
i18n translation of block options
  • Loading branch information
avoinea authored Feb 1, 2024
2 parents 1fd9708 + a359fc0 commit 5f43419
Show file tree
Hide file tree
Showing 22 changed files with 1,767 additions and 107 deletions.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Jest configuration variables
# - possible values: ON, OFF
JEST_USE_SETUP=OFF
65 changes: 65 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
const fs = require('fs');
const path = require('path');
const projectRootPath = fs.realpathSync(__dirname + '/../../../');

let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto');
let configFile;
if (fs.existsSync(`${projectRootPath}/tsconfig.json`))
configFile = `${projectRootPath}/tsconfig.json`;
else if (fs.existsSync(`${projectRootPath}/jsconfig.json`))
configFile = `${projectRootPath}/jsconfig.json`;

if (configFile) {
const jsConfig = require(configFile).compilerOptions;
const pathsConfig = jsConfig.paths;
if (pathsConfig['@plone/volto'])
voltoPath = `./${jsConfig.baseUrl}/${pathsConfig['@plone/volto'][0]}`;
}

const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`);
const reg = new AddonConfigurationRegistry(projectRootPath);

// Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
const addonAliases = Object.keys(reg.packages).map((o) => [
o,
reg.packages[o].modulePath,
]);

const addonExtenders = reg.getEslintExtenders().map((m) => require(m));

const defaultConfig = {
extends: `${voltoPath}/.eslintrc`,
settings: {
'import/resolver': {
alias: {
map: [
['@plone/volto', '@plone/volto/src'],
['@plone/volto-slate', '@plone/volto/packages/volto-slate/src'],
...addonAliases,
['@package', `${__dirname}/src`],
['@root', `${__dirname}/src`],
['~', `${__dirname}/src`],
],
extensions: ['.js', '.jsx', '.json'],
},
'babel-plugin-root-import': {
rootPathSuffix: 'src',
},
},
},
rules: {
'react/jsx-no-target-blank': [
'error',
{
allowReferrer: true,
},
],
}
};

const config = addonExtenders.reduce(
(acc, extender) => extender.modify(acc),
defaultConfig,
);

module.exports = config;
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.vscode/
.history
.eslintrc.js
.nyc_output
project
coverage
Expand Down
48 changes: 0 additions & 48 deletions .project.eslintrc.js

This file was deleted.

25 changes: 24 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,30 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

### [6.0.0](https://github.com/eea/volto-block-style/compare/5.2.6...6.0.0) - 8 December 2023
### [6.1.0](https://github.com/eea/volto-block-style/compare/6.0.0...6.1.0) - 1 February 2024

#### :bug: Bug Fixes

- fix(tests): as we need to mock intl object when testing [David Ichim - [`0e1d26c`](https://github.com/eea/volto-block-style/commit/0e1d26c9ed28a544258e9eff8638835ba72c7499)]
- fix(styles): remove body main overflow that was hiding popup selectors [David Ichim - [`e0c9ea4`](https://github.com/eea/volto-block-style/commit/e0c9ea4d994b369ed4c95414e1279a4e76855be6)]

#### :nail_care: Enhancements

- change(i118n): updated translation po files [David Ichim - [`5faa308`](https://github.com/eea/volto-block-style/commit/5faa308ec9505d4c24c95673b7489cfaa29eb92d)]

#### :house: Internal changes

- chore: package.json [Alin Voinea - [`d794858`](https://github.com/eea/volto-block-style/commit/d79485811c4e9b6eeb05deaafff1462ddfcfe405)]

#### :hammer_and_wrench: Others

- Bump package version [David Ichim - [`2566d02`](https://github.com/eea/volto-block-style/commit/2566d0230fcb6157c0e8a55569907144bbd58241)]
- lint fix [David Ichim - [`269f833`](https://github.com/eea/volto-block-style/commit/269f8332e0c731956b6db99a6cee9b6bf9cb8209)]
- Add i18n support and pt_BR translation #88 from andreclimaco/develop [ichim-david - [`8ff6dae`](https://github.com/eea/volto-block-style/commit/8ff6dae61960999f7d4d7a5ad1217a0311d18490)]
- test: Update jest,Jenkinsfile,lint to volto-addons-template PR30 [valentinab25 - [`302006a`](https://github.com/eea/volto-block-style/commit/302006ab4331c4ee5ba72e77157029e6e60743c1)]
- test: Update jest,Jenkinsfile,lint to volto-addons-template PR30 [valentinab25 - [`42c89fa`](https://github.com/eea/volto-block-style/commit/42c89fad9272403998a4a80f0fd8561bc09947fc)]
- Add i18n support and pt_BR translation [André Clímaco - [`7c65445`](https://github.com/eea/volto-block-style/commit/7c65445ab8208b963fc12536bb4162c3109d7933)]
## [6.0.0](https://github.com/eea/volto-block-style/compare/5.2.6...6.0.0) - 8 December 2023

#### :house: Internal changes

Expand Down
9 changes: 8 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,16 @@ pipeline {
script {
try {
sh '''docker run --pull always --rm -d --name="$IMAGE_NAME-plone" -e SITE="Plone" -e PROFILES="$BACKEND_PROFILES" -e ADDONS="$BACKEND_ADDONS" eeacms/plone-backend'''
sh '''docker run -d --shm-size=3g --link $IMAGE_NAME-plone:plone --name="$IMAGE_NAME-cypress" -e "RAZZLE_INTERNAL_API_PATH=http://plone:8080/Plone" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend start-ci'''
sh '''docker run -d --shm-size=4g --link $IMAGE_NAME-plone:plone --name="$IMAGE_NAME-cypress" -e "RAZZLE_INTERNAL_API_PATH=http://plone:8080/Plone" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend start-ci'''
frontend = sh script:'''docker exec --workdir=/app/src/addons/${GIT_NAME} $IMAGE_NAME-cypress make check-ci''', returnStatus: true
if ( frontend != 0 ) {
sh '''docker logs $IMAGE_NAME-cypress; exit 1'''
}

sh '''timeout -s 9 1800 docker exec --workdir=/app/src/addons/${GIT_NAME} $IMAGE_NAME-cypress make cypress-ci'''
} finally {
try {
if ( frontend == 0 ) {
sh '''rm -rf cypress-videos cypress-results cypress-coverage cypress-screenshots'''
sh '''mkdir -p cypress-videos cypress-results cypress-coverage cypress-screenshots'''
videos = sh script: '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/cypress/videos cypress-videos/''', returnStatus: true
Expand All @@ -189,6 +195,7 @@ pipeline {
sh '''for file in $(find cypress-results -name *.xml); do if [ $(grep -E 'failures="[1-9].*"' $file | wc -l) -eq 0 ]; then testname=$(grep -E 'file=.*failures="0"' $file | sed 's#.* file=".*\\/\\(.*\\.[jsxt]\\+\\)" time.*#\\1#' ); rm -f cypress-videos/videos/$testname.mp4; fi; done'''
archiveArtifacts artifacts: 'cypress-videos/**/*.mp4', fingerprint: true, allowEmptyArchive: true
}
}
} finally {
catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
junit testResults: 'cypress-results/**/*.xml', allowEmptyResults: true
Expand Down
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ cypress-open: ## Open cypress integration tests

.PHONY: cypress-run
cypress-run: ## Run cypress integration tests
CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}" NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress run --browser chromium
CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}" NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress run

.PHONY: test
test: ## Run jest tests
Expand Down Expand Up @@ -155,8 +155,11 @@ start-ci:
cd ../..
yarn start

.PHONY: check-ci
check-ci:
$(NODE_MODULES)/.bin/wait-on -t 240000 http://localhost:3000

.PHONY: cypress-ci
cypress-ci:
$(NODE_MODULES)/.bin/wait-on -t 240000 http://localhost:3000
NODE_ENV=development make cypress-run

CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}" NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress run --browser chromium
20 changes: 16 additions & 4 deletions jest-addon.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require('dotenv').config({ path: __dirname + '/.env' })

module.exports = {
testMatch: ['**/src/addons/**/?(*.)+(spec|test).[jt]s?(x)'],
collectCoverageFrom: [
Expand All @@ -9,16 +11,21 @@ module.exports = {
'@plone/volto/cypress': '<rootDir>/node_modules/@plone/volto/cypress',
'@plone/volto/babel': '<rootDir>/node_modules/@plone/volto/babel',
'@plone/volto/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
'@package/(.*)$': '<rootDir>/src/$1',
'@root/(.*)$': '<rootDir>/src/$1',
'@package/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
'@root/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
'@plone/volto-quanta/(.*)$': '<rootDir>/src/addons/volto-quanta/src/$1',
'@eeacms/(.*?)/(.*)$': '<rootDir>/node_modules/@eeacms/$1/src/$2',
'@plone/volto-slate':
'@plone/volto-slate$':
'<rootDir>/node_modules/@plone/volto/packages/volto-slate/src',
'@plone/volto-slate/(.*)$':
'<rootDir>/node_modules/@plone/volto/packages/volto-slate/src/$1',
'~/(.*)$': '<rootDir>/src/$1',
'load-volto-addons':
'<rootDir>/node_modules/@plone/volto/jest-addons-loader.js',
},
transformIgnorePatterns: [
'/node_modules/(?!(@plone|@root|@package|@eeacms)/).*/',
],
transform: {
'^.+\\.js(x)?$': 'babel-jest',
'^.+\\.(png)$': 'jest-file',
Expand All @@ -33,4 +40,9 @@ module.exports = {
statements: 5,
},
},
};
...(process.env.JEST_USE_SETUP === 'ON' && {
setupFilesAfterEnv: [
'<rootDir>/node_modules/@eeacms/volto-block-style/jest.setup.js',
],
}),
}
45 changes: 45 additions & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { jest } from '@jest/globals';
import configureStore from 'redux-mock-store';

const mockStore = configureStore();

global.store = mockStore({
intl: {
locale: 'en',
messages: {},
},
content: {
create: {},
subrequests: [],
},
connected_data_parameters: {},
});

const mockSemanticComponents = jest.requireActual('semantic-ui-react');
const mockComponents = jest.requireActual('@plone/volto/components');

jest.mock('semantic-ui-react', () => ({
...mockSemanticComponents,
Popup: ({ content, trigger }) => {
return (
<div className="popup">
<div className="trigger">{trigger}</div>
<div className="content">{content}</div>
</div>
);
},
}));

jest.doMock('@plone/volto/components', () => {
return {
__esModule: true,
...mockComponents,
SidebarPortal: ({ children }) => <div id="sidebar">{children}</div>,
};
});

global.fetch = jest.fn(() =>
Promise.resolve({
json: () => Promise.resolve({}),
}),
);
Loading

0 comments on commit 5f43419

Please sign in to comment.