Skip to content

Commit

Permalink
Merge pull request #26063 from storybookjs/feature/portable-stories-i…
Browse files Browse the repository at this point in the history
…mprovements

Portable stories: Introduce experimental Playwright CT API and Support for more renderers
  • Loading branch information
yannbf authored Mar 18, 2024
2 parents af79778 + 89d7ef9 commit 7d282b2
Show file tree
Hide file tree
Showing 214 changed files with 57,444 additions and 82 deletions.
66 changes: 64 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@ executors:
environment:
NODE_OPTIONS: --max_old_space_size=6144
resource_class: <<parameters.class>>
sb_playwright_component_testing:
parameters:
class:
description: The Resource class
type: enum
enum: ["small", "medium", "medium+", "large", "xlarge"]
default: "small"
working_directory: /tmp/storybook
docker:
- image: mcr.microsoft.com/playwright:v1.42.1-jammy
environment:
NODE_OPTIONS: --max_old_space_size=6144
resource_class: <<parameters.class>>

orbs:
git-shallow-clone: guitarrapc/git-shallow-clone@2.5.0
Expand Down Expand Up @@ -565,7 +578,39 @@ jobs:
STORYBOOK_INIT_EMPTY_TYPE: << parameters.template >>
STORYBOOK_DISABLE_TELEMETRY: true
- report-workflow-on-failure

test-portable-stories:
parameters:
directory:
type: string
executor:
name: sb_playwright_component_testing
class: medium
steps:
- git-shallow-clone/checkout_advanced:
clone_options: "--depth 1 --verbose"
- attach_workspace:
at: .
- run:
name: Install dependencies
command: yarn install
working_directory: test-storybooks/portable-stories-kitchen-sink/<< parameters.directory >>
- run:
name: Run Jest tests
command: yarn jest
working_directory: test-storybooks/portable-stories-kitchen-sink/<< parameters.directory >>
- run:
name: Run Vitest tests
command: yarn vitest
working_directory: test-storybooks/portable-stories-kitchen-sink/<< parameters.directory >>
- run:
name: Run Playwright CT tests
command: yarn playwright
working_directory: test-storybooks/portable-stories-kitchen-sink/<< parameters.directory >>
- run:
name: Run Cypress CT tests
command: yarn cypress
working_directory: test-storybooks/portable-stories-kitchen-sink/<< parameters.directory >>
- report-workflow-on-failure
workflows:
docs:
when:
Expand Down Expand Up @@ -624,6 +669,12 @@ workflows:
parallelism: 5
requires:
- build-sandboxes
- test-portable-stories:
requires:
- build
matrix:
parameters:
directory: ["react", "vue3", "nextjs", "svelte"]
# TODO: reenable once we find out the source of flakyness
# - test-runner-dev:
# requires:
Expand Down Expand Up @@ -676,6 +727,12 @@ workflows:
parallelism: 14
requires:
- build-sandboxes
- test-portable-stories:
requires:
- build
matrix:
parameters:
directory: ["react", "vue3", "nextjs", "svelte"]
- bench:
parallelism: 5
requires:
Expand Down Expand Up @@ -733,7 +790,12 @@ workflows:
parallelism: 30
requires:
- build-sandboxes

- test-portable-stories:
requires:
- build
matrix:
parameters:
directory: ["react", "vue3", "nextjs", "svelte"]
- test-empty-init:
requires:
- build
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion code/addons/a11y/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@
"require": "./dist/index.js",
"import": "./dist/index.mjs"
},
"./preview": {
"types": "./dist/preview.d.ts",
"require": "./dist/preview.js",
"import": "./dist/preview.mjs"
},
"./manager": "./dist/manager.js",
"./preview": "./dist/preview.js",
"./register": "./dist/manager.js",
"./package.json": "./package.json"
},
Expand Down
6 changes: 5 additions & 1 deletion code/addons/actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@
"require": "./dist/decorator.js",
"import": "./dist/decorator.mjs"
},
"./preview": {
"types": "./dist/preview.d.ts",
"require": "./dist/preview.js",
"import": "./dist/preview.mjs"
},
"./manager": "./dist/manager.js",
"./preview": "./dist/preview.js",
"./register.js": "./dist/manager.js",
"./package.json": "./package.json"
},
Expand Down
6 changes: 5 additions & 1 deletion code/addons/backgrounds/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@
"require": "./dist/index.js",
"import": "./dist/index.mjs"
},
"./preview": {
"types": "./dist/preview.d.ts",
"require": "./dist/preview.js",
"import": "./dist/preview.mjs"
},
"./manager": "./dist/manager.js",
"./preview": "./dist/preview.js",
"./register": "./dist/manager.js",
"./package.json": "./package.json"
},
Expand Down
42 changes: 35 additions & 7 deletions code/addons/essentials/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,50 @@
"require": "./dist/index.js",
"import": "./dist/index.mjs"
},
"./actions/preview": "./dist/actions/preview.js",
"./actions/preview": {
"types": "./dist/actions/preview.d.ts",
"import": "./dist/actions/preview.mjs",
"require": "./dist/actions/preview.js"
},
"./actions/manager": "./dist/actions/manager.js",
"./backgrounds/preview": "./dist/backgrounds/preview.js",
"./backgrounds/preview": {
"types": "./dist/backgrounds/preview.d.ts",
"import": "./dist/backgrounds/preview.mjs",
"require": "./dist/backgrounds/preview.js"
},
"./backgrounds/manager": "./dist/backgrounds/manager.js",
"./controls/manager": "./dist/controls/manager.js",
"./docs/preview": "./dist/docs/preview.js",
"./docs/preview": {
"types": "./dist/docs/preview.d.ts",
"import": "./dist/docs/preview.mjs",
"require": "./dist/docs/preview.js"
},
"./docs/preset": "./dist/docs/preset.js",
"./docs/mdx-react-shim": "./dist/docs/mdx-react-shim.js",
"./highlight/preview": "./dist/highlight/preview.js",
"./measure/preview": "./dist/measure/preview.js",
"./highlight/preview": {
"types": "./dist/highlight/preview.d.ts",
"import": "./dist/highlight/preview.mjs",
"require": "./dist/highlight/preview.js"
},
"./measure/preview": {
"types": "./dist/measure/preview.d.ts",
"import": "./dist/measure/preview.mjs",
"require": "./dist/measure/preview.js"
},
"./measure/manager": "./dist/measure/manager.js",
"./outline/preview": "./dist/outline/preview.js",
"./outline/preview": {
"types": "./dist/outline/preview.d.ts",
"import": "./dist/outline/preview.mjs",
"require": "./dist/outline/preview.js"
},
"./outline/manager": "./dist/outline/manager.js",
"./toolbars/manager": "./dist/toolbars/manager.js",
"./viewport/manager": "./dist/viewport/manager.js",
"./viewport/preview": "./dist/viewport/preview.js",
"./viewport/preview": {
"types": "./dist/viewport/preview.d.ts",
"import": "./dist/viewport/preview.mjs",
"require": "./dist/viewport/preview.js"
},
"./package.json": "./package.json"
},
"main": "dist/index.js",
Expand Down
1 change: 0 additions & 1 deletion code/addons/essentials/src/measure/preview.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
// @ts-expect-error (no types needed for this)
export * from '@storybook/addon-measure/preview';
6 changes: 5 additions & 1 deletion code/addons/highlight/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@
"require": "./dist/index.js",
"import": "./dist/index.mjs"
},
"./preview": "./dist/preview.js",
"./preview": {
"types": "./dist/preview.d.ts",
"require": "./dist/preview.js",
"import": "./dist/preview.mjs"
},
"./package.json": "./package.json"
},
"main": "dist/index.js",
Expand Down
8 changes: 1 addition & 7 deletions code/addons/highlight/src/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,12 @@ const { document } = global;

type OutlineStyle = 'dotted' | 'dashed' | 'solid' | 'double';

export const highlightStyle = (color = '#FF4785', style: OutlineStyle = 'dashed') => `
const highlightStyle = (color = '#FF4785', style: OutlineStyle = 'dashed') => `
outline: 2px ${style} ${color};
outline-offset: 2px;
box-shadow: 0 0 0 6px rgba(255,255,255,0.6);
`;

export const highlightObject = (color: string) => ({
outline: `2px dashed ${color}`,
outlineOffset: 2,
boxShadow: '0 0 0 6px rgba(255,255,255,0.6)',
});

interface HighlightInfo {
/** html selector of the element */
elements: string[];
Expand Down
6 changes: 5 additions & 1 deletion code/addons/interactions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@
"require": "./dist/index.js",
"import": "./dist/index.mjs"
},
"./preview": {
"types": "./dist/preview.d.ts",
"require": "./dist/preview.js",
"import": "./dist/preview.mjs"
},
"./manager": "./dist/manager.js",
"./preview": "./dist/preview.js",
"./preset": "./dist/preset.js",
"./register.js": "./dist/manager.js",
"./package.json": "./package.json"
Expand Down
6 changes: 5 additions & 1 deletion code/addons/links/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@
"require": "./dist/react/index.js",
"import": "./dist/react/index.mjs"
},
"./preview": {
"types": "./dist/preview.d.ts",
"require": "./dist/preview.js",
"import": "./dist/preview.mjs"
},
"./manager": "./dist/manager.js",
"./preview": "./dist/preview.js",
"./register": "./dist/manager.js",
"./package.json": "./package.json"
},
Expand Down
6 changes: 5 additions & 1 deletion code/addons/measure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@
"require": "./dist/index.js",
"import": "./dist/index.mjs"
},
"./preview": {
"types": "./dist/preview.d.ts",
"require": "./dist/preview.js",
"import": "./dist/preview.mjs"
},
"./manager": "./dist/manager.js",
"./preview": "./dist/preview.js",
"./register": "./dist/manager.js",
"./package.json": "./package.json"
},
Expand Down
6 changes: 5 additions & 1 deletion code/addons/outline/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@
"require": "./dist/index.js",
"import": "./dist/index.mjs"
},
"./preview": {
"types": "./dist/preview.d.ts",
"require": "./dist/preview.js",
"import": "./dist/preview.mjs"
},
"./manager": "./dist/manager.js",
"./preview": "./dist/preview.js",
"./register": "./dist/manager.js",
"./package.json": "./package.json"
},
Expand Down
Loading

0 comments on commit 7d282b2

Please sign in to comment.