diff --git a/code/lib/preview-api/src/modules/store/csf/prepareStory.test.ts b/code/lib/preview-api/src/modules/store/csf/prepareStory.test.ts index a84c5796b8ce..4ce62b94277b 100644 --- a/code/lib/preview-api/src/modules/store/csf/prepareStory.test.ts +++ b/code/lib/preview-api/src/modules/store/csf/prepareStory.test.ts @@ -2,13 +2,7 @@ import { global } from '@storybook/global'; import { expect } from '@jest/globals'; -import type { - Renderer, - ArgsEnhancer, - PlayFunctionContext, - SBObjectType, - SBScalarType, -} from '@storybook/types'; +import type { Renderer, ArgsEnhancer, PlayFunctionContext, SBScalarType } from '@storybook/types'; import { addons, HooksContext } from '../../addons'; import { NO_TARGET_NAME } from '../args'; @@ -32,20 +26,6 @@ const moduleExport = {}; const stringType: SBScalarType = { name: 'string' }; const numberType: SBScalarType = { name: 'number' }; const booleanType: SBScalarType = { name: 'boolean' }; -const complexType: SBObjectType = { - name: 'object', - value: { - complex: { - name: 'object', - value: { - object: { - name: 'array', - value: { name: 'string' }, - }, - }, - }, - }, -}; beforeEach(() => { global.FEATURES = { breakingChangesV7: true }; @@ -195,44 +175,6 @@ describe('prepareStory', () => { expect(initialArgs).toEqual({}); }); - it('are initialized to argTypes[x].defaultValue if unset', () => { - const { initialArgs } = prepareStory( - { - id, - name, - args: { - arg2: 3, - arg4: 'foo', - arg7: false, - }, - argTypes: { - arg1: { name: 'arg1', type: stringType, defaultValue: 'arg1' }, - arg2: { name: 'arg2', type: numberType, defaultValue: 2 }, - arg3: { - name: 'arg3', - type: complexType, - defaultValue: { complex: { object: ['type'] } }, - }, - arg4: { name: 'arg4', type: stringType }, - arg5: { name: 'arg5', type: stringType }, - arg6: { name: 'arg6', type: numberType, defaultValue: 0 }, // See https://github.com/storybookjs/storybook/issues/12767 } - }, - moduleExport, - }, - { id, title }, - { render: () => {} } - ); - - expect(initialArgs).toEqual({ - arg1: 'arg1', - arg2: 3, - arg3: { complex: { object: ['type'] } }, - arg4: 'foo', - arg6: 0, - arg7: false, - }); - }); - describe('argsEnhancers', () => { it('are applied in the right order', () => { const run: number[] = []; diff --git a/code/lib/preview-api/src/modules/store/csf/prepareStory.ts b/code/lib/preview-api/src/modules/store/csf/prepareStory.ts index 9398a8ee084e..cb6cff8467e0 100644 --- a/code/lib/preview-api/src/modules/store/csf/prepareStory.ts +++ b/code/lib/preview-api/src/modules/store/csf/prepareStory.ts @@ -1,5 +1,3 @@ -import { dedent } from 'ts-dedent'; -import deprecate from 'util-deprecate'; import { global } from '@storybook/global'; import type { @@ -28,15 +26,6 @@ import { applyHooks } from '../../addons'; import { combineParameters } from '../parameters'; import { defaultDecorateStory } from '../decorators'; import { groupArgsByTarget, NO_TARGET_NAME } from '../args'; -import { getValuesFromArgTypes } from './getValuesFromArgTypes'; - -const argTypeDefaultValueWarning = deprecate( - () => {}, - dedent` - \`argType.defaultValue\` is deprecated and will be removed in Storybook 7.0. - - https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#no-longer-inferring-default-values-of-args` -); // Combine all the metadata about a story (both direct and inherited from the component/global scope) // into a "renderable" story function, with all decorators applied, parameters passed as context etc @@ -234,15 +223,7 @@ function preparePartialAnnotations( contextForEnhancers.argTypes ); - // Add argTypes[X].defaultValue to initial args (note this deprecated) - // We need to do this *after* the argTypesEnhancers as they may add defaultValues - const defaultArgs = getValuesFromArgTypes(contextForEnhancers.argTypes); - - if (Object.keys(defaultArgs).length > 0) { - argTypeDefaultValueWarning(); - } - - const initialArgsBeforeEnhancers = { ...defaultArgs, ...passedArgs }; + const initialArgsBeforeEnhancers = { ...passedArgs }; contextForEnhancers.initialArgs = argsEnhancers.reduce( (accumulatedArgs: Args, enhancer) => ({ diff --git a/code/renderers/react/src/__test__/__snapshots__/internals.test.tsx.snap b/code/renderers/react/src/__test__/__snapshots__/internals.test.tsx.snap index dcd51c8244fb..4507f513248b 100644 --- a/code/renderers/react/src/__test__/__snapshots__/internals.test.tsx.snap +++ b/code/renderers/react/src/__test__/__snapshots__/internals.test.tsx.snap @@ -5,7 +5,6 @@ exports[`Renders CSF2Secondary story 1`] = `