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

docs(ClipboardButton): CSF 3 & visual testing #1621

Closed
wants to merge 3 commits into from
Closed
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
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.
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.
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.
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.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React from 'react';

import {action} from '@storybook/addon-actions';
import type {Meta, StoryObj} from '@storybook/react';

import {Showcase} from '../../../demo/Showcase';
import {ShowcaseItem} from '../../../demo/ShowcaseItem';
import type {ClipboardButtonProps} from '../ClipboardButton';
import {ClipboardButton} from '../ClipboardButton';

export default {
Expand All @@ -13,7 +15,69 @@ export default {

type Story = StoryObj<typeof ClipboardButton>;

export const Default: Story = {};
export const Default: Story = {
args: {
onCopy: action('onCopy'),
onMouseEnter: action('onMouseEnter'),
onMouseLeave: action('onMouseLeave'),
onFocus: action('onFocus'),
onBlur: action('onBlur'),
},
};

export const CustomTooltipText: Story = {
args: {
hasTooltip: true,
tooltipInitialText: 'Initial text',
tooltipSuccessText: 'Success text',
},
name: 'Custom tooltip text',
};

export const CustomTimeout: Story = {
args: {
timeout: 5000,
},
name: 'Custom timeout',
};

const viewCases: Array<ClipboardButtonProps['view']> = [
'normal',
'action',
'outlined',
'outlined-info',
'outlined-success',
'outlined-warning',
'outlined-danger',
'outlined-utility',
'outlined-action',
'raised',
'flat',
'flat-secondary',
'flat-info',
'flat-success',
'flat-warning',
'flat-danger',
'flat-utility',
'flat-action',
'normal-contrast',
'outlined-contrast',
'flat-contrast',
];

export const View: Story = {
render: (args) => (
<Showcase>
{viewCases.map((view) => {
return (
<ShowcaseItem title={`View ${view}`} key={view}>
<ClipboardButton {...args} view={view} />
</ShowcaseItem>
);
})}
</Showcase>
),
};

export const Size: Story = {
render: (args) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';

import {test} from '~playwright/core';

import {ClipboardButtonStories} from './helpersPlaywright';

const mountOptions = {};

test.describe('ClipboardButton', () => {
test('render story: <Default>', async ({mount, expectScreenshot}) => {
await mount(<ClipboardButtonStories.Default />, mountOptions);

await expectScreenshot();
});

test('render story: <CustomTooltipText>', async ({mount, expectScreenshot}) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

While tooltip not shown screenshots are the same as default. Let's either remove this story from test or active the tooltip and capture it with the button

await mount(<ClipboardButtonStories.CustomTooltipText />, mountOptions);

await expectScreenshot();
});

test('render story: <View>', async ({mount, expectScreenshot}) => {
await mount(<ClipboardButtonStories.View />, mountOptions);

await expectScreenshot();
});

test('render story: <Size>', async ({mount, expectScreenshot}) => {
await mount(<ClipboardButtonStories.Size />, mountOptions);

await expectScreenshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {composeStories} from '@storybook/react';

import * as DefaultClipboardButtonStories from '../__stories__/ClipboardButton.stories';

export const ClipboardButtonStories = composeStories(DefaultClipboardButtonStories);
Loading