Skip to content

Commit

Permalink
Revert "Addon Test: Error when addon interactions exists"
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinpalkovic authored Oct 23, 2024
1 parent 12dd5b2 commit ce8dd08
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 35 deletions.
1 change: 1 addition & 0 deletions code/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const config: StorybookConfig = {
addons: [
'@storybook/addon-themes',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
'@storybook/addon-storysource',
'@storybook/addon-designs',
'@storybook/experimental-addon-test',
Expand Down
3 changes: 0 additions & 3 deletions code/addons/interactions/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,3 @@ export const checkActionsLoaded = (configDir: string) => {
getConfig: (configFile) => serverRequire(configFile),
});
};

// This annotation is read by addon-test, so it can throw an error if both addons are used
export const ADDON_INTERACTIONS_IN_USE = true;
33 changes: 1 addition & 32 deletions code/addons/test/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
TESTING_MODULE_WATCH_MODE_REQUEST,
} from 'storybook/internal/core-events';
import { oneWayHash, telemetry } from 'storybook/internal/telemetry';
import type { Options, PresetProperty, StoryId } from 'storybook/internal/types';
import type { Options, StoryId } from 'storybook/internal/types';

import picocolors from 'picocolors';
import { dedent } from 'ts-dedent';
Expand Down Expand Up @@ -99,34 +99,3 @@ export const experimental_serverChannel = async (channel: Channel, options: Opti

return channel;
};

export const previewAnnotations: PresetProperty<'previewAnnotations'> = async (
entry = [],
options
) => {
checkActionsLoaded(options.configDir);
return entry;
};

export const managerEntries: PresetProperty<'managerEntries'> = async (entry = [], options) => {
// Throw an error when addon-interactions is used.
// This is done by reading an annotation defined in addon-interactions, which although not ideal,
// is a way to handle addon conflict without having to worry about the order of which they are registered
const annotation = await options.presets.apply('ADDON_INTERACTIONS_IN_USE', false);
if (annotation) {
// eslint-disable-next-line local-rules/no-uncategorized-errors
const error = new Error(
dedent`
You have both addon-interactions and addon-test enabled, which is not allowed.
addon-test is a replacement for addon-interactions, please uninstall and remove addon-interactions from the addons list in your main config at ${options.configDir}.
`
);
error.name = 'AddonConflictError';

throw error;
}

// for whatever reason seems like the return type of managerEntries is not correct (it expects never instead of string[])
return entry as never;
};

0 comments on commit ce8dd08

Please sign in to comment.