Skip to content

Commit

Permalink
Merge pull request #635 from open-formulieren/fix/3778-render-content…
Browse files Browse the repository at this point in the history
…-component

[OF#3778] Render content component in summary
  • Loading branch information
SilviaAmAm authored Jan 19, 2024
2 parents 42b47c4 + 68d518d commit 20091ae
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/FormStepSummary/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ import {DEBUG} from 'utils';

import ComponentValueDisplay from './ComponentValueDisplay';

// Components without a label that should still be displayed
const COMPONENTS_WITH_NO_NAME = ['content'];

const LabelValueRow = ({name, value, component}) => {
if (!name) {
if (!name && !COMPONENTS_WITH_NO_NAME.includes(component.type)) {
return null;
}

Expand Down
97 changes: 97 additions & 0 deletions src/components/Summary/Summary.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ export default {
slug: 'uw-gegevens',
name: 'Uw gegevens',
data: [
{
name: '',
value: 'In this section you can enter your personal details.',
component: {
type: 'content',
label: 'Content',
key: 'content',
},
},
{
name: 'Voornaam',
value: 'John',
Expand Down Expand Up @@ -61,6 +70,36 @@ export default {
slug: 'uw-partner',
name: 'Uw partner',
data: [
{
name: 'Partner details',
value: null,
component: {
type: 'fieldset',
key: 'fieldset1',
label: 'Partner details',
hideLabel: false,
components: [
{
key: 'voornaam2',
type: 'textfield',
label: 'Voornaam',
hidden: false,
},
{
key: 'achternaam2',
type: 'textfield',
label: 'Achternaam',
hidden: false,
},
{
key: 'emailAdres2',
type: 'email',
label: 'Email adres',
hidden: false,
},
],
},
},
{
name: 'Voornaam',
value: 'Carl',
Expand Down Expand Up @@ -93,6 +132,40 @@ export default {
},
],
},
{
slug: 'uw-huisdier',
name: 'Uw huisdier',
data: [
{
name: '',
value: null,
component: {
type: 'fieldset',
key: 'fieldset2',
label: 'Pet details',
hideLabel: true,
components: [
{
key: 'huisdierNaam',
type: 'textfield',
label: 'Huisdier naam',
hidden: false,
},
],
},
},
{
name: 'Huisdier Naam',
value: 'Nemo',
component: {
key: 'huisdierNaam',
type: 'textfield',
label: 'Huisdier naam',
hidden: false,
},
},
],
},
],
showPaymentInformation: true,
amountToPay: 54.05,
Expand Down Expand Up @@ -191,6 +264,30 @@ const render = ({

export const Default = {
render,
play: async ({canvasElement, step}) => {
const canvas = within(canvasElement);

const contentNodes = canvas.getAllByText((content, element) => {
return element.className.split(' ').includes('utrecht-data-list__item--openforms-content');
});

await expect(contentNodes.length).toEqual(1);

const contentNode = contentNodes[0];

await expect(contentNode.firstChild.textContent).toEqual('');

const fieldsetNodes = canvas.getAllByText((content, element) => {
return element.className.split(' ').includes('utrecht-data-list__item--openforms-fieldset');
});

// The fieldset with hidden label is not rendered
await expect(fieldsetNodes.length).toEqual(1);

const fieldsetPartnerNode = fieldsetNodes[0];

await expect(fieldsetPartnerNode.firstChild.textContent).toEqual('Partner details');
},
};

export const MultipleRequiredStatements = {
Expand Down

0 comments on commit 20091ae

Please sign in to comment.