Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove helptext from som properties #14369

Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,89 @@ describe('FormComponentConfig', () => {
).toBeInTheDocument();
});

it('should render an empty text for "sortOrder" and display text for other properties', () => {
const schema = {
properties: {
sortOrder: {
type: 'string',
description: 'Description for sortOrder',
},
otherProperty: {
type: 'string',
description: 'Description for otherProperty',
},
},
};
render({
props: {
schema,
},
});
const sortOrderHelpText = screen.queryByText('Description for sortOrder');
expect(sortOrderHelpText).not.toBeInTheDocument();
const otherPropertyHelpText = screen.getByText('Description for otherProperty');
expect(otherPropertyHelpText).toBeInTheDocument();
expect(
screen.getByLabelText(textMock('ux_editor.component_properties.sortOrder')),
).toBeInTheDocument();
});

it('should render an empty text for "showValidations" and display text for other properties', () => {
const schema = {
properties: {
showValidations: {
type: 'boolean',
description: 'Description for showValidations',
},
otherProperty: {
type: 'string',
description: 'Description for otherProperty',
},
},
};
render({
props: {
schema,
},
});
const showValidationsHelpText = screen.queryByText('Description for showValidations');
expect(showValidationsHelpText).not.toBeInTheDocument();
const otherPropertyHelpText = screen.getByText('Description for otherProperty');
expect(otherPropertyHelpText).toBeInTheDocument();
expect(
screen.getByLabelText(textMock('ux_editor.component_properties.showValidations')),
).toBeInTheDocument();
});

it('should render an empty text for "preselectedOptionIndex" and display text for other properties', () => {
const schema = {
properties: {
preselectedOptionIndex: {
type: 'number',
description: 'Description for preselectedOptionIndex',
},
otherProperty: {
type: 'string',
description: 'Description for otherProperty',
},
},
};
render({
props: {
schema,
},
});
const preselectedOptionIndexHelpText = screen.queryByText(
'Description for preselectedOptionIndex',
);
expect(preselectedOptionIndexHelpText).not.toBeInTheDocument();
const otherPropertyHelpText = screen.getByText('Description for otherProperty');
expect(otherPropertyHelpText).toBeInTheDocument();
expect(
screen.getByLabelText(textMock('ux_editor.component_properties.preselectedOptionIndex')),
).toBeInTheDocument();
});

it('should render default boolean values if defined', async () => {
const user = userEvent.setup();
render({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,41 +193,44 @@ export const FormComponentConfig = ({

{/** String properties */}
{stringPropertyKeys.map((propertyKey) => {
const isSortOrder = propertyKey === 'sortOrder';
return (
<EditStringValue
component={component}
handleComponentChange={handleComponentUpdate}
propertyKey={propertyKey}
key={propertyKey}
helpText={properties[propertyKey]?.description}
helpText={isSortOrder ? '' : properties[propertyKey]?.description}
enumValues={properties[propertyKey]?.enum || properties[propertyKey]?.examples}
/>
);
})}

{/** Number properties (number and integer types) */}
{numberPropertyKeys.map((propertyKey) => {
const isPreselectedOptionIndex = propertyKey === 'preselectedOptionIndex';
return (
<EditNumberValue
component={component}
handleComponentChange={handleComponentUpdate}
propertyKey={propertyKey}
key={propertyKey}
helpText={t('ux_editor.component_properties.preselected_help_text')}
helpText={isPreselectedOptionIndex ? '' : properties[propertyKey]?.description}
enumValues={properties[propertyKey]?.enum}
/>
);
})}

{/** Array properties with enum values) */}
{arrayPropertyKeys.map((propertyKey) => {
const isShowValidations = propertyKey === 'showValidations';
return (
<EditStringValue
component={component}
handleComponentChange={handleComponentUpdate}
propertyKey={propertyKey}
key={propertyKey}
helpText={properties[propertyKey]?.description}
helpText={isShowValidations ? '' : properties[propertyKey]?.description}
enumValues={properties[propertyKey]?.items?.enum}
multiple={true}
/>
Expand Down
Loading