diff --git a/wormhole-connect/src/components/AlertBanner.tsx b/wormhole-connect/src/components/AlertBanner.tsx index a3c26f283..63e2c13a1 100644 --- a/wormhole-connect/src/components/AlertBanner.tsx +++ b/wormhole-connect/src/components/AlertBanner.tsx @@ -29,6 +29,7 @@ type Props = { warning?: boolean; error?: boolean; margin?: string; + testId?: string; }; function AlertBanner(props: Props) { @@ -43,6 +44,7 @@ function AlertBanner(props: Props) { !!props.error && classes.error, ])} style={{ margin: props.margin || 0 }} + data-testid={props.testId} > {props.content} diff --git a/wormhole-connect/src/components/Button.tsx b/wormhole-connect/src/components/Button.tsx index 9f8370598..fe30bef6f 100644 --- a/wormhole-connect/src/components/Button.tsx +++ b/wormhole-connect/src/components/Button.tsx @@ -40,6 +40,7 @@ type Props = { disabled?: boolean; children: React.ReactNode; onClick?: MouseEventHandler; + testId?: string; }; function Button(props: Props) { @@ -59,6 +60,7 @@ function Button(props: Props) { !!props.disabled && classes.disabled, ])} onClick={click} + data-testid={props.testId} > {props.children} diff --git a/wormhole-connect/src/components/ConnectWallet.tsx b/wormhole-connect/src/components/ConnectWallet.tsx index 0931fdf71..37234c29f 100644 --- a/wormhole-connect/src/components/ConnectWallet.tsx +++ b/wormhole-connect/src/components/ConnectWallet.tsx @@ -16,6 +16,7 @@ import WalletIcons from 'icons/WalletIcons'; import PopupState, { bindTrigger, bindPopover } from 'material-ui-popup-state'; import Popover from '@mui/material/Popover'; import config from 'config'; +import { TransferSide } from 'config/types'; import { ExplorerConfig } from 'config/types'; type StyleProps = { disabled?: boolean }; @@ -57,6 +58,7 @@ const useStyles = makeStyles()((theme: any, { disabled }) => ({ })); type Props = { + side: TransferSide; type: TransferWallet; disabled?: boolean; }; @@ -181,7 +183,11 @@ function ConnectWallet(props: Props) { ); } else { const button = ( -
connect()}> +
connect()} + data-testid={`${props.side}-section-connect-wallet-button`} + >
{mobile ? 'Connect' : 'Connect wallet'}
diff --git a/wormhole-connect/src/components/Header.tsx b/wormhole-connect/src/components/Header.tsx index 3003a5f8a..e8c846ef8 100644 --- a/wormhole-connect/src/components/Header.tsx +++ b/wormhole-connect/src/components/Header.tsx @@ -22,6 +22,7 @@ type Props = { text: string; align?: Alignment; size?: number; + testId?: string; }; function Header(props: Props) { @@ -30,7 +31,11 @@ function Header(props: Props) { fontSize: props.size || 42, }; const { classes } = useStyles(styleProps); - return
{props.text}
; + return ( +
+ {props.text} +
+ ); } export default Header; diff --git a/wormhole-connect/src/components/InputTransparent.tsx b/wormhole-connect/src/components/InputTransparent.tsx index cacc02b03..1354b001f 100644 --- a/wormhole-connect/src/components/InputTransparent.tsx +++ b/wormhole-connect/src/components/InputTransparent.tsx @@ -39,6 +39,7 @@ type Props = { onEnter?: React.KeyboardEventHandler; disabled?: boolean; value?: string | number; + testId?: string; }; const NUMBER_FORMAT_REGEX = /^\d*\.?\d*$/; @@ -76,6 +77,7 @@ function InputTransparent(props: Props) { onKeyDown={handleKeyDown} readOnly={props.disabled} value={props.value} + data-testid={props.testId} /> ); } diff --git a/wormhole-connect/src/components/PageHeader.tsx b/wormhole-connect/src/components/PageHeader.tsx index 38c17a6b1..17873fb17 100644 --- a/wormhole-connect/src/components/PageHeader.tsx +++ b/wormhole-connect/src/components/PageHeader.tsx @@ -52,6 +52,7 @@ type PageHeaderProps = { description?: string; back?: boolean; showHamburgerMenu?: boolean; + testId?: string; }; function PageHeader({ @@ -60,6 +61,7 @@ function PageHeader({ align = 'left', description, showHamburgerMenu = true, + testId, }: PageHeaderProps) { const { classes } = useStyles({ showHamburgerMenu, align }); const dispatch = useDispatch(); @@ -78,7 +80,7 @@ function PageHeader({ onClick={goBack} /> )} -
+
{showHamburgerMenu ? : null} diff --git a/wormhole-connect/src/config/types.ts b/wormhole-connect/src/config/types.ts index f5d4126c6..13cca7bf2 100644 --- a/wormhole-connect/src/config/types.ts +++ b/wormhole-connect/src/config/types.ts @@ -55,6 +55,9 @@ export enum Route { wstETHBridge = 'wstETHBridge', } +// Used in bridging components +export type TransferSide = 'source' | 'destination'; + export type SupportedRoutes = keyof typeof Route; export type Network = 'mainnet' | 'testnet' | 'devnet'; diff --git a/wormhole-connect/src/views/Bridge/Inputs/AmountInput.tsx b/wormhole-connect/src/views/Bridge/Inputs/AmountInput.tsx index 4736f8ce3..77343fa39 100644 --- a/wormhole-connect/src/views/Bridge/Inputs/AmountInput.tsx +++ b/wormhole-connect/src/views/Bridge/Inputs/AmountInput.tsx @@ -10,12 +10,14 @@ import Input from './Input'; import config from 'config'; import Price from 'components/Price'; import { getTokenPrice, getUSDFormat } from 'utils'; +import { TransferSide } from 'config/types'; type Props = { handleAmountChange: (value: number | string) => void; value: string; disabled?: boolean; label?: string; + side: TransferSide; }; function AmountInput(props: Props) { const amountEl = useRef(null); @@ -77,6 +79,7 @@ function AmountInput(props: Props) { onChange={handleAmountChange} disabled={isTransactionInProgress || props.disabled} value={props.value} + testId={props.side + '-section-amount-input'} /> {price && {price}} diff --git a/wormhole-connect/src/views/Bridge/Inputs/From.tsx b/wormhole-connect/src/views/Bridge/Inputs/From.tsx index 93d685b33..e8ea93672 100644 --- a/wormhole-connect/src/views/Bridge/Inputs/From.tsx +++ b/wormhole-connect/src/views/Bridge/Inputs/From.tsx @@ -81,6 +81,7 @@ function FromInputs() { const tokenInput = (
{props.balance ? ( diff --git a/wormhole-connect/src/views/Bridge/Inputs/Select.tsx b/wormhole-connect/src/views/Bridge/Inputs/Select.tsx index 3429031d5..f50c03095 100644 --- a/wormhole-connect/src/views/Bridge/Inputs/Select.tsx +++ b/wormhole-connect/src/views/Bridge/Inputs/Select.tsx @@ -29,6 +29,7 @@ type Selected = { type Props = { label: string; + testId?: string; selected: Selected | undefined; error?: boolean; editable?: boolean; @@ -54,7 +55,7 @@ function Select(props: Props) { onClick={handleClick} > {selected ? ( -
+
{selected.text} {selected.secondaryText && ( @@ -66,7 +67,7 @@ function Select(props: Props) { ) : props.disabled ? ( NO_INPUT ) : ( -
+
Select
diff --git a/wormhole-connect/src/views/Bridge/Inputs/To.tsx b/wormhole-connect/src/views/Bridge/Inputs/To.tsx index dbc1f7e02..018d64edb 100644 --- a/wormhole-connect/src/views/Bridge/Inputs/To.tsx +++ b/wormhole-connect/src/views/Bridge/Inputs/To.tsx @@ -74,6 +74,7 @@ function ToInputs() { const tokenInput = (