Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .yarn/install-state.gz
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const Section = ({
onFieldChange,
onFieldErrorsChange,
renderField,
...otherProps
}) => {
const onColumnFieldChange = (fieldId, value, error) => {
onFieldChange(fieldId, value);
Expand All @@ -22,6 +23,7 @@ const Section = ({
return <div
className={styles.section}
data-testid={`schema-form-section-${id}`}
{...otherProps}
>
{details.label && <h3 className={styles.header}>{details.label}</h3>}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ describe('ReportManager - DetailsSection - SchemaForm - fields - Section', () =>
{...props}
/>);

test('configures the section with other props', async () => {
renderSectionField({ hidden: true });

expect(screen.getByTestId('schema-form-section-section-1')).toHaveAttribute('hidden');
});

test('does not show a header if the label is not defined', async () => {
details.label = '';
renderSectionField();
Expand Down
3 changes: 2 additions & 1 deletion src/ReportManager/DetailsSection/SchemaForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,12 @@ const SchemaForm = ({
}, [formData, formElements, setLocationMarkers]);

return <form onSubmit={onSubmit}>
{visibleSectionIds.map((sectionId) => <Section
{formElements[ROOT_CANVAS_ID]?.details.sections.map((sectionId) => <Section
details={formElements[sectionId].details}
fieldErrors={fieldErrors}
focusLocationMarker={focusLocationMarker}
formData={formData}
hidden={!visibleSectionIds.includes(sectionId)}
id={sectionId}
key={sectionId}
onFieldChange={onSectionFieldChange}
Expand Down
4 changes: 2 additions & 2 deletions src/ReportManager/DetailsSection/SchemaForm/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ describe('ReportManager - DetailsSection - SchemaForm', () => {
expect(screen.getByTestId('schema-form-text-field-text_field_2')).toBeVisible();

// section-1 has condition text_field === "invalid", which fails, so it should not be visible
expect(screen.queryByTestId('schema-form-section-section-1')).toBeNull();
expect(screen.queryByTestId('schema-form-text-field-text_field_3')).toBeNull();
expect(screen.getByTestId('schema-form-section-section-1')).not.toBeVisible();
expect(screen.getByTestId('schema-form-text-field-text_field_3')).not.toBeVisible();
});

test('shows validation errors if there are any when the user submits the form', async () => {
Expand Down
Loading