Skip to content

Commit

Permalink
refactor(summary2): move displayType default to shared default logic (#…
Browse files Browse the repository at this point in the history
…14654)

Co-authored-by: Lars <[email protected]>
  • Loading branch information
Jondyr and lassopicasso authored Feb 14, 2025
1 parent 16630f9 commit 8255827
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
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

0 comments on commit 8255827

Please sign in to comment.