hwookim / storybook-addon-cookie

Set document.cookie for each Storybook.
MIT License
9 stars 4 forks source link

Portable Stories Compatibility w/ 4.0 #15

Closed jcq closed 1 day ago

jcq commented 2 weeks ago

We are using stories in our automated tests in the manner described by the Storybook team as "portable stories". This entails using the composeStories functionality and running the .run() fn from composed story.

In order to make this work correctly, one needs to use the setProjectAnnotations functionality: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#1-apply-project-level-annotations

For addons, one is supposed to import the "preview annotations" and apply those to the test environment so that it works the same as it does through the Storybook GUI:

import { beforeAll } from 'vitest';
// šŸ‘‡ If you're using Next.js, import from @storybook/nextjs
//   If you're using Next.js with Vite, import from @storybook/experimental-nextjs-vite
import { setProjectAnnotations } from '@storybook/react';
// šŸ‘‡ Import the exported annotations, if any, from the addons you're using; otherwise remove this
import * as addonAnnotations from 'my-addon/preview';
import * as previewAnnotations from './.storybook/preview';

const annotations = setProjectAnnotations([previewAnnotations, addonAnnotations]);

// Run Storybook's beforeAll hook
beforeAll(annotations.beforeAll);

Best I can tell, the current 4.0 release is missing that export (it looks like there is a preview.js file that is supposed to re-export from dist/preview, but that file doesn't exist.

hwookim commented 5 days ago

@jcq

Thank you for bringing this issue to our attention. I apologize for the delayed response.

I've investigated the problem and confirmed that several files were indeed missing from the dist folder. This oversight has now been addressed through a redeployment of the package.

The missing files, including the preview.js file you mentioned, should now be present in the dist folder. This should resolve the issue you were experiencing with portable stories and the setProjectAnnotations functionality.

I hope this resolves the problem you were facing. If you continue to experience any issues or have any further questions, please don't hesitate to let me know.

Once again, I apologize for the inconvenience caused and thank you for your patience and for reporting this issue. Your feedback helps improve the addon for everyone.

jcq commented 1 day ago

That seems to have fixed it. Thank you for the rapid response!