From eb6d200a6a0fa9fc4775b267f433704e1c578078 Mon Sep 17 00:00:00 2001 From: Valentin Palkovic Date: Wed, 10 Jan 2024 09:08:00 +0100 Subject: [PATCH 1/4] API: Removed deprecated functions, methods and props from manager and preview API --- MIGRATION.md | 30 ++++++++ code/lib/manager-api/src/lib/addons.ts | 69 ++----------------- code/lib/manager-api/src/modules/addons.ts | 47 ++----------- code/lib/manager-api/src/tests/addons.test.js | 62 ----------------- .../preview-api/src/modules/store/hooks.ts | 65 ----------------- code/lib/types/src/modules/api.ts | 17 +---- .../src/components/preview/Toolbar.tsx | 4 +- code/ui/manager/src/container/Panel.tsx | 28 +++++++- code/ui/manager/src/runtime.ts | 16 +---- 9 files changed, 72 insertions(+), 266 deletions(-) diff --git a/MIGRATION.md b/MIGRATION.md index 33d6c213033e..da1e6895e6ea 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -28,6 +28,9 @@ - [Svelte](#svelte) - [Require Svelte 4 and up](#require-svelte-4-and-up) - [Deprecations which are now removed](#deprecations-which-are-now-removed) + - [Methods and properties from AddonStore](#methods-and-properties-from-addonstore) + - [Methods and properties from PreviewAPI](#methods-and-properties-from-previewapi) + - [Removals in @storybook/types](#removals-in-storybooktypes) - [--use-npm flag in storybook CLI](#--use-npm-flag-in-storybook-cli) - [`setGlobalConfig` from `@storybook/react`](#setglobalconfig-from-storybookreact) - [StorybookViteConfig type from @storybook/builder-vite](#storybookviteconfig-type-from-storybookbuilder-vite) @@ -581,6 +584,33 @@ Starting in 8.0, Storybook requires Svelte 4 and up. ### Deprecations which are now removed +#### Methods and properties from AddonStore + +The following methods and properties from the class `AddonStore` in `@storybook/manager-api` are now removed: + +- `serverChannel` -> Use `channel` instead +- `getServerChannel` -> Use `getChannel` instead +- `setServerChannel` -> Use `setChannel` instead +- `hasServerChannel` +- `addPanel` + +#### Methods and properties from PreviewAPI + +The following exports from `@storybook/preview-api` are now removed: + +- `useSharedState` +- `useAddonState` + +Please file an issue if you need these APIs. + +#### Removals in @storybook/types + +The following exports from `@storybook/types` are now removed: + +- `API_ADDON` -> Use `Addon_Type` instead +- `API_COLLECTION` -> Use `Addon_Collection` instead +- `API_Panels` + #### --use-npm flag in storybook CLI The `--use-npm` is now removed. Use `--package-manager=npm` instead. [More info here](#cli-option---use-npm-deprecated). diff --git a/code/lib/manager-api/src/lib/addons.ts b/code/lib/manager-api/src/lib/addons.ts index bbcffff46494..5242fd82e921 100644 --- a/code/lib/manager-api/src/lib/addons.ts +++ b/code/lib/manager-api/src/lib/addons.ts @@ -27,13 +27,6 @@ export function isSupportedType(type: Addon_Types): boolean { return !!Object.values(Addon_TypesEnum).find((typeVal) => typeVal === type); } -interface DeprecatedAddonWithId { - /** - * @deprecated will be removed in 8.0, when registering addons, please use the addon id as the first argument - */ - id?: string; -} - export class AddonStore { constructor() { this.promise = new Promise((res) => { @@ -49,11 +42,6 @@ export class AddonStore { private channel: Channel | undefined; - /** - * @deprecated will be removed in 8.0 - */ - private serverChannel: Channel | undefined; - private promise: any; private resolve: any; @@ -67,38 +55,15 @@ export class AddonStore { return this.channel!; }; - /** - * @deprecated will be removed in 8.0, use getChannel instead - */ - getServerChannel = (): Channel => { - if (!this.serverChannel) { - throw new Error('Accessing non-existent serverChannel'); - } - - return this.serverChannel; - }; - ready = (): Promise => this.promise; hasChannel = (): boolean => !!this.channel; - /** - * @deprecated will be removed in 8.0, please use the normal channel instead - */ - hasServerChannel = (): boolean => !!this.serverChannel; - setChannel = (channel: Channel): void => { this.channel = channel; this.resolve(); }; - /** - * @deprecated will be removed in 8.0, please use the normal channel instead - */ - setServerChannel = (channel: Channel): void => { - this.serverChannel = channel; - }; - getElements< T extends | Addon_Types @@ -112,30 +77,6 @@ export class AddonStore { return this.elements[type]; } - /** - * Adds a panel to the addon store. - * @param {string} id - The id of the panel. - * @param {Addon_Type} options - The options for the panel. - * @returns {void} - * - * @deprecated Use the 'add' method instead. - * @example - * addons.add('My Panel', { - * title: 'My Title', - * type: types.PANEL, - * render: () =>
My Content
, - * }); - */ - addPanel = ( - id: string, - options: Omit & DeprecatedAddonWithId - ): void => { - this.add(id, { - type: Addon_TypesEnum.PANEL, - ...options, - }); - }; - /** * Adds an addon to the addon store. * @param {string} id - The id of the addon. @@ -146,14 +87,14 @@ export class AddonStore { id: string, addon: | Addon_BaseType - | (Omit & DeprecatedAddonWithId) - | (Omit & DeprecatedAddonWithId) - | (Omit & DeprecatedAddonWithId) - | (Omit & DeprecatedAddonWithId) + | Omit + | Omit + | Omit + | Omit ): void { const { type } = addon; const collection = this.getElements(type); - collection[id] = { id, ...addon }; + collection[id] = { ...addon, id }; } setConfig = (value: Addon_Config) => { diff --git a/code/lib/manager-api/src/modules/addons.ts b/code/lib/manager-api/src/modules/addons.ts index c0084552d85d..bb10acdce155 100644 --- a/code/lib/manager-api/src/modules/addons.ts +++ b/code/lib/manager-api/src/modules/addons.ts @@ -3,7 +3,6 @@ import type { Addon_Collection, Addon_Types, Addon_TypesMapping, - API_Panels, API_StateMerger, } from '@storybook/types'; import { Addon_TypesEnum } from '@storybook/types'; @@ -21,7 +20,7 @@ export interface SubAPI { * @protected This is used internally in storybook's manager. * @template T - The type of the elements in the collection. * @param {Addon_Types | Addon_TypesEnum.experimental_PAGE} type - The type of the elements to retrieve. - * @returns {API_Collection} - A collection of elements of the specified type. + * @returns {Addon_Collection} - A collection of elements of the specified type. */ getElements: < T extends @@ -32,21 +31,6 @@ export interface SubAPI { >( type: T ) => Addon_Collection; - /** - * Returns a collection of all panels. - * This is the same as calling getElements('panel') - * @protected This is used internally in storybook's manager. - * @deprecated please use getElements('panel') instead. This API will be removed in storybook 8.0. - * @returns {API_Panels} - A collection of all panels. - */ - getPanels: () => API_Panels; - /** - * Returns a collection of panels currently enabled for the selected story. - * @protected This is used internally in storybook's manager. - * @deprecated please use getElements('panel') instead, and do the filtering manually. This API will be removed in storybook 8.0. - * @returns {API_Panels} - A collection of all panels. - */ - getStoryPanels: () => API_Panels; /** * Returns the id of the currently selected panel. * @returns {string} - The ID of the currently selected panel. @@ -82,7 +66,11 @@ export interface SubAPI { getAddonState(addonId: string): S; } -export function ensurePanel(panels: API_Panels, selectedPanel?: string, currentPanel?: string) { +export function ensurePanel( + panels: Addon_Collection, + selectedPanel?: string, + currentPanel?: string +) { const keys = Object.keys(panels); if (keys.indexOf(selectedPanel!) >= 0) { @@ -98,29 +86,6 @@ export function ensurePanel(panels: API_Panels, selectedPanel?: string, currentP export const init: ModuleFn = ({ provider, store, fullAPI }): any => { const api: SubAPI = { getElements: (type) => provider.getElements(type), - getPanels: () => api.getElements(Addon_TypesEnum.PANEL), - getStoryPanels: () => { - const allPanels = api.getElements(Addon_TypesEnum.PANEL); - const { storyId } = store.getState(); - const story = fullAPI.getData(storyId); - - if (!allPanels || !story || story.type !== 'story') { - return allPanels; - } - - const { parameters } = story; - - const filteredPanels: Addon_Collection = {}; - Object.entries(allPanels).forEach(([id, panel]) => { - const { paramKey }: any = panel; - if (paramKey && parameters && parameters[paramKey] && parameters[paramKey].disable) { - return; - } - filteredPanels[id] = panel; - }); - - return filteredPanels; - }, getSelectedPanel: (): any => { const { selectedPanel } = store.getState(); return ensurePanel(api.getElements(Addon_TypesEnum.PANEL), selectedPanel, selectedPanel); diff --git a/code/lib/manager-api/src/tests/addons.test.js b/code/lib/manager-api/src/tests/addons.test.js index 46770d083cc9..b30cff92a7e7 100644 --- a/code/lib/manager-api/src/tests/addons.test.js +++ b/code/lib/manager-api/src/tests/addons.test.js @@ -47,68 +47,6 @@ describe('Addons API', () => { }); }); - describe('#getPanels', () => { - it('should return provider panels', () => { - // given - const { api } = initAddons({ provider, store }); - - // when - const panels = api.getPanels(); - - // then - expect(panels).toBe(PANELS); - }); - }); - - describe('#getStoryPanels', () => { - it('should return all panels by default', () => { - // given - const { api } = initAddons({ provider, store, fullAPI: { getData: () => undefined } }); - - // when - const filteredPanels = api.getStoryPanels(); - - // then - expect(filteredPanels).toBe(PANELS); - }); - - it('should filter disabled addons', () => { - // given - const storyId = 'story 1'; - const storiesHash = { - [storyId]: { - type: 'story', - parameters: { - a11y: { disable: true }, - }, - }, - }; - - const storeWithStory = { - getState: () => ({ - storyId, - storiesHash, - }), - setState: vi.fn(), - }; - - const { api } = initAddons({ - provider, - store: storeWithStory, - fullAPI: { getData: (id) => storiesHash[id] }, - }); - - // when - const filteredPanels = api.getStoryPanels(); - - // then - expect(filteredPanels).toEqual({ - actions: PANELS.actions, - knobs: PANELS.knobs, - }); - }); - }); - describe('#getSelectedPanel', () => { it('should return provider panels', () => { // given diff --git a/code/lib/preview-api/src/modules/store/hooks.ts b/code/lib/preview-api/src/modules/store/hooks.ts index 29762cec575a..857845c9b3d7 100644 --- a/code/lib/preview-api/src/modules/store/hooks.ts +++ b/code/lib/preview-api/src/modules/store/hooks.ts @@ -1,7 +1,4 @@ -import { SHARED_STATE_CHANGED, SHARED_STATE_SET } from '@storybook/core-events'; - import { - addons, HooksContext, applyHooks, useMemo, @@ -32,65 +29,3 @@ export { useArgs, useGlobals, }; - -/** - * @param {string} sharedId - The ID of the shared state. - * @param {S} [defaultState] - The default state of the shared state. - * @deprecated This API might get dropped, if you are using this, please file an issue. - * @returns {[S, (s: S) => void]} - A tuple containing the current state and a function to update the state. - * @example - * const [state, setState] = useSharedState('my-addon', { count: 0 }); - * console.log(state); // { count: 0 } - * setState({ count: 1 }); - * console.log(state); // { count: 1 } - */ -export function useSharedState(sharedId: string, defaultState?: S): [S, (s: S) => void] { - const channel = addons.getChannel(); - - const [lastValue] = - channel.last(`${SHARED_STATE_CHANGED}-manager-${sharedId}`) || - channel.last(`${SHARED_STATE_SET}-manager-${sharedId}`) || - []; - - const [state, setState] = useState(lastValue || defaultState); - - const allListeners = useMemo( - () => ({ - [`${SHARED_STATE_CHANGED}-manager-${sharedId}`]: (s: S) => setState(s), - [`${SHARED_STATE_SET}-manager-${sharedId}`]: (s: S) => setState(s), - }), - [sharedId] - ); - - const emit = useChannel(allListeners, [sharedId]); - - useEffect(() => { - // init - if (defaultState !== undefined && !lastValue) { - emit(`${SHARED_STATE_SET}-client-${sharedId}`, defaultState); - } - }, [sharedId]); - - return [ - state, - (s) => { - setState(s); - emit(`${SHARED_STATE_CHANGED}-client-${sharedId}`, s); - }, - ]; -} - -/** - * @param {string} sharedId - The ID of the shared state. - * @param {S} [defaultState] - The default state of the shared state. - * @deprecated This API might get dropped, if you are using this, please file an issue. - * @returns {[S, (s: S) => void]} - A tuple containing the current state and a function to update the state. - * @example - * const [state, setState] = useSharedState('my-addon', { count: 0 }); - * console.log(state); // { count: 0 } - * setState({ count: 1 }); - * console.log(state); // { count: 1 } - */ -export function useAddonState(addonId: string, defaultState?: S): [S, (s: S) => void] { - return useSharedState(addonId, defaultState); -} diff --git a/code/lib/types/src/modules/api.ts b/code/lib/types/src/modules/api.ts index be510b4bdfe4..cee23ca903ee 100644 --- a/code/lib/types/src/modules/api.ts +++ b/code/lib/types/src/modules/api.ts @@ -7,7 +7,7 @@ import type { ThemeVars } from '../../../theming/src/types'; import type { DocsOptions } from './core-common'; import type { API_FilterFunction, API_HashEntry, API_IndexHash } from './api-stories'; import type { SetStoriesStory, SetStoriesStoryData } from './channelApi'; -import type { Addon_BaseType, Addon_Collection, Addon_RenderOptions, Addon_Type } from './addons'; +import type { Addon_RenderOptions } from './addons'; import type { StoryIndex } from './indexer'; type OrString = T | (string & {}); @@ -29,21 +29,6 @@ export interface API_MatchOptions { path: string; } -/** - * @deprecated this is synonymous with `Addon_Type`. This interface will be removed in 8.0 - */ -export type API_Addon = Addon_Type; - -/** - * @deprecated this is synonymous with `Addon_Collection`. This interface will be removed in 8.0 - */ -export type API_Collection = Addon_Collection; - -/** - * @deprecated This interface will be removed in 8.0 - */ -export type API_Panels = Addon_Collection; - export type API_StateMerger = (input: S) => S; export interface API_ProviderData { diff --git a/code/ui/manager/src/components/preview/Toolbar.tsx b/code/ui/manager/src/components/preview/Toolbar.tsx index 57d3048ce502..b09d8f3e2a57 100644 --- a/code/ui/manager/src/components/preview/Toolbar.tsx +++ b/code/ui/manager/src/components/preview/Toolbar.tsx @@ -17,7 +17,7 @@ import { } from '@storybook/manager-api'; import { Location, type RenderData } from '@storybook/router'; -import type { Addon_BaseType } from '@storybook/types'; +import { Addon_TypesEnum, type Addon_BaseType } from '@storybook/types'; import { CloseIcon, ExpandIcon } from '@storybook/icons'; import { zoomTool } from './tools/zoom'; @@ -39,7 +39,7 @@ const fullScreenMapper = ({ api, state }: Combo) => { toggle: api.toggleFullscreen, isFullscreen: api.getIsFullscreen(), shortcut: shortcutToHumanString(api.getShortcutKeys().fullScreen), - hasPanel: Object.keys(api.getPanels()).length > 0, + hasPanel: Object.keys(api.getElements(Addon_TypesEnum.PANEL)).length > 0, singleStory: state.singleStory, }; }; diff --git a/code/ui/manager/src/container/Panel.tsx b/code/ui/manager/src/container/Panel.tsx index a5c1154604b8..ec0cf75e5048 100644 --- a/code/ui/manager/src/container/Panel.tsx +++ b/code/ui/manager/src/container/Panel.tsx @@ -1,7 +1,9 @@ import type { FC } from 'react'; import React from 'react'; import memoize from 'memoizerific'; -import { Consumer, type Combo } from '@storybook/manager-api'; +import { Consumer } from '@storybook/manager-api'; +import type { API, Combo } from '@storybook/manager-api'; +import { Addon_TypesEnum } from '@storybook/types'; import { AddonPanel } from '../components/panel/Panel'; @@ -11,8 +13,30 @@ const createPanelActions = memoize(1)((api) => ({ togglePosition: () => api.togglePanelPosition(), })); +const getPanels = (api: API) => { + const allPanels = api.getElements(Addon_TypesEnum.PANEL); + const story = api.getCurrentStoryData(); + + if (!allPanels || !story || story.type !== 'story') { + return allPanels; + } + + const { parameters } = story; + + const filteredPanels: typeof allPanels = {}; + Object.entries(allPanels).forEach(([id, panel]) => { + const { paramKey }: any = panel; + if (paramKey && parameters && parameters[paramKey] && parameters[paramKey].disable) { + return; + } + filteredPanels[id] = panel; + }); + + return filteredPanels; +}; + const mapper = ({ state, api }: Combo) => ({ - panels: api.getStoryPanels(), + panels: getPanels(api), selectedPanel: api.getSelectedPanel(), panelPosition: state.layout.panelPosition, actions: createPanelActions(api), diff --git a/code/ui/manager/src/runtime.ts b/code/ui/manager/src/runtime.ts index 861fc3b88fcb..0a1e153bffb4 100644 --- a/code/ui/manager/src/runtime.ts +++ b/code/ui/manager/src/runtime.ts @@ -9,17 +9,10 @@ import { CHANNEL_CREATED } from '@storybook/core-events'; import Provider from './provider'; import { renderStorybookUI } from './index'; -const { FEATURES, CONFIG_TYPE } = global; - class ReactProvider extends Provider { - private addons: AddonStore; - - private channel: Channel; + addons: AddonStore; - /** - * @deprecated will be removed in 8.0, please use channel instead - */ - private serverChannel?: Channel; + channel: Channel; constructor() { super(); @@ -33,11 +26,6 @@ class ReactProvider extends Provider { this.addons = addons; this.channel = channel; global.__STORYBOOK_ADDONS_CHANNEL__ = channel; - - if (FEATURES?.storyStoreV7 && CONFIG_TYPE === 'DEVELOPMENT') { - this.serverChannel = this.channel; - addons.setServerChannel(this.serverChannel); - } } getElements(type: Addon_Types) { From 583e308b4ceb44b13e269dc558d31b6c594621d3 Mon Sep 17 00:00:00 2001 From: Valentin Palkovic Date: Wed, 10 Jan 2024 09:31:23 +0100 Subject: [PATCH 2/4] Remove deprecated APIs from preview-api --- MIGRATION.md | 9 +++++- .../preview-api/src/modules/addons/main.ts | 28 ------------------- .../src/modules/preview-web/Preview.tsx | 3 -- .../src/components/preview/Preview.tsx | 2 +- 4 files changed, 9 insertions(+), 33 deletions(-) diff --git a/MIGRATION.md b/MIGRATION.md index 1987ee712a27..dadf046d1555 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -778,9 +778,16 @@ The following methods and properties from the class `AddonStore` in `@storybook - `serverChannel` -> Use `channel` instead - `getServerChannel` -> Use `getChannel` instead - `setServerChannel` -> Use `setChannel` instead -- `hasServerChannel` +- `hasServerChannel` -> Use `hasChannel` instead - `addPanel` +The following methods and properties from the class `AddonStore` in `@storybook/preview-api` are now removed: + +- `serverChannel` -> Use `channel` instead +- `getServerChannel` -> Use `getChannel` instead +- `setServerChannel` -> Use `setChannel` instead +- `hasServerChannel` -> Use `hasChannel` instead + #### Methods and properties from PreviewAPI The following exports from `@storybook/preview-api` are now removed: diff --git a/code/lib/preview-api/src/modules/addons/main.ts b/code/lib/preview-api/src/modules/addons/main.ts index cf81d655724d..53bc20092a0e 100644 --- a/code/lib/preview-api/src/modules/addons/main.ts +++ b/code/lib/preview-api/src/modules/addons/main.ts @@ -12,11 +12,6 @@ export class AddonStore { private channel: Channel | undefined; - /** - * @deprecated will be removed in 8.0, please use channel instead - */ - private serverChannel: Channel | undefined; - private promise: any; private resolve: any; @@ -32,37 +27,14 @@ export class AddonStore { return this.channel; }; - /** - * @deprecated will be removed in 8.0, please use getChannel instead - */ - getServerChannel = (): Channel => { - if (!this.serverChannel) { - throw new Error('Accessing non-existent serverChannel'); - } - - return this.serverChannel; - }; - ready = (): Promise => this.promise; hasChannel = (): boolean => !!this.channel; - /** - * @deprecated will be removed in 8.0, please use the normal channel instead - */ - hasServerChannel = (): boolean => !!this.serverChannel; - setChannel = (channel: Channel): void => { this.channel = channel; this.resolve(); }; - - /** - * @deprecated will be removed in 8.0, please use the normal channel instead - */ - setServerChannel = (channel: Channel): void => { - this.serverChannel = channel; - }; } // Enforce addons store to be a singleton diff --git a/code/lib/preview-api/src/modules/preview-web/Preview.tsx b/code/lib/preview-api/src/modules/preview-web/Preview.tsx index e55681bf9d18..593b14c7c3f7 100644 --- a/code/lib/preview-api/src/modules/preview-web/Preview.tsx +++ b/code/lib/preview-api/src/modules/preview-web/Preview.tsx @@ -60,9 +60,6 @@ export class Preview { previewEntryError?: Error; constructor(protected channel: Channel = addons.getChannel()) { - if (addons.hasServerChannel()) { - this.serverChannel = addons.getServerChannel(); - } this.storyStore = new StoryStore(); } diff --git a/code/ui/manager/src/components/preview/Preview.tsx b/code/ui/manager/src/components/preview/Preview.tsx index 71c1bf945256..42f56827cbd1 100644 --- a/code/ui/manager/src/components/preview/Preview.tsx +++ b/code/ui/manager/src/components/preview/Preview.tsx @@ -160,7 +160,7 @@ const Canvas: FC<{ withLoader: boolean; baseUrl: string; children?: never }> = ( useEffect(() => { if (global.CONFIG_TYPE === 'DEVELOPMENT') { try { - const channel = addons.getServerChannel(); + const channel = addons.getChannel(); channel.on(PREVIEW_BUILDER_PROGRESS, (options) => { setProgress(options); From 9bdddc81f0ee6ff9041a619fa8fb5e525af4b0b3 Mon Sep 17 00:00:00 2001 From: Valentin Palkovic Date: Wed, 10 Jan 2024 15:14:40 +0100 Subject: [PATCH 3/4] Fix types and remove deprecated APIs in tests --- .../src/modules/preview-web/PreviewWeb.integration.test.ts | 3 +-- .../lib/preview-api/src/modules/preview-web/PreviewWeb.test.ts | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/code/lib/preview-api/src/modules/preview-web/PreviewWeb.integration.test.ts b/code/lib/preview-api/src/modules/preview-web/PreviewWeb.integration.test.ts index 00dc743dc4f1..61e0f239df15 100644 --- a/code/lib/preview-api/src/modules/preview-web/PreviewWeb.integration.test.ts +++ b/code/lib/preview-api/src/modules/preview-web/PreviewWeb.integration.test.ts @@ -6,7 +6,7 @@ import { describe, beforeEach, it, expect, vi } from 'vitest'; import React from 'react'; import { global } from '@storybook/global'; import type { RenderContext } from '@storybook/types'; -import { addons, mockChannel as createMockChannel } from '../addons'; +import { addons } from '../addons'; import { PreviewWeb } from './PreviewWeb'; import { WebView } from './WebView'; @@ -67,7 +67,6 @@ beforeEach(() => { // projectAnnotations.parameters.docs.renderer = () => new DocsRenderer() as any; addons.setChannel(mockChannel as any); - addons.setServerChannel(createMockChannel()); vi.mocked(WebView.prototype).prepareForDocs.mockReturnValue('docs-element' as any); vi.mocked(WebView.prototype).prepareForStory.mockReturnValue('story-element' as any); diff --git a/code/lib/preview-api/src/modules/preview-web/PreviewWeb.test.ts b/code/lib/preview-api/src/modules/preview-web/PreviewWeb.test.ts index b40da83fc1b3..130c6ff0e642 100644 --- a/code/lib/preview-api/src/modules/preview-web/PreviewWeb.test.ts +++ b/code/lib/preview-api/src/modules/preview-web/PreviewWeb.test.ts @@ -131,7 +131,6 @@ beforeEach(() => { mockStoryIndex.mockReset().mockReturnValue(storyIndex); addons.setChannel(mockChannel as any); - addons.setServerChannel(createMockChannel()); mockFetchResult = { status: 200, json: mockStoryIndex, text: () => 'error text' }; vi.mocked(WebView.prototype).prepareForDocs.mockReturnValue('docs-element' as any); From 9c06e2e1ee57ebbd730de368023850b911e2afb0 Mon Sep 17 00:00:00 2001 From: Valentin Palkovic Date: Wed, 10 Jan 2024 15:29:16 +0100 Subject: [PATCH 4/4] Remove unused import --- code/lib/preview-api/src/modules/preview-web/PreviewWeb.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/lib/preview-api/src/modules/preview-web/PreviewWeb.test.ts b/code/lib/preview-api/src/modules/preview-web/PreviewWeb.test.ts index 130c6ff0e642..f6d27e21c031 100644 --- a/code/lib/preview-api/src/modules/preview-web/PreviewWeb.test.ts +++ b/code/lib/preview-api/src/modules/preview-web/PreviewWeb.test.ts @@ -32,7 +32,7 @@ import { } from '@storybook/core-events'; import { logger } from '@storybook/client-logger'; import type { Renderer, ModuleImportFn, ProjectAnnotations } from '@storybook/types'; -import { addons, mockChannel as createMockChannel } from '../addons'; +import { addons } from '../addons'; import { PreviewWeb } from './PreviewWeb'; import {