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

Vue: Add repro template for vue-cli #19165

Merged
merged 37 commits into from
Sep 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
e757728
Vue: Add repro templates for vue-cli
shilman Sep 11, 2022
33a1d7d
Merge branch 'next' into shilman/vue-cli-repro-templates
shilman Sep 11, 2022
5f220b6
Vue-cli: Don't nuke cwd on init
shilman Sep 11, 2022
7e84537
Escape vue-cli vue2 preset properly
shilman Sep 11, 2022
06d885a
Vue2: Add template components for sandbox
shilman Sep 12, 2022
19f25e0
Merge branch 'next' into shilman/vue-cli-repro-templates
shilman Sep 13, 2022
3dbf5f6
CLI/Vue3: Upgrade vue-loader and install `@vue/compiler-sfc`
shilman Sep 13, 2022
60f1aa5
Vue: Fix typo in template Button
shilman Sep 13, 2022
55f4668
Merge branch 'next' into shilman/vue-cli-repro-templates
shilman Sep 14, 2022
10cfadd
Try fix missing typescript in JS-only project
shilman Sep 14, 2022
05dfc5c
Apply the same fix for vue3 webpack preset
shilman Sep 14, 2022
ac16a23
Vue3: Fix babel / ts-loader both run against .ts files
shilman Sep 14, 2022
fde61fc
Revert "Apply the same fix for vue3 webpack preset"
tmeasday Sep 14, 2022
024e8a7
Revert "Try fix missing typescript in JS-only project"
tmeasday Sep 14, 2022
2dc7254
Exclude all rules from template-stories
tmeasday Sep 14, 2022
48e3af9
Vue: Add Form/Html template components
shilman Sep 14, 2022
b8380fa
Vue2: Fix play's within(canvas) by preserving `#storybook-root`
shilman Sep 15, 2022
1aa24c9
Update snapshots
shilman Sep 15, 2022
70fc932
Don't run source snippet e2e on vue-cli's vue3
shilman Sep 15, 2022
1036cbc
Addon-a11y: Fix template stories
shilman Sep 15, 2022
398dadc
Vue: Fixed Pre template component
shilman Sep 15, 2022
7e7bffb
Fix skip logic for vue-cli snippet test
shilman Sep 15, 2022
5dbe451
Fix duplicate import
shilman Sep 15, 2022
5ef1742
Added Vue2 DOM breaking change to MIGRATION guide
shilman Sep 15, 2022
7571d14
CLI: Don't add babel dependencies
shilman Sep 15, 2022
cb4b205
Fix stories
shilman Sep 15, 2022
000e6a1
Actions/Interactions: Identify actions by isAction to fix production …
shilman Sep 16, 2022
18709fc
Task: Prefix chromatic junit keys with templateKey
shilman Sep 16, 2022
e957951
Merge branch 'next' into shilman/vue-cli-repro-templates
shilman Sep 16, 2022
b9add15
Vue: Disable Vue2 repro template until rendering is fixed
shilman Sep 17, 2022
b613372
Fix location of store manual title story
shilman Sep 17, 2022
150cf37
Skip story re-rendering test for vue3/svelte
shilman Sep 17, 2022
e5de18d
Fix typo
shilman Sep 17, 2022
4857588
Scripts: Prefix junit into base task runner
shilman Sep 17, 2022
c2042c3
fix typo
shilman Sep 17, 2022
aa3a8ea
Revert "Vue2: Fix play's within(canvas) by preserving `#storybook-root`"
shilman Sep 18, 2022
1034ba9
Revert "Added Vue2 DOM breaking change to MIGRATION guide"
shilman Sep 18, 2022
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
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ jobs:
executor:
class: medium+
name: sb_node_14_browsers
parallelism: 7
parallelism: 8
steps:
- git-shallow-clone/checkout_advanced:
clone_options: '--depth 1 --verbose'
Expand All @@ -497,7 +497,7 @@ jobs:
executor:
class: medium+
name: sb_node_14_browsers
parallelism: 7
parallelism: 8
steps:
- git-shallow-clone/checkout_advanced:
clone_options: '--depth 1 --verbose'
Expand All @@ -513,7 +513,7 @@ jobs:
executor:
class: medium+
name: sb_node_14_browsers
parallelism: 7
parallelism: 8
steps:
- git-shallow-clone/checkout_advanced:
clone_options: '--depth 1 --verbose'
Expand All @@ -533,7 +533,7 @@ jobs:
executor:
class: medium+
name: sb_node_14_browsers
parallelism: 7
parallelism: 8
steps:
- git-shallow-clone/checkout_advanced:
clone_options: '--depth 1 --verbose'
Expand All @@ -549,7 +549,7 @@ jobs:
executor:
class: medium+
name: sb_node_14_browsers
parallelism: 7
parallelism: 8
steps:
- git-shallow-clone/checkout_advanced:
clone_options: '--depth 1 --verbose'
Expand All @@ -565,7 +565,7 @@ jobs:
executor:
class: medium+
name: sb_playwright
parallelism: 7
parallelism: 8
steps:
- git-shallow-clone/checkout_advanced:
clone_options: '--depth 1 --verbose'
Expand Down
4 changes: 2 additions & 2 deletions code/addons/a11y/template/stories/parameters.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import globalThis from 'global';
export default {
component: globalThis.Components.Html,
args: {
contents: '<button>Click Me!</button>',
content: '<button>Click Me!</button>',
},
parameters: {
chromatic: { disable: true },
Expand All @@ -12,7 +12,7 @@ export default {

export const Options = {
args: {
contents:
content:
'<button style="color: rgb(255, 255, 255); background-color: rgb(76, 175, 80);">Click me!</button>',
},
parameters: {
Expand Down
6 changes: 3 additions & 3 deletions code/addons/a11y/template/stories/tests.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import globalThis from 'global';
export default {
component: globalThis.Components.Html,
args: {
contents: '',
content: '',
},
parameters: {
chromatic: { disable: true },
Expand All @@ -12,7 +12,7 @@ export default {

export const Violations = {
args: {
contents: `
content: `
<div>
<p>empty heading</p>
<h1></h1>
Expand All @@ -39,7 +39,7 @@ export const Violations = {

export const Passes = {
args: {
contents: `
content: `
<div>
<p>heading</p>
<h1>heading 1</h1>
Expand Down
1 change: 1 addition & 0 deletions code/addons/actions/src/preview/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export function action(name: string, options: ActionOptions = {}): HandlerFuncti
};
channel.emit(EVENT_ID, actionDisplayToEmit);
};
handler.isAction = true;

return handler;
}
2 changes: 1 addition & 1 deletion code/addons/interactions/src/preset/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const addSpies = (id: string, val: any, key?: string): any => {
if (Array.isArray(val)) {
return val.map((item, index) => addSpies(id, item, `${key}[${index}]`));
}
if (typeof val === 'function' && val.name === 'actionHandler') {
if (typeof val === 'function' && val.isAction) {
ghengeveld marked this conversation as resolved.
Show resolved Hide resolved
Object.defineProperty(val, 'name', { value: key, writable: false });
Object.defineProperty(val, '__storyId__', { value: id, writable: false });
const spy = action(val);
Expand Down
3 changes: 2 additions & 1 deletion code/e2e-tests/addon-docs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ test.describe('addon-docs', () => {
});

test('should provide source snippet', async ({ page }) => {
// templateName is e.g. 'Vue-CLI (Default JS)'
test.skip(
/^vue3/.test(templateName),
/^(vue3|vue-cli)/i.test(templateName),
`Skipping ${templateName}, which does not support dynamic source snippets`
);

Expand Down
12 changes: 4 additions & 8 deletions code/frameworks/vue-webpack5/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ export const core: PresetProperty<'core', StorybookConfig> = async (config, opti
};
};

export const typescript = async (
config: StorybookConfig['typescript']
): Promise<StorybookConfig['typescript']> => {
return {
...config,
skipBabel: true,
};
};
export const typescript: PresetProperty<'typescript', StorybookConfig> = async (config) => ({
...config,
skipBabel: true,
});
5 changes: 5 additions & 0 deletions code/frameworks/vue3-webpack5/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ export const core: PresetProperty<'core', StorybookConfig> = async (config, opti
},
};
};

export const typescript: PresetProperty<'typescript', StorybookConfig> = async (config) => ({
...config,
skipBabel: true,
});
2 changes: 1 addition & 1 deletion code/lib/cli/src/generators/VUE3/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Generator } from '../types';

const generator: Generator = async (packageManager, npmOptions, options) => {
await baseGenerator(packageManager, npmOptions, options, 'vue3', {
extraPackages: ['vue-loader@^16.0.0'],
extraPackages: ['vue-loader@^17.0.0', '@vue/compiler-sfc@^3.2.0'],
});
};

Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli/src/generators/baseGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const defaultOptions: FrameworkOptions = {
staticDir: undefined,
addScripts: true,
addComponents: true,
addBabel: true,
addBabel: false,
addESLint: false,
extraMain: undefined,
framework: undefined,
Expand Down
28 changes: 28 additions & 0 deletions code/lib/cli/src/repro-templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,39 @@ const svelteViteTemplates = {
// }
};

const vueCliTemplates = {
'vue-cli/default-js': {
name: 'Vue-CLI (Default JS)',
script: 'npx -p @vue/cli vue create . --default --packageManager=yarn --force --merge',
cadence: ['ci', 'daily', 'weekly'],
expected: {
framework: '@storybook/vue3-webpack5',
renderer: '@storybook/vue3',
builder: '@storybook/builder-webpack5',
},
},
//
// FIXME: https://github.com/storybookjs/storybook/issues/19204
//
// 'vue-cli/vue2-default-js': {
// name: 'Vue-CLI (Vue2 JS)',
// script:
// 'npx -p @vue/cli vue create . --default --packageManager=yarn --force --merge --preset=Default\\ (Vue\\ 2)',
// cadence: ['ci', 'daily', 'weekly'],
// expected: {
// framework: '@storybook/vue-webpack5',
// renderer: '@storybook/vue',
// builder: '@storybook/builder-webpack5',
// },
// },
};

export default {
...craTemplates,
...reactViteTemplates,
...vue3ViteTemplates,
...svelteViteTemplates,
...vueCliTemplates,
// FIXME: missing documentation.json
// 'angular/latest': {
// name: 'Angular (latest)',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Object {
"include": Array [
"ROOT",
],
"test": "/\\\\.(mjs|tsx?|jsx?)$/",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is just a snapshot update, but was the removal of tsx intentional?

"test": "/\\\\.(mjs|jsx?)$/",
"use": Array [
Object {
"loader": "NODE_MODULES/babel-loader/lib/index.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Object {
"include": Array [
"ROOT",
],
"test": "/\\\\.(mjs|tsx?|jsx?)$/",
"test": "/\\\\.(mjs|jsx?)$/",
"use": Array [
Object {
"loader": "NODE_MODULES/babel-loader/lib/index.js",
Expand Down
6 changes: 5 additions & 1 deletion code/lib/store/template/stories/rendering.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ export const ForceReRender = {

export const ChangeArgs = {
play: async ({ canvasElement, id }: PlayFunctionContext) => {
// const channel = globalThis.__STORYBOOK_ADDONS_CHANNEL__;
const channel = globalThis.__STORYBOOK_ADDONS_CHANNEL__;
const button = await within(canvasElement).findByRole('button');
await button.focus();
await expect(button).toHaveFocus();

// Vue3: https://github.com/storybookjs/storybook/issues/13913
// Svelte: https://github.com/storybookjs/storybook/issues/19205
if (['vue3', 'svelte'].includes(globalThis.storybookRenderer)) return;

// When we change the args to the button, it should not rerender
await channel.emit('updateStoryArgs', { storyId: id, updatedArgs: { children: 'New Text' } });
await within(canvasElement).findByText(/New Text/);
Expand Down
2 changes: 1 addition & 1 deletion code/lib/store/template/stories/title.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { PlayFunctionContext } from '@storybook/csf';

export default {
component: globalThis.Components.Pre,
title: 'manual title',
title: 'lib/store/manual title',
args: { text: 'No content' },
};

Expand Down
1 change: 1 addition & 0 deletions code/renderers/react/template/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ import { Form } from './Form.jsx';
import { Html } from './Html.jsx';

globalThis.Components = { Button, Pre, Form, Html };
globalThis.storybookRenderer = 'react';
1 change: 1 addition & 0 deletions code/renderers/svelte/template/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ import Form from './Form.svelte';
import Html from './Html.svelte';

globalThis.Components = { Button, Pre, Form, Html };
globalThis.storybookRenderer = 'svelte';
54 changes: 54 additions & 0 deletions code/renderers/vue/template/components/Button.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<template>
<button type="button" :class="classes" @click="onClick" :style="style">{{ children }}</button>
</template>

<script>
import './button.css';

export default {
name: 'my-button',

props: {
children: {
type: String,
required: true,
},
primary: {
type: Boolean,
default: false,
},
size: {
type: String,
default: 'medium',
validator: function (value) {
return ['small', 'medium', 'large'].indexOf(value) !== -1;
},
},
backgroundColor: {
type: String,
},
},

computed: {
classes() {
return {
'storybook-button': true,
'storybook-button--primary': this.primary,
'storybook-button--secondary': !this.primary,
[`storybook-button--${this.size}`]: true,
};
},
style() {
return {
backgroundColor: this.backgroundColor,
};
},
},

methods: {
onClick() {
this.$emit('onClick');
},
},
};
</script>
44 changes: 44 additions & 0 deletions code/renderers/vue/template/components/Form.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<template>
<form id="interaction-test-form" @submit.prevent="onSubmit">
<label>
Enter Value
<input type="text" data-testid="value" :value="value" required @click="setValue" />
</label>
<button type="submit">Submit</button>
<p v-if="complete">Completed!!</p>
</form>
</template>

<script>
export default {
name: 'my-form',

props: {
onSuccess: {
type: Function,
},
},

data() {
return {
value: '',
complete: false,
};
},

methods: {
setValue(event) {
this.value = event.target.value;
},
onSubmit() {
this.onSuccess(this.value);
setTimeout(() => {
this.complete = true;
}, 500);
setTimeout(() => {
this.complete = false;
}, 1500);
},
},
};
</script>
17 changes: 17 additions & 0 deletions code/renderers/vue/template/components/Html.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<div v-html="content"></div>
</template>

<script>

export default {
name: 'my-html',

props: {
content: {
type: String,
required: true,
},
},
};
</script>
Loading