Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nextjs: Fix default annotations for portable stories #28825

Merged
merged 4 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions code/frameworks/nextjs/src/portable-stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
composeStory as originalComposeStory,
composeStories as originalComposeStories,
setProjectAnnotations as originalSetProjectAnnotations,
setDefaultProjectAnnotations,
composeConfigs,
} from 'storybook/internal/preview-api';
import type {
Expand Down Expand Up @@ -41,11 +42,12 @@ export function setProjectAnnotations(
| NamedOrDefaultProjectAnnotations<ReactRenderer>
| NamedOrDefaultProjectAnnotations<ReactRenderer>[]
): ProjectAnnotations<ReactRenderer> {
setDefaultProjectAnnotations(INTERNAL_DEFAULT_PROJECT_ANNOTATIONS);
return originalSetProjectAnnotations<ReactRenderer>(projectAnnotations);
}

// This will not be necessary once we have auto preset loading
const defaultProjectAnnotations: ProjectAnnotations<ReactRenderer> = composeConfigs([
const INTERNAL_DEFAULT_PROJECT_ANNOTATIONS: ProjectAnnotations<ReactRenderer> = composeConfigs([
reactAnnotations,
// we only provide the RSC decorator, but not the feature flag. Should be set by the user
{ decorators: rscAnnotations.decorators },
Expand Down Expand Up @@ -89,7 +91,7 @@ export function composeStory<TArgs extends Args = Args>(
story as StoryAnnotationsOrFn<ReactRenderer, Args>,
componentAnnotations,
projectAnnotations,
defaultProjectAnnotations,
INTERNAL_DEFAULT_PROJECT_ANNOTATIONS,
exportsName
);
}
Expand Down
4 changes: 3 additions & 1 deletion scripts/tasks/sandbox-parts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,9 @@ export async function setupVitest(details: TemplateDetails) {
${!isNextjs ? 'viteConfig' : '{}'},
defineConfig({
plugins: [
storybookTest(),
storybookTest({
storybookScript: 'yarn storybook --ci',
}),
${isSvelte ? 'svelteTesting(),' : ''}
${isNextjs ? "vitePluginNext({ dir: path.join(__dirname, '..') })," : ''}
],
Expand Down