Skip to content

Commit

Permalink
Merge branch 'next' of github.com:storybookjs/storybook into jeppe/fi…
Browse files Browse the repository at this point in the history
…x-duplicate-include
  • Loading branch information
JReinhold committed Dec 12, 2024
2 parents d5b2286 + 014e862 commit 0ece491
Show file tree
Hide file tree
Showing 13 changed files with 177 additions and 21 deletions.
7 changes: 6 additions & 1 deletion code/addons/a11y/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
},
"./manager": "./dist/manager.js",
"./register": "./dist/manager.js",
"./package.json": "./package.json"
"./package.json": "./package.json",
"./postinstall": "./dist/postinstall.js"
},
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down Expand Up @@ -74,6 +75,7 @@
"@storybook/global": "^5.0.0",
"@storybook/icons": "^1.2.12",
"@testing-library/react": "^14.0.0",
"execa": "^9.5.2",
"picocolors": "^1.1.0",
"pretty-format": "^29.7.0",
"react": "^18.2.0",
Expand All @@ -97,6 +99,9 @@
],
"previewEntries": [
"./src/preview.tsx"
],
"nodeEntries": [
"./src/postinstall.ts"
]
},
"gitHead": "e6a7fd8a655c69780bc20b9749c2699e44beae16",
Expand Down
15 changes: 15 additions & 0 deletions code/addons/a11y/src/postinstall.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { PostinstallOptions } from '@storybook/cli/src/add';

// eslint-disable-next-line depend/ban-dependencies
import { execa } from 'execa';

const $ = execa({
preferLocal: true,
stdio: 'inherit',
// we stream the stderr to the console
reject: false,
});

export default async function postinstall(options: PostinstallOptions) {
await $`storybook automigrate addonA11yAddonTest ${options.yes ? '--yes' : ''}`;
}
4 changes: 1 addition & 3 deletions code/addons/onboarding/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,13 @@
"check": "jiti ../../../scripts/prepare/check.ts",
"prep": "jiti ../../../scripts/prepare/addon-bundle.ts"
},
"dependencies": {
"react-confetti": "^6.1.0"
},
"devDependencies": {
"@radix-ui/react-dialog": "^1.0.5",
"@storybook/icons": "^1.2.12",
"@storybook/react": "workspace:*",
"framer-motion": "^11.0.3",
"react": "^18.2.0",
"react-confetti": "^6.1.0",
"react-dom": "^18.2.0",
"react-joyride": "^2.8.2",
"react-use-measure": "^2.1.1",
Expand Down
2 changes: 1 addition & 1 deletion code/addons/test/src/components/ContextMenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const ContextMenuItem: FC<{
padding="small"
disabled={state.crashed || isDisabled}
>
<Icon fill={theme.barTextColor} />
<Icon fill={theme.textMutedColor} />
</Button>
}
/>
Expand Down
2 changes: 1 addition & 1 deletion code/addons/test/src/components/Description.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const Wrapper = styled.div(({ theme }) => ({
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
fontSize: theme.typography.size.s1,
color: theme.barTextColor,
color: theme.textMutedColor,
}));

const PositiveText = styled.span(({ theme }) => ({
Expand Down
20 changes: 15 additions & 5 deletions code/addons/test/src/components/TestProviderRender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ const StopIcon = styled(StopAltIcon)({
width: 10,
});

const ItemTitle = styled.span<{ enabled?: boolean }>(
({ enabled, theme }) =>
!enabled && {
color: theme.textMutedColor,
'&:after': {
content: '" (disabled)"',
},
}
);

const statusOrder: TestStatus[] = ['failed', 'warning', 'pending', 'passed', 'skipped'];
const statusMap: Record<TestStatus, ComponentProps<typeof TestStatusIcon>['status']> = {
failed: 'negative',
Expand Down Expand Up @@ -241,7 +251,7 @@ export const TestProviderRender: FC<
/>
<ListItem
as="label"
title="Coverage"
title={<ItemTitle enabled={config.coverage}>Coverage</ItemTitle>}
icon={<ShieldIcon color={theme.textMutedColor} />}
right={
<Checkbox
Expand All @@ -255,7 +265,7 @@ export const TestProviderRender: FC<
{isA11yAddon && (
<ListItem
as="label"
title="Accessibility"
title={<ItemTitle enabled={config.a11y}>Accessibility</ItemTitle>}
icon={<AccessibilityIcon color={theme.textMutedColor} />}
right={
<Checkbox
Expand Down Expand Up @@ -293,7 +303,7 @@ export const TestProviderRender: FC<
/>
{coverageSummary ? (
<ListItem
title="Coverage"
title={<ItemTitle enabled={config.coverage}>Coverage</ItemTitle>}
href={'/coverage/index.html'}
// @ts-expect-error ListItem doesn't include all anchor attributes in types, but it is an achor element
target="_blank"
Expand All @@ -308,13 +318,13 @@ export const TestProviderRender: FC<
/>
) : (
<ListItem
title="Coverage"
title={<ItemTitle enabled={config.coverage}>Coverage</ItemTitle>}
icon={<TestStatusIcon status="unknown" aria-label={`status: unknown`} />}
/>
)}
{isA11yAddon && (
<ListItem
title="Accessibility"
title={<ItemTitle enabled={config.a11y}>Accessibility</ItemTitle>}
onClick={
(a11yStatus === 'negative' || a11yStatus === 'warning') && a11yResults.length
? () => {
Expand Down
6 changes: 4 additions & 2 deletions code/addons/test/src/node/vitest-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type { TestingModuleRunRequestPayload } from 'storybook/internal/core-eve

import type { DocsIndexEntry, StoryIndex, StoryIndexEntry } from '@storybook/types';

import path, { normalize } from 'pathe';
import path, { dirname, join, normalize } from 'pathe';
import slash from 'slash';

import { COVERAGE_DIRECTORY, type Config } from '../constants';
Expand All @@ -29,6 +29,8 @@ type TagsFilter = {
skip: string[];
};

const packageDir = dirname(require.resolve('@storybook/experimental-addon-test/package.json'));

export class VitestManager {
vitest: Vitest | null = null;

Expand All @@ -44,7 +46,7 @@ export class VitestManager {
const { createVitest } = await import('vitest/node');

const storybookCoverageReporter: [string, StorybookCoverageReporterOptions] = [
'@storybook/experimental-addon-test/internal/coverage-reporter',
join(packageDir, 'dist/node/coverage-reporter.js'),
{
testManager: this.testManager,
coverageOptions: this.vitest?.config?.coverage as ResolvedCoverageOptions<'v8'>,
Expand Down
10 changes: 7 additions & 3 deletions code/addons/test/src/vitest-plugin/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* eslint-disable no-underscore-dangle */
import { dirname } from 'node:path';

import type { Plugin } from 'vitest/config';
import { mergeConfig } from 'vitest/config';
import type { ViteUserConfig } from 'vitest/config';
Expand Down Expand Up @@ -62,6 +64,8 @@ const getStoryGlobsAndFiles = async (
};
};

const packageDir = dirname(require.resolve('@storybook/experimental-addon-test/package.json'));

export const storybookTest = async (options?: UserOptions): Promise<Plugin> => {
const finalOptions = {
...defaultOptions,
Expand Down Expand Up @@ -149,16 +153,16 @@ export const storybookTest = async (options?: UserOptions): Promise<Plugin> => {
const baseConfig: Omit<ViteUserConfig, 'plugins'> = {
test: {
setupFiles: [
'@storybook/experimental-addon-test/internal/setup-file',
join(packageDir, 'dist/vitest-plugin/setup-file.mjs'),
// if the existing setupFiles is a string, we have to include it otherwise we're overwriting it
typeof inputConfig_ONLY_MUTATE_WHEN_STRICTLY_NEEDED_OR_YOU_WILL_BE_FIRED.test
?.setupFiles === 'string' &&
inputConfig_ONLY_MUTATE_WHEN_STRICTLY_NEEDED_OR_YOU_WILL_BE_FIRED.test?.setupFiles,
].filter(Boolean),
].filter(Boolean) as string[],

...(finalOptions.storybookScript
? {
globalSetup: ['@storybook/experimental-addon-test/internal/global-setup'],
globalSetup: [join(packageDir, 'dist/vitest-plugin/global-setup.mjs')],
}
: {}),

Expand Down
2 changes: 1 addition & 1 deletion code/core/src/components/components/Loader/Loader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const ProgressBar = styled.div(({ theme }) => ({
const ProgressMessage = styled.div(({ theme }) => ({
minHeight: '2em',
fontSize: `${theme.typography.size.s1}px`,
color: theme.barTextColor,
color: theme.textMutedColor,
}));

const ErrorIcon = styled(LightningOffIcon)(({ theme }) => ({
Expand Down
2 changes: 1 addition & 1 deletion code/core/src/components/components/tooltip/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const Title = styled(({ active, loading, disabled, ...rest }: TitleProps) => <sp
({ disabled, theme }) =>
disabled
? {
color: transparentize(0.7, theme.color.defaultText),
color: theme.textMutedColor,
}
: {}
);
Expand Down
2 changes: 1 addition & 1 deletion code/core/src/manager/components/sidebar/LegacyRender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const TitleWrapper = styled.div<{ crashed?: boolean }>(({ crashed, theme }) => (

const DescriptionWrapper = styled.div(({ theme }) => ({
fontSize: theme.typography.size.s1,
color: theme.barTextColor,
color: theme.textMutedColor,
}));

const Progress = styled(ProgressSpinner)({
Expand Down
2 changes: 1 addition & 1 deletion code/core/src/manager/components/sidebar/SearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const NoResults = styled.div(({ theme }) => ({
lineHeight: `18px`,
color: theme.color.defaultText,
small: {
color: theme.barTextColor,
color: theme.textMutedColor,
fontSize: `${theme.typography.size.s1}px`,
},
}));
Expand Down
Loading

0 comments on commit 0ece491

Please sign in to comment.