• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

input-output-hk / lace / 8521260523

02 Apr 2024 10:25AM UTC coverage: 50.577%. Remained the same
8521260523

push

github

web-flow
test(extension): add tests for LW-10143, LW-10147, LW-10148, LW-10149 (#994)

* test(extension): add tests for LW-10143, LW-10147, LW-10148, LW-10149

* test(extension): make LW-2550 and LW-2561 more stable

* test(extension): adjust timeout

2172 of 5359 branches covered (40.53%)

Branch coverage included in aggregate %.

5146 of 9110 relevant lines covered (56.49%)

52.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/apps/browser-extension-wallet/src/features/delegation/components/Staking.tsx
1
import React from 'react';
×
2
import isNumber from 'lodash/isNumber';
×
3
import { useTranslation } from 'react-i18next';
×
4
import { Skeleton, Typography } from 'antd';
×
5
import { Wallet } from '@lace/cardano';
6
import { StakePoolSearch, StakePoolSearchProps } from '@lace/staking';
×
7
import { StakeFundsBanner } from '@views/browser/features/staking/components/StakeFundsBanner';
×
8
import { FundWalletBanner } from '@src/views/browser-view/components';
×
9
import { StakingInfo } from '@views/browser/features/staking/components/StakingInfo';
×
10
import { ExpandViewBanner } from './ExpandViewBanner';
×
11
import styles from './DelegationLayout.module.scss';
×
12
import { useWalletStore } from '@src/stores';
×
13

14
const { Text } = Typography;
×
15

16
export interface StakePool {
17
  id: string;
18
  theme?: string;
19
  name?: string;
20
  ticker?: string;
21
  logo?: string;
22
  pledgeMet?: boolean;
23
  retired?: boolean;
24
  onClick?: () => unknown;
25
}
26

27
export type StakingProps = {
28
  searchedPools: StakePoolSearchProps['pools'];
29
  currentStakePool?: StakePool;
30
  handleSearchChange: (val: string) => unknown;
31
  coinBalance: number;
32
  showAddFunds?: boolean;
33
  isSearching?: boolean;
34
  hasNoFunds?: boolean;
35
  isDelegating?: boolean;
36
  canDelegate?: boolean;
37
  walletAddress: Wallet.Cardano.PaymentAddress;
38
  fiat?: number;
39
  totalRewards: string;
40
  lastReward: string;
41
  onStakePoolSelect: () => void;
42
  onStakePoolClick?: (id: string) => void;
43
  cardanoCoin: Wallet.CoinId;
44
};
45

46
export const Staking = ({
×
47
  searchedPools,
48
  handleSearchChange,
49
  coinBalance,
50
  currentStakePool,
51
  fiat,
52
  isSearching,
53
  hasNoFunds,
54
  isDelegating,
55
  canDelegate,
56
  walletAddress,
57
  totalRewards,
58
  lastReward,
59
  onStakePoolSelect,
60
  onStakePoolClick,
61
  cardanoCoin
62
}: StakingProps): React.ReactElement => {
63
  const { t } = useTranslation();
×
64
  const totalResultCount = useWalletStore(({ stakePoolSearchResults }) => stakePoolSearchResults?.totalResultCount);
×
65
  const showExpandView = hasNoFunds || (!hasNoFunds && !isDelegating) || isDelegating;
×
66

67
  const stakePoolSearchTranslations = {
×
68
    gettingSaturated: t('cardano.stakePoolSearch.gettingSaturated'),
69
    saturated: t('cardano.stakePoolSearch.saturated'),
70
    overSaturation: t('cardano.stakePoolSearch.overSaturated'),
71
    staking: t('cardano.stakePoolSearch.staking'),
72
    searchPlaceholder: t('cardano.stakePoolSearch.searchPlaceholder')
73
  };
74

75
  return (
×
76
    <div className={styles.content}>
77
      <Skeleton loading={!isNumber(coinBalance)}>
78
        <div className={styles.contentWrapper}>
79
          {canDelegate && <StakeFundsBanner balance={coinBalance} popupView />}
×
80

81
          {hasNoFunds && (
×
82
            <FundWalletBanner
83
              title={t('browserView.assets.welcome')}
84
              subtitle={t('browserView.staking.fundWalletBanner.subtitle')}
85
              prompt={t('browserView.staking.fundWalletBanner.prompt')}
86
              walletAddress={walletAddress?.toString()}
×
87
              shouldHaveVerticalContent
88
            />
89
          )}
90
          {isDelegating && (
×
91
            <StakingInfo
92
              {...{
93
                ...currentStakePool,
94
                coinBalance,
95
                fiat,
96
                totalRewards,
97
                lastReward,
98
                cardanoCoin
99
              }}
100
              onStakePoolSelect={onStakePoolSelect}
101
              popupView
102
            />
103
          )}
104
          <div>
105
            <div className={styles.title}>
106
              <h1 className={styles.subHeader}>{t('staking.stakePools.sectionTitle')}</h1>
107
              <Text data-testid="section-title-counter" className={styles.sideText}>
108
                ({totalResultCount || 0})
×
109
              </Text>
110
            </div>
111

112
            <StakePoolSearch
113
              // eslint-disable-next-line unicorn/no-null
114
              value={null}
115
              pools={searchedPools}
116
              onChange={handleSearchChange}
117
              isSearching={isSearching}
118
              onStakePoolClick={onStakePoolClick}
119
              translations={stakePoolSearchTranslations}
120
              withSuggestions
121
            />
122
          </div>
123
          {showExpandView && <ExpandViewBanner />}
×
124
        </div>
125
      </Skeleton>
126
    </div>
127
  );
128
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc