Skip to content

Commit a1f87c6

Browse files
committed
fix(mocks): Storybook 8 compatibility
1 parent 54004da commit a1f87c6

File tree

7 files changed

+20
-7
lines changed

7 files changed

+20
-7
lines changed

.changeset/thin-wombats-nail.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@web/mocks': minor
3+
---
4+
5+
fix Storybook 8 compatibility

packages/mocks/storybook/addon.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import { createAddon } from '@web/storybook-prebuilt/create-addon.js';
44
import { React } from '@web/storybook-prebuilt/manager.js';
5-
import { addons } from '@web/storybook-prebuilt/addons.js';
5+
import { addons, types } from '@web/storybook-prebuilt/addons.js';
66
import { registerAddon } from './addon/register-addon.js';
77

88
// Storybook 6
9-
registerAddon(addons, React, createAddon);
9+
registerAddon(addons, types, React, createAddon);

packages/mocks/storybook/addon/manager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import { createAddon } from '@web/storybook-utils';
44
import React from 'react';
5-
import { addons } from '@storybook/manager-api';
5+
import { addons, types } from '@storybook/manager-api';
66
import { registerAddon } from './register-addon.js';
77

88
// Storybook 7+
9-
registerAddon(addons, React, createAddon);
9+
registerAddon(addons, types, React, createAddon);

packages/mocks/storybook/addon/register-addon.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { LitElement, html, css } from 'lit';
44
import { when } from 'lit/directives/when.js';
55

6-
export function registerAddon(addons, React, createAddon) {
6+
export function registerAddon(addons, types, React, createAddon) {
77
const { createElement } = React;
88

99
class MocksAddonElement extends LitElement {
@@ -242,7 +242,8 @@ export function registerAddon(addons, React, createAddon) {
242242
});
243243

244244
addons.register('web/mocks', api => {
245-
addons.addPanel('web/mocks/panel', {
245+
addons.add('web/mocks/panel', {
246+
type: types.PANEL,
246247
title: 'Mocks',
247248
paramKey: 'mocks',
248249
render: ({ active }) => createElement(MocksAddon, { api, active }),

packages/storybook-framework-web-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
},
2929
"scripts": {
3030
"build": "tsc",
31-
"test": "npm run test:build && npm run test:ui:build && npm run test:ui:runtime",
31+
"test": "npm run test:build && npm run test:ui:runtime",
3232
"test:build": "storybook build -c ./tests/fixtures/all-in-one/.storybook -o ./tests/fixtures/all-in-one/storybook-build",
3333
"test:start:build": "wds -r ./tests/fixtures/all-in-one/storybook-build -p 3000",
3434
"test:start:runtime": "storybook dev -c ./tests/fixtures/all-in-one/.storybook -p 3000 --no-open",

packages/storybook-framework-web-components/tests/all-in-one.spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ test.describe('all in one', () => {
7979
await panelButton.click();
8080
await expect(panelButton).toHaveClass(/tabbutton-active/);
8181
});
82+
83+
test('renders @web/mocks/storybook-addon panel', async () => {
84+
const panelButton = sbPage.panelButtonByText('Mocks');
85+
await panelButton.click();
86+
await expect(panelButton).toHaveClass(/tabbutton-active/);
87+
});
8288
});
8389

8490
test.describe('docs', () => {

packages/storybook-framework-web-components/tests/fixtures/all-in-one/.storybook/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const config = {
88
'@storybook/addon-links',
99
'@storybook/addon-interactions',
1010
'@storybook/addon-a11y',
11+
'@web/mocks/storybook-addon',
1112
],
1213
framework: {
1314
name: '@web/storybook-framework-web-components',

0 commit comments

Comments
 (0)