Skip to content

Commit

Permalink
Merge pull request #7 from eea/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
avoinea committed Jun 12, 2023
2 parents dde7490 + b2884ac commit 08a1156
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 5 deletions.
23 changes: 22 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,36 @@ 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).

### [1.1.1](https://github.com/eea/volto-widget-theme-picker/compare/1.1.0...1.1.1) - 12 June 2023

#### :hammer_and_wrench: Others

- test: jest should look for addons in node_modules Refs #253277 [valentinab25 - [`e1ce5b5`](https://github.com/eea/volto-widget-theme-picker/commit/e1ce5b55affe732c5637ee1e092fd304b8ee752e)]
- test: Add unit tests for ThemePicker - refs #253277 [ana-oprea - [`af101a9`](https://github.com/eea/volto-widget-theme-picker/commit/af101a9151b86078a5d6e1f37656ac1f56446f03)]
- test: Fix test config, coverage Refs #253277 [valentinab25 - [`3ff76f4`](https://github.com/eea/volto-widget-theme-picker/commit/3ff76f4002645a834c5d45c2bbb0683716cba2e4)]
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`855f029`](https://github.com/eea/volto-widget-theme-picker/commit/855f0291af4cc38ecfbbee70ffa0a799b82bda6d)]
- Add Sonarqube tag using industry-frontend addons list [EEA Jenkins - [`6bcac86`](https://github.com/eea/volto-widget-theme-picker/commit/6bcac86da76ad9e42bf99db93459be408bd48f52)]
### [1.1.0](https://github.com/eea/volto-widget-theme-picker/compare/1.0.3...1.1.0) - 27 March 2023

#### :hammer_and_wrench: Others

- Release 1.1.0 [Alin Voinea - [`6ff00dd`](https://github.com/eea/volto-widget-theme-picker/commit/6ff00dd300f71c14f76a66d305392437af2530ec)]
- Add Sonarqube tag using marine-frontend addons list [EEA Jenkins - [`33b090c`](https://github.com/eea/volto-widget-theme-picker/commit/33b090c443f5e4e5dbebf0c5946865fcad006584)]
- Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`b647ad7`](https://github.com/eea/volto-widget-theme-picker/commit/b647ad7fd68de0f700fe7f1af02f294990d48db7)]
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`8c07ffe`](https://github.com/eea/volto-widget-theme-picker/commit/8c07ffe86318c85ba97d5cb0a8ae7b8072cc59b5)]
- Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`405feb5`](https://github.com/eea/volto-widget-theme-picker/commit/405feb55714d982adc0c6ba4df4db388291835f2)]
- Add Sonarqube tag using forests-frontend addons list [EEA Jenkins - [`23d2411`](https://github.com/eea/volto-widget-theme-picker/commit/23d2411fc2fbf7bc5e4505fc05f934f0e9b4744b)]
- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`43e5107`](https://github.com/eea/volto-widget-theme-picker/commit/43e51073f63b0b911bd030c5cd03965ce4ffded1)]
- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`b064246`](https://github.com/eea/volto-widget-theme-picker/commit/b064246f48be642af450b2d1d3db17acf57490da)]
- Add Sonarqube tag using demo-kitkat-frontend addons list [EEA Jenkins - [`8667727`](https://github.com/eea/volto-widget-theme-picker/commit/8667727f125b2fdd57b938bfa082313afcfc2cc7)]
- Add Sonarqube tag using ims-frontend addons list [EEA Jenkins - [`bf4a677`](https://github.com/eea/volto-widget-theme-picker/commit/bf4a67766c52b5d5d52f0e5c14556c4ec0b30938)]
- Add Sonarqube tag using bise-frontend addons list [EEA Jenkins - [`9ccf553`](https://github.com/eea/volto-widget-theme-picker/commit/9ccf553f23ab84ad52ab9b1c28138ddda45ec081)]
### [1.0.3](https://github.com/eea/volto-widget-theme-picker/compare/1.0.2...1.0.3) - 8 February 2023

#### :hammer_and_wrench: Others

- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`de3314a`](https://github.com/eea/volto-widget-theme-picker/commit/de3314a716dae4d38cac81f4fa6733d904712d07)]
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`c576cc7`](https://github.com/eea/volto-widget-theme-picker/commit/c576cc79bc481cf67c6b592e4baea6477d07e5ae)]
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`19d97ad`](https://github.com/eea/volto-widget-theme-picker/commit/19d97ad979ea739f001159765ea529bf647ab022)]
- back to no theme / undefined [andreiggr - [`e046c5f`](https://github.com/eea/volto-widget-theme-picker/commit/e046c5fb332180a4dd43d07512284c6be8d8a0ed)]
### [1.0.2](https://github.com/eea/volto-widget-theme-picker/compare/1.0.1...1.0.2) - 3 February 2023

Expand Down
3 changes: 2 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pipeline {
environment {
GIT_NAME = "volto-widget-theme-picker"
NAMESPACE = "@eeacms"
SONARQUBE_TAGS = "volto.eea.europa.eu,demo-www.eea.europa.eu,prod-www.eea.europa.eu,biodiversity.europa.eu,www.eea.europa.eu-ims,demo-kitkat.dev2aws.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,climate-advisory-board.europa.eu,forest.eea.europa.eu,climate-adapt.eea.europa.eu,www.eea.europa.eu-en,circularity.eea.europa.eu,water.europa.eu-marine"
SONARQUBE_TAGS = "volto.eea.europa.eu,demo-www.eea.europa.eu,biodiversity.europa.eu,www.eea.europa.eu-ims,clmsdemo.devel6cph.eea.europa.eu,climate-advisory-board.europa.eu,forest.eea.europa.eu,climate-adapt.eea.europa.eu,www.eea.europa.eu-en,water.europa.eu-marine,industry.eea.europa.eu"
DEPENDENCIES = ""
VOLTO = ""
}
Expand Down Expand Up @@ -188,6 +188,7 @@ pipeline {
def nodeJS = tool 'NodeJS';
withSonarQubeEnv('Sonarqube') {
sh '''sed -i "s#/opt/frontend/my-volto-project/src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info'''
sh '''sed -i "s#src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info'''
sh "export PATH=${scannerHome}/bin:${nodeJS}/bin:$PATH; 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"
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'''
}
Expand Down
4 changes: 2 additions & 2 deletions jest-addon.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ module.exports = {
'!src/**/*.d.ts',
],
moduleNameMapper: {
'\\.(css|less|scss|sass)$': 'identity-obj-proxy',
'@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',
'@plone/volto-quanta/(.*)$': '<rootDir>/src/addons/volto-quanta/src/$1',
'@eeacms/(.*?)/(.*)$': '<rootDir>/src/addons/$1/src/$2',
'@eeacms/(.*?)/(.*)$': '<rootDir>/node_modules/@eeacms/$1/src/$2',
'@plone/volto-slate':
'<rootDir>/node_modules/@plone/volto/packages/volto-slate/src',
'~/(.*)$': '<rootDir>/src/$1',
'load-volto-addons':
'<rootDir>/node_modules/@plone/volto/jest-addons-loader.js',
'\\.(css|less|scss|sass)$': 'identity-obj-proxy',
},
transform: {
'^.+\\.js(x)?$': 'babel-jest',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eeacms/volto-widget-theme-picker",
"version": "1.1.0",
"version": "1.1.1",
"description": "@eeacms/volto-widget-theme-picker: Volto add-on",
"main": "src/index.js",
"author": "European Environment Agency: IDM2 A-Team",
Expand Down
50 changes: 50 additions & 0 deletions src/Widgets/ThemePicker.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React from 'react';
import { render, fireEvent } from '@testing-library/react';
import renderer from 'react-test-renderer';
import ThemePicker from './ThemePicker';

describe('ThemePicker', () => {
const props = {
id: 'test-theme-picker',
title: 'Test Theme Picker',
value: 'color1',
colors: [
{ name: 'color1', label: 'Color 1' },
{ name: 'color2', label: 'Color 2' },
],
onChange: () => {},
};

it('renders correctly', () => {
const component = renderer.create(<ThemePicker {...props} />);

const json = component.toJSON();
expect(json).toMatchSnapshot();
const label = component.toJSON().children[0].children[0].children[0]
.children[0].children[0];
const buttons = component.toJSON().children[0].children[0].children[0]
.children[0].children[1];

expect(label.children[0]).toBe('Test Theme Picker');
expect(buttons.children[0].props.className).toContain('color1');
expect(buttons.children[1].props.className).toContain('color2');
});

it('calls onChange with correct value when a color button is clicked', () => {
const onChange = jest.fn();
const { getByTitle } = render(
<ThemePicker {...props} onChange={onChange} />,
);

fireEvent.click(getByTitle('Color 2'));
expect(onChange).toHaveBeenCalledWith('test-theme-picker', 'color2');
});

it('does not render when no colors are provided', () => {
const component = renderer.create(<ThemePicker {...props} colors={[]} />);

let json = component.toJSON();
expect(json).toMatchSnapshot();
expect(json).toBeNull();
});
});
48 changes: 48 additions & 0 deletions src/Widgets/__snapshots__/ThemePicker.test.jsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`ThemePicker does not render when no colors are provided 1`] = `null`;

exports[`ThemePicker renders correctly 1`] = `
<div
className="inline field"
id="field-test-theme-picker"
>
<div
className="ui grid"
>
<div
className="row"
>
<div
className="middle aligned twelve wide column color-picker-widget"
>
<div
className="wrapper"
>
<label
htmlFor="field-test-theme-picker"
>
Test Theme Picker
</label>
<div
className="buttons"
>
<button
aria-label="Color 1"
className="ui active circular button color1"
onClick={[Function]}
title="Color 1"
/>
<button
aria-label="Color 2"
className="ui circular button color2"
onClick={[Function]}
title="Color 2"
/>
</div>
</div>
</div>
</div>
</div>
</div>
`;

0 comments on commit 08a1156

Please sign in to comment.