From ef5d95a32539340882b66ef69c79f400d3ee3c71 Mon Sep 17 00:00:00 2001 From: EEA Jenkins Date: Fri, 18 Nov 2022 09:16:59 +0200 Subject: [PATCH 01/13] Add Sonarqube tag using demo-kitkat-frontend addons list --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3fe6b3e..f4e8ca4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,7 +4,7 @@ pipeline { environment { GIT_NAME = "volto-block-image-cards" NAMESPACE = "@eeacms" - SONARQUBE_TAGS = "volto.eea.europa.eu,biodiversity.europa.eu,climate-energy.eea.europa.eu,www.eea.europa.eu-ims,sustainability.eionet.europa.eu,forest.eea.europa.eu,clms.land.copernicus.eu,industry.eea.europa.eu,water.europa.eu-freshwater,demo-www.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,circularity.eea.europa.eu,prod-www.eea.europa.eu,water.europa.eu-marine" + SONARQUBE_TAGS = "volto.eea.europa.eu,biodiversity.europa.eu,climate-energy.eea.europa.eu,www.eea.europa.eu-ims,sustainability.eionet.europa.eu,forest.eea.europa.eu,clms.land.copernicus.eu,industry.eea.europa.eu,water.europa.eu-freshwater,demo-www.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,circularity.eea.europa.eu,prod-www.eea.europa.eu,water.europa.eu-marine,demo-kitkat.dev2aws.eea.europa.eu" DEPENDENCIES = "" VOLTO = "alpha" } From 20893a1fcb0e538ac344feb1d296a12d6af69e2d Mon Sep 17 00:00:00 2001 From: Alin Voinea Date: Fri, 25 Nov 2022 15:07:06 +0200 Subject: [PATCH 02/13] yarn 3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9595bd3..4612529 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,8 @@ "slick-carousel": "^1.8.1" }, "devDependencies": { - "@plone/scripts": "*", "@cypress/code-coverage": "^3.10.0", + "@plone/scripts": "*", "babel-plugin-transform-class-properties": "^6.24.1", "md5": "^2.3.0" }, From 252e88f0b91d35fb5c336223c90db030c4058b4b Mon Sep 17 00:00:00 2001 From: EEA Jenkins Date: Tue, 13 Dec 2022 14:49:52 +0200 Subject: [PATCH 03/13] Add Sonarqube tag using cca-frontend addons list --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index f4e8ca4..6f71a98 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,7 +4,7 @@ pipeline { environment { GIT_NAME = "volto-block-image-cards" NAMESPACE = "@eeacms" - SONARQUBE_TAGS = "volto.eea.europa.eu,biodiversity.europa.eu,climate-energy.eea.europa.eu,www.eea.europa.eu-ims,sustainability.eionet.europa.eu,forest.eea.europa.eu,clms.land.copernicus.eu,industry.eea.europa.eu,water.europa.eu-freshwater,demo-www.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,circularity.eea.europa.eu,prod-www.eea.europa.eu,water.europa.eu-marine,demo-kitkat.dev2aws.eea.europa.eu" + SONARQUBE_TAGS = "volto.eea.europa.eu,biodiversity.europa.eu,climate-energy.eea.europa.eu,www.eea.europa.eu-ims,sustainability.eionet.europa.eu,forest.eea.europa.eu,clms.land.copernicus.eu,industry.eea.europa.eu,water.europa.eu-freshwater,demo-www.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,circularity.eea.europa.eu,prod-www.eea.europa.eu,water.europa.eu-marine,demo-kitkat.dev2aws.eea.europa.eu,climate-adapt.eea.europa.eu" DEPENDENCIES = "" VOLTO = "alpha" } From 210bb591a1ab2688d6ee614535c718ca974103f0 Mon Sep 17 00:00:00 2001 From: Alin Voinea Date: Fri, 16 Dec 2022 17:51:30 +0200 Subject: [PATCH 04/13] test(Jenkins): Run tests and cypress with latest canary @plone/volto --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6f71a98..8c90eec 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,7 +6,7 @@ pipeline { NAMESPACE = "@eeacms" SONARQUBE_TAGS = "volto.eea.europa.eu,biodiversity.europa.eu,climate-energy.eea.europa.eu,www.eea.europa.eu-ims,sustainability.eionet.europa.eu,forest.eea.europa.eu,clms.land.copernicus.eu,industry.eea.europa.eu,water.europa.eu-freshwater,demo-www.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,circularity.eea.europa.eu,prod-www.eea.europa.eu,water.europa.eu-marine,demo-kitkat.dev2aws.eea.europa.eu,climate-adapt.eea.europa.eu" DEPENDENCIES = "" - VOLTO = "alpha" + VOLTO = "" } stages { From dcd39c33387fb9aa93f3555e069bd064d8c9a37c Mon Sep 17 00:00:00 2001 From: EEA Jenkins Date: Tue, 20 Dec 2022 16:33:35 +0200 Subject: [PATCH 05/13] Add Sonarqube tag using advisory-board-frontend addons list --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8c90eec..d6354ba 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,7 +4,7 @@ pipeline { environment { GIT_NAME = "volto-block-image-cards" NAMESPACE = "@eeacms" - SONARQUBE_TAGS = "volto.eea.europa.eu,biodiversity.europa.eu,climate-energy.eea.europa.eu,www.eea.europa.eu-ims,sustainability.eionet.europa.eu,forest.eea.europa.eu,clms.land.copernicus.eu,industry.eea.europa.eu,water.europa.eu-freshwater,demo-www.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,circularity.eea.europa.eu,prod-www.eea.europa.eu,water.europa.eu-marine,demo-kitkat.dev2aws.eea.europa.eu,climate-adapt.eea.europa.eu" + SONARQUBE_TAGS = "volto.eea.europa.eu,biodiversity.europa.eu,climate-energy.eea.europa.eu,www.eea.europa.eu-ims,sustainability.eionet.europa.eu,forest.eea.europa.eu,clms.land.copernicus.eu,industry.eea.europa.eu,water.europa.eu-freshwater,demo-www.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,circularity.eea.europa.eu,prod-www.eea.europa.eu,water.europa.eu-marine,demo-kitkat.dev2aws.eea.europa.eu,climate-adapt.eea.europa.eu,climate-advisory-board.devel4cph.eea.europa.eu" DEPENDENCIES = "" VOLTO = "" } From e8f56df77f823328adaebac712544ea3907810d3 Mon Sep 17 00:00:00 2001 From: EEA Jenkins Date: Mon, 9 Jan 2023 17:42:15 +0200 Subject: [PATCH 06/13] Add Sonarqube tag using advisory-board-frontend addons list --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index d6354ba..8d9b6b9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,7 +4,7 @@ pipeline { environment { GIT_NAME = "volto-block-image-cards" NAMESPACE = "@eeacms" - SONARQUBE_TAGS = "volto.eea.europa.eu,biodiversity.europa.eu,climate-energy.eea.europa.eu,www.eea.europa.eu-ims,sustainability.eionet.europa.eu,forest.eea.europa.eu,clms.land.copernicus.eu,industry.eea.europa.eu,water.europa.eu-freshwater,demo-www.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,circularity.eea.europa.eu,prod-www.eea.europa.eu,water.europa.eu-marine,demo-kitkat.dev2aws.eea.europa.eu,climate-adapt.eea.europa.eu,climate-advisory-board.devel4cph.eea.europa.eu" + SONARQUBE_TAGS = "volto.eea.europa.eu,biodiversity.europa.eu,climate-energy.eea.europa.eu,www.eea.europa.eu-ims,sustainability.eionet.europa.eu,forest.eea.europa.eu,clms.land.copernicus.eu,industry.eea.europa.eu,water.europa.eu-freshwater,demo-www.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,circularity.eea.europa.eu,prod-www.eea.europa.eu,water.europa.eu-marine,demo-kitkat.dev2aws.eea.europa.eu,climate-adapt.eea.europa.eu,climate-advisory-board.devel4cph.eea.europa.eu,climate-advisory-board.europa.eu" DEPENDENCIES = "" VOLTO = "" } From 0b2ad7816bfd5d06dcbe786ef35e2bcc32754e5b Mon Sep 17 00:00:00 2001 From: tedw87 Date: Fri, 20 Jan 2023 16:46:34 +0200 Subject: [PATCH 07/13] improve code quality --- src/ImageCards/CommonAssets/schema.jsx | 2 +- src/ImageCards/ImageCardsEdit.jsx | 2 +- src/ImageCards/ResponsiveContainer.jsx | 2 +- src/ImageCards/displays/Cards.jsx | 8 ++++++-- src/ImageCards/displays/Carousel.jsx | 10 +++++++--- src/ImageCards/displays/DiscreetCarousel.jsx | 15 +++++++-------- src/ImageCards/displays/RoundTiled.jsx | 8 ++++++-- 7 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/ImageCards/CommonAssets/schema.jsx b/src/ImageCards/CommonAssets/schema.jsx index 78d8c62..853ada5 100644 --- a/src/ImageCards/CommonAssets/schema.jsx +++ b/src/ImageCards/CommonAssets/schema.jsx @@ -1,7 +1,7 @@ import React from 'react'; // See https://react-slick.neostack.com/docs/api -export const CommonCarouselschemaExtender = ({ data, schema, intl }) => { +export const CommonCarouselschemaExtender = ({ data }) => { return { fieldsets: [ { diff --git a/src/ImageCards/ImageCardsEdit.jsx b/src/ImageCards/ImageCardsEdit.jsx index 5c994de..302bf11 100644 --- a/src/ImageCards/ImageCardsEdit.jsx +++ b/src/ImageCards/ImageCardsEdit.jsx @@ -19,7 +19,7 @@ const tweakSchema = (schema, data) => { const CardsEdit = (props) => { const { selected, onChangeBlock, data = {}, block } = props; const basicSchema = ImageCardSchema(props); - const schema = tweakSchema(basicSchema, props.data, props.intl); + const schema = tweakSchema(basicSchema, props.data); return ( <> diff --git a/src/ImageCards/ResponsiveContainer.jsx b/src/ImageCards/ResponsiveContainer.jsx index d369e1c..576a47f 100644 --- a/src/ImageCards/ResponsiveContainer.jsx +++ b/src/ImageCards/ResponsiveContainer.jsx @@ -84,7 +84,7 @@ class ResponsiveContainer extends Component { } }; - renderChildren(props) { + renderChildren() { const { containerWidth, containerHeight } = this.state; const { diff --git a/src/ImageCards/displays/Cards.jsx b/src/ImageCards/displays/Cards.jsx index 3c020e1..48567b1 100644 --- a/src/ImageCards/displays/Cards.jsx +++ b/src/ImageCards/displays/Cards.jsx @@ -58,7 +58,11 @@ const Cards = (props) => { ); - return cards && cards.length > 0 ? ( + if (!cards?.length && editable) { + return No image cards; + } + + return cards?.length ? (
{cards.map((item) => ( { ))}
) : ( - <>{editable ? No image cards : ''} + '' ); }; diff --git a/src/ImageCards/displays/Carousel.jsx b/src/ImageCards/displays/Carousel.jsx index 342c7d6..6ef07af 100644 --- a/src/ImageCards/displays/Carousel.jsx +++ b/src/ImageCards/displays/Carousel.jsx @@ -65,7 +65,7 @@ const Carousel = (props) => { } = data; const slider = React.useRef(null); - var settings = { + const settings = { fade: fade, infinite: infinite, autoplay: autoplay && !editable, @@ -78,7 +78,11 @@ const Carousel = (props) => { lazyLoad: 'ondemand', }; - return cards && cards.length > 0 ? ( + if (!cards?.length && editable) { + return No image cards; + } + + return cards?.length ? (
{
) : ( - <>{editable ? No image cards : ''} + '' ); }; diff --git a/src/ImageCards/displays/DiscreetCarousel.jsx b/src/ImageCards/displays/DiscreetCarousel.jsx index 86c582d..df2e87b 100644 --- a/src/ImageCards/displays/DiscreetCarousel.jsx +++ b/src/ImageCards/displays/DiscreetCarousel.jsx @@ -7,7 +7,6 @@ import { CommonCarouselschemaExtender } from './../CommonAssets/schema'; import 'slick-carousel/slick/slick.css'; import '../css/discreetcarousel.less'; -// import 'slick-carousel/slick/slick-theme.css'; import { getScaleUrl, getPath } from '../utils'; @@ -106,13 +105,11 @@ const DiscreetCarousel = (props) => { ], }; - return !cards.length ? ( - editable ? ( - No cards - ) : ( - '' - ) - ) : ( + if (!cards?.length && editable) { + return No image cards; + } + + return cards?.length ? (
{({ parentWidth }) => { @@ -135,6 +132,8 @@ const DiscreetCarousel = (props) => { }}
+ ) : ( + '' ); }; diff --git a/src/ImageCards/displays/RoundTiled.jsx b/src/ImageCards/displays/RoundTiled.jsx index f33227e..65bec58 100644 --- a/src/ImageCards/displays/RoundTiled.jsx +++ b/src/ImageCards/displays/RoundTiled.jsx @@ -61,7 +61,11 @@ const RoundTiled = (props) => { const { data, editable } = props; const { title, cards, image_scale } = data; - return cards && cards.length > 0 ? ( + if (!cards?.length && editable) { + return No image cards; + } + + return cards?.length ? (
{
) : ( - <>{editable ? No image cards : ''} + '' ); }; From 25f6440e7e26e0df8d4fd227d9e4d9a095cff74d Mon Sep 17 00:00:00 2001 From: Miu Razvan Date: Wed, 25 Jan 2023 15:04:17 +0200 Subject: [PATCH 08/13] update --- src/ImageCards/ResponsiveContainer.jsx | 34 +++++--------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/src/ImageCards/ResponsiveContainer.jsx b/src/ImageCards/ResponsiveContainer.jsx index 576a47f..d2fe6a6 100644 --- a/src/ImageCards/ResponsiveContainer.jsx +++ b/src/ImageCards/ResponsiveContainer.jsx @@ -72,10 +72,8 @@ class ResponsiveContainer extends Component { const newSize = this.getContainerSize(); if (newSize) { - const { - containerWidth: oldWidth, - containerHeight: oldHeight, - } = this.state; + const { containerWidth: oldWidth, containerHeight: oldHeight } = + this.state; const { containerWidth, containerHeight } = newSize; if (containerWidth !== oldWidth || containerHeight !== oldHeight) { @@ -87,15 +85,7 @@ class ResponsiveContainer extends Component { renderChildren() { const { containerWidth, containerHeight } = this.state; - const { - aspect, - width, - height, - // minWidth, - // minHeight, - maxHeight, - children, - } = this.props; + const { aspect, width, height, children } = this.props; let calculatedWidth = isPercent(width) ? containerWidth : asNumber(width); let calculatedHeight = isPercent(height) @@ -111,25 +101,13 @@ class ResponsiveContainer extends Component { // But we should also take height into consideration calculatedWidth = calculatedHeight * aspect; } - - // if maxHeight is set, overwrite if calculatedHeight is greater than maxHeight - if (maxHeight && calculatedHeight > maxHeight) { - calculatedHeight = maxHeight; - } } return __CLIENT__ ? children({ parentWidth: calculatedWidth }) : children; } render() { - const { - minWidth, - minHeight, - width, - height, - maxHeight, - id, - className, - } = this.props; + const { minWidth, minHeight, width, height, maxHeight, id, className } = + this.props; const style = { width, height, minWidth, minHeight, maxHeight }; return (
- {this.renderChildren(this.props)} + {this.renderChildren()} Date: Wed, 25 Jan 2023 15:17:05 +0200 Subject: [PATCH 09/13] eslint fix --- src/ImageCards/ResponsiveContainer.jsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/ImageCards/ResponsiveContainer.jsx b/src/ImageCards/ResponsiveContainer.jsx index d2fe6a6..a3c378f 100644 --- a/src/ImageCards/ResponsiveContainer.jsx +++ b/src/ImageCards/ResponsiveContainer.jsx @@ -72,8 +72,10 @@ class ResponsiveContainer extends Component { const newSize = this.getContainerSize(); if (newSize) { - const { containerWidth: oldWidth, containerHeight: oldHeight } = - this.state; + const { + containerWidth: oldWidth, + containerHeight: oldHeight, + } = this.state; const { containerWidth, containerHeight } = newSize; if (containerWidth !== oldWidth || containerHeight !== oldHeight) { @@ -106,8 +108,15 @@ class ResponsiveContainer extends Component { } render() { - const { minWidth, minHeight, width, height, maxHeight, id, className } = - this.props; + const { + minWidth, + minHeight, + width, + height, + maxHeight, + id, + className, + } = this.props; const style = { width, height, minWidth, minHeight, maxHeight }; return (
Date: Wed, 25 Jan 2023 13:28:09 +0000 Subject: [PATCH 10/13] Automated release 1.0.2 --- CHANGELOG.md | 12 ++++++++++++ package.json | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1ffa8d..e57a13a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ 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.0.2](https://github.com/eea/volto-block-image-cards/compare/1.0.1...1.0.2) - 25 January 2023 + +#### :hammer_and_wrench: Others + +- eslint fix [Miu Razvan - [`d306b48`](https://github.com/eea/volto-block-image-cards/commit/d306b48f099c92ac24440ae72df1424d4ae8e84e)] +- update [Miu Razvan - [`25f6440`](https://github.com/eea/volto-block-image-cards/commit/25f6440e7e26e0df8d4fd227d9e4d9a095cff74d)] +- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`e8f56df`](https://github.com/eea/volto-block-image-cards/commit/e8f56df77f823328adaebac712544ea3907810d3)] +- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`dcd39c3`](https://github.com/eea/volto-block-image-cards/commit/dcd39c33387fb9aa93f3555e069bd064d8c9a37c)] +- test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`210bb59`](https://github.com/eea/volto-block-image-cards/commit/210bb591a1ab2688d6ee614535c718ca974103f0)] +- Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`252e88f`](https://github.com/eea/volto-block-image-cards/commit/252e88f0b91d35fb5c336223c90db030c4058b4b)] +- yarn 3 [Alin Voinea - [`20893a1`](https://github.com/eea/volto-block-image-cards/commit/20893a1fcb0e538ac344feb1d296a12d6af69e2d)] +- Add Sonarqube tag using demo-kitkat-frontend addons list [EEA Jenkins - [`ef5d95a`](https://github.com/eea/volto-block-image-cards/commit/ef5d95a32539340882b66ef69c79f400d3ee3c71)] ### [1.0.1](https://github.com/eea/volto-block-image-cards/compare/1.0.0...1.0.1) - 16 November 2022 #### :hammer_and_wrench: Others diff --git a/package.json b/package.json index 4612529..78b51a3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@eeacms/volto-block-image-cards", - "version": "1.0.1", + "version": "1.0.2", "description": "volto-block-image-cards: Volto add-on", "main": "src/index.js", "author": "European Environment Agency: IDM2 A-Team", From 0d12987f01678929397d8443a643ea02029a3b70 Mon Sep 17 00:00:00 2001 From: Miu Razvan Date: Wed, 25 Jan 2023 16:25:18 +0200 Subject: [PATCH 11/13] add cypress test --- cypress.config.js | 1 + cypress/e2e/01-block-basics.cy.js | 12 +--- cypress/e2e/02-block-image-cards.cy.js | 52 +++++++++++++++++ cypress/support/commands.js | 78 +++++++++++++++++++++----- cypress/support/e2e.js | 3 + package.json | 1 + 6 files changed, 125 insertions(+), 22 deletions(-) create mode 100644 cypress/e2e/02-block-image-cards.cy.js diff --git a/cypress.config.js b/cypress.config.js index 30be8ac..da8e7ba 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -19,6 +19,7 @@ module.exports = defineConfig({ setupNodeEvents(on, config) { // e2e testing node events setup code require('@cypress/code-coverage/task')(on, config); + require('cypress-fail-fast/plugin')(on, config); return config; }, baseUrl: 'http://localhost:3000', diff --git a/cypress/e2e/01-block-basics.cy.js b/cypress/e2e/01-block-basics.cy.js index 81e421c..ed34ca4 100644 --- a/cypress/e2e/01-block-basics.cy.js +++ b/cypress/e2e/01-block-basics.cy.js @@ -6,23 +6,17 @@ describe('Blocks Tests', () => { it('Add Block: Empty', () => { // Change page title - cy.get('[contenteditable=true]').first().clear(); - - cy.get('[contenteditable=true]').first().type('My Add-on Page'); - + cy.clearSlateTitle(); + cy.getSlateTitle().type('My Add-on Page'); cy.get('.documentFirstHeading').contains('My Add-on Page'); - - cy.get('[contenteditable=true]').first().type('{enter}'); - + cy.getSlate().click(); // Add block cy.get('.ui.basic.icon.button.block-add-button').first().click(); cy.get('.blocks-chooser .title').contains('Media').click(); cy.get('.content.active.media .button.image').contains('Image').click(); - // Save cy.get('#toolbar-save').click(); cy.url().should('eq', Cypress.config().baseUrl + '/cypress/my-page'); - // then the page view should contain our changes cy.contains('My Add-on Page'); cy.get('.block.image'); diff --git a/cypress/e2e/02-block-image-cards.cy.js b/cypress/e2e/02-block-image-cards.cy.js new file mode 100644 index 0000000..1ea82f2 --- /dev/null +++ b/cypress/e2e/02-block-image-cards.cy.js @@ -0,0 +1,52 @@ +import { slateBeforeEach, slateAfterEach } from '../support/e2e'; + +describe('Blocks Tests', () => { + beforeEach(slateBeforeEach); + afterEach(slateAfterEach); + + it('Add image cards block: Empty', () => { + // Add block + cy.getSlate().click(); + cy.get('.ui.basic.icon.button.block-add-button').first().click(); + cy.get('.blocks-chooser .title').contains('Common').click(); + cy.get('.content.active.common .button.imagecards') + .contains('Image Cards') + .click({ force: true }); + // Save + cy.get('#toolbar-save').click(); + cy.url().should('eq', Cypress.config().baseUrl + '/cypress/my-page'); + // then the page view should contain our changes + // cy.get('.block.imagecards'); + }); + + it('Add image cards block: Round tile', () => { + // Add block + cy.getSlate().click(); + cy.get('.ui.basic.icon.button.block-add-button').first().click(); + cy.get('.blocks-chooser .title').contains('Common').click(); + cy.get('.content.active.common .button.imagecards') + .contains('Image Cards') + .click({ force: true }); + // Select round tile display + cy.get('#sidebar .field-wrapper-display .react-select__control').click(); + cy.get('#sidebar .field-wrapper-display .react-select__menu div') + .contains('Round Tile') + .click(); + // Add Round Tile 1 + cy.get('#sidebar .add-item-button-wrapper').click(); + cy.get('.ui.accordion .active.content #field-title-0-cards-0').type( + 'Round Tile 1', + ); + // Add Round Tile 2 + cy.get('#sidebar .add-item-button-wrapper').click(); + cy.get('.ui.accordion .active.content #field-title-0-cards-1').type( + 'Round Tile 2', + ); + // Save + cy.get('#toolbar-save').click(); + cy.url().should('eq', Cypress.config().baseUrl + '/cypress/my-page'); + // then the page view should contain our changes + cy.get('.card .card-title').contains('Round Tile 1'); + cy.get('.card .card-title').contains('Round Tile 2'); + }); +}); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 0a63558..4578508 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -1,10 +1,13 @@ /* eslint no-console: ["error", { allow: ["log"] }] */ +const SLATE_SELECTOR = '.content-area .slate-editor [contenteditable=true]'; +const SLATE_TITLE_SELECTOR = '.block.inner.title [contenteditable="true"]'; + // --- AUTOLOGIN ------------------------------------------------------------- Cypress.Commands.add('autologin', () => { let api_url, user, password; api_url = Cypress.env('API_PATH') || 'http://localhost:8080/Plone'; - user = 'admin'; + user = 'admin2'; password = 'admin'; return cy @@ -30,7 +33,7 @@ Cypress.Commands.add( let api_url, auth; api_url = Cypress.env('API_PATH') || 'http://localhost:8080/Plone'; auth = { - user: 'admin', + user: 'admin2', pass: 'admin', }; if (contentType === 'File') { @@ -130,7 +133,7 @@ Cypress.Commands.add('addContentType', (name) => { let api_url, auth; api_url = Cypress.env('API_PATH') || 'http://localhost:8080/Plone'; auth = { - user: 'admin', + user: 'admin2', pass: 'admin', }; return cy @@ -153,7 +156,7 @@ Cypress.Commands.add('removeContentType', (name) => { let api_url, auth; api_url = Cypress.env('API_PATH') || 'http://localhost:8080/Plone'; auth = { - user: 'admin', + user: 'admin2', pass: 'admin', }; return cy @@ -174,7 +177,7 @@ Cypress.Commands.add('addSlateJSONField', (type, name) => { let api_url, auth; api_url = Cypress.env('API_PATH') || 'http://localhost:8080/Plone'; auth = { - user: 'admin', + user: 'admin2', pass: 'admin', }; return cy @@ -201,7 +204,7 @@ Cypress.Commands.add('removeSlateJSONField', (type, name) => { let api_url, auth; api_url = Cypress.env('API_PATH') || 'http://localhost:8080/Plone'; auth = { - user: 'admin', + user: 'admin2', pass: 'admin', }; return cy @@ -224,7 +227,7 @@ Cypress.Commands.add('removeContent', (path) => { let api_url, auth; api_url = Cypress.env('API_PATH') || 'http://localhost:8080/Plone'; auth = { - user: 'admin', + user: 'admin2', pass: 'admin', }; return cy @@ -292,7 +295,7 @@ Cypress.Commands.add( let api_url, auth; api_url = Cypress.env('API_PATH') || 'http://localhost:8080/Plone'; auth = { - user: 'admin', + user: 'admin2', pass: 'admin', }; return cy.request({ @@ -376,12 +379,42 @@ Cypress.Commands.add( }, ); -Cypress.Commands.add('getSlateEditorAndType', (type) => { - cy.get('.content-area .slate-editor [contenteditable=true]') +Cypress.Commands.add('getSlate', ({ createNewSlate = true } = {}) => { + let slate; + cy.getIfExists( + SLATE_SELECTOR, + () => { + slate = cy.get(SLATE_SELECTOR).last(); + }, + () => { + if (createNewSlate) { + cy.get('.block.inner').last().type('{moveToEnd}{enter}'); + } + slate = cy.get(SLATE_SELECTOR, { timeout: 10000 }).last(); + }, + ); + return slate; +}); + +Cypress.Commands.add('clearSlate', (selector) => { + return cy + .get(selector) .focus() .click() .wait(1000) - .type(type); + .type('{selectAll}') + .wait(1000) + .type('{backspace}'); +}); + +Cypress.Commands.add('getSlateTitle', () => { + return cy.get(SLATE_TITLE_SELECTOR, { + timeout: 10000, + }); +}); + +Cypress.Commands.add('clearSlateTitle', () => { + return cy.clearSlate(SLATE_TITLE_SELECTOR); }); Cypress.Commands.add('setSlateSelection', (subject, query, endQuery) => { @@ -389,7 +422,11 @@ Cypress.Commands.add('setSlateSelection', (subject, query, endQuery) => { .focus() .click() .setSelection(subject, query, endQuery) - .wait(1000); + .wait(1000); // this wait is needed for the selection change to be detected after +}); + +Cypress.Commands.add('getSlateEditorAndType', (type) => { + cy.getSlate().focus().click().type(type); }); Cypress.Commands.add('setSlateCursor', (subject, query, endQuery) => { @@ -401,7 +438,9 @@ Cypress.Commands.add('setSlateCursor', (subject, query, endQuery) => { }); Cypress.Commands.add('clickSlateButton', (button) => { - cy.get(`.slate-inline-toolbar .button-wrapper a[title="${button}"]`).click(); + cy.get(`.slate-inline-toolbar .button-wrapper a[title="${button}"]`, { + timeout: 10000, + }).click({ force: true }); //force click is needed to ensure the button in visible in view. }); Cypress.Commands.add('toolbarSave', () => { @@ -483,3 +522,16 @@ Cypress.Commands.add('store', () => { Cypress.Commands.add('settings', (key, value) => { return cy.window().its('settings'); }); + +Cypress.Commands.add( + 'getIfExists', + (selector, successAction = () => {}, failAction = () => {}) => { + cy.get('body').then((body) => { + if (body.find(selector).length > 0 && successAction) { + successAction(); + } else if (failAction) { + failAction(); + } + }); + }, +); diff --git a/cypress/support/e2e.js b/cypress/support/e2e.js index f696418..f347f36 100644 --- a/cypress/support/e2e.js +++ b/cypress/support/e2e.js @@ -21,6 +21,9 @@ import './commands'; //Generate code-coverage import '@cypress/code-coverage/support'; +// Fail Fast +import 'cypress-fail-fast'; + export const slateBeforeEach = (contentType = 'Document') => { cy.autologin(); cy.createContent({ diff --git a/package.json b/package.json index 78b51a3..72416c1 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "@cypress/code-coverage": "^3.10.0", "@plone/scripts": "*", "babel-plugin-transform-class-properties": "^6.24.1", + "cypress-fail-fast": "^5.0.1", "md5": "^2.3.0" }, "peerDependencies": { From 534fecadd05da50f344e556f75988abb37cb187a Mon Sep 17 00:00:00 2001 From: Miu Razvan Date: Wed, 25 Jan 2023 16:33:21 +0200 Subject: [PATCH 12/13] change username for cypress tests --- cypress/support/commands.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 4578508..6f813fd 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -7,7 +7,7 @@ const SLATE_TITLE_SELECTOR = '.block.inner.title [contenteditable="true"]'; Cypress.Commands.add('autologin', () => { let api_url, user, password; api_url = Cypress.env('API_PATH') || 'http://localhost:8080/Plone'; - user = 'admin2'; + user = 'admin'; password = 'admin'; return cy @@ -33,7 +33,7 @@ Cypress.Commands.add( let api_url, auth; api_url = Cypress.env('API_PATH') || 'http://localhost:8080/Plone'; auth = { - user: 'admin2', + user: 'admin', pass: 'admin', }; if (contentType === 'File') { @@ -133,7 +133,7 @@ Cypress.Commands.add('addContentType', (name) => { let api_url, auth; api_url = Cypress.env('API_PATH') || 'http://localhost:8080/Plone'; auth = { - user: 'admin2', + user: 'admin', pass: 'admin', }; return cy @@ -156,7 +156,7 @@ Cypress.Commands.add('removeContentType', (name) => { let api_url, auth; api_url = Cypress.env('API_PATH') || 'http://localhost:8080/Plone'; auth = { - user: 'admin2', + user: 'admin', pass: 'admin', }; return cy @@ -177,7 +177,7 @@ Cypress.Commands.add('addSlateJSONField', (type, name) => { let api_url, auth; api_url = Cypress.env('API_PATH') || 'http://localhost:8080/Plone'; auth = { - user: 'admin2', + user: 'admin', pass: 'admin', }; return cy @@ -204,7 +204,7 @@ Cypress.Commands.add('removeSlateJSONField', (type, name) => { let api_url, auth; api_url = Cypress.env('API_PATH') || 'http://localhost:8080/Plone'; auth = { - user: 'admin2', + user: 'admin', pass: 'admin', }; return cy @@ -227,7 +227,7 @@ Cypress.Commands.add('removeContent', (path) => { let api_url, auth; api_url = Cypress.env('API_PATH') || 'http://localhost:8080/Plone'; auth = { - user: 'admin2', + user: 'admin', pass: 'admin', }; return cy @@ -295,7 +295,7 @@ Cypress.Commands.add( let api_url, auth; api_url = Cypress.env('API_PATH') || 'http://localhost:8080/Plone'; auth = { - user: 'admin2', + user: 'admin', pass: 'admin', }; return cy.request({ From f2f0bef8aad2652e97b4ae2270c6d33589852ee5 Mon Sep 17 00:00:00 2001 From: EEA Jenkins <@users.noreply.github.com> Date: Wed, 25 Jan 2023 14:44:54 +0000 Subject: [PATCH 13/13] Automated release 1.0.2 --- CHANGELOG.md | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e57a13a..5b32ada 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,14 +8,11 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). #### :hammer_and_wrench: Others +- change username for cypress tests [Miu Razvan - [`534feca`](https://github.com/eea/volto-block-image-cards/commit/534fecadd05da50f344e556f75988abb37cb187a)] +- add cypress test [Miu Razvan - [`0d12987`](https://github.com/eea/volto-block-image-cards/commit/0d12987f01678929397d8443a643ea02029a3b70)] - eslint fix [Miu Razvan - [`d306b48`](https://github.com/eea/volto-block-image-cards/commit/d306b48f099c92ac24440ae72df1424d4ae8e84e)] - update [Miu Razvan - [`25f6440`](https://github.com/eea/volto-block-image-cards/commit/25f6440e7e26e0df8d4fd227d9e4d9a095cff74d)] -- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`e8f56df`](https://github.com/eea/volto-block-image-cards/commit/e8f56df77f823328adaebac712544ea3907810d3)] -- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`dcd39c3`](https://github.com/eea/volto-block-image-cards/commit/dcd39c33387fb9aa93f3555e069bd064d8c9a37c)] - test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`210bb59`](https://github.com/eea/volto-block-image-cards/commit/210bb591a1ab2688d6ee614535c718ca974103f0)] -- Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`252e88f`](https://github.com/eea/volto-block-image-cards/commit/252e88f0b91d35fb5c336223c90db030c4058b4b)] -- yarn 3 [Alin Voinea - [`20893a1`](https://github.com/eea/volto-block-image-cards/commit/20893a1fcb0e538ac344feb1d296a12d6af69e2d)] -- Add Sonarqube tag using demo-kitkat-frontend addons list [EEA Jenkins - [`ef5d95a`](https://github.com/eea/volto-block-image-cards/commit/ef5d95a32539340882b66ef69c79f400d3ee3c71)] ### [1.0.1](https://github.com/eea/volto-block-image-cards/compare/1.0.0...1.0.1) - 16 November 2022 #### :hammer_and_wrench: Others @@ -31,8 +28,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - Prepare 1.0.0 release [Miu Razvan - [`283992f`](https://github.com/eea/volto-block-image-cards/commit/283992f1ec4767a43ed3c311e9df1958c429821e)] - use volto 16 alpha 14 for cypress [Andrei Grigore - [`e0d147d`](https://github.com/eea/volto-block-image-cards/commit/e0d147d5af6d28419b426c32837831d0c7f91549)] -- Add Sonarqube tag using marine-frontend addons list [EEA Jenkins - [`33ebd41`](https://github.com/eea/volto-block-image-cards/commit/33ebd41cda6680037ecb3aa24a683ed414a2663b)] -- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`1d508f3`](https://github.com/eea/volto-block-image-cards/commit/1d508f3399adbef25b255c2aa5c3a55d7f15f870)] ### [0.6.5](https://github.com/eea/volto-block-image-cards/compare/0.6.4...0.6.5) - 31 July 2022 #### :nail_care: Enhancements @@ -48,7 +43,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). #### :hammer_and_wrench: Others -- Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`78c4423`](https://github.com/eea/volto-block-image-cards/commit/78c4423f2e976dccf8a8656b0b08dbc3d70a362c)] ### [0.6.3](https://github.com/eea/volto-block-image-cards/compare/0.6.2...0.6.3) - 23 June 2022 ### [0.6.2](https://github.com/eea/volto-block-image-cards/compare/0.6.1...0.6.2) - 22 June 2022 @@ -91,7 +85,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - Fix slick carousel wrong width calculation inside flexbox [kreafox - [`14e5f96`](https://github.com/eea/volto-block-image-cards/commit/14e5f96c89a644d21b82b3bc4032ea10fbb21cd9)] - Refactor Carousel [kreafox - [`a1d2ed5`](https://github.com/eea/volto-block-image-cards/commit/a1d2ed5e46839fc12f51cb8b87b8fb0314fb3554)] - Add a placeholder if cards are missing [kreafox - [`2211ecb`](https://github.com/eea/volto-block-image-cards/commit/2211ecb95a34f61956a0d950e6bc197408d09e14)] -- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`169560f`](https://github.com/eea/volto-block-image-cards/commit/169560f27524e8d0cadcb29d3f75bd21fca724ee)] ### [0.2.0](https://github.com/eea/volto-block-image-cards/compare/0.1.11...0.2.0) - 9 March 2022 #### :rocket: New Features @@ -101,7 +94,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). #### :hammer_and_wrench: Others - add exports to displays and widgets [Miu Razvan - [`712362a`](https://github.com/eea/volto-block-image-cards/commit/712362ae4ef2dc3c9d7e0c111a8e8fb0bee2a0a4)] -- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`178a36a`](https://github.com/eea/volto-block-image-cards/commit/178a36a1f10d162ff6e8f8c0b348953fe4d9f519)] - bump to 0.2.x version [Miu Razvan - [`5d22bdc`](https://github.com/eea/volto-block-image-cards/commit/5d22bdcaebf58a20023906b27f7d9fd18202dd02)] ### [0.1.11](https://github.com/eea/volto-block-image-cards/compare/0.1.10...0.1.11) - 4 January 2022 @@ -116,7 +108,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). #### :hammer_and_wrench: Others -- Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`f860947`](https://github.com/eea/volto-block-image-cards/commit/f860947ba3529f03d3a8c2701b9dc9d82ba901d3)] ### [0.1.7](https://github.com/eea/volto-block-image-cards/compare/0.1.6...0.1.7) - 14 December 2021 #### :hammer_and_wrench: Others @@ -131,25 +122,17 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - Refs #142010 - Optimize Volto-addons gitflow pipelines [valentinab25 - [`6c4d897`](https://github.com/eea/volto-block-image-cards/commit/6c4d897d02bc4d691cba15b92d918c3abcec6f07)] - Adjust layout on smaller screen sizes [kreafox - [`b349225`](https://github.com/eea/volto-block-image-cards/commit/b3492257a2f9d6fd4b908e3b8407e584ee96faa7)] - Add default carousel display view [kreafox - [`e1a54af`](https://github.com/eea/volto-block-image-cards/commit/e1a54af412dd52c50bb4b71009a748af9c994073)] -- Add Sonarqube tag using industry-frontend addons list [EEA Jenkins - [`b867e0c`](https://github.com/eea/volto-block-image-cards/commit/b867e0c8df94a7867b4422633d325ec7eea3d392)] -- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`87279fc`](https://github.com/eea/volto-block-image-cards/commit/87279fc23d908f3a92cc9b499837752293dbe616)] -- Add Sonarqube tag using forests-frontend addons list [EEA Jenkins - [`ab67a9a`](https://github.com/eea/volto-block-image-cards/commit/ab67a9aa09a77531001bf98a58e9d0af84f11d6c)] ### [0.1.4](https://github.com/eea/volto-block-image-cards/compare/0.1.3...0.1.4) - 1 October 2021 #### :hammer_and_wrench: Others -- Add Sonarqube tag using sustainability-frontend addons list [EEA Jenkins - [`89e7ca9`](https://github.com/eea/volto-block-image-cards/commit/89e7ca907c51a040fea5924304b4751680b7cbbd)] -- Add Sonarqube tag using ims-frontend addons list [EEA Jenkins - [`168f82d`](https://github.com/eea/volto-block-image-cards/commit/168f82da52647a53331bb7d2c5a6c53f48f35769)] -- Add Sonarqube tag using climate-energy-frontend addons list [EEA Jenkins - [`af11533`](https://github.com/eea/volto-block-image-cards/commit/af115336dbd0922790f4c9a51d5601b3d37eba1b)] ### [0.1.3](https://github.com/eea/volto-block-image-cards/compare/0.1.2...0.1.3) - 27 August 2021 #### :hammer_and_wrench: Others -- yarn i18n [Alin Voinea - [`f9dc209`](https://github.com/eea/volto-block-image-cards/commit/f9dc209b0f04e1e425e974e1441456a31a5ab532)] - Update scripts: i18n, test [Alin Voinea - [`7d22fc2`](https://github.com/eea/volto-block-image-cards/commit/7d22fc2c312b2227ae56bbad6431b6f747168636)] - Fixes [kreafox - [`7853bf0`](https://github.com/eea/volto-block-image-cards/commit/7853bf0312b0b97e09d220093231fb0bb1f6b35c)] - Don't break if unknown template [Tiberiu Ichim - [`f75b6ef`](https://github.com/eea/volto-block-image-cards/commit/f75b6ef2f2661e1447c98fb825ef5f195e9756ef)] -- Add Sonarqube tag using frontend addons list [EEA Jenkins - [`b70356d`](https://github.com/eea/volto-block-image-cards/commit/b70356d457f094d922130b241906e9a51ba07ad7)] - Add templates edit view [kreafox - [`994c8fb`](https://github.com/eea/volto-block-image-cards/commit/994c8fb17da0ac1fe00cc6f4ee000a4f99d7e149)] - Update dependency [razvanMiu - [`9488235`](https://github.com/eea/volto-block-image-cards/commit/9488235d064cb20bcc297d46724bfacc35e4bdd6)] - Updated dependencies [razvanMiu - [`79b35ee`](https://github.com/eea/volto-block-image-cards/commit/79b35eeda6dfc15242bb2eaf04d9ab8b5c4f7dea)] @@ -202,7 +185,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - Refs #126375 added AttachedImageWidget.jsx: [David Ichim - [`f6fbe2e`](https://github.com/eea/volto-block-image-cards/commit/f6fbe2ed959c5cf43d3b19cf43300fbc21e855d6)] - Refs #126375 run stylelint fix on less [David Ichim - [`62d02e8`](https://github.com/eea/volto-block-image-cards/commit/62d02e87ac23105255988f04cb49e19e59831285)] - Refs #126375 use volto-slate in generated app [David Ichim - [`8ff127f`](https://github.com/eea/volto-block-image-cards/commit/8ff127f15fc0f9c6b63fcb9219cf4988672eab55)] -- Refs #126375 add yarn.lock file [David Ichim - [`4d4acb9`](https://github.com/eea/volto-block-image-cards/commit/4d4acb996ba68a20cac7464408b12c2d92afacd7)] - Refs #126375 prettier fix for missing , [David Ichim - [`8aa6464`](https://github.com/eea/volto-block-image-cards/commit/8aa64647277ae5314aefa658b44d2d988160b795)] - Refs #126375 prettier fix with single quotes [David Ichim - [`7544e5e`](https://github.com/eea/volto-block-image-cards/commit/7544e5e6d6fdf84c4ae02183e4daf6e9b35c745f)] - Refs #126375 prettier fix and add volto-slate as addons to package [David Ichim - [`1eefe4d`](https://github.com/eea/volto-block-image-cards/commit/1eefe4d3945757297babd63b6777b6e236201fa9)]