From 1e3576739f95ba7603d2e128fad27786e945bc6e Mon Sep 17 00:00:00 2001 From: Dimitrije Dragasevic Date: Wed, 17 Jan 2024 18:09:10 +0100 Subject: [PATCH 01/21] Added testid for setup in Automation framework --- src/app/components/HeaderIconButton.tsx | 8 +++++++- src/app/sections/settings/SettingsButton.tsx | 1 + src/auth/modules/create/CreatedWallet.tsx | 5 +++-- src/auth/modules/create/SelectAddress.tsx | 14 ++++++++++---- src/pages/wallet/AssetList.tsx | 3 +++ src/pages/wallet/WalletActionButtons.tsx | 13 ++++++++++--- 6 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/app/components/HeaderIconButton.tsx b/src/app/components/HeaderIconButton.tsx index 8f8f7e8b8..814593078 100644 --- a/src/app/components/HeaderIconButton.tsx +++ b/src/app/components/HeaderIconButton.tsx @@ -9,7 +9,13 @@ const HeaderIconButton = forwardRef( return ( // wrap for tooltip - diff --git a/src/auth/modules/create/SelectAddress.tsx b/src/auth/modules/create/SelectAddress.tsx index c9a942642..a0e2ac483 100644 --- a/src/auth/modules/create/SelectAddress.tsx +++ b/src/auth/modules/create/SelectAddress.tsx @@ -98,10 +98,16 @@ const SelectAddress = () => { const length = coins.length return ( -
-
-

m/44'/{bip}'

-

{truncate(address)}

+
+
+

m/44'/{bip}'

+

{truncate(address)}

diff --git a/src/pages/wallet/AssetList.tsx b/src/pages/wallet/AssetList.tsx index 6b1ee8eac..12d33332e 100644 --- a/src/pages/wallet/AssetList.tsx +++ b/src/pages/wallet/AssetList.tsx @@ -122,6 +122,7 @@ const AssetList = () => { value={search} placeholder={t("Filter by tokens, chains, etc.")} onChange={(e) => setSearch(e.target.value)} + data-testid="assetlist-filter-input" />
)} @@ -153,6 +154,7 @@ const AssetList = () => { width={16} height={16} onClick={toggleFilter} + data-testid="assetlist-filter-icon" />
{render()}
@@ -162,6 +164,7 @@ const AssetList = () => { onClick={toggleFilter} label={t("Clear Filter")} variant="secondary" + data-testid="assetlist-clear-filter-button" /> )} diff --git a/src/pages/wallet/WalletActionButtons.tsx b/src/pages/wallet/WalletActionButtons.tsx index b755c7593..846f90d9c 100644 --- a/src/pages/wallet/WalletActionButtons.tsx +++ b/src/pages/wallet/WalletActionButtons.tsx @@ -57,7 +57,10 @@ const WalletActionButtons = ({ token }: { token?: TokenItem }) => { primary: true, label: t("Send"), onClick: () => - (isLedger ? openURL : navigate)(`/send/1`, token ? { state: token?.symbol } : undefined), + (isLedger ? openURL : navigate)( + `/send/1`, + token ? { state: token?.symbol } : undefined + ), disabled: sendButtonDisabled, }, { @@ -71,7 +74,10 @@ const WalletActionButtons = ({ token }: { token?: TokenItem }) => { size: "default", label: t("Swap"), onClick: () => - (isLedger ? openURL : navigate)(`/swap`, token ? { state: token?.token } : undefined), + (isLedger ? openURL : navigate)( + `/swap`, + token ? { state: token?.token } : undefined + ), hide: networkName !== "mainnet", }, { @@ -95,7 +101,7 @@ const WalletActionButtons = ({ token }: { token?: TokenItem }) => { return (
{buttons.map( - ({ size, icon, label, onClick, disabled, primary, hide }) => + ({ size, icon, label, onClick, disabled, primary, hide }, index) => !hide && ( { onClick={onClick} icon={icon} disabled={disabled} + data-testid={`wallet-action-button-${index}`} // Add the data-testid attribute here /> {capitalize(label)} From c2b3a8382acb29c5d42de064c5691660c67805f6 Mon Sep 17 00:00:00 2001 From: Dimitrije Dragasevic Date: Wed, 17 Jan 2024 18:10:46 +0100 Subject: [PATCH 02/21] removed comment --- src/pages/wallet/WalletActionButtons.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/wallet/WalletActionButtons.tsx b/src/pages/wallet/WalletActionButtons.tsx index 846f90d9c..9b4e6efde 100644 --- a/src/pages/wallet/WalletActionButtons.tsx +++ b/src/pages/wallet/WalletActionButtons.tsx @@ -110,7 +110,7 @@ const WalletActionButtons = ({ token }: { token?: TokenItem }) => { onClick={onClick} icon={icon} disabled={disabled} - data-testid={`wallet-action-button-${index}`} // Add the data-testid attribute here + data-testid={`wallet-action-button-${index}`} /> {capitalize(label)} From ae289c5eb6834c1c041fafc3d67e56d52ae33faa Mon Sep 17 00:00:00 2001 From: Dimitrije Dragasevic Date: Mon, 29 Jan 2024 16:55:25 +0100 Subject: [PATCH 03/21] Add more testids --- src/app/sections/settings/NetworkSetting.tsx | 15 +++++-- .../create/CreateMultisigWalletForm.tsx | 41 +++++++++++-------- src/auth/modules/create/CreateWalletForm.tsx | 5 ++- src/components/layout/SettingsSelector.tsx | 4 +- src/extension/auth/SelectWalletsPage.tsx | 2 + src/extension/components/ExtensionList.tsx | 15 +++++-- src/extension/components/ExtensionPage.tsx | 1 + src/pages/wallet/WalletMain.tsx | 32 +++++++++++---- src/txs/AddressBook/AddressWalletList.tsx | 13 ++++-- 9 files changed, 93 insertions(+), 35 deletions(-) diff --git a/src/app/sections/settings/NetworkSetting.tsx b/src/app/sections/settings/NetworkSetting.tsx index 382f6ef5a..ea1e4353e 100644 --- a/src/app/sections/settings/NetworkSetting.tsx +++ b/src/app/sections/settings/NetworkSetting.tsx @@ -28,23 +28,30 @@ const NetworkSetting = () => { if (!networkOptions) return null return ( - + } label="Add Custom LCD Endpoint" onClick={() => navigate("/preferences/network/lcd")} + data-testid="add-custom-lcd-button" /> {!!list.length && ( <> - - {list.map((i) => ( + + {list.map((i, index) => ( { state: { chainID: i.chainID }, }) } + data-testid={`address-selectable-list-item-${index}`} + data-debug="true" /> ))} diff --git a/src/auth/modules/create/CreateMultisigWalletForm.tsx b/src/auth/modules/create/CreateMultisigWalletForm.tsx index d583959cb..dab2e640b 100644 --- a/src/auth/modules/create/CreateMultisigWalletForm.tsx +++ b/src/auth/modules/create/CreateMultisigWalletForm.tsx @@ -145,24 +145,33 @@ const CreateMultisigWalletForm = ({ onCreated, onPubkey, onBack }: Props) => { {fields.map(({ id }, index) => ( - 2 - ? { - icon: , - onClick: () => remove(index), - } - : undefined - } - /> +
+ {" "} + {/* Wrapper with data-testid */} + 2 + ? { + icon: , + onClick: () => remove(index), + } + : undefined + } + /> +
))} -
diff --git a/src/auth/modules/create/CreateWalletForm.tsx b/src/auth/modules/create/CreateWalletForm.tsx index 48874108f..86866117e 100644 --- a/src/auth/modules/create/CreateWalletForm.tsx +++ b/src/auth/modules/create/CreateWalletForm.tsx @@ -238,6 +238,7 @@ const CreateWalletForm = () => { {...register("name", { validate: validate.name })} autoFocus placeholder="e.g. 'my-wallet'" + data-testid="wallet-name-input" /> @@ -251,7 +252,7 @@ const CreateWalletForm = () => { {mnemonic} - + { {...register("checked", { required: true })} checked={!!checked} label={t("I have written down the recovery phrase")} + data-testid="recovery-phrase-checkbox" /> ) : ( @@ -304,6 +306,7 @@ const CreateWalletForm = () => { disabled={!isValid} variant={"primary"} className={styles.submit__button} + data-testid="submit-button" > {generated ? t("Create Wallet") : t("Import")} diff --git a/src/components/layout/SettingsSelector.tsx b/src/components/layout/SettingsSelector.tsx index d11591c95..634ce2a5e 100644 --- a/src/components/layout/SettingsSelector.tsx +++ b/src/components/layout/SettingsSelector.tsx @@ -19,13 +19,15 @@ const SettingsSelector = ({ const { networks } = useNetworks() return ( - + {options.map(({ value, label }, index) => ( onChange(value)} + data-testid={`radio-list-item-${index}`} + data-debug="true" {...(accordion && { isOpen: openAcc === index, setOpenAcc: () => setOpenAcc(openAcc === index ? undefined : index), diff --git a/src/extension/auth/SelectWalletsPage.tsx b/src/extension/auth/SelectWalletsPage.tsx index 641c72fdd..864975e41 100644 --- a/src/extension/auth/SelectWalletsPage.tsx +++ b/src/extension/auth/SelectWalletsPage.tsx @@ -25,8 +25,10 @@ export default function SelectWalletsPage() { navigate("/manage-wallet/add")} + data-testid="add-wallet-button" /> { ), key: index, + "data-testid": `list-item-${index}`, } return "to" in item ? ( - + ) : ( -
diff --git a/src/pages/wallet/WalletMain.tsx b/src/pages/wallet/WalletMain.tsx index 95dc82e8d..92aeb6518 100644 --- a/src/pages/wallet/WalletMain.tsx +++ b/src/pages/wallet/WalletMain.tsx @@ -21,11 +21,11 @@ const WalletMain = () => { return ( <>
-
+
-
+
{ @@ -37,23 +37,39 @@ const WalletMain = () => { }} tabs={[ t("Assets"), - + {t("Activity")} {!!totalSuccess && ( - + )} {!!totalPending && ( - + )} {!!totalFailed && ( - + )} , ]} />
-
- {tab === 0 ? : } +
+ {tab === 0 ? ( + + ) : ( + + )}
diff --git a/src/txs/AddressBook/AddressWalletList.tsx b/src/txs/AddressBook/AddressWalletList.tsx index d013f387f..13c36fed4 100644 --- a/src/txs/AddressBook/AddressWalletList.tsx +++ b/src/txs/AddressBook/AddressWalletList.tsx @@ -16,10 +16,16 @@ const AddressWalletList = ({ }) => { if (!items.length) return null return ( - - {title && } + + {title && ( + + )} - {items.map((item) => ( + {items.map((item, index) => ( onClick?.(item) : undefined} label={item.name} subLabel={truncate(item.recipient, [11, 6])} + data-testid={`wallet-item-${index}`} /> ))} From 901d4221bb691174896e70ef9ffd85fd97276b73 Mon Sep 17 00:00:00 2001 From: Alessandro Candeago <54709706+alecande11@users.noreply.github.com> Date: Tue, 30 Jan 2024 16:07:40 +0100 Subject: [PATCH 04/21] Select gas denom in ConfirmTx page --- package-lock.json | 11 +++++----- package.json | 2 +- src/extension/modules/ConfirmTx.tsx | 31 ++++++++++++++++------------- src/extension/modules/TxDetails.tsx | 8 ++++++-- 4 files changed, 29 insertions(+), 23 deletions(-) diff --git a/package-lock.json b/package-lock.json index 32e890d28..68327d639 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "@terra-money/log-finder-ruleset": "^3.0.3", "@terra-money/msg-reader": "^3.0.1", "@terra-money/station-connector": "^1.0.12", - "@terra-money/station-ui": "^1.0.4", + "@terra-money/station-ui": "file:../station-ui/terra-money-station-ui-1.0.4.tgz", "@terra-money/terra-utils": "^1.2.0-beta.7", "@terra-money/terra.js": "^3.1.9", "@terra-money/terra.proto": "^2.0.0", @@ -7731,8 +7731,8 @@ }, "node_modules/@terra-money/station-ui": { "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@terra-money/station-ui/-/station-ui-1.0.4.tgz", - "integrity": "sha512-ULh/k/2V5+jGodUj5FgeQ0qNw3xrLtwqjn/Y07QRuzgwixSqiMQf3hwFSP43VBQ9Yko8upB+dDCbKe/VK3fIww==", + "resolved": "file:../station-ui/terra-money-station-ui-1.0.4.tgz", + "integrity": "sha512-kbTh4uy5n4jew/RDfKOUotgFgTUS3N751RzWu2LpsIfNpLzK/GThAKFvyqlQ4cndTKWXkVFyhl0vtEMHOcGEVw==", "dependencies": { "@emotion/styled": "^11.11.0", "@mui/icons-material": "^5.14.1", @@ -39978,9 +39978,8 @@ } }, "@terra-money/station-ui": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@terra-money/station-ui/-/station-ui-1.0.4.tgz", - "integrity": "sha512-ULh/k/2V5+jGodUj5FgeQ0qNw3xrLtwqjn/Y07QRuzgwixSqiMQf3hwFSP43VBQ9Yko8upB+dDCbKe/VK3fIww==", + "version": "file:../station-ui/terra-money-station-ui-1.0.4.tgz", + "integrity": "sha512-kbTh4uy5n4jew/RDfKOUotgFgTUS3N751RzWu2LpsIfNpLzK/GThAKFvyqlQ4cndTKWXkVFyhl0vtEMHOcGEVw==", "requires": { "@emotion/styled": "^11.11.0", "@mui/icons-material": "^5.14.1", diff --git a/package.json b/package.json index 8d642d647..d6559e620 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "@terra-money/log-finder-ruleset": "^3.0.3", "@terra-money/msg-reader": "^3.0.1", "@terra-money/station-connector": "^1.0.12", - "@terra-money/station-ui": "^1.0.4", + "@terra-money/station-ui": "file:../station-ui/terra-money-station-ui-1.0.4.tgz", "@terra-money/terra-utils": "^1.2.0-beta.7", "@terra-money/terra.js": "^3.1.9", "@terra-money/terra.proto": "^2.0.0", diff --git a/src/extension/modules/ConfirmTx.tsx b/src/extension/modules/ConfirmTx.tsx index 9b509aa73..b08762760 100644 --- a/src/extension/modules/ConfirmTx.tsx +++ b/src/extension/modules/ConfirmTx.tsx @@ -73,6 +73,15 @@ const ConfirmTx = (props: TxRequest | SignBytesRequest) => { const [rememberPassword, setStorePassword] = useState(shouldStorePassword()) const [areFeesReady, setFeesReady] = useState(!("tx" in props)) const [showPasswordInput, setShowPasswordInput] = useState(false) + const { baseAsset, gasPrices } = + "tx" in props ? network[props.tx?.chainID] : ({} as any) + const [feeDenom, setFeeDenom] = useState( + "tx" in props + ? props.tx.fee?.amount?.toAmino()?.[0]?.denom ?? baseAsset in gasPrices + ? baseAsset + : Object.keys(gasPrices ?? {})[0] + : undefined + ) useEffect(() => { getStoredPassword().then((password) => { @@ -100,16 +109,12 @@ const ConfirmTx = (props: TxRequest | SignBytesRequest) => { try { if (!addresses || !addresses[tx?.chainID] || !network[tx?.chainID]) return 0 - const { baseAsset, gasPrices } = network[tx?.chainID] - - const feeDenom = - baseAsset in gasPrices ? baseAsset : Object.keys(gasPrices ?? {})[0] const unsignedTx = await lcd.tx.create( [{ address: addresses[tx?.chainID] }], { ...tx, - feeDenoms: [feeDenom], + feeDenoms: [feeDenom as string], } ) @@ -131,19 +136,16 @@ const ConfirmTx = (props: TxRequest | SignBytesRequest) => { ) let fee: Fee | undefined + let gas = 0 if ("tx" in props && network[props.tx?.chainID]) { const { tx } = props - fee = tx.fee - if (!tx.fee?.gas_limit) { - const { baseAsset, gasPrices, gasAdjustment } = network[tx?.chainID] - const gas = Math.ceil((estimatedGas ?? 0) * gasAdjustment) - - const feeDenom = - baseAsset in gasPrices ? baseAsset : Object.keys(gasPrices ?? {})[0] + const { gasPrices, gasAdjustment } = network[tx?.chainID] + gas = tx.fee?.gas_limit || Math.ceil((estimatedGas ?? 0) * gasAdjustment) - fee = new Fee(gas, { [feeDenom]: Math.ceil(gasPrices[feeDenom] * gas) }) - } + fee = new Fee(gas, { + [feeDenom as string]: Math.ceil(gasPrices[feeDenom as string] * gas), + }) } const disabled = @@ -317,6 +319,7 @@ const ConfirmTx = (props: TxRequest | SignBytesRequest) => { {...props} tx={{ ...props.tx, fee }} onFeesReady={(state) => setFeesReady(state)} + setFeeDenom={(denom) => setFeeDenom(denom)} /> )} {"bytes" in props && } diff --git a/src/extension/modules/TxDetails.tsx b/src/extension/modules/TxDetails.tsx index a2bae5184..b47d32a56 100644 --- a/src/extension/modules/TxDetails.tsx +++ b/src/extension/modules/TxDetails.tsx @@ -11,7 +11,11 @@ const TxDetails = ({ timestamp, tx, onFeesReady, -}: TxRequest & { onFeesReady: (state: boolean) => void }) => { + setFeeDenom, +}: TxRequest & { + onFeesReady: (state: boolean) => void + setFeeDenom: (denom: string) => void +}) => { const { msgs, memo, fee, chainID } = tx const { t } = useTranslation() @@ -37,7 +41,7 @@ const TxDetails = ({ gas={fee?.gas_limit} gasDenom={fee?.amount.denoms()[0]} descriptions={contents.filter(({ value }) => !!value)} - setGasDenom={() => {}} + setGasDenom={setFeeDenom} onReady={(state) => onFeesReady(state)} /> From 22953e1489305d40ace7ce6690eccbcd8a5cdfc1 Mon Sep 17 00:00:00 2001 From: Alessandro Candeago <54709706+alecande11@users.noreply.github.com> Date: Wed, 31 Jan 2024 14:40:54 +0100 Subject: [PATCH 05/21] fix fee default selection --- src/extension/modules/ConfirmTx.tsx | 21 +++++++++++++-------- src/extension/modules/TxDetails.tsx | 2 +- src/txs/feeAbstraction/DisplayFees.tsx | 6 +++--- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/extension/modules/ConfirmTx.tsx b/src/extension/modules/ConfirmTx.tsx index b08762760..833ff4cee 100644 --- a/src/extension/modules/ConfirmTx.tsx +++ b/src/extension/modules/ConfirmTx.tsx @@ -73,15 +73,16 @@ const ConfirmTx = (props: TxRequest | SignBytesRequest) => { const [rememberPassword, setStorePassword] = useState(shouldStorePassword()) const [areFeesReady, setFeesReady] = useState(!("tx" in props)) const [showPasswordInput, setShowPasswordInput] = useState(false) - const { baseAsset, gasPrices } = + const { baseAsset, gasPrices, isClassic } = "tx" in props ? network[props.tx?.chainID] : ({} as any) + console.log("tx" in props && props.tx.fee?.amount?.toData()?.[0]?.denom) const [feeDenom, setFeeDenom] = useState( "tx" in props - ? props.tx.fee?.amount?.toAmino()?.[0]?.denom ?? baseAsset in gasPrices - ? baseAsset - : Object.keys(gasPrices ?? {})[0] + ? props.tx.fee?.amount?.toData()?.[0]?.denom ?? + (baseAsset in gasPrices ? baseAsset : Object.keys(gasPrices ?? {})[0]) : undefined ) + console.log(feeDenom) useEffect(() => { getStoredPassword().then((password) => { @@ -143,9 +144,11 @@ const ConfirmTx = (props: TxRequest | SignBytesRequest) => { const { gasPrices, gasAdjustment } = network[tx?.chainID] gas = tx.fee?.gas_limit || Math.ceil((estimatedGas ?? 0) * gasAdjustment) - fee = new Fee(gas, { - [feeDenom as string]: Math.ceil(gasPrices[feeDenom as string] * gas), - }) + fee = isClassic + ? tx.fee + : new Fee(gas, { + [feeDenom as string]: Math.ceil(gasPrices[feeDenom as string] * gas), + }) } const disabled = @@ -319,7 +322,9 @@ const ConfirmTx = (props: TxRequest | SignBytesRequest) => { {...props} tx={{ ...props.tx, fee }} onFeesReady={(state) => setFeesReady(state)} - setFeeDenom={(denom) => setFeeDenom(denom)} + setFeeDenom={ + isClassic ? undefined : (denom) => setFeeDenom(denom) + } /> )} {"bytes" in props && } diff --git a/src/extension/modules/TxDetails.tsx b/src/extension/modules/TxDetails.tsx index b47d32a56..e789219e4 100644 --- a/src/extension/modules/TxDetails.tsx +++ b/src/extension/modules/TxDetails.tsx @@ -14,7 +14,7 @@ const TxDetails = ({ setFeeDenom, }: TxRequest & { onFeesReady: (state: boolean) => void - setFeeDenom: (denom: string) => void + setFeeDenom?: (denom: string) => void }) => { const { msgs, memo, fee, chainID } = tx diff --git a/src/txs/feeAbstraction/DisplayFees.tsx b/src/txs/feeAbstraction/DisplayFees.tsx index 8efd74086..dc620b670 100644 --- a/src/txs/feeAbstraction/DisplayFees.tsx +++ b/src/txs/feeAbstraction/DisplayFees.tsx @@ -29,7 +29,7 @@ export default function DisplayFees({ chainID: string gas: number | undefined gasDenom: string | undefined - setGasDenom: (gasDenom: string) => void + setGasDenom?: (gasDenom: string) => void descriptions?: { label: ReactNode; value: ReactNode }[] onReady: (state: boolean) => void }) { @@ -58,7 +58,7 @@ export default function DisplayFees({ availableGasDenoms.length && !availableGasDenoms.includes(gasDenom ?? "") ) { - setGasDenom(availableGasDenoms[0]) + setGasDenom && setGasDenom(availableGasDenoms[0]) } }, [availableGasDenoms]) // eslint-disable-line @@ -126,7 +126,7 @@ export default function DisplayFees({ label: (
{t("Fee")}{" "} - {availableGasDenoms.length > 1 && ( + {availableGasDenoms.length > 1 && setGasDenom && (