From ea0bf68c78b73b6098a2cf15d0acbbccfaa60c58 Mon Sep 17 00:00:00 2001 From: Kasper Peulen Date: Wed, 3 Jul 2024 20:53:34 +0200 Subject: [PATCH 1/4] Set default targets for next babel config --- code/frameworks/nextjs/src/babel/preset.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/code/frameworks/nextjs/src/babel/preset.ts b/code/frameworks/nextjs/src/babel/preset.ts index c21e7e281caf..1b48e4a663c0 100644 --- a/code/frameworks/nextjs/src/babel/preset.ts +++ b/code/frameworks/nextjs/src/babel/preset.ts @@ -82,6 +82,12 @@ export default (api: any, options: NextBabelPresetOptions = {}): BabelPreset => // In production/development this option is set to `false` so that webpack can handle import/export with tree-shaking modules: 'auto', exclude: ['transform-typeof-symbol'], + bugfixes: true, + targets: { + chrome: 100, + safari: 15, + firefox: 91, + }, ...options['preset-env'], }; From 9057d646500427703378e9489c8558c05ea80884 Mon Sep 17 00:00:00 2001 From: Kasper Peulen Date: Wed, 3 Jul 2024 20:57:59 +0200 Subject: [PATCH 2/4] Put back storybook/test templates in CI --- scripts/tasks/sandbox-parts.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/tasks/sandbox-parts.ts b/scripts/tasks/sandbox-parts.ts index 13e9d5dcbd99..90cdd9c43e45 100644 --- a/scripts/tasks/sandbox-parts.ts +++ b/scripts/tasks/sandbox-parts.ts @@ -488,6 +488,12 @@ export const addStories: Task['run'] = async ( cwd, disableDocs, }); + + await linkPackageStories(await workspacePath('test package', '@storybook/test'), { + mainConfig, + cwd, + disableDocs, + }); } const mainAddons = (mainConfig.getSafeFieldValue(['addons']) || []).reduce( From 62177376d15a13549557d60e4c487ad7f6caf0d8 Mon Sep 17 00:00:00 2001 From: Kasper Peulen Date: Wed, 3 Jul 2024 22:02:17 +0200 Subject: [PATCH 3/4] Remove redundant stories --- .../template/stories/before-each.stories.ts | 44 ------------------- .../stories/module-mocking.stories.ts | 28 ------------ 2 files changed, 72 deletions(-) delete mode 100644 code/core/template/stories/before-each.stories.ts delete mode 100644 code/core/template/stories/module-mocking.stories.ts diff --git a/code/core/template/stories/before-each.stories.ts b/code/core/template/stories/before-each.stories.ts deleted file mode 100644 index a6f613e7698c..000000000000 --- a/code/core/template/stories/before-each.stories.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { expect, mocked, getByRole, spyOn, userEvent } from '@storybook/test'; - -const meta = { - component: globalThis.Components.Button, - loaders() { - spyOn(console, 'log').mockName('console.log'); - console.log('1 - [from loaders]'); - }, - beforeEach() { - console.log('2 - [from meta beforeEach]'); - }, -}; - -export default meta; - -export const BeforeEachOrder = { - parameters: { - chromatic: { disable: true }, - }, - beforeEach() { - console.log('3 - [from story beforeEach]'); - }, - decorators: (StoryFn: any) => { - console.log('4 - [from decorator]'); - return StoryFn(); - }, - args: { - label: 'Button', - onClick: () => { - console.log('5 - [from onClick]'); - }, - }, - async play({ canvasElement }: any) { - await userEvent.click(getByRole(canvasElement, 'button')); - - await expect(mocked(console.log).mock.calls).toEqual([ - ['1 - [from loaders]'], - ['2 - [from meta beforeEach]'], - ['3 - [from story beforeEach]'], - ['4 - [from decorator]'], - ['5 - [from onClick]'], - ]); - }, -}; diff --git a/code/core/template/stories/module-mocking.stories.ts b/code/core/template/stories/module-mocking.stories.ts deleted file mode 100644 index dc9b8e2430b7..000000000000 --- a/code/core/template/stories/module-mocking.stories.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { global as globalThis } from '@storybook/global'; -// eslint-disable-next-line @typescript-eslint/ban-ts-comment -// @ts-ignore This alias is set in the sandbox. Using ts-ignore instead of ts-expect-error to avoid build errors in the sandbox. - -import { foo } from '#utils'; -import { expect, fn, isMockFunction, mocked } from '@storybook/test'; - -export default { - component: globalThis.Components.Button, - args: { - onClick: fn(), - label: 'Mock story', - }, - parameters: { - chromatic: { - disable: true, - }, - }, - beforeEach: () => { - mocked(foo).mockReturnValue('mocked'); - }, - async play() { - await expect(isMockFunction(foo)).toBe(true); - await expect(foo()).toBe('mocked'); - }, -}; - -export const Basic = {}; From 5b81e5b3c2b70ff66227c1783336026635713f2c Mon Sep 17 00:00:00 2001 From: Kasper Peulen Date: Wed, 3 Jul 2024 22:47:55 +0200 Subject: [PATCH 4/4] Fix e2e test --- code/e2e-tests/module-mocking.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/e2e-tests/module-mocking.spec.ts b/code/e2e-tests/module-mocking.spec.ts index f82bac6e27b2..8b6b43713b61 100644 --- a/code/e2e-tests/module-mocking.spec.ts +++ b/code/e2e-tests/module-mocking.spec.ts @@ -14,7 +14,7 @@ test.describe('module-mocking', () => { test('should assert story lifecycle order', async ({ page }) => { const sbPage = new SbPage(page); - await sbPage.navigateToStory('core/before-each', 'before-each-order'); + await sbPage.navigateToStory('lib/test/before-each', 'before-each-order'); await sbPage.viewAddonPanel('Actions'); const logItem = await page.locator('#storybook-panel-root #panel-tab-content'); @@ -38,7 +38,7 @@ test.describe('module-mocking', () => { test('should assert that utils import is mocked', async ({ page }) => { const sbPage = new SbPage(page); - await sbPage.navigateToStory('core/module-mocking', 'basic'); + await sbPage.navigateToStory('lib/test/module-mocking', 'basic'); await sbPage.viewAddonPanel('Actions'); const logItem = await page.locator('#storybook-panel-root #panel-tab-content', {