Skip to content

Commit

Permalink
fix(config): don't accept non-arrays for attributesToDisplay
Browse files Browse the repository at this point in the history
This makes it consistent with `attributesForFaceting`. See  #6023 for more info, although it doesn't change that use case.
  • Loading branch information
Haroenv committed Jan 31, 2024
1 parent c841133 commit 307f26d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,23 @@ test('removes `imageAttribute` from `attributesToDisplay`', async () => {
})
);
});

test('ignores invalid input', async () => {
expect(
await postProcessAnswers({
configuration: {},
templateConfig: {},
optionsFromArguments: {},
answers: {
attributesToDisplay: 'test',
attributesForFaceting: 'test',
},
})
).toEqual(
expect.objectContaining({
attributesForFaceting: false,
attributesToDisplay: false,
flags: { autocomplete: false, dynamicWidgets: false, insights: false },
})
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ async function postProcessAnswers({
template: templatePath,
installation: optionsFromArguments.installation,
currentYear: new Date().getFullYear(),
attributesToDisplay: combinedAnswers.attributesToDisplay?.filter(
(attribute) => attribute !== combinedAnswers.imageAttribute
),
attributesToDisplay:
Array.isArray(combinedAnswers.attributesToDisplay) &&
combinedAnswers.attributesToDisplay.filter(
(attribute) => attribute !== combinedAnswers.imageAttribute
),
attributesForFaceting:
Array.isArray(combinedAnswers.attributesForFaceting) &&
combinedAnswers.attributesForFaceting.filter(
Expand Down

0 comments on commit 307f26d

Please sign in to comment.