From c66c6920ba3846ec1f433b7eab5b1dfe55014a4a Mon Sep 17 00:00:00 2001 From: Stepan Lavrentev <40560660+stepanLav@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:56:26 +0300 Subject: [PATCH] Update test implementation (#2668) * fix: add testId to components * fix: import problem * fix: link test * fix: regress tests * fix: fee test fix: remove redundant locator fix: update fee test implementation * fix: import resolution fix: import resolution fix: import resolution fix: remove redundant ids fix: return some buttons * fix: rename testId * fix: move constants out of ui-kit * fix: rename main to common * fix: change name for testid --- .../ui/FeeWithLabel/FeeWithLabel.tsx | 2 + .../wallet/ui/AccountsList/AccountsList.tsx | 3 +- .../AssetsSettings/ui/AssetsSettings.tsx | 2 + .../Transfer/ui/Confirmation.tsx | 2 + .../wallets/WalletSelect/ui/WalletButton.tsx | 2 + .../pages/Onboarding/WatchOnly/WatchOnly.tsx | 7 +- .../pages/Onboarding/Welcome/Welcome.tsx | 6 ++ .../pages/Onboarding/Welcome/WelcomeCard.tsx | 4 +- src/renderer/shared/constants/index.ts | 1 + src/renderer/shared/constants/testIds.ts | 24 ++++++ .../AccountExplorer/AccountExplorers.tsx | 5 +- .../ui/Buttons/IconButton/IconButton.tsx | 3 + .../shared/ui/DetailRow/DetailRow.tsx | 8 +- src/renderer/shared/ui/Inputs/Input/Input.tsx | 3 + .../ui/Popovers/MenuPopover/MenuPopover.tsx | 8 +- tests/system/data/chains/chainsList.ts | 11 ++- tests/system/pages/BaseModalWindow.ts | 24 ++---- tests/system/pages/BasePage.ts | 28 +------ .../pages/_elements/AssetsPageElements.ts | 5 +- .../pages/_elements/LoginPageElements.ts | 14 ++-- .../pages/_elements/TransferModalElements.ts | 7 +- .../pages/assetsPage/VaultAssetsPage.ts | 5 +- .../pages/assetsPage/WatchOnlyAssetsPage.ts | 2 +- tests/system/pages/loginPage/BaseLoginPage.ts | 10 +-- .../pages/loginPage/WatchOnlyLoginPage.ts | 21 +++-- .../pages/modals/TransferModalWindow.ts | 5 +- .../system/pages/modals/WalletModalWindow.ts | 4 +- .../system/tests/assets/load.eth.fee.test.ts | 28 +------ tests/system/tests/assets/load.fee.test.ts | 28 +------ .../vault.onboarding.system.test.ts | 79 ++++++------------- .../watch.only.onboarding.system.test.ts | 32 ++------ tests/system/utils/baseRegularFixture.ts | 39 +++++++++ tests/system/utils/feeFixture.ts | 19 +++++ tests/system/utils/interactWithDatabase.ts | 30 +++---- tsconfig.json | 2 +- 35 files changed, 230 insertions(+), 243 deletions(-) create mode 100644 src/renderer/shared/constants/index.ts create mode 100644 src/renderer/shared/constants/testIds.ts create mode 100644 tests/system/utils/baseRegularFixture.ts create mode 100644 tests/system/utils/feeFixture.ts diff --git a/src/renderer/entities/transaction/ui/FeeWithLabel/FeeWithLabel.tsx b/src/renderer/entities/transaction/ui/FeeWithLabel/FeeWithLabel.tsx index e287469d29..9086545368 100644 --- a/src/renderer/entities/transaction/ui/FeeWithLabel/FeeWithLabel.tsx +++ b/src/renderer/entities/transaction/ui/FeeWithLabel/FeeWithLabel.tsx @@ -1,5 +1,6 @@ import { type ComponentProps } from 'react'; +import { TEST_IDS } from '@/shared/constants'; import { useI18n } from '@/shared/i18n'; import { cnTw } from '@/shared/lib/utils'; import { DetailRow, FootnoteText } from '@/shared/ui'; @@ -17,6 +18,7 @@ export const FeeWithLabel = ({ label, wrapperClassName, ...feeProps }: Props) => {label || t('operation.networkFee')}} className={cnTw('text-text-primary', wrapperClassName)} + testId={TEST_IDS.OPERATIONS.ESTIMATE_FEE} > diff --git a/src/renderer/entities/wallet/ui/AccountsList/AccountsList.tsx b/src/renderer/entities/wallet/ui/AccountsList/AccountsList.tsx index 8fd311b3ab..b003aa99f6 100644 --- a/src/renderer/entities/wallet/ui/AccountsList/AccountsList.tsx +++ b/src/renderer/entities/wallet/ui/AccountsList/AccountsList.tsx @@ -1,3 +1,4 @@ +import { TEST_IDS } from '@/shared/constants'; import { type AccountId, type Chain } from '@/shared/core'; import { useI18n } from '@/shared/i18n'; import { cnTw, toAddress } from '@/shared/lib/utils'; @@ -35,7 +36,7 @@ export const AccountsList = ({ accountId, chains, className }: Props) => {
- + ); diff --git a/src/renderer/features/assets/AssetsSettings/ui/AssetsSettings.tsx b/src/renderer/features/assets/AssetsSettings/ui/AssetsSettings.tsx index 17f9f71ea6..7bde47ecd1 100644 --- a/src/renderer/features/assets/AssetsSettings/ui/AssetsSettings.tsx +++ b/src/renderer/features/assets/AssetsSettings/ui/AssetsSettings.tsx @@ -1,5 +1,6 @@ import { useUnit } from 'effector-react'; +import { TEST_IDS } from '@/shared/constants'; import { useI18n } from '@/shared/i18n'; import { FootnoteText, IconButton, MenuPopover, Select, Switch } from '@/shared/ui'; import { AssetsListView } from '@/entities/asset'; @@ -30,6 +31,7 @@ export const AssetsSettings = () => { position="top-full right-0" buttonClassName="rounded-full" offsetPx={0} + testId={TEST_IDS.ASSETS.SETTINGS_WIDGET} content={ <> {t('operation.networkFee')}} className="text-text-primary" + testId={TEST_IDS.OPERATIONS.CONFIRM_NETWORK_FEE} >
diff --git a/src/renderer/features/wallets/WalletSelect/ui/WalletButton.tsx b/src/renderer/features/wallets/WalletSelect/ui/WalletButton.tsx index f41aafc0c4..d74160a4d2 100644 --- a/src/renderer/features/wallets/WalletSelect/ui/WalletButton.tsx +++ b/src/renderer/features/wallets/WalletSelect/ui/WalletButton.tsx @@ -1,3 +1,4 @@ +import { TEST_IDS } from '@/shared/constants'; import { type Wallet } from '@/shared/core'; import { Icon } from '@/shared/ui'; import { Box, Popover } from '@/shared/ui-kit'; @@ -13,6 +14,7 @@ export const WalletButton = ({ wallet }: Props) => {
} + testId={TEST_IDS.ONBOARDING.WALLET_ADDRESS_INPUT} onChange={onChange} /> @@ -165,11 +168,11 @@ const WatchOnly = ({ isOpen, onClose, onComplete }: Props) => { />
- -
diff --git a/src/renderer/pages/Onboarding/Welcome/Welcome.tsx b/src/renderer/pages/Onboarding/Welcome/Welcome.tsx index 8c227c7263..d99c5677d4 100644 --- a/src/renderer/pages/Onboarding/Welcome/Welcome.tsx +++ b/src/renderer/pages/Onboarding/Welcome/Welcome.tsx @@ -1,6 +1,7 @@ import throttle from 'lodash/throttle'; import { useLayoutEffect, useRef, useState } from 'react'; +import { TEST_IDS } from '@/shared/constants'; import { WalletType } from '@/shared/core'; import { useI18n } from '@/shared/i18n'; import { cnTw } from '@/shared/lib/utils'; @@ -45,6 +46,7 @@ export const Welcome = () => { title={t('onboarding.welcome.polkadotVaultTitle')} description={t('onboarding.welcome.polkadotVaultDescription')} iconName="vaultOnboarding" + testId={TEST_IDS.ONBOARDING.VAULT_BUTTON} onClick={() => walletPairingModel.events.walletTypeSet(WalletType.POLKADOT_VAULT)} /> @@ -52,6 +54,7 @@ export const Welcome = () => { title={t('onboarding.welcome.novaWalletTitle')} description={t('onboarding.welcome.novaWalletDescription')} iconName="novaWalletOnboarding" + testId={TEST_IDS.ONBOARDING.NOVA_WALLET_BUTTON} onClick={() => walletPairingModel.events.walletTypeSet(WalletType.NOVA_WALLET)} /> @@ -59,6 +62,7 @@ export const Welcome = () => { title={t('onboarding.welcome.walletConnectTitle')} description={t('onboarding.welcome.walletConnectDescription')} iconName="walletConnectOnboarding" + testId={TEST_IDS.ONBOARDING.WALLET_CONNECT_BUTTON} onClick={() => walletPairingModel.events.walletTypeSet(WalletType.WALLET_CONNECT)} /> @@ -66,6 +70,7 @@ export const Welcome = () => { title={t('onboarding.welcome.watchOnlyTitle')} description={t('onboarding.welcome.watchOnlyDescription')} iconName="watchOnlyOnboarding" + testId={TEST_IDS.ONBOARDING.WATCH_ONLY_BUTTON} onClick={() => walletPairingModel.events.walletTypeSet(WalletType.WATCH_ONLY)} /> { description={t('onboarding.welcome.ledgerDescription')} iconName="ledgerOnboarding" disabled + testId={TEST_IDS.ONBOARDING.LEDGER_BUTTON} /> diff --git a/src/renderer/pages/Onboarding/Welcome/WelcomeCard.tsx b/src/renderer/pages/Onboarding/Welcome/WelcomeCard.tsx index dc365907d5..eddea7382e 100644 --- a/src/renderer/pages/Onboarding/Welcome/WelcomeCard.tsx +++ b/src/renderer/pages/Onboarding/Welcome/WelcomeCard.tsx @@ -9,13 +9,15 @@ type Props = { iconName: IconNames; onClick?: () => void; disabled?: boolean; + testId?: string; }; -export const WelcomeCard = ({ title, description, iconName, disabled, onClick }: Props) => { +export const WelcomeCard = ({ title, description, iconName, disabled, onClick, testId: testId }: Props) => { const { t } = useI18n(); return (