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

Release: Prerelease 8.1.0-alpha.7 #26752

Merged
merged 96 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
74b7434
Bump webpack-dev-middleware to patch high security issue
jwilliams-met Mar 27, 2024
e7e7442
Update yarn.lock
valentinpalkovic Mar 27, 2024
34695ac
Merge branch 'next' into patch-1
valentinpalkovic Mar 27, 2024
31d1092
Merge branch 'next' into patch-1
valentinpalkovic Apr 3, 2024
6ea5bd8
Make mocks reactive, and listen to them in addon actions
kasperpeulen Apr 4, 2024
d2ad4a0
Add test
kasperpeulen Apr 4, 2024
7b5f532
Fix bug
kasperpeulen Apr 4, 2024
afdfd03
Change name
kasperpeulen Apr 4, 2024
0dc9e58
Also make spyOn reactive
kasperpeulen Apr 4, 2024
e69fa60
docs: set correct dependency in import example
larsdouweschuitema Apr 4, 2024
c6d5795
Merge branch 'next' into patch-1
jonniebigodes Apr 5, 2024
e226c4e
Merge pull request #26742 from larsdouweschuitema/patch-1
jonniebigodes Apr 5, 2024
c0ad197
fix(vue): disable controls for events, slots and expose
larsrickert Mar 28, 2024
771691d
only disable events and exposed
larsrickert Mar 29, 2024
4c42d21
update vitest snapshots
larsrickert Mar 29, 2024
f47eff3
Merge branch 'next' into fix/disable-vue3-controls
shilman Apr 5, 2024
1663270
Merge pull request #26751 from storybookjs/fix/disable-vue3-controls
shilman Apr 5, 2024
c8f7090
Update CHANGELOG.md for v8.0.6 [skip ci]
storybook-bot Apr 5, 2024
df20fa8
Fix incorrect link
kylegach Apr 5, 2024
27f10ba
add VTA automigration
ndelangen Apr 8, 2024
c298abd
cleanup
ndelangen Apr 8, 2024
777433d
add to index
ndelangen Apr 8, 2024
ab38a3c
"It should only run if beforeVersion is < 8.0.x where x is the versio…
ndelangen Apr 8, 2024
29078ce
CLI: Add --config-dir flag to add command
eric-blue Apr 8, 2024
3c645b5
Merge pull request #26756 from storybookjs/update-addon-mdx-gmf-readme
kylegach Apr 8, 2024
3a35428
Implement draft version of the file search
valentinpalkovic Apr 2, 2024
5199da5
Add test files
valentinpalkovic Apr 2, 2024
df6e16c
Remove node_modules from gitignore
valentinpalkovic Apr 2, 2024
d0a68b2
Add normalize-path helper util
valentinpalkovic Apr 3, 2024
abeaac6
Adjust test files in controls
valentinpalkovic Apr 3, 2024
f0eec0a
Finalized filesearch in controls
valentinpalkovic Apr 3, 2024
b696c78
Finalized parser API
valentinpalkovic Apr 3, 2024
4aaa5b6
Add isNotNull function to ts-utils.ts
valentinpalkovic Apr 3, 2024
48f0f3b
API Doc: Add fallback for renderer name if not set
valentinpalkovic Apr 3, 2024
efec0b5
Extract util to extract proper framework name
valentinpalkovic Apr 3, 2024
6654fd6
Extract utils and types into @storybook/core-common and @storybook/types
valentinpalkovic Apr 3, 2024
e86e004
Add new function extractProperRendererNameFromFramework
valentinpalkovic Apr 3, 2024
0ee1d50
Implement file-search channel
valentinpalkovic Apr 3, 2024
492a43b
Adjust globbification of search query
valentinpalkovic Apr 3, 2024
272c3d5
Add dependencies and remove unused dependency in package.json and yar…
valentinpalkovic Apr 3, 2024
7e79e80
Improve glob search pattern for file search
valentinpalkovic Apr 3, 2024
3ae848c
Update yarn install command to exclude immutable flag
valentinpalkovic Apr 3, 2024
75b4873
Update yarn.lock
valentinpalkovic Apr 3, 2024
871699e
import globby dynamically because it is a pure ESM module
valentinpalkovic Apr 4, 2024
ca39719
Bump esmodule-lexer
valentinpalkovic Apr 4, 2024
a1305c3
Only search for specific file extensions
valentinpalkovic Apr 4, 2024
7431a0e
Ignore test files in filesearch
valentinpalkovic Apr 4, 2024
7095732
Fix tests
valentinpalkovic Apr 4, 2024
e4a49f8
Fix test
valentinpalkovic Apr 4, 2024
061dbf9
Return null for files which cannot be parsed
valentinpalkovic Apr 4, 2024
e79979b
Add .eslintignore changes and exclude __tests__ directory
valentinpalkovic Apr 4, 2024
8adf047
Increase timeout in test
valentinpalkovic Apr 4, 2024
d015419
Apply requested changes
valentinpalkovic Apr 8, 2024
7fec522
Only eslintignore specific __tests__ directory
valentinpalkovic Apr 8, 2024
e36a1c0
Fix eslintignore pattern
valentinpalkovic Apr 8, 2024
9264728
Fix loading of experimental channel for essential addons
valentinpalkovic Apr 8, 2024
8cbb7fa
Fix server channel registration
valentinpalkovic Apr 8, 2024
58c9c78
Cleanup
valentinpalkovic Apr 8, 2024
23fce6f
Fix normalization on windows
valentinpalkovic Apr 9, 2024
4a879f7
Add VTA automigration tests
ndelangen Apr 9, 2024
7b6e966
Move code to core-server
valentinpalkovic Apr 9, 2024
e67928a
Adjust gitignore
valentinpalkovic Apr 9, 2024
7f5b3b6
Fix tests and finalize
valentinpalkovic Apr 9, 2024
314112a
Adjust eslintignore
valentinpalkovic Apr 9, 2024
81ce3d4
Update manager global exports
valentinpalkovic Apr 9, 2024
423d404
Remove leftovers
valentinpalkovic Apr 9, 2024
b2d3149
Update lock file
valentinpalkovic Apr 9, 2024
997551d
Docs: MDX minor fixes
jonniebigodes Apr 9, 2024
b2147af
Merge branch 'next' into docs_fix_MDX
jonniebigodes Apr 9, 2024
4d055fb
Update exports
valentinpalkovic Apr 9, 2024
cd5d79e
Merge pull request #26781 from storybookjs/docs_fix_MDX
jonniebigodes Apr 9, 2024
726a80a
Make sure test packages attaches name to arg spies
kasperpeulen Apr 9, 2024
945843e
Merge pull request #26726 from storybookjs/valentin/add-file-search-api
valentinpalkovic Apr 9, 2024
412b525
Move test
kasperpeulen Apr 9, 2024
f3d1452
Resolve review
kasperpeulen Apr 9, 2024
a784747
Fix test
kasperpeulen Apr 9, 2024
840070f
add to cli-options docs
eric-blue Apr 9, 2024
c67bf67
Merge pull request #26771 from eric-blue/next
valentinpalkovic Apr 9, 2024
bf1fe10
Fix test
kasperpeulen Apr 10, 2024
e98dfb8
Fix test
kasperpeulen Apr 10, 2024
176dbee
Fix test
kasperpeulen Apr 10, 2024
91d7a7f
Merge branch 'next' into patch-1
valentinpalkovic Apr 10, 2024
f9cb419
Make listeners a set
kasperpeulen Apr 10, 2024
ce192c2
resolve review comment
ndelangen Apr 10, 2024
1a61960
resolve review comment
ndelangen Apr 10, 2024
374520e
resolve review comment
ndelangen Apr 10, 2024
c9c9a2e
Add text provided by @joevaugh4n
ndelangen Apr 10, 2024
a542515
Merge branch 'next' into norbert/vta-added-on-upgrade
ndelangen Apr 10, 2024
62a85b1
Merge pull request #26740 from storybookjs/kasper/reactive-spies
kasperpeulen Apr 10, 2024
849de75
Merge pull request #26655 from jwilliams-met/patch-1
valentinpalkovic Apr 10, 2024
3b8bc27
Fix review comments
ndelangen Apr 10, 2024
ea4d20e
Merge branch 'norbert/vta-added-on-upgrade' of https://github.com/sto…
ndelangen Apr 10, 2024
8a3e909
cleanup
ndelangen Apr 10, 2024
90055cb
Merge branch 'next' into norbert/vta-added-on-upgrade
ndelangen Apr 10, 2024
c9fbb76
Merge pull request #26766 from storybookjs/norbert/vta-added-on-upgrade
ndelangen Apr 10, 2024
7e29280
Write changelog for 8.1.0-alpha.7 [skip ci]
storybook-bot Apr 10, 2024
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ jobs:
at: .
- run:
name: Install dependencies
command: yarn install
command: yarn install --no-immutable
working_directory: test-storybooks/portable-stories-kitchen-sink/<< parameters.directory >>
- run:
name: Run Jest tests
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 8.0.6

- CLI: Add --config-dir flag to migrate command - [#26721](https://github.com/storybookjs/storybook/pull/26721), thanks @yannbf!
- Next.js: Fix next/font usage on Windows machines - [#26700](https://github.com/storybookjs/storybook/pull/26700), thanks @valentinpalkovic!
- Next.js: Support path aliases when no base url is set - [#26651](https://github.com/storybookjs/storybook/pull/26651), thanks @yannbf!
- Webpack: Fix sourcemap generation in webpack react-docgen-loader - [#26676](https://github.com/storybookjs/storybook/pull/26676), thanks @valentinpalkovic!

## 8.0.5

- Addon-docs: Fix `react-dom/server` imports breaking stories and docs - [#26557](https://github.com/storybookjs/storybook/pull/26557), thanks @JReinhold!
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.prerelease.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 8.1.0-alpha.7

- CLI: Add --config-dir flag to add command - [#26771](https://github.com/storybookjs/storybook/pull/26771), thanks @eric-blue!
- CLI: Add Visual Tests addon install auto-migration when upgrading to 8.0.x - [#26766](https://github.com/storybookjs/storybook/pull/26766), thanks @ndelangen!
- Controls: Add Channels API to search for files in the project root - [#26726](https://github.com/storybookjs/storybook/pull/26726), thanks @valentinpalkovic!
- Test: Make spies reactive so that they can be logged by addon-actions - [#26740](https://github.com/storybookjs/storybook/pull/26740), thanks @kasperpeulen!
- Vue: Disable controls for events, slots, and expose - [#26751](https://github.com/storybookjs/storybook/pull/26751), thanks @shilman!
- Webpack: Bump webpack-dev-middleware to patch high security issue - [#26655](https://github.com/storybookjs/storybook/pull/26655), thanks @jwilliams-met!

## 8.1.0-alpha.6

- CLI: Add --config-dir flag to migrate command - [#26721](https://github.com/storybookjs/storybook/pull/26721), thanks @yannbf!
Expand Down
3 changes: 2 additions & 1 deletion code/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ ember-output
!.eslintrc.js
!.eslintrc-markdown.js
!.storybook
lib/core-common/templates/base-preview-head.html
lib/core-common/templates/base-preview-head.html
lib/core-server/src/utils/__search-files-tests__
38 changes: 14 additions & 24 deletions code/addons/actions/src/loaders.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,26 @@
/* eslint-disable no-underscore-dangle */
import type { LoaderFunction } from '@storybook/types';
import { global } from '@storybook/global';
import type { onMockCall as onMockCallType } from '@storybook/test';
import { action } from './runtime';

export const tinySpyInternalState = Symbol.for('tinyspy:spy');
let subscribed = false;

const attachActionsToFunctionMocks: LoaderFunction = (context) => {
const logActionsWhenMockCalled: LoaderFunction = (context) => {
const {
args,
parameters: { actions },
} = context;
if (actions?.disable) return;

Object.entries(args)
.filter(
([, value]) =>
typeof value === 'function' && '_isMockFunction' in value && value._isMockFunction
)
.forEach(([key, value]) => {
// See this discussion for context:
// https://github.com/vitest-dev/vitest/pull/5352
const previous =
value.getMockImplementation() ??
(tinySpyInternalState in value ? value[tinySpyInternalState]?.getOriginal() : undefined);
if (previous?._actionAttached !== true && previous?.isAction !== true) {
const implementation = (...params: unknown[]) => {
action(key)(...params);
return previous?.(...params);
};
implementation._actionAttached = true;
value.mockImplementation(implementation);
}
});
if (
!subscribed &&
'__STORYBOOK_TEST_ON_MOCK_CALL__' in global &&
typeof global.__STORYBOOK_TEST_ON_MOCK_CALL__ === 'function'
) {
const onMockCall = global.__STORYBOOK_TEST_ON_MOCK_CALL__ as typeof onMockCallType;
onMockCall((mock, args) => action(mock.getMockName())(args));
subscribed = true;
}
};

export const loaders: LoaderFunction[] = [attachActionsToFunctionMocks];
export const loaders: LoaderFunction[] = [logActionsWhenMockCalled];
24 changes: 24 additions & 0 deletions code/addons/actions/template/stories/spies.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { global as globalThis } from '@storybook/global';
import { spyOn } from '@storybook/test';

export default {
component: globalThis.Components.Button,
loaders() {
spyOn(console, 'log').mockName('console.log');
},
args: {
label: 'Button',
},
parameters: {
chromatic: { disable: true },
},
};

export const ShowSpyOnInActions = {
args: {
onClick: () => {
console.log('first');
console.log('second');
},
},
};
2 changes: 1 addition & 1 deletion code/addons/gfm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ The "@storybook/addon-mdx-gfm" addon is meant as a migration assistant for Story
> This addon will likely be removed in a future version.

It's recommended you read this document and follow its instructions instead:
https://storybook.js.org/docs/react/writing-docs/mdx#lack-of-github-flavored-markdown-gfm
https://storybook.js.org/docs/writing-docs/mdx#markdown-tables-arent-rendering-correctly

Once you've made the necessary changes, you can remove the addon from your package.json and storybook config.
42 changes: 0 additions & 42 deletions code/addons/interactions/src/preview.test.ts

This file was deleted.

53 changes: 1 addition & 52 deletions code/addons/interactions/src/preview.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import type {
ArgsEnhancer,
PlayFunction,
PlayFunctionContext,
Renderer,
StepLabel,
} from '@storybook/types';
import { fn, isMockFunction } from '@storybook/test';
import type { PlayFunction, PlayFunctionContext, StepLabel } from '@storybook/types';
import { instrument } from '@storybook/instrumenter';

export const { step: runStep } = instrument(
Expand All @@ -16,50 +9,6 @@ export const { step: runStep } = instrument(
{ intercept: true }
);

export const traverseArgs = (value: unknown, depth = 0, key?: string): unknown => {
// Make sure to not get in infinite loops with self referencing args
if (depth > 5) return value;
if (value == null) return value;
if (isMockFunction(value)) {
// Makes sure we get the arg name in the interactions panel
if (key) value.mockName(key);
return value;
}

// wrap explicit actions in a spy
if (
typeof value === 'function' &&
'isAction' in value &&
value.isAction &&
!('implicit' in value && value.implicit)
) {
const mock = fn(value as any);
if (key) mock.mockName(key);
return mock;
}

if (Array.isArray(value)) {
depth++;
return value.map((item) => traverseArgs(item, depth));
}

if (typeof value === 'object' && value.constructor === Object) {
depth++;
for (const [k, v] of Object.entries(value)) {
if (Object.getOwnPropertyDescriptor(value, k).writable) {
// We have to mutate the original object for this to survive HMR.
(value as Record<string, unknown>)[k] = traverseArgs(v, depth, k);
}
}
return value;
}
return value;
};

const wrapActionsInSpyFns: ArgsEnhancer<Renderer> = ({ initialArgs }) => traverseArgs(initialArgs);

export const argsEnhancers = [wrapActionsInSpyFns];

export const parameters = {
throwPlayFunctionExceptions: false,
};
2 changes: 1 addition & 1 deletion code/builders/builder-webpack5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"util": "^0.12.4",
"util-deprecate": "^1.0.2",
"webpack": "5",
"webpack-dev-middleware": "^6.1.1",
"webpack-dev-middleware": "^6.1.2",
"webpack-hot-middleware": "^2.25.1",
"webpack-virtual-modules": "^0.5.0"
},
Expand Down
22 changes: 22 additions & 0 deletions code/e2e-tests/addon-actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,26 @@ test.describe('addon-actions', () => {
});
await expect(logItem).toBeVisible();
});

test('should show spies', async ({ page }) => {
test.skip(
templateName.includes('svelte') && templateName.includes('prerelease'),
'Svelte 5 prerelase does not support automatic actions with our current example components yet'
);
await page.goto(storybookUrl);
const sbPage = new SbPage(page);
sbPage.waitUntilLoaded();

await sbPage.navigateToStory('addons/actions/spies', 'show-spy-on-in-actions');

const root = sbPage.previewRoot();
const button = root.locator('button', { hasText: 'Button' });
await button.click();

await sbPage.viewAddonPanel('Actions');
const logItem = await page.locator('#storybook-panel-root #panel-tab-content', {
hasText: 'console.log',
});
await expect(logItem).toBeVisible();
});
});
17 changes: 13 additions & 4 deletions code/lib/cli/src/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ const checkInstalled = (addonName: string, main: any) => {

const isCoreAddon = (addonName: string) => Object.hasOwn(versions, addonName);

type CLIOptions = {
packageManager?: PackageManagerName;
configDir?: string;
skipPostinstall: boolean;
};

/**
* Install the given addon package and add it to main.js
*
Expand All @@ -61,15 +67,18 @@ const isCoreAddon = (addonName: string) => Object.hasOwn(versions, addonName);
*/
export async function add(
addon: string,
options: { packageManager: PackageManagerName; skipPostinstall: boolean },
{ packageManager: pkgMgr, skipPostinstall, configDir: userSpecifiedConfigDir }: CLIOptions,
logger = console
) {
const { packageManager: pkgMgr } = options;
const [addonName, inputVersion] = getVersionSpecifier(addon);

const packageManager = JsPackageManagerFactory.getPackageManager({ force: pkgMgr });
const packageJson = await packageManager.retrievePackageJson();
const { mainConfig, configDir } = getStorybookInfo(packageJson);
const { mainConfig, configDir: inferredConfigDir } = getStorybookInfo(
packageJson,
userSpecifiedConfigDir
);
const configDir = userSpecifiedConfigDir || inferredConfigDir || '.storybook';

if (typeof configDir === 'undefined') {
throw new Error(dedent`
Expand Down Expand Up @@ -119,7 +128,7 @@ export async function add(
main.appendValueToArray(['addons'], addonName);
await writeConfig(main);

if (!options.skipPostinstall && isCoreAddon(addonName)) {
if (!skipPostinstall && isCoreAddon(addonName)) {
await postinstallAddon(addonName, { packageManager: packageManager.type });
}
}
Expand Down
2 changes: 2 additions & 0 deletions code/lib/cli/src/automigrate/fixes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { removeJestTestingLibrary } from './remove-jest-testing-library';
import { addonsAPI } from './addons-api';
import { mdx1to3 } from './mdx-1-to-3';
import { addonPostCSS } from './addon-postcss';
import { vta } from './vta';
import { upgradeStorybookRelatedDependencies } from './upgrade-storybook-related-dependencies';

export * from '../types';
Expand Down Expand Up @@ -58,6 +59,7 @@ export const allFixes: Fix[] = [
webpack5CompilerSetup,
mdx1to3,
upgradeStorybookRelatedDependencies,
vta,
];

export const initFixes: Fix[] = [eslintPlugin];
61 changes: 61 additions & 0 deletions code/lib/cli/src/automigrate/fixes/vta.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { describe, expect, it } from 'vitest';
import type { StorybookConfig } from '@storybook/types';
import { vta } from './vta';

const check = async ({
packageManager,
main: mainConfig,
storybookVersion = '7.0.0',
}: {
packageManager: any;
main: Partial<StorybookConfig> & Record<string, unknown>;
storybookVersion?: string;
}) => {
return vta.check({
packageManager,
configDir: '',
mainConfig: mainConfig as any,
storybookVersion,
});
};

describe('no-ops', () => {
it('with addon setup', async () => {
await expect(
check({
packageManager: {},
main: {
addons: ['@chromatic-com/storybook'],
},
})
).resolves.toBeFalsy();
});
it('with addon setup with options', async () => {
await expect(
check({
packageManager: {},
main: {
addons: [
{
name: '@chromatic-com/storybook',
options: {},
},
],
},
})
).resolves.toBeFalsy();
});
});

describe('continue', () => {
it('no addons', async () => {
await expect(
check({
packageManager: {},
main: {
stories: ['**/*.stories.mdx'],
},
})
).resolves.toBeTruthy();
});
});
Loading