Skip to content

Commit

Permalink
Merge pull request #24924 from storybookjs/fix-disabled-addons
Browse files Browse the repository at this point in the history
FastBuild: Fix disabledAddons filter
  • Loading branch information
ndelangen authored Nov 22, 2023
2 parents f1031bf + 07b7e0c commit 95f02fe
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
64 changes: 64 additions & 0 deletions code/lib/core-common/src/presets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -655,4 +655,68 @@ describe('loadPreset', () => {
]
`);
});

it('should filter out disabledAddons', async () => {
const loaded = await loadPreset(
{
name: '',
type: 'virtual',
framework: '@storybook/react',
presets: ['@storybook/preset-typescript'],
addons: ['@storybook/addon-docs', 'addon-bar'],
},
0,
{
build: {
test: {
disabledAddons: ['@storybook/addon-docs'],
},
},
}
);

// addon-docs should not be at the top level, but addon-bar and others should be.
expect(loaded).toMatchInlineSnapshot(`
Array [
Object {
"name": "@storybook/preset-typescript",
"options": Object {},
"preset": Object {},
},
Object {
"name": "@storybook/addon-interactions/preset",
"options": Object {},
"preset": Object {},
},
Object {
"name": "@storybook/addon-cool",
"options": Object {},
"preset": Object {},
},
Object {
"name": "addon-bar",
"options": Object {},
"preset": Object {},
},
Object {
"name": Object {
"addons": Array [
"@storybook/addon-docs",
"addon-bar",
],
"framework": "@storybook/react",
"name": "",
"presets": Array [
"@storybook/preset-typescript",
],
"type": "virtual",
},
"options": Object {},
"preset": Object {
"framework": "@storybook/react",
},
},
]
`);
});
});
2 changes: 1 addition & 1 deletion code/lib/core-common/src/presets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ export async function loadPreset(
// @ts-expect-error (Converted from ts-ignore)
const name = i.name ? i.name : i;

return !!storybookOptions.build?.test?.disabledAddons?.find((n) => name.includes(n));
return !storybookOptions.build?.test?.disabledAddons?.find((n) => name.includes(n));
};
}

Expand Down

0 comments on commit 95f02fe

Please sign in to comment.