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

chore: Create a story for AddNetworkModal component #25498

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import React from 'react';
import type { Meta, StoryObj } from '@storybook/react';
import { Provider } from 'react-redux';
import { configureStore } from '@reduxjs/toolkit';
import { within, fireEvent } from '@storybook/testing-library';
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove everything to do with play function and storybook/testing-library

import AddNetworkModal from './index';
import { useSafeChainsListValidationSelector } from '../../../selectors';

const storeMock = configureStore({
reducer: {
// Mock reducers here
networks: (state = {}, action) => state, // Mock networks reducer
metamask: (state = {}, action) => state, // Mock metamask reducer
},
preloadedState: {
networks: {
safeChainsList: [
{
chainId: 1,
nativeCurrency: { symbol: 'ETH' },
},
{
chainId: 56,
nativeCurrency: { symbol: 'BNB' },
},
],
},
metamask: {
useSafeChainsListValidation: true, // Mock state for useSafeChainsListValidationSelector
},
},
});

const meta: Meta<typeof AddNetworkModal> = {
title: 'Components/OnboardingFlow/AddNetworkModal',
component: AddNetworkModal as React.ComponentType<{
showHeader?: boolean;
isNewNetworkFlow?: boolean;
addNewNetwork?: boolean;
networkToEdit?: null;
}>,
decorators: [
(Story) => (
<Provider store={storeMock}>
<Story />
</Provider>
),
],
argTypes: {
showHeader: { control: 'boolean' },
isNewNetworkFlow: { control: 'boolean' },
addNewNetwork: { control: 'boolean' },
networkToEdit: { control: 'object' },
},
args: {
showHeader: false,
isNewNetworkFlow: false,
addNewNetwork: true,
networkToEdit: null,
},
};

export default meta;
type Story = StoryObj<typeof AddNetworkModal>;

export const DefaultStory: Story = {};

DefaultStory.storyName = 'Default';

export const OpenModal: Story = {
args: {
showHeader: true,
isNewNetworkFlow: true,
addNewNetwork: true,
networkToEdit: null,
},
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
await fireEvent.click(canvas.getByRole('button', { name: 'Open Modal' }));
},
Comment on lines +77 to +80
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this

Suggested change
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
await fireEvent.click(canvas.getByRole('button', { name: 'Open Modal' }));
},

};
Loading