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

refactor(summary2): move displayType default to shared default logic #14654

Merged
merged 4 commits into from
Feb 14, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const Summary2OverrideDisplayType = ({
<StudioNativeSelect
size='sm'
label={t('ux_editor.component_properties.summary.override.display_type')}
value={displayType || 'list'}
value={displayType}
onChange={(e) => handleCustomTypeChange(e.target.value as OverrideDisplayType)}
>
{customConfigTypes.map((type: CustomConfigType) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import type {
const checkBoxId = componentWithOptionsMock.id;
const multipleSelectId = componentWithMultipleSelectMock.id;
const subformComponentId = subformComponentMock.id;
const repeatingGroupComponentId = container2IdMock;
const layoutMockWithMultipleSelect = {
...layoutMock,
components: {
Expand Down Expand Up @@ -191,25 +192,29 @@ describe('Summary2Override', () => {

it('should render component specific overrides', async () => {
const user = userEvent.setup();
render({ overrides: [{ componentId: container2IdMock }] });
render({ overrides: [{ componentId: repeatingGroupComponentId }] });

await user.click(overrideCollapsedButton(1));
await user.selectOptions(overrideDisplaySelector(), overrideDisplaySelectType('table'));

expect(defaultProps.onChange).toHaveBeenCalledWith(
expect.arrayContaining([{ componentId: container2IdMock, display: 'table' }]),
expect.arrayContaining([{ componentId: repeatingGroupComponentId, display: 'table' }]),
);
});

it.each([
{
componentId: container2IdMock,
defaultProps: { componentId: container2IdMock, display: 'full' },
componentId: repeatingGroupComponentId,
defaultProps: { componentId: repeatingGroupComponentId, display: 'full' },
},
{
componentId: subformComponentId,
defaultProps: { componentId: subformComponentId, display: 'table' },
},
{
componentId: multipleSelectId,
defaultProps: { componentId: multipleSelectId, displayType: 'list' },
},
])('should set default props for components', async (args) => {
const user = userEvent.setup();
render({ overrides: [{ componentId: component1IdMock }] });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ export const Summary2OverrideEntry = ({
return { display: 'full' };
case ComponentType.Subform:
return { display: 'table' };
case ComponentType.Checkboxes:
case ComponentType.MultipleSelect:
return { displayType: 'list' };
default:
return {};
}
Expand Down