Skip to content

Commit

Permalink
(#9307) Fix filterExcludedPreset of adf-content-metadata-card configu…
Browse files Browse the repository at this point in the history
…ration to include all excluded properties (#9309)

* fix filterExcludedPreset to include all configurations instead of only the first with exclusions. (#9307)

* New test for property exclusion in layout-oriented-config.service (9307)
  • Loading branch information
StephenDunn committed Feb 16, 2024
1 parent 1331a6d commit 9b0104f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -320,5 +320,27 @@ describe('LayoutOrientedConfigService', () => {
});
});
});

it('should include all exclusions passed to filterExcludedPreset', () => {
let properties: OrganisedPropertyGroup[] = [{
name: 'propGroup',
title: 'propGroup',
properties: [ { name: 'property1', title: 'Custom title', editable: true } as Property,
{ name: 'property2', title: 'Custom title', editable: true } as Property,
{ name: 'property3', title: 'Custom title', editable: true } as Property,
{ name: 'property4', title: 'Custom title', editable: true } as Property,
]}];

configService = createConfigService([
{ title: 'Property group', items: [ { aspect: 'berseria', properties: ['property1', 'property2', 'property3', 'property4'] } ] },
{ title: 'Exclude group 1', items: [ { exclude: ['property1'], properties: [] } ] },
{ title: 'Exclude group 2', items: [ { exclude: ['property2'], properties: [] } ] },
{ title: 'Exclude group 3', items: [ { exclude: ['property3'], properties: [] } ] },
]);

let result = configService.filterExcludedPreset(properties);

expect(result.length).toBe(1);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ export class LayoutOrientedConfigService implements ContentMetadataConfig {
public filterExcludedPreset(propertyGroups: OrganisedPropertyGroup[]): OrganisedPropertyGroup[] {
let excludedConfig = this.config
.map((config) => config.exclude)
.find((exclude) => exclude !== undefined);
.filter((exclude) => exclude !== undefined)
.flat();

if (excludedConfig === undefined) {
excludedConfig = [];
Expand Down

0 comments on commit 9b0104f

Please sign in to comment.