Skip to content

Commit

Permalink
feat: add example CSF Button with Play test
Browse files Browse the repository at this point in the history
  • Loading branch information
ndom91 committed Nov 27, 2024
1 parent 0c05428 commit 5cee2cc
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 12 deletions.
1 change: 0 additions & 1 deletion apps/desktop/src/lib/components/ShareIssueModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@
<Textarea
label="Comments"
placeholder="Provide any steps necessary to reproduce the problem."
autocomplete="off"
autocorrect="off"
spellcheck
id="comments"
Expand Down
5 changes: 2 additions & 3 deletions packages/ui/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,20 @@ import type { StorybookConfig } from '@storybook/sveltekit';

const config: StorybookConfig = {
stories: ['../src/stories/**/*.mdx', '../src/stories/**/*.stories.@(js|jsx|mjs|ts|tsx|svelte)'],

addons: [
getAbsolutePath('@storybook/addon-links'),
getAbsolutePath('@storybook/addon-essentials'),
'@storybook/addon-svelte-csf',
getAbsolutePath('@storybook/experimental-addon-test'),
getAbsolutePath('storybook-dark-mode')
],

framework: {
name: getAbsolutePath('@storybook/sveltekit'),
options: {}
},

docs: {}
};

export default config;

function getAbsolutePath(value: string): any {
Expand Down
3 changes: 3 additions & 0 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@
"@csstools/postcss-bundler": "^2.0.5",
"@storybook/addon-docs": "^8.4.5",
"@storybook/addon-essentials": "^8.4.5",
"@storybook/addon-interactions": "^8.4.5",
"@storybook/addon-links": "^8.4.5",
"@storybook/addon-svelte-csf": "5.0.0--canary.228.e697925.0",
"@storybook/blocks": "^8.4.5",
"@storybook/experimental-addon-test": "^8.4.5",
"@storybook/svelte": "^8.4.5",
"@storybook/sveltekit": "^8.4.5",
"@storybook/test": "^8.4.5",
"@sveltejs/adapter-static": "catalog:svelte",
"@sveltejs/kit": "catalog:svelte",
"@sveltejs/package": "^2.3.7",
Expand Down
49 changes: 49 additions & 0 deletions packages/ui/src/stories/button/Button.stories.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<script module lang="ts">
import Button from '$lib/Button.svelte';
import { defineMeta } from '@storybook/addon-svelte-csf';
import { fn, expect, userEvent, within } from '@storybook/test';
const { Story } = defineMeta({
title: 'Inputs / Button / CSF Buttons',
component: Button,
tags: ['autodocs'],
args: {
loading: false,
disabled: false,
clickable: true,
size: 'button',
icon: 'ai-small',
style: 'neutral',
kind: 'solid',
outline: false,
dashed: false,
solidBackground: false,
helpShowDelay: 1200,
id: 'button',
tabindex: 0,
type: 'button',
shrinkable: false,
reversedDirection: false,
width: undefined,
wide: false,
grow: false,
align: 'center',
dropdownChild: false,
onclick: fn(() => {
console.log('Button clicked');
})
}
});
</script>

<Story
name="Primary"
play={async ({ args, canvasElement }) => {
const canvas = within(canvasElement);
const submitButton = canvas.getByRole('button');
await userEvent.click(submitButton);
await expect(args.onclick).toHaveBeenCalled();
}}
>
Button Text
</Story>
115 changes: 107 additions & 8 deletions pnpm-lock.yaml

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

0 comments on commit 5cee2cc

Please sign in to comment.