1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-11 20:27:12 +01:00
metamask-extension/ui/components/app/transaction-list-item/transaction-list-item.stories.js
Nidhi Kumari c5368c152b
Added storybook check to CI (#17092)
* added storybook test runner

* added test runner in ci

* updated test for ci and fixed lint error

* updated lavamoat policy

* updated test command

* updated playwright

* changed command to storybook;ci

* updated command

* updated instance for test-storybook

* updated playwright

* added playwright step

* replaced concurrently with start-server-and-test

* updated the static storybook directory

* replaced first with last

* updated lock file

* replaced first with last

* updated test-storybook with maxworkers

* updated .depchechrc

* updated yml

* removed id from banner base

* replaced broken stories with .stories-to-do.js extesnsion

* updated token allowance story

* removed duplicacies from yarn

* fixed lavamoat

* removed filename comment

* updated links for docs

* fixed file extension for stories

* updated path for stories.json

* updated stories.json path

* yarn updated

* updated stories

* updated yarn

* updated wait on
2023-01-21 00:57:46 +05:30

207 lines
5.9 KiB
JavaScript

import React from 'react';
import {
TransactionStatus,
TransactionType,
} from '../../../../shared/constants/transaction';
import { MOCK_TRANSACTION_BY_TYPE } from '../../../../.storybook/initial-states/transactions';
import TransactionListItem from '.';
/**
* @typedef {(import('../../selectors/transactions').TransactionGroup} TransactionGroup
*/
/**
* @param {object} args
* @returns {TransactionGroup}
*/
const getMockTransactionGroup = (args) => {
const status = args['transactionGroup.primaryTransaction.status'];
const tx = {
...args['transactionGroup.primaryTransaction'],
status,
submittedTime: args['transactionGroup.primaryTransaction.submittedTime'],
};
return {
hasCancelled: args['transactionGroup.hasCancelled'],
hasRetried: args['transactionGroup.hasRetried'],
nonce: '0x1',
initialTransaction: tx,
primaryTransaction: tx,
transactions: [tx],
};
};
/**
* Transaction List Item Storybook Page
*
* Each page displays a different Transaction Type (TransactionType)
* except TransactionType.cancel and TransactionType.retry as these two types
* are never initialTransactions
*/
export default {
title: 'Components/App/TransactionListItem',
argTypes: {
isEarliestNonce: { control: 'boolean' },
'transactionGroup.hasCancelled': { control: 'boolean' },
'transactionGroup.hasRetried': { control: 'boolean' },
'transactionGroup.primaryTransaction.status': {
options: Object.values(TransactionStatus)
.filter((status) => {
return status !== TransactionStatus.signed;
})
.sort(),
control: { type: 'select' },
},
'transactionGroup.primaryTransaction.submittedTime': { control: 'number' },
'transactionGroup.primaryTransaction': { control: 'object' },
},
args: {
isEarliestNonce: true,
'transactionGroup.hasCancelled': false,
'transactionGroup.hasRetried': false,
'transactionGroup.primaryTransaction.status': TransactionStatus.pending,
'transactionGroup.primaryTransaction.submittedTime': 19999999999999,
},
};
const Template = (args) => {
const transactionGroup = getMockTransactionGroup(args);
return (
<TransactionListItem
transactionGroup={transactionGroup}
isEarliestNonce={args.isEarliestNonce}
/>
);
};
export const ContractInteraction = Template.bind({});
export const DeployContract = Template.bind({});
export const EthDecrypt = Template.bind({});
export const EthGetEncryptionPublicKey = Template.bind({});
export const Incoming = Template.bind({});
export const PersonalSign = Template.bind({});
export const Sign = Template.bind({});
export const SignTypeData = Template.bind({});
export const SimpleSend = Template.bind({});
export const Smart = Template.bind({});
export const Swap = Template.bind({});
export const SwapApproval = Template.bind({});
export const TokenMethodApprove = Template.bind({});
export const TokenMethodSafeTransferFrom = Template.bind({});
export const TokenMethodTransfer = Template.bind({});
export const TokenMethodTransferFrom = Template.bind({});
ContractInteraction.storyName = 'contractInteraction';
ContractInteraction.args = {
'transactionGroup.primaryTransaction': {
...MOCK_TRANSACTION_BY_TYPE[TransactionType.contractInteraction],
},
};
DeployContract.storyName = 'contractDeployment';
DeployContract.args = {
'transactionGroup.primaryTransaction': {
...MOCK_TRANSACTION_BY_TYPE[TransactionType.deployContract],
},
};
EthDecrypt.storyName = 'eth_decrypt';
EthDecrypt.args = {
'transactionGroup.primaryTransaction': {
...MOCK_TRANSACTION_BY_TYPE[TransactionType.ethDecrypt],
},
};
EthGetEncryptionPublicKey.storyName = 'eth_getEncryptionPublicKey';
EthGetEncryptionPublicKey.args = {
'transactionGroup.primaryTransaction': {
...MOCK_TRANSACTION_BY_TYPE[TransactionType.ethGetEncryptionPublicKey],
},
};
Incoming.storyName = 'incoming';
Incoming.args = {
'transactionGroup.primaryTransaction': {
...MOCK_TRANSACTION_BY_TYPE[TransactionType.incoming],
},
};
PersonalSign.storyName = 'personal_sign';
PersonalSign.args = {
'transactionGroup.primaryTransaction': {
...MOCK_TRANSACTION_BY_TYPE[TransactionType.personalSign],
},
};
Sign.storyName = 'eth_sign';
Sign.args = {
'transactionGroup.primaryTransaction': {
...MOCK_TRANSACTION_BY_TYPE[TransactionType.sign],
},
};
SignTypeData.storyName = 'eth_signTypedData';
SignTypeData.args = {
'transactionGroup.primaryTransaction': {
...MOCK_TRANSACTION_BY_TYPE[TransactionType.signTypedData],
},
};
SimpleSend.storyName = 'simpleSend';
SimpleSend.args = {
'transactionGroup.primaryTransaction': {
...MOCK_TRANSACTION_BY_TYPE[TransactionType.simpleSend],
},
};
Smart.storyName = 'smart';
Smart.args = {
'transactionGroup.primaryTransaction': {
...MOCK_TRANSACTION_BY_TYPE[TransactionType.smart],
},
};
Swap.storyName = 'swap';
Swap.args = {
'transactionGroup.primaryTransaction': {
...MOCK_TRANSACTION_BY_TYPE[TransactionType.swap],
},
};
SwapApproval.storyName = 'swapApproval';
SwapApproval.args = {
'transactionGroup.primaryTransaction': {
...MOCK_TRANSACTION_BY_TYPE[TransactionType.swapApproval],
},
};
TokenMethodApprove.storyName = 'approve';
TokenMethodApprove.args = {
'transactionGroup.primaryTransaction': {
...MOCK_TRANSACTION_BY_TYPE[TransactionType.tokenMethodApprove],
},
};
TokenMethodSafeTransferFrom.storyName = 'safetransferfrom';
TokenMethodSafeTransferFrom.args = {
'transactionGroup.primaryTransaction': {
...MOCK_TRANSACTION_BY_TYPE[TransactionType.tokenMethodSafeTransferFrom],
},
};
TokenMethodTransfer.storyName = 'transfer';
TokenMethodTransfer.args = {
'transactionGroup.primaryTransaction': {
...MOCK_TRANSACTION_BY_TYPE[TransactionType.tokenMethodTransfer],
},
};
TokenMethodTransferFrom.storyName = 'transferfrom';
TokenMethodTransferFrom.args = {
'transactionGroup.primaryTransaction': {
...MOCK_TRANSACTION_BY_TYPE[TransactionType.tokenMethodTransferFrom],
},
};