Skip to content

Commit

Permalink
test(Button): add visual test for Button inside text (#1451)
Browse files Browse the repository at this point in the history
  • Loading branch information
amje authored Mar 26, 2024
1 parent 2f0e83e commit b7da9e1
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 2 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions src/components/Button/__stories__/Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ export const Loading: Story = {
};

export const Width: Story = {
args: {
...Default.args,
},
render: (args) => {
return (
<div style={{width: 100, border: '2px dashed gray', overflow: 'hidden', padding: 2}}>
Expand All @@ -137,6 +140,9 @@ export const Width: Story = {
};

export const Pin: Story = {
args: {
...Default.args,
},
render: (args) => {
return (
<Showcase>
Expand All @@ -154,13 +160,32 @@ export const Pin: Story = {

export const Link: Story = {
args: {
...Default.args,
children: ['Link Button', <IconComponent key="icon" data={ArrowUpRightFromSquare} />],
href: 'https://gravity-ui.com',
target: '_blank',
},
name: 'As Link',
};

export const InsideText: Story = {
args: {
...Default.args,
},
render: (args) => {
return (
<div>
Lorem ipsum
<br />
<Button {...args} /> dolor
<br />
sit amet
</div>
);
},
name: 'Inside Text',
};

export const Custom: Story = {
args: {
children: 'Fancy Button',
Expand Down
7 changes: 7 additions & 0 deletions src/components/Button/__tests__/Button.visual.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Default,
Disabled,
Icon,
InsideText,
Link,
Loading,
Pin,
Expand Down Expand Up @@ -75,4 +76,10 @@ test.describe('Button', () => {

await expectScreenshot();
});

test('render story: <InsideText>', async ({mount, expectScreenshot}) => {
await mount(<InsideText />);

await expectScreenshot();
});
});
15 changes: 13 additions & 2 deletions src/components/Button/__tests__/helpersPlaywright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,16 @@ import {composeStories} from '@storybook/react';

import * as ButtonStories from '../__stories__/Button.stories';

export const {Default, Selected, Size, View, Icon, Disabled, Loading, Width, Pin, Link} =
composeStories(ButtonStories);
export const {
Default,
Selected,
Size,
View,
Icon,
Disabled,
Loading,
Width,
Pin,
Link,
InsideText,
} = composeStories(ButtonStories);

0 comments on commit b7da9e1

Please sign in to comment.