Sync my stories with primary device
This commit is contained in:
parent
7554d8326a
commit
9155784d56
67 changed files with 2954 additions and 1238 deletions
81
ts/components/MyStoriesButton.stories.tsx
Normal file
81
ts/components/MyStoriesButton.stories.tsx
Normal file
|
@ -0,0 +1,81 @@
|
|||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { Meta, ReactFramework, Story } from '@storybook/react';
|
||||
import type { PlayFunction } from '@storybook/csf';
|
||||
import React from 'react';
|
||||
import { expect } from '@storybook/jest';
|
||||
import { within, userEvent } from '@storybook/testing-library';
|
||||
|
||||
import type { PropsType } from './MyStoriesButton';
|
||||
import enMessages from '../../_locales/en/messages.json';
|
||||
import { MyStoriesButton } from './MyStoriesButton';
|
||||
import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation';
|
||||
import { getFakeStoryView } from '../test-both/helpers/getFakeStory';
|
||||
import { setupI18n } from '../util/setupI18n';
|
||||
|
||||
const i18n = setupI18n('en', enMessages);
|
||||
|
||||
export default {
|
||||
title: 'Components/MyStoriesButton',
|
||||
component: MyStoriesButton,
|
||||
argTypes: {
|
||||
hasMultiple: {
|
||||
control: 'checkbox',
|
||||
defaultValue: false,
|
||||
},
|
||||
i18n: {
|
||||
defaultValue: i18n,
|
||||
},
|
||||
me: {
|
||||
defaultValue: getDefaultConversation(),
|
||||
},
|
||||
newestStory: {
|
||||
defaultValue: getFakeStoryView(),
|
||||
},
|
||||
onClick: {
|
||||
action: true,
|
||||
},
|
||||
queueStoryDownload: {
|
||||
action: true,
|
||||
},
|
||||
},
|
||||
} as Meta;
|
||||
|
||||
const Template: Story<PropsType> = args => <MyStoriesButton {...args} />;
|
||||
|
||||
const interactionTest: PlayFunction<ReactFramework, PropsType> = async ({
|
||||
args,
|
||||
canvasElement,
|
||||
}) => {
|
||||
const canvas = within(canvasElement);
|
||||
const [btnStory] = canvas.getAllByLabelText('Story');
|
||||
await userEvent.click(btnStory);
|
||||
await expect(args.onClick).toHaveBeenCalled();
|
||||
};
|
||||
|
||||
export const NoStory = Template.bind({});
|
||||
NoStory.args = {
|
||||
hasMultiple: false,
|
||||
newestStory: undefined,
|
||||
};
|
||||
NoStory.story = {
|
||||
name: 'No Story',
|
||||
};
|
||||
NoStory.play = interactionTest;
|
||||
|
||||
export const OneStory = Template.bind({});
|
||||
OneStory.args = {};
|
||||
OneStory.story = {
|
||||
name: 'One Story',
|
||||
};
|
||||
OneStory.play = interactionTest;
|
||||
|
||||
export const ManyStories = Template.bind({});
|
||||
ManyStories.args = {
|
||||
hasMultiple: true,
|
||||
};
|
||||
ManyStories.story = {
|
||||
name: 'Many Stories',
|
||||
};
|
||||
ManyStories.play = interactionTest;
|
Loading…
Add table
Add a link
Reference in a new issue