Added two new tests to test dependencies
MODIFY
bin-src/lib/getDependentStoryFiles.test.ts
bin-src/lib/getDependentStoryFiles.test.ts
@@ -511,18 +511,23 @@ describe('getDependentStoryFiles', () => {
});
});
- it('does not bail on changed dependency of untraced config file and untraced dependency', async () => {
- const changedFiles = ['src/utils.js', 'src/docs-decorator.jsx'];
+ it('does not bail on changed wrapper component of untraced config file', async () => {
+ const changedFiles = ['src/utils.js', 'src/docs-wrapper.jsx'];
const modules = [
{
id: './path/to/storybook-config/preview.js-generated-config-entry.js',
- name: './path/to/storybook-config/preview.js-generated-config-entry.js + 1 modules',
+ name: './path/to/storybook-config/preview.js-generated-config-entry.js + 28 modules', // untraced
modules: [
{ name: './path/to/storybook-config/preview.js-generated-config-entry.js' },
- { name: './src/docs-decorator.jsx' },
+ { name: './src/docs-wrapper.jsx' },
],
reasons: [],
},
+ {
+ id: './src/docs-wrapper.jsx',
+ name: './src/docs-wrapper.jsx', // untraced
+ reasons: [{ moduleName: './src/docs-wrapper.stories.js' }],
+ },
{
id: './src/utils.js',
name: './src/utils.js', // changed
@@ -530,7 +535,7 @@ describe('getDependentStoryFiles', () => {
},
{
id: './src/foo.js',
- name: './src/foo.js', // untraced
+ name: './src/foo.js',
reasons: [{ moduleName: './src/foo.stories.js' }],
},
{
@@ -547,7 +552,7 @@ describe('getDependentStoryFiles', () => {
const ctx = getContext({
configDir: 'path/to/storybook-config',
untraced: [
- '**/docs-decorator.jsx',
+ '**/docs-wrapper.jsx',
'**/path/to/storybook-config/preview.js-generated-config-entry.js',
],
});
@@ -557,6 +562,119 @@ describe('getDependentStoryFiles', () => {
'./src/foo.stories.js': ['src/foo.stories.js'],
});
});
+
+ it('does not bail on changed wrapper component of untraced config file and untraced dependencies of a wrapper component', async () => {
+ const changedFiles = ['src/utils.js', 'src/packages/design-system/components/button.jsx'];
+ const modules = [
+ {
+ id: './path/to/storybook-config/preview.js-generated-config-entry.js',
+ name: './path/to/storybook-config/preview.js-generated-config-entry.js + 28 modules', // untraced
+ modules: [
+ { name: './path/to/storybook-config/preview.js-generated-config-entry.js' },
+ { name: './src/docs-wrapper.jsx' },
+ ],
+ reasons: [],
+ },
+ {
+ id: './src/docs-wrapper.jsx',
+ name: './src/docs-wrapper.jsx',
+ reasons: [{ moduleName: './src/packages/design-system/components/button.jsx' }],
+ },
+ {
+ id: './src/packages/design-system/components/button.jsx',
+ name: './src/packages/design-system/components/button.jsx', // changed
+ reasons: [{ moduleName: './src/packages/design-system/components/button.stories.js' }],
+ },
+ {
+ id: './src/utils.js',
+ name: './src/utils.js', // changed
+ reasons: [{ moduleName: './src/foo.js' }],
+ },
+ {
+ id: './src/foo.js',
+ name: './src/foo.js',
+ reasons: [{ moduleName: './src/foo.stories.js' }],
+ },
+ {
+ id: './src/foo.stories.js',
+ name: './src/foo.stories.js',
+ reasons: [{ moduleName: CSF_GLOB }],
+ },
+ {
+ id: CSF_GLOB,
+ name: CSF_GLOB,
+ reasons: [{ moduleName: './path/to/storybook-config/generated-stories-entry.js' }],
+ },
+ ];
+ const ctx = getContext({
+ configDir: 'path/to/storybook-config',
+ untraced: ['**/docs-wrapper.jsx'],
+ });
+ const res = await getDependentStoryFiles(ctx, { modules }, statsPath, changedFiles);
+ expect(ctx.turboSnap.bailReason).toBeUndefined();
+ expect(res).toEqual({
+ './src/foo.stories.js': ['src/foo.stories.js'],
+ });
+ });
+
+ it('does not bail on changed dynamic import of untraced config file', async () => {
+ const changedFiles = ['src/utils.js', 'src/packages/design-system/components/button.jsx'];
+ const modules = [
+ {
+ id: './path/to/storybook-config/preview.js-generated-config-entry.js',
+ name: './path/to/storybook-config/preview.js-generated-config-entry.js + 28 modules', // untraced
+ modules: [
+ { name: './path/to/storybook-config/preview.js-generated-config-entry.js' },
+ { name: './src/docs-wrapper.jsx' },
+ ],
+ reasons: [],
+ },
+ {
+ id: './src/docs-wrapper.jsx',
+ name: './src/docs-wrapper.jsx',
+ reasons: [{ moduleName: './src/packages/design-system/component/src/component.jsx' }],
+ },
+ {
+ id: './src/packages/design-system/component/src/component.jsx',
+ name: './src/packages/design-system/component/src/component.jsx',
+ reasons: [{ moduleName: './src/packages/design-system/components/button.jsx' }],
+ },
+ {
+ id: './src/packages/design-system/components/button.jsx',
+ name: './src/packages/design-system/components/button.jsx', // changed
+ reasons: [{ moduleName: './src/packages/design-system/components/button.stories.js' }],
+ },
+ {
+ id: './src/utils.js',
+ name: './src/utils.js', // changed
+ reasons: [{ moduleName: './src/foo.js' }],
+ },
+ {
+ id: './src/foo.js',
+ name: './src/foo.js',
+ reasons: [{ moduleName: './src/foo.stories.js' }],
+ },
+ {
+ id: './src/foo.stories.js',
+ name: './src/foo.stories.js',
+ reasons: [{ moduleName: CSF_GLOB }],
+ },
+ {
+ id: CSF_GLOB,
+ name: CSF_GLOB,
+ reasons: [{ moduleName: './path/to/storybook-config/generated-stories-entry.js' }],
+ },
+ ];
+ const ctx = getContext({
+ configDir: 'path/to/storybook-config',
+ untraced: ['**/docs-wrapper.jsx'],
+ });
+ const res = await getDependentStoryFiles(ctx, { modules }, statsPath, changedFiles);
+ expect(ctx.turboSnap.bailReason).toBeUndefined();
+ expect(res).toEqual({
+ './src/foo.stories.js': ['src/foo.stories.js'],
+ });
+ });
});
describe('normalizePath', () => {

Added two new tests to test dependencies