Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 0 additions & 5 deletions packages/components/src/Accordion/Accordion.test.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ const meta: Meta<typeof Accordion> = {
layout: 'padded',
},
tags: ['!dev'],
argTypes: {
initiallyExpanded: {
control: 'boolean',
},
},
args: { onHandleExpand: fn() },
};

Expand Down
23 changes: 6 additions & 17 deletions packages/components/src/Button/Button.test.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,20 @@ const meta: Meta<typeof Button> = {
layout: 'centered',
},
tags: ['!dev'],
argTypes: {
size: {
control: 'select',
},
type: {
control: 'select',
},
className: {
control: 'text',
},
args: {
type: 'primary',
children: 'Button label',
onClick: fn(),
},
args: { onClick: fn() },
};

export default meta;

type Story = StoryObj<typeof Button>;

export const TestActive: Story = {
name: 'Primary',
export const TestEnabled: Story = {
name: 'Enabled',
args: {
type: 'primary',
children: 'Button label',
disabled: false,
},
play: async ({ canvasElement, step, args }) => {
Expand All @@ -53,8 +44,6 @@ export const TestActive: Story = {
export const TestDisabled: Story = {
name: 'Disabled',
args: {
type: 'primary',
children: 'Button label',
disabled: true,
},
play: async ({ canvasElement, step }) => {
Expand Down
19 changes: 4 additions & 15 deletions packages/components/src/Expander/Expander.test.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,11 @@ const meta: Meta<typeof Expander> = {
layout: 'centered',
},
tags: ['!dev'],
argTypes: {
hasIcon: {
control: 'boolean',
},
isExpanded: {
control: 'boolean',
},
type: {
control: 'select',
},
args: {
collapseLabel: 'Show more',
expandLabel: 'Show less',
onClick: fn(),
},
args: { onClick: fn() },
};

export default meta;
Expand All @@ -30,8 +23,6 @@ type Story = StoryObj<typeof Expander>;
export const ExpanderIsNotExpanded: Story = {
args: {
isExpanded: false,
collapseLabel: 'Show more',
expandLabel: 'Show less',
},
play: async ({ canvasElement, step, args }) => {
const canvas = within(canvasElement);
Expand All @@ -56,8 +47,6 @@ export const ExpanderIsNotExpanded: Story = {
export const ExpanderIsExpanded: Story = {
args: {
isExpanded: true,
collapseLabel: 'Show more',
expandLabel: 'Show less',
},
play: async ({ canvasElement, step, args }) => {
const canvas = within(canvasElement);
Expand Down
20 changes: 6 additions & 14 deletions packages/components/src/IconButton/IconButton.test.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,20 @@ const meta: Meta<typeof IconButton> = {
layout: 'centered',
},
tags: ['!dev'],
argTypes: {
size: {
control: 'select',
},
type: {
control: 'select',
},
args: {
type: 'primary',
icon: 'edit',
onClick: fn(),
},
args: { onClick: fn() },
};

export default meta;

type Story = StoryObj<typeof IconButton>;

export const TestActive: Story = {
name: 'Primary',
export const TestEnabled: Story = {
name: 'Enabled',
args: {
type: 'primary',
icon: 'edit',
disabled: false,
},
play: async ({ canvasElement, step, args }) => {
Expand All @@ -50,8 +44,6 @@ export const TestActive: Story = {
export const TestDisabled: Story = {
name: 'Disabled',
args: {
type: 'primary',
icon: 'edit',
disabled: true,
},
play: async ({ canvasElement, step }) => {
Expand Down
26 changes: 10 additions & 16 deletions packages/components/src/inputs/InputText/InputText.test.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,8 @@ const meta: Meta<typeof InputText> = {
layout: 'centered',
},
tags: ['!dev'],
argTypes: {
size: {
control: 'select',
},
type: {
control: 'select',
},
className: {
control: 'text',
},
},
args: {
name: 'default-input',
onBlur: fn(),
onChange: fn(),
onFocus: fn(),
Expand All @@ -32,26 +22,29 @@ export default meta;

type Story = StoryObj<typeof InputText>;

export const TestActive: Story = {
name: 'Events',
args: {
name: 'default-input',
},
export const Default: Story = {
name: 'Default',
play: async ({ canvasElement, step, args }) => {
const canvas = within(canvasElement);
const input = canvas.getByRole('textbox');

await step('InputText handles focus event', async () => {
await expect(args.onFocus).not.toHaveBeenCalled();

await userEvent.click(input);

await expect(args.onFocus).toHaveBeenCalledOnce();

await userEvent.click(input);

await expect(args.onFocus).toHaveBeenCalledOnce();
});

await step('InputText handles blur event', async () => {
await expect(args.onBlur).not.toHaveBeenCalled();

await userEvent.click(canvasElement);

await expect(args.onBlur).toHaveBeenCalledOnce();
});

Expand All @@ -61,6 +54,7 @@ export const TestActive: Story = {
const numberOfExpectedFocusCalls = 2;

await userEvent.type(input, insertText);

await expect(args.onFocus).toHaveBeenCalledTimes(numberOfExpectedFocusCalls);
await expect(args.onChange).toHaveBeenCalledTimes(insertTextLength);
await expect(args.onInput).toHaveBeenCalledTimes(insertTextLength);
Expand Down
8 changes: 4 additions & 4 deletions packages/components/src/ui/ClearBtn/ClearBtn.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Meta, StoryObj } from '@storybook/react';
import { action } from 'storybook/actions';

import Expander from './ClearBtn';
import ClearBtn from './ClearBtn';

const meta: Meta<typeof Expander> = {
component: Expander,
const meta: Meta<typeof ClearBtn> = {
component: ClearBtn,
parameters: {
layout: 'centered',
},
Expand All @@ -15,7 +15,7 @@ const meta: Meta<typeof Expander> = {

export default meta;

type Story = StoryObj<typeof Expander>;
type Story = StoryObj<typeof ClearBtn>;

export const Default: Story = {
name: 'Default',
Expand Down
13 changes: 6 additions & 7 deletions packages/components/src/ui/ClearBtn/ClearBtn.test.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import type { Meta, StoryObj } from '@storybook/react';
import { expect, fn, userEvent, within } from 'storybook/test';

import Expander from './ClearBtn';
import ClearBtn from './ClearBtn';

const meta: Meta<typeof Expander> = {
component: Expander,
const meta: Meta<typeof ClearBtn> = {
component: ClearBtn,
parameters: {
layout: 'centered',
},
tags: ['!dev'],
argTypes: {},
args: { onClick: fn() },
};

export default meta;

type Story = StoryObj<typeof Expander>;
type Story = StoryObj<typeof ClearBtn>;

export const TestActive: Story = {
name: 'Primary',
export const TestEnabled: Story = {
name: 'Enabled',
args: {
disabled: false,
},
Expand Down