Skip to content

Commit

Permalink
Merge pull request #47 from eea/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
avoinea committed Nov 24, 2023
2 parents 8849acf + dd726f2 commit 0e4f8af
Show file tree
Hide file tree
Showing 15 changed files with 377 additions and 156 deletions.
27 changes: 25 additions & 2 deletions CHANGELOG.md
Expand Up @@ -4,11 +4,34 @@ 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.3.4](https://github.com/eea/volto-group-block/compare/6.3.3...6.3.4) - 19 October 2023
### [6.3.5](https://github.com/eea/volto-group-block/compare/6.3.4...6.3.5) - 24 November 2023

#### :bug: Bug Fixes

- fix: Pass location to RenderBlocks [kreafox - [`87ae0df`](https://github.com/eea/volto-group-block/commit/87ae0dff17cb508466b17f959e99d62c6ab69a60)]

#### :house: Internal changes

- chore: [JENKINS] Refactor automated testing [valentinab25 - [`616f6eb`](https://github.com/eea/volto-group-block/commit/616f6ebe0385d82a827c6679eabdcf4e92a18c11)]

#### :hammer_and_wrench: Others

- Update README.md [ana-oprea - [`2a956b7`](https://github.com/eea/volto-group-block/commit/2a956b73cf19c1d0ef173bf647fb5fa8d698fb83)]
- test: update cypress test [kreafox - [`f84a866`](https://github.com/eea/volto-group-block/commit/f84a866a313f30f94fd1c0a41737face83dac3e0)]
- more tests [kreafox - [`7f93774`](https://github.com/eea/volto-group-block/commit/7f93774774119fe1fa5e8266e8ec700cd2bc9427)]
- test: fix bug reported by sonarqube, add more tests [kreafox - [`3599b0f`](https://github.com/eea/volto-group-block/commit/3599b0f7edf22037729c52e35f29d8919e466e5f)]
- test: add more tests [kreafox - [`0c5fc63`](https://github.com/eea/volto-group-block/commit/0c5fc63866d6590e64051483ee8ec97e548d0b14)]
- test: update jest tests [kreafox - [`88d9945`](https://github.com/eea/volto-group-block/commit/88d9945c6f338992247232325a25ea9795c2fe42)]
- test: increase coverage [kreafox - [`081a2d0`](https://github.com/eea/volto-group-block/commit/081a2d0bb001c980d2023bcce81830d71d23aeca)]
- Prettier [kreafox - [`0c5d2d1`](https://github.com/eea/volto-group-block/commit/0c5d2d1a494489663cc97c5dc0f4ad13c4b67c8d)]
- test: mock useLocation [kreafox - [`746887f`](https://github.com/eea/volto-group-block/commit/746887fa0e778f2d4cbe86661fc8c38c8a4bafb5)]
- test: mock useLocation [kreafox - [`a360401`](https://github.com/eea/volto-group-block/commit/a360401b8ee05e9cb54b253b0e605d0a040c8f78)]
- test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`25030fb`](https://github.com/eea/volto-group-block/commit/25030fbd69108f90df02130e5010e56398941ad2)]
- test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`1517dbb`](https://github.com/eea/volto-group-block/commit/1517dbb81cf9128752d835ae59dc22b251f4b035)]
- test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`b0ba5f9`](https://github.com/eea/volto-group-block/commit/b0ba5f9c6d37526411a7a984595ac624401f8ac5)]
- test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`8dbdfeb`](https://github.com/eea/volto-group-block/commit/8dbdfeb89fe53c6dc2f476b183a53c9266ab2bdf)]
- test: [JENKINS] Improve cypress time [valentinab25 - [`d0324f4`](https://github.com/eea/volto-group-block/commit/d0324f4aad6d94233ca8ce3645ca5162f39d9834)]
### [6.3.4](https://github.com/eea/volto-group-block/compare/6.3.3...6.3.4) - 22 October 2023

### [6.3.3](https://github.com/eea/volto-group-block/compare/6.3.2...6.3.3) - 17 October 2023

#### :house: Internal changes
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1
ARG VOLTO_VERSION
FROM plone/frontend-builder:${VOLTO_VERSION}
FROM eeacms/frontend-builder:${VOLTO_VERSION}

ARG ADDON_NAME
ARG ADDON_PATH
Expand Down
294 changes: 160 additions & 134 deletions Jenkinsfile

Large diffs are not rendered by default.

35 changes: 33 additions & 2 deletions Makefile
Expand Up @@ -50,6 +50,11 @@ VOLTO_VERSION?=16
ADDON_PATH="${DIR}"
ADDON_NAME="@eeacms/${ADDON_PATH}"
DOCKER_COMPOSE=PLONE_VERSION=${PLONE_VERSION} VOLTO_VERSION=${VOLTO_VERSION} ADDON_NAME=${ADDON_NAME} ADDON_PATH=${ADDON_PATH} docker compose
RAZZLE_INTERNAL_API_PATH?="http://localhost:8080/Plone"
RAZZLE_DEV_PROXY_API_PATH?="${RAZZLE_INTERNAL_API_PATH}"
CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}"



# Top-level targets
.PHONY: all
Expand Down Expand Up @@ -77,11 +82,11 @@ shell: ## Start a shell in the frontend container

.PHONY: cypress-open
cypress-open: ## Open cypress integration tests
NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress open
CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}" NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress open

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

.PHONY: test
test: ## Run jest tests
Expand Down Expand Up @@ -129,3 +134,29 @@ i18n: ## i18n
help: ## Show this help.
@echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)"
head -n 14 Makefile

.PHONY: ci-fix
ci-fix:
echo "Running lint-fix"
make lint-fix
echo "Running prettier-fix"
make prettier-fix
echo "Running stylelint-fix"
make stylelint-fix

.PHONY: test-ci
test-ci:
cd /app
RAZZLE_JEST_CONFIG=src/addons/${ADDON_PATH}/jest-addon.config.js CI=true yarn test src/addons/${ADDON_PATH}/src --watchAll=false --reporters=default --reporters=jest-junit --collectCoverage --coverageReporters lcov cobertura text

.PHONY: start-ci
start-ci:
cp .coverage.babel.config.js /app/babel.config.js
cd ../..
yarn start

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

6 changes: 3 additions & 3 deletions cypress.config.js
Expand Up @@ -2,12 +2,12 @@ const { defineConfig } = require('cypress');

module.exports = defineConfig({
viewportWidth: 1280,
defaultCommandTimeout: 5000,
defaultCommandTimeout: 8888,
chromeWebSecurity: false,
reporter: 'junit',
video: true,
video: false,
retries: {
runMode: 1,
runMode: 2,
openMode: 0,
},
reporterOptions: {
Expand Down
23 changes: 22 additions & 1 deletion cypress/e2e/02-dexterity-controlpanel-layout.cy.js
Expand Up @@ -36,6 +36,25 @@ describe('ControlPanel: Dexterity Content-Types Layout', () => {
cy.get('.content.active.common .button.group')
.contains('Section (Group)')
.click({ force: true });

cy.get('legend').contains('Section').click();
cy.get('#sidebar-settings .field-wrapper-title input').type(
'Intro section',
);
cy.get('#sidebar-settings .field-wrapper-placeholder input').type(
'Highlighted description',
);
cy.get('#sidebar-settings .field-wrapper-maxChars').type('250');
cy.get(
'#sidebar-settings .field-wrapper-allowedBlocks .react-select__value-container',
)
.click()
.type('Image{enter}');
cy.get(
'#sidebar-settings .field-wrapper-ignoreSpaces .ui.checkbox',
).click();
cy.get('.block-editor-group .blocks-form .block-editor-slate').click();

cy.get('.ui.basic.icon.button.group-block-add-button:visible').click();
cy.get('.blocks-chooser .title').contains('Media').click({ force: true });
cy.get('.content.active.media .button.image')
Expand Down Expand Up @@ -64,7 +83,9 @@ describe('ControlPanel: Dexterity Content-Types Layout', () => {
cy.getSlateTitle().type('My First Book');
cy.get('.documentFirstHeading').contains('My First Book');

cy.get('.section-block .text-slate-editor-inner').click().type('My description');
cy.get('.section-block .text-slate-editor-inner')
.click()
.type('My description');

cy.get('#toolbar-save').click();
cy.get('.documentFirstHeading').contains('My First Book');
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/e2e.js
Expand Up @@ -36,7 +36,7 @@ export const slateBeforeEach = (contentType = 'Document') => {
});
cy.visit('/cypress/my-page');
cy.waitForResourceToLoad('@navigation');
cy.waitForResourceToLoad('@breadcrumbs');
// cy.waitForResourceToLoad('@breadcrumbs');
cy.waitForResourceToLoad('@actions');
cy.waitForResourceToLoad('@types');
cy.waitForResourceToLoad('my-page');
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@eeacms/volto-group-block",
"version": "6.3.4",
"version": "6.3.5",
"description": "volto-group-block: Volto block to be used to group other blocks",
"main": "src/index.js",
"author": "European Environment Agency: IDM2 A-Team",
Expand Down
12 changes: 2 additions & 10 deletions src/components/manage/Blocks/Group/CounterComponent.jsx
Expand Up @@ -7,15 +7,7 @@ import { visitBlocks } from '@plone/volto/helpers/Blocks/Blocks';
import { serializeNodesToText } from '@plone/volto-slate/editor/render';
import delightedSVG from '@plone/volto/icons/delighted.svg';
import dissatisfiedSVG from '@plone/volto/icons/dissatisfied.svg';

const countCharsWithoutSpaces = (paragraph) => {
const regex = /[^\s\\]/g;
return (paragraph.match(regex) || []).length;
};

const countCharsWithSpaces = (paragraph) => {
return paragraph?.length || 0;
};
import { countCharsWithoutSpaces, countCharsWithSpaces } from './utils';

const countTextInEachBlock = (countTextIn, ignoreSpaces, groupCharCount) => ([
id,
Expand All @@ -36,7 +28,7 @@ const countTextInEachBlock = (countTextIn, ignoreSpaces, groupCharCount) => ([
};

const countTextInBlocks = (blocksObject, ignoreSpaces, maxChars) => {
const { countTextIn } = config.blocks?.blocksConfig?.group;
const { countTextIn } = config.blocks?.blocksConfig?.group || [];
// use obj ref to update value - if you send number it will not be updated
const groupCharCount = { value: 0 };

Expand Down
8 changes: 7 additions & 1 deletion src/components/manage/Blocks/Group/DefaultBody.jsx
@@ -1,10 +1,12 @@
import { Button } from 'semantic-ui-react';
import { BlocksForm, Icon, RenderBlocks } from '@plone/volto/components';
import EditBlockWrapper from './EditBlockWrapper';
import { useLocation } from 'react-router-dom';

import helpSVG from '@plone/volto/icons/help.svg';

const GroupBlockDefaultBody = (props) => {
const location = useLocation();
const {
block,
data,
Expand Down Expand Up @@ -98,7 +100,11 @@ const GroupBlockDefaultBody = (props) => {
)}
</BlocksForm>
) : (
<RenderBlocks metadata={metadata} content={data?.data || {}} />
<RenderBlocks
location={location}
metadata={metadata}
content={data?.data || {}}
/>
);
};

Expand Down
75 changes: 75 additions & 0 deletions src/components/manage/Blocks/Group/DefaultBody.test.jsx
@@ -0,0 +1,75 @@
import React from 'react';
import { render } from '@testing-library/react';
import { Provider } from 'react-intl-redux';
import DefaultBody from './DefaultBody';
import configureStore from 'redux-mock-store';
import '@testing-library/jest-dom/extend-expect';

jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useLocation: () => ({
pathname: '/',
hash: '',
search: '',
}),
}));

jest.mock('@plone/volto/components', () => ({
BlocksForm: jest.fn(() => <div className="blocks-form">RenderBlocks</div>),
RenderBlocks: jest.fn(() => <div>RenderBlocks</div>),
}));

const mockStore = configureStore();
const store = mockStore({
intl: {
locale: 'en',
messages: {},
},
});

describe('DefaultBody', () => {
it('renders children', () => {
const props = {
data: {
variation: {},
},
metadata: {},
properties: {},
variation: {},
};

const { getByText } = render(
<Provider store={store}>
<DefaultBody {...props} />
</Provider>,
);
expect(getByText('RenderBlocks')).toBeInTheDocument();
});
});

describe('DefaultBody Edit', () => {
it('renders children', () => {
const props = {
isEditMode: true,
data: {
variation: {},
allowedBlocks: ['listing'],
},
metadata: {},
properties: {},
variation: {},
onSelectBlock: jest.fn(),
onDeleteBlock: jest.fn(),
onMutateBlock: jest.fn(),
onInsertBlock: jest.fn(),
selected: true,
};

const { getByText } = render(
<Provider store={store}>
<DefaultBody {...props} />
</Provider>,
);
expect(getByText('RenderBlocks')).toBeInTheDocument();
});
});
9 changes: 9 additions & 0 deletions src/components/manage/Blocks/Group/Edit.test.jsx
Expand Up @@ -30,6 +30,15 @@ jest.mock('@plone/volto/helpers', () => ({
getBlocksLayoutFieldname: jest.fn(),
}));

jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useLocation: () => ({
pathname: '/',
hash: '',
search: '',
}),
}));

describe('Edit', () => {
const onChangeBlock = jest.fn();
const onChangeField = jest.fn();
Expand Down
15 changes: 15 additions & 0 deletions src/components/manage/Blocks/Group/View.test.jsx
Expand Up @@ -14,6 +14,15 @@ jest.mock('@plone/volto/helpers', () => ({
withBlockExtensions: jest.fn((Component) => Component),
}));

jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useLocation: () => ({
pathname: '/',
hash: '',
search: '',
}),
}));

describe('View', () => {
it('should render without crashing', () => {
const props = {
Expand Down Expand Up @@ -66,12 +75,18 @@ describe('View', () => {
metadata: { meta: 'data' },
properties: { prop: 'erty' },
variation: {},
location: {
pathname: '/',
search: '',
hash: '',
},
};
render(<View {...props} />);
expect(RenderBlocks).toHaveBeenCalledWith(
expect.objectContaining({
metadata: props.metadata,
content: props.data.data,
location: props.location,
}),
{},
);
Expand Down
8 changes: 8 additions & 0 deletions src/components/manage/Blocks/Group/utils.js
@@ -0,0 +1,8 @@
export function countCharsWithoutSpaces(paragraph) {
const regex = /[^\s\\]/g;
return (paragraph.match(regex) || []).length;
}

export function countCharsWithSpaces(paragraph) {
return paragraph?.length || 0;
}
15 changes: 15 additions & 0 deletions src/components/manage/Blocks/Group/utils.test.js
@@ -0,0 +1,15 @@
import { countCharsWithoutSpaces, countCharsWithSpaces } from './utils';

describe('countCharsWithoutSpaces', () => {
it('should return number of charts without spaces', () => {
const paragraph = 'Lorem ipsum dolor sit';
expect(countCharsWithoutSpaces(paragraph)).toBe(18);
});
});

describe('countCharsWithSpaces', () => {
it('should return number of charts with spaces', () => {
const paragraph = 'Lorem ipsum dolor sit';
expect(countCharsWithSpaces(paragraph)).toBe(21);
});
});

0 comments on commit 0e4f8af

Please sign in to comment.