diff --git a/.circleci/config.yml b/.circleci/config.yml index 385972ef21d8..ddc8d0667b12 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -884,6 +884,26 @@ jobs: template: $(yarn get-template --cadence << pipeline.parameters.workflow >> --task test-runner) - store_test_results: path: test-results + test-yarn-pnp: + executor: + class: medium + name: sb_playwright + steps: + - git-shallow-clone/checkout_advanced: + clone_options: --depth 1 --verbose + - attach_workspace: + at: . + - run: + command: yarn install --no-immutable + environment: + YARN_ENABLE_IMMUTABLE_INSTALLS: false + name: Install dependencies + working_directory: test-storybooks/yarn-pnp + - run: + command: yarn storybook --smoke-test + name: Run Storybook smoke test + working_directory: test-storybooks/yarn-pnp + - report-workflow-on-failure unit-tests: executor: class: xlarge @@ -1024,6 +1044,9 @@ workflows: - svelte requires: - build + - test-yarn-pnp: + requires: + - build - e2e-ui: requires: - build @@ -1119,6 +1142,9 @@ workflows: - svelte requires: - build + - test-yarn-pnp: + requires: + - build - e2e-ui: requires: - build @@ -1185,6 +1211,9 @@ workflows: parallelism: 5 requires: - create-sandboxes + - test-yarn-pnp: + requires: + - build - e2e-ui: requires: - build diff --git a/.circleci/src/jobs/test-yarn-pnp.yml b/.circleci/src/jobs/test-yarn-pnp.yml new file mode 100644 index 000000000000..b89e4d8bd540 --- /dev/null +++ b/.circleci/src/jobs/test-yarn-pnp.yml @@ -0,0 +1,21 @@ +executor: + name: sb_playwright + class: medium + +steps: + - git-shallow-clone/checkout_advanced: + clone_options: '--depth 1 --verbose' + - attach_workspace: + at: . + - run: + name: Install dependencies + command: yarn install --no-immutable + working_directory: test-storybooks/yarn-pnp + environment: + YARN_ENABLE_IMMUTABLE_INSTALLS: false + - run: + name: Run Storybook smoke test + command: yarn storybook --smoke-test + working_directory: test-storybooks/yarn-pnp + + - report-workflow-on-failure diff --git a/.circleci/src/workflows/daily.yml b/.circleci/src/workflows/daily.yml index 0f31c5279609..e79f8479054e 100644 --- a/.circleci/src/workflows/daily.yml +++ b/.circleci/src/workflows/daily.yml @@ -63,6 +63,9 @@ jobs: matrix: parameters: directory: ['react', 'vue3', 'nextjs', 'svelte'] + - test-yarn-pnp: + requires: + - build - e2e-ui: requires: - build diff --git a/.circleci/src/workflows/merged.yml b/.circleci/src/workflows/merged.yml index bdf687d408a4..5cfc1b836e33 100644 --- a/.circleci/src/workflows/merged.yml +++ b/.circleci/src/workflows/merged.yml @@ -63,6 +63,9 @@ jobs: matrix: parameters: directory: ['react', 'vue3', 'nextjs', 'svelte'] + - test-yarn-pnp: + requires: + - build - e2e-ui: requires: - build diff --git a/.circleci/src/workflows/normal.yml b/.circleci/src/workflows/normal.yml index 5aa63679dffb..2a9639f46535 100644 --- a/.circleci/src/workflows/normal.yml +++ b/.circleci/src/workflows/normal.yml @@ -62,6 +62,9 @@ jobs: # parallelism: 5 # requires: # - create-sandboxes + - test-yarn-pnp: + requires: + - build - e2e-ui: requires: - build diff --git a/test-storybooks/yarn-pnp/.storybook/main.ts b/test-storybooks/yarn-pnp/.storybook/main.ts index d0d77ba98234..88cd184ea953 100644 --- a/test-storybooks/yarn-pnp/.storybook/main.ts +++ b/test-storybooks/yarn-pnp/.storybook/main.ts @@ -1,25 +1,16 @@ -import { fileURLToPath } from "node:url"; -import { dirname } from "node:path"; -import type { StorybookConfig } from '@storybook/react-vite'; - -const config: StorybookConfig = { - "stories": [ - "../src/**/*.mdx", - "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)" - ], - "addons": [ - getAbsolutePath("@chromatic-com/storybook"), - getAbsolutePath("@storybook/addon-docs"), - getAbsolutePath("@storybook/addon-a11y"), - getAbsolutePath("@storybook/addon-vitest") - ], - "framework": { - "name": getAbsolutePath("@storybook/react-vite"), - "options": {} - } -}; -export default config; - -function getAbsolutePath(value: string): any { - return dirname(fileURLToPath(import.meta.resolve(`${value}/package.json`))); -} \ No newline at end of file +import type { StorybookConfig } from "@storybook/vue3-vite"; + +const config: StorybookConfig = { + stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"], + addons: [ + "@chromatic-com/storybook", + "@storybook/addon-docs", + "@storybook/addon-a11y", + "@storybook/addon-vitest", + ], + framework: { + name: "@storybook/vue3-vite", + options: {}, + }, +}; +export default config; diff --git a/test-storybooks/yarn-pnp/.storybook/vitest.setup.ts b/test-storybooks/yarn-pnp/.storybook/vitest.setup.ts index 44922d55e49d..d3876789a13a 100644 --- a/test-storybooks/yarn-pnp/.storybook/vitest.setup.ts +++ b/test-storybooks/yarn-pnp/.storybook/vitest.setup.ts @@ -1,7 +1,7 @@ import * as a11yAddonAnnotations from "@storybook/addon-a11y/preview"; -import { setProjectAnnotations } from '@storybook/react-vite'; -import * as projectAnnotations from './preview'; +import { setProjectAnnotations } from "@storybook/vue3-vite"; +import * as projectAnnotations from "./preview"; // This is an important step to apply the right configuration when testing your stories. // More info at: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#setprojectannotations -setProjectAnnotations([a11yAddonAnnotations, projectAnnotations]); \ No newline at end of file +setProjectAnnotations([a11yAddonAnnotations, projectAnnotations]); diff --git a/test-storybooks/yarn-pnp/README.md b/test-storybooks/yarn-pnp/README.md deleted file mode 100644 index 7959ce426934..000000000000 --- a/test-storybooks/yarn-pnp/README.md +++ /dev/null @@ -1,69 +0,0 @@ -# React + TypeScript + Vite - -This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. - -Currently, two official plugins are available: - -- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) for Fast Refresh -- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh - -## Expanding the ESLint configuration - -If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules: - -```js -export default tseslint.config([ - globalIgnores(['dist']), - { - files: ['**/*.{ts,tsx}'], - extends: [ - // Other configs... - - // Remove tseslint.configs.recommended and replace with this - ...tseslint.configs.recommendedTypeChecked, - // Alternatively, use this for stricter rules - ...tseslint.configs.strictTypeChecked, - // Optionally, add this for stylistic rules - ...tseslint.configs.stylisticTypeChecked, - - // Other configs... - ], - languageOptions: { - parserOptions: { - project: ['./tsconfig.node.json', './tsconfig.app.json'], - tsconfigRootDir: import.meta.dirname, - }, - // other options... - }, - }, -]) -``` - -You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules: - -```js -// eslint.config.js -import reactX from 'eslint-plugin-react-x' -import reactDom from 'eslint-plugin-react-dom' - -export default tseslint.config([ - globalIgnores(['dist']), - { - files: ['**/*.{ts,tsx}'], - extends: [ - // Other configs... - // Enable lint rules for React - reactX.configs['recommended-typescript'], - // Enable lint rules for React DOM - reactDom.configs.recommended, - ], - languageOptions: { - parserOptions: { - project: ['./tsconfig.node.json', './tsconfig.app.json'], - tsconfigRootDir: import.meta.dirname, - }, - // other options... - }, - }, -]) -``` diff --git a/test-storybooks/yarn-pnp/eslint.config.js b/test-storybooks/yarn-pnp/eslint.config.js index bc656236fe0c..279fc495572d 100644 --- a/test-storybooks/yarn-pnp/eslint.config.js +++ b/test-storybooks/yarn-pnp/eslint.config.js @@ -3,8 +3,6 @@ import storybook from "eslint-plugin-storybook"; import js from '@eslint/js' import globals from 'globals' -import reactHooks from 'eslint-plugin-react-hooks' -import reactRefresh from 'eslint-plugin-react-refresh' import tseslint from 'typescript-eslint' import { globalIgnores } from 'eslint/config' @@ -15,8 +13,6 @@ export default tseslint.config([ extends: [ js.configs.recommended, tseslint.configs.recommended, - reactHooks.configs['recommended-latest'], - reactRefresh.configs.vite, ], languageOptions: { ecmaVersion: 2020, diff --git a/test-storybooks/yarn-pnp/index.html b/test-storybooks/yarn-pnp/index.html index e4b78eae1230..fc7120dd11e1 100644 --- a/test-storybooks/yarn-pnp/index.html +++ b/test-storybooks/yarn-pnp/index.html @@ -1,13 +1,16 @@ - - - - - Vite + React + TS - - -
- - - + + + + + + vue3-vite + + + +
+ + + + \ No newline at end of file diff --git a/test-storybooks/yarn-pnp/package.json b/test-storybooks/yarn-pnp/package.json index 63e2d3e7eca3..8e30706caaa6 100644 --- a/test-storybooks/yarn-pnp/package.json +++ b/test-storybooks/yarn-pnp/package.json @@ -4,12 +4,11 @@ "private": true, "type": "module", "scripts": { - "build": "tsc -b && vite build", - "build-storybook": "storybook build", "dev": "vite", - "lint": "eslint .", + "build": "vue-tsc -b && vite build", "preview": "vite preview", - "storybook": "storybook dev -p 6006" + "storybook": "storybook dev -p 6006", + "build-storybook": "storybook build" }, "resolutions": { "@playwright/test": "1.52.0", @@ -50,32 +49,28 @@ "storybook": "file:../../code/core" }, "dependencies": { - "react": "^19.1.0", - "react-dom": "^19.1.0" + "vue": "^3.5.22" }, "devDependencies": { "@chromatic-com/storybook": "^4.1.2", - "@eslint/js": "^9.29.0", - "@playwright/test": "1.52.0", - "@storybook/addon-a11y": "9.1.0-alpha.6", - "@storybook/addon-docs": "9.1.0-alpha.6", - "@storybook/addon-vitest": "9.1.0-alpha.6", - "@storybook/react-vite": "9.1.0-alpha.6", - "@types/react": "^19.1.8", - "@types/react-dom": "^19.1.6", - "@vitejs/plugin-react": "^4.5.2", - "@vitest/browser": "^3.2.4", - "@vitest/coverage-v8": "^3.2.4", + "@storybook/addon-a11y": "^10.1.0-alpha.6", + "@storybook/addon-docs": "^10.1.0-alpha.6", + "@storybook/addon-onboarding": "^10.1.0-alpha.6", + "@storybook/addon-vitest": "^10.1.0-alpha.6", + "@storybook/vue3-vite": "^10.1.0-alpha.6", + "@types/node": "^24.6.0", + "@vitejs/plugin-vue": "^6.0.1", + "@vitest/browser-playwright": "^4.0.7", + "@vitest/coverage-v8": "^4.0.7", + "@vue/tsconfig": "^0.8.1", "eslint": "^9.29.0", - "eslint-plugin-react-hooks": "^5.2.0", - "eslint-plugin-react-refresh": "^0.4.20", "eslint-plugin-storybook": "9.1.0-alpha.6", - "globals": "^16.2.0", - "playwright": "1.52.0", - "storybook": "file:../../code/core", - "typescript": "~5.8.3", + "playwright": "^1.56.1", + "storybook": "^10.1.0-alpha.6", + "typescript": "~5.9.3", "typescript-eslint": "^8.34.1", - "vite": "^7.0.0", - "vitest": "^3.2.4" + "vite": "^7.1.7", + "vitest": "^4.0.7", + "vue-tsc": "^3.1.0" } } diff --git a/test-storybooks/yarn-pnp/src/App.css b/test-storybooks/yarn-pnp/src/App.css deleted file mode 100644 index b9d355df2a59..000000000000 --- a/test-storybooks/yarn-pnp/src/App.css +++ /dev/null @@ -1,42 +0,0 @@ -#root { - max-width: 1280px; - margin: 0 auto; - padding: 2rem; - text-align: center; -} - -.logo { - height: 6em; - padding: 1.5em; - will-change: filter; - transition: filter 300ms; -} -.logo:hover { - filter: drop-shadow(0 0 2em #646cffaa); -} -.logo.react:hover { - filter: drop-shadow(0 0 2em #61dafbaa); -} - -@keyframes logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} - -@media (prefers-reduced-motion: no-preference) { - a:nth-of-type(2) .logo { - animation: logo-spin infinite 20s linear; - } -} - -.card { - padding: 2em; -} - -.read-the-docs { - color: #888; -} diff --git a/test-storybooks/yarn-pnp/src/App.tsx b/test-storybooks/yarn-pnp/src/App.tsx deleted file mode 100644 index 3d7ded3ff624..000000000000 --- a/test-storybooks/yarn-pnp/src/App.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import { useState } from 'react' -import reactLogo from './assets/react.svg' -import viteLogo from '/vite.svg' -import './App.css' - -function App() { - const [count, setCount] = useState(0) - - return ( - <> -
- - Vite logo - - - React logo - -
-

Vite + React

-
- -

- Edit src/App.tsx and save to test HMR -

-
-

- Click on the Vite and React logos to learn more -

- - ) -} - -export default App diff --git a/test-storybooks/yarn-pnp/src/App.vue b/test-storybooks/yarn-pnp/src/App.vue new file mode 100644 index 000000000000..58b0f21b1647 --- /dev/null +++ b/test-storybooks/yarn-pnp/src/App.vue @@ -0,0 +1,30 @@ + + + + + diff --git a/test-storybooks/yarn-pnp/src/assets/react.svg b/test-storybooks/yarn-pnp/src/assets/react.svg deleted file mode 100644 index 6c87de9bb335..000000000000 --- a/test-storybooks/yarn-pnp/src/assets/react.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/test-storybooks/yarn-pnp/src/assets/vue.svg b/test-storybooks/yarn-pnp/src/assets/vue.svg new file mode 100644 index 000000000000..770e9d333ee7 --- /dev/null +++ b/test-storybooks/yarn-pnp/src/assets/vue.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-storybooks/yarn-pnp/src/components/HelloWorld.vue b/test-storybooks/yarn-pnp/src/components/HelloWorld.vue new file mode 100644 index 000000000000..b58e52b965f6 --- /dev/null +++ b/test-storybooks/yarn-pnp/src/components/HelloWorld.vue @@ -0,0 +1,41 @@ + + + + + diff --git a/test-storybooks/yarn-pnp/src/main.ts b/test-storybooks/yarn-pnp/src/main.ts new file mode 100644 index 000000000000..2425c0f745be --- /dev/null +++ b/test-storybooks/yarn-pnp/src/main.ts @@ -0,0 +1,5 @@ +import { createApp } from 'vue' +import './style.css' +import App from './App.vue' + +createApp(App).mount('#app') diff --git a/test-storybooks/yarn-pnp/src/main.tsx b/test-storybooks/yarn-pnp/src/main.tsx deleted file mode 100644 index bef5202a32cb..000000000000 --- a/test-storybooks/yarn-pnp/src/main.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { StrictMode } from 'react' -import { createRoot } from 'react-dom/client' -import './index.css' -import App from './App.tsx' - -createRoot(document.getElementById('root')!).render( - - - , -) diff --git a/test-storybooks/yarn-pnp/src/stories/Button.stories.ts b/test-storybooks/yarn-pnp/src/stories/Button.stories.ts index 0c3151f3089c..fafb4c8ff006 100644 --- a/test-storybooks/yarn-pnp/src/stories/Button.stories.ts +++ b/test-storybooks/yarn-pnp/src/stories/Button.stories.ts @@ -1,31 +1,33 @@ -import type { Meta, StoryObj } from '@storybook/react-vite'; +import type { Meta, StoryObj } from '@storybook/vue3-vite'; import { fn } from 'storybook/test'; -import { Button } from './Button'; +import Button from './Button.vue'; -// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export +// More on how to set up stories at: https://storybook.js.org/docs/writing-stories const meta = { title: 'Example/Button', component: Button, - parameters: { - // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout - layout: 'centered', - }, - // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs + // This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/writing-docs/autodocs tags: ['autodocs'], - // More on argTypes: https://storybook.js.org/docs/api/argtypes argTypes: { + size: { control: 'select', options: ['small', 'medium', 'large'] }, backgroundColor: { control: 'color' }, }, - // Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args - args: { onClick: fn() }, + args: { + primary: false, + // Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#story-args + onClick: fn(), + }, } satisfies Meta; export default meta; type Story = StoryObj; - -// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args +/* + *👇 Render functions are a framework specific feature to allow you control on how the component renders. + * See https://storybook.js.org/docs/api/csf + * to learn how to use render functions. + */ export const Primary: Story = { args: { primary: true, @@ -35,20 +37,21 @@ export const Primary: Story = { export const Secondary: Story = { args: { + primary: false, label: 'Button', }, }; export const Large: Story = { args: { - size: 'large', label: 'Button', + size: 'large', }, }; export const Small: Story = { args: { - size: 'small', label: 'Button', + size: 'small', }, }; diff --git a/test-storybooks/yarn-pnp/src/stories/Button.tsx b/test-storybooks/yarn-pnp/src/stories/Button.tsx deleted file mode 100644 index f35dafdcb427..000000000000 --- a/test-storybooks/yarn-pnp/src/stories/Button.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import React from 'react'; - -import './button.css'; - -export interface ButtonProps { - /** Is this the principal call to action on the page? */ - primary?: boolean; - /** What background color to use */ - backgroundColor?: string; - /** How large should the button be? */ - size?: 'small' | 'medium' | 'large'; - /** Button contents */ - label: string; - /** Optional click handler */ - onClick?: () => void; -} - -/** Primary UI component for user interaction */ -export const Button = ({ - primary = false, - size = 'medium', - backgroundColor, - label, - ...props -}: ButtonProps) => { - const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary'; - return ( - - ); -}; diff --git a/test-storybooks/yarn-pnp/src/stories/Button.vue b/test-storybooks/yarn-pnp/src/stories/Button.vue new file mode 100644 index 000000000000..338b97c658d4 --- /dev/null +++ b/test-storybooks/yarn-pnp/src/stories/Button.vue @@ -0,0 +1,50 @@ + + + diff --git a/test-storybooks/yarn-pnp/src/stories/Configure.mdx b/test-storybooks/yarn-pnp/src/stories/Configure.mdx index dca091c16b1a..34a34ea9e3e0 100644 --- a/test-storybooks/yarn-pnp/src/stories/Configure.mdx +++ b/test-storybooks/yarn-pnp/src/stories/Configure.mdx @@ -48,7 +48,7 @@ export const RightArrow = () => Add styling and CSS

Like with web applications, there are many ways to include CSS within Storybook. Learn more about setting up styling within Storybook.

Learn more @@ -60,7 +60,7 @@ export const RightArrow = () => Provide context and mocking

Often when a story doesn't render, it's because your component is expecting a specific environment or context (like a theme provider) to be available.

Learn more @@ -72,7 +72,7 @@ export const RightArrow = () => Learn more @@ -94,7 +94,7 @@ export const RightArrow = () => Auto-generate living, interactive reference documentation from your components and stories.

Learn more @@ -103,7 +103,7 @@ export const RightArrow = () => Publish to Chromatic

Publish your Storybook to review and collaborate with your entire team.

Learn more @@ -113,7 +113,7 @@ export const RightArrow = () => Embed your stories into Figma to cross-reference the design and live implementation in one place.

Learn more @@ -123,7 +123,7 @@ export const RightArrow = () => Use stories to test a component in all its variations, no matter how complex.

Learn more @@ -132,7 +132,7 @@ export const RightArrow = () => Accessibility

Automatically test your components for a11y issues as you develop.

Learn more @@ -141,7 +141,7 @@ export const RightArrow = () => Theming

Theme Storybook's UI to personalize it to your project.

Learn more diff --git a/test-storybooks/yarn-pnp/src/stories/Header.stories.ts b/test-storybooks/yarn-pnp/src/stories/Header.stories.ts index 36a3b8f9f2b1..47caa29a09e3 100644 --- a/test-storybooks/yarn-pnp/src/stories/Header.stories.ts +++ b/test-storybooks/yarn-pnp/src/stories/Header.stories.ts @@ -1,14 +1,23 @@ -import type { Meta, StoryObj } from '@storybook/react-vite'; +import type { Meta, StoryObj } from '@storybook/vue3-vite'; import { fn } from 'storybook/test'; -import { Header } from './Header'; +import MyHeader from './Header.vue'; const meta = { + /* 👇 The title prop is optional. + * See https://storybook.js.org/docs/configure/#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Example/Header', - component: Header, - // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs - tags: ['autodocs'], + component: MyHeader, + render: (args: any) => ({ + components: { MyHeader }, + setup() { + return { args }; + }, + template: '', + }), parameters: { // More on how to position stories at: https://storybook.js.org/docs/configure/story-layout layout: 'fullscreen', @@ -18,7 +27,9 @@ const meta = { onLogout: fn(), onCreateAccount: fn(), }, -} satisfies Meta; + // This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/writing-docs/autodocs + tags: ['autodocs'], +} satisfies Meta; export default meta; type Story = StoryObj; @@ -31,4 +42,8 @@ export const LoggedIn: Story = { }, }; -export const LoggedOut: Story = {}; +export const LoggedOut: Story = { + args: { + user: null, + }, +}; diff --git a/test-storybooks/yarn-pnp/src/stories/Header.tsx b/test-storybooks/yarn-pnp/src/stories/Header.tsx deleted file mode 100644 index 1bf981a4251f..000000000000 --- a/test-storybooks/yarn-pnp/src/stories/Header.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import React from 'react'; - -import { Button } from './Button'; -import './header.css'; - -type User = { - name: string; -}; - -export interface HeaderProps { - user?: User; - onLogin?: () => void; - onLogout?: () => void; - onCreateAccount?: () => void; -} - -export const Header = ({ user, onLogin, onLogout, onCreateAccount }: HeaderProps) => ( -
-
-
- - - - - - - -

Acme

-
-
- {user ? ( - <> - - Welcome, {user.name}! - -
-
-
-); diff --git a/test-storybooks/yarn-pnp/src/stories/Header.vue b/test-storybooks/yarn-pnp/src/stories/Header.vue new file mode 100644 index 000000000000..bade22d0979f --- /dev/null +++ b/test-storybooks/yarn-pnp/src/stories/Header.vue @@ -0,0 +1,53 @@ + + + diff --git a/test-storybooks/yarn-pnp/src/stories/Page.stories.ts b/test-storybooks/yarn-pnp/src/stories/Page.stories.ts index 7bbda250dec4..ec3d2488dd06 100644 --- a/test-storybooks/yarn-pnp/src/stories/Page.stories.ts +++ b/test-storybooks/yarn-pnp/src/stories/Page.stories.ts @@ -1,26 +1,30 @@ -import type { Meta, StoryObj } from '@storybook/react-vite'; +import type { Meta, StoryObj } from '@storybook/vue3-vite'; import { expect, userEvent, within } from 'storybook/test'; -import { Page } from './Page'; +import MyPage from './Page.vue'; const meta = { title: 'Example/Page', - component: Page, + component: MyPage, + render: () => ({ + components: { MyPage }, + template: '', + }), parameters: { // More on how to position stories at: https://storybook.js.org/docs/configure/story-layout layout: 'fullscreen', }, -} satisfies Meta; + // This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/writing-docs/autodocs + tags: ['autodocs'], +} satisfies Meta; export default meta; type Story = StoryObj; -export const LoggedOut: Story = {}; - // More on component testing: https://storybook.js.org/docs/writing-tests/interaction-testing export const LoggedIn: Story = { - play: async ({ canvasElement }) => { + play: async ({ canvasElement }: any) => { const canvas = within(canvasElement); const loginButton = canvas.getByRole('button', { name: /Log in/i }); await expect(loginButton).toBeInTheDocument(); @@ -31,3 +35,5 @@ export const LoggedIn: Story = { await expect(logoutButton).toBeInTheDocument(); }, }; + +export const LoggedOut: Story = {}; diff --git a/test-storybooks/yarn-pnp/src/stories/Page.tsx b/test-storybooks/yarn-pnp/src/stories/Page.tsx deleted file mode 100644 index e11748301390..000000000000 --- a/test-storybooks/yarn-pnp/src/stories/Page.tsx +++ /dev/null @@ -1,73 +0,0 @@ -import React from 'react'; - -import { Header } from './Header'; -import './page.css'; - -type User = { - name: string; -}; - -export const Page: React.FC = () => { - const [user, setUser] = React.useState(); - - return ( -
-
setUser({ name: 'Jane Doe' })} - onLogout={() => setUser(undefined)} - onCreateAccount={() => setUser({ name: 'Jane Doe' })} - /> - -
-

Pages in Storybook

-

- We recommend building UIs with a{' '} - - component-driven - {' '} - process starting with atomic components and ending with pages. -

-

- Render pages with mock data. This makes it easy to build and review page states without - needing to navigate to them in your app. Here are some handy patterns for managing page - data in Storybook: -

-
    -
  • - Use a higher-level connected component. Storybook helps you compose such data from the - "args" of child component stories -
  • -
  • - Assemble data in the page component from your services. You can mock these services out - using Storybook. -
  • -
-

- Get a guided tutorial on component-driven development at{' '} - - Storybook tutorials - - . Read more in the{' '} - - docs - - . -

-
- Tip Adjust the width of the canvas with the{' '} - - - - - - Viewports addon in the toolbar -
-
-
- ); -}; diff --git a/test-storybooks/yarn-pnp/src/stories/Page.vue b/test-storybooks/yarn-pnp/src/stories/Page.vue new file mode 100644 index 000000000000..85701a3bdf00 --- /dev/null +++ b/test-storybooks/yarn-pnp/src/stories/Page.vue @@ -0,0 +1,73 @@ + + + diff --git a/test-storybooks/yarn-pnp/src/index.css b/test-storybooks/yarn-pnp/src/style.css similarity index 90% rename from test-storybooks/yarn-pnp/src/index.css rename to test-storybooks/yarn-pnp/src/style.css index 08a3ac9e1e5c..f6913154345d 100644 --- a/test-storybooks/yarn-pnp/src/index.css +++ b/test-storybooks/yarn-pnp/src/style.css @@ -54,6 +54,17 @@ button:focus-visible { outline: 4px auto -webkit-focus-ring-color; } +.card { + padding: 2em; +} + +#app { + max-width: 1280px; + margin: 0 auto; + padding: 2rem; + text-align: center; +} + @media (prefers-color-scheme: light) { :root { color: #213547; diff --git a/test-storybooks/yarn-pnp/src/vite-env.d.ts b/test-storybooks/yarn-pnp/src/vite-env.d.ts deleted file mode 100644 index 11f02fe2a006..000000000000 --- a/test-storybooks/yarn-pnp/src/vite-env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/test-storybooks/yarn-pnp/tsconfig.app.json b/test-storybooks/yarn-pnp/tsconfig.app.json index 227a6c6723b6..a2d3056b819b 100644 --- a/test-storybooks/yarn-pnp/tsconfig.app.json +++ b/test-storybooks/yarn-pnp/tsconfig.app.json @@ -6,6 +6,7 @@ "lib": ["ES2022", "DOM", "DOM.Iterable"], "module": "ESNext", "skipLibCheck": true, + "types": ["vite/client"], /* Bundler mode */ "moduleResolution": "bundler", @@ -13,7 +14,6 @@ "verbatimModuleSyntax": true, "moduleDetection": "force", "noEmit": true, - "jsx": "react-jsx", /* Linting */ "strict": true, @@ -23,5 +23,5 @@ "noFallthroughCasesInSwitch": true, "noUncheckedSideEffectImports": true }, - "include": ["src"] + "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"] } diff --git a/test-storybooks/yarn-pnp/tsconfig.node.json b/test-storybooks/yarn-pnp/tsconfig.node.json index f85a39906e55..8a67f62f4cee 100644 --- a/test-storybooks/yarn-pnp/tsconfig.node.json +++ b/test-storybooks/yarn-pnp/tsconfig.node.json @@ -4,6 +4,7 @@ "target": "ES2023", "lib": ["ES2023"], "module": "ESNext", + "types": ["node"], "skipLibCheck": true, /* Bundler mode */ diff --git a/test-storybooks/yarn-pnp/vite.config.ts b/test-storybooks/yarn-pnp/vite.config.ts index 8b0f57b91aeb..28cb993f3fde 100644 --- a/test-storybooks/yarn-pnp/vite.config.ts +++ b/test-storybooks/yarn-pnp/vite.config.ts @@ -1,7 +1,46 @@ -import { defineConfig } from 'vite' -import react from '@vitejs/plugin-react' +/// +import { defineConfig } from "vite"; +import vue from "@vitejs/plugin-vue"; // https://vite.dev/config/ +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import { storybookTest } from "@storybook/addon-vitest/vitest-plugin"; +import { playwright } from "@vitest/browser-playwright"; +const dirname = + typeof __dirname !== "undefined" + ? __dirname + : path.dirname(fileURLToPath(import.meta.url)); + +// More info at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon export default defineConfig({ - plugins: [react()], -}) + plugins: [vue()], + test: { + projects: [ + { + extends: true, + plugins: [ + // The plugin will run tests for the stories defined in your Storybook config + // See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest + storybookTest({ + configDir: path.join(dirname, ".storybook"), + }), + ], + test: { + name: "storybook", + browser: { + enabled: true, + headless: true, + provider: playwright({}), + instances: [ + { + browser: "chromium", + }, + ], + }, + setupFiles: [".storybook/vitest.setup.ts"], + }, + }, + ], + }, +}); diff --git a/test-storybooks/yarn-pnp/vitest.shims.d.ts b/test-storybooks/yarn-pnp/vitest.shims.d.ts index f923d47d483f..03b1801a60cb 100644 --- a/test-storybooks/yarn-pnp/vitest.shims.d.ts +++ b/test-storybooks/yarn-pnp/vitest.shims.d.ts @@ -1 +1 @@ -/// \ No newline at end of file +/// diff --git a/test-storybooks/yarn-pnp/vitest.workspace.ts b/test-storybooks/yarn-pnp/vitest.workspace.ts deleted file mode 100644 index 4b1fcc8dc232..000000000000 --- a/test-storybooks/yarn-pnp/vitest.workspace.ts +++ /dev/null @@ -1,32 +0,0 @@ -import path from 'node:path'; -import { fileURLToPath } from 'node:url'; - -import { defineWorkspace } from 'vitest/config'; - -import { storybookTest } from '@storybook/addon-vitest/vitest-plugin'; - -const dirname = - typeof __dirname !== 'undefined' ? __dirname : path.dirname(fileURLToPath(import.meta.url)); - -// More info at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon -export default defineWorkspace([ - 'vite.config.ts', - { - extends: 'vite.config.ts', - plugins: [ - // The plugin will run tests for the stories defined in your Storybook config - // See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest - storybookTest({ configDir: path.join(dirname, '.storybook') }), - ], - test: { - name: 'storybook', - browser: { - enabled: true, - headless: true, - provider: 'playwright', - instances: [{ browser: 'chromium' }] - }, - setupFiles: ['.storybook/vitest.setup.ts'], - }, - }, -]); diff --git a/test-storybooks/yarn-pnp/yarn.lock b/test-storybooks/yarn-pnp/yarn.lock index e69de29bb2d1..8b137891791f 100644 --- a/test-storybooks/yarn-pnp/yarn.lock +++ b/test-storybooks/yarn-pnp/yarn.lock @@ -0,0 +1 @@ +