diff --git a/src/app/components/AddEscrowForm/__tests__/__snapshots__/index.test.tsx.snap b/src/app/components/AddEscrowForm/__tests__/__snapshots__/index.test.tsx.snap
index f0a7740ba3..4ffafdb684 100644
--- a/src/app/components/AddEscrowForm/__tests__/__snapshots__/index.test.tsx.snap
+++ b/src/app/components/AddEscrowForm/__tests__/__snapshots__/index.test.tsx.snap
@@ -316,14 +316,16 @@ exports[` should match snapshot 1`] = `
>
+ >
+ TEST
+
should match snapshot 1`] = `
class="notranslate"
translate="no"
>
-
+ TEST
diff --git a/src/app/components/ReclaimEscrowForm/__tests__/__snapshots__/index.test.tsx.snap b/src/app/components/ReclaimEscrowForm/__tests__/__snapshots__/index.test.tsx.snap
index 7815269f8c..33e6f46326 100644
--- a/src/app/components/ReclaimEscrowForm/__tests__/__snapshots__/index.test.tsx.snap
+++ b/src/app/components/ReclaimEscrowForm/__tests__/__snapshots__/index.test.tsx.snap
@@ -435,7 +435,9 @@ exports[` should match snapshot 1`] = `
>
+ >
+ TEST
+
should match snapshot 1`] = `
class="notranslate"
translate="no"
>
-
+ TEST
diff --git a/src/app/components/TimeToEpoch/__tests__/index.test.tsx b/src/app/components/TimeToEpoch/__tests__/index.test.tsx
index e579a5b11f..607dd4e142 100644
--- a/src/app/components/TimeToEpoch/__tests__/index.test.tsx
+++ b/src/app/components/TimeToEpoch/__tests__/index.test.tsx
@@ -1,34 +1,16 @@
-import * as React from 'react'
import { render } from '@testing-library/react'
-import { Provider } from 'react-redux'
-import { configureAppStore } from 'store/configureStore'
-import { NetworkState } from 'app/state/network/types'
import { TimeToEpoch } from '..'
-const renderComponent = (store: any, epoch: number) =>
- render(
-
-
- ,
- )
+const renderComponent = (currentEpoch: number, epoch: number) =>
+ render()
describe('', () => {
- let store: ReturnType
-
- beforeEach(() => {
- store = configureAppStore({
- network: {
- epoch: 10000,
- } as NetworkState,
- })
- })
-
it('should estimate debonding times', () => {
- expect(renderComponent(store, 10336).container.textContent).toEqual('in 14 days')
- expect(renderComponent(store, 10306).container.textContent).toEqual('in 13 days')
- expect(renderComponent(store, 10086).container.textContent).toEqual('in 4 days')
- expect(renderComponent(store, 10047).container.textContent).toEqual('in 47 hours')
- expect(renderComponent(store, 10001).container.textContent).toEqual('in 1 hour')
+ expect(renderComponent(10000, 10336).container.textContent).toEqual('in 14 days')
+ expect(renderComponent(10000, 10306).container.textContent).toEqual('in 13 days')
+ expect(renderComponent(10000, 10086).container.textContent).toEqual('in 4 days')
+ expect(renderComponent(10000, 10047).container.textContent).toEqual('in 47 hours')
+ expect(renderComponent(10000, 10001).container.textContent).toEqual('in 1 hour')
})
})
diff --git a/src/app/components/Toolbar/Features/Account/__tests__/__snapshots__/Account.test.tsx.snap b/src/app/components/Toolbar/Features/Account/__tests__/__snapshots__/Account.test.tsx.snap
index ad27c50f3e..bbeadcf737 100644
--- a/src/app/components/Toolbar/Features/Account/__tests__/__snapshots__/Account.test.tsx.snap
+++ b/src/app/components/Toolbar/Features/Account/__tests__/__snapshots__/Account.test.tsx.snap
@@ -531,7 +531,7 @@ exports[` should match snapshot 1`] = `
class="notranslate"
translate="no"
>
-
+ TEST
diff --git a/src/app/components/Toolbar/Features/AccountSelector/__tests__/__snapshots__/index.test.tsx.snap b/src/app/components/Toolbar/Features/AccountSelector/__tests__/__snapshots__/index.test.tsx.snap
index c2829b263b..e7734352c3 100644
--- a/src/app/components/Toolbar/Features/AccountSelector/__tests__/__snapshots__/index.test.tsx.snap
+++ b/src/app/components/Toolbar/Features/AccountSelector/__tests__/__snapshots__/index.test.tsx.snap
@@ -750,7 +750,7 @@ exports[` should match snapshot 1`] = `
class="notranslate"
translate="no"
>
-
+ TEST
diff --git a/src/app/pages/AccountPage/__tests__/__snapshots__/index.test.tsx.snap b/src/app/pages/AccountPage/__tests__/__snapshots__/index.test.tsx.snap
index 398b5025e8..bff8311e30 100644
--- a/src/app/pages/AccountPage/__tests__/__snapshots__/index.test.tsx.snap
+++ b/src/app/pages/AccountPage/__tests__/__snapshots__/index.test.tsx.snap
@@ -966,7 +966,7 @@ exports[` should match snapshot 1`] = `
class="notranslate"
translate="no"
>
-
+ TEST
@@ -989,7 +989,7 @@ exports[` should match snapshot 1`] = `
class="notranslate"
translate="no"
>
-
+ TEST
@@ -1013,7 +1013,7 @@ exports[` should match snapshot 1`] = `
class="notranslate"
translate="no"
>
-
+ TEST
@@ -1036,7 +1036,7 @@ exports[` should match snapshot 1`] = `
class="notranslate"
translate="no"
>
-
+ TEST
@@ -1123,7 +1123,9 @@ exports[` should match snapshot 1`] = `
>
+ >
+ TEST
+
should match snapshot 1`] = `
`;
-exports[` with missing delegations 1`] = `"Total-Available100.0 Staked-Debonding-"`;
+exports[` with missing delegations 1`] = `"Total-Available100.0 TEST Staked-Debonding-"`;
diff --git a/src/app/pages/StakingPage/Features/CommissionBounds/__tests__/index.test.tsx b/src/app/pages/StakingPage/Features/CommissionBounds/__tests__/index.test.tsx
index 6d44630706..8c2d566959 100644
--- a/src/app/pages/StakingPage/Features/CommissionBounds/__tests__/index.test.tsx
+++ b/src/app/pages/StakingPage/Features/CommissionBounds/__tests__/index.test.tsx
@@ -21,7 +21,11 @@ describe('', () => {
let store: ReturnType
beforeEach(() => {
- store = configureAppStore()
+ store = configureAppStore({
+ network: {
+ epoch: 0,
+ } as NetworkState,
+ })
})
it('should match snapshot when empty', () => {
@@ -43,7 +47,7 @@ describe('', () => {
store = configureAppStore()
const component = renderComponent(store, [{ epochStart: 0, lower: 0.1, upper: 0.2, epochEnd: 100 }])
act(() => {
- store.dispatch(networkActions.networkSelected({ epoch: 50 } as NetworkState))
+ store.dispatch(networkActions.setEpoch(50))
})
expect(component.baseElement).toMatchSnapshot()
})
diff --git a/src/app/pages/StakingPage/Features/CommissionBounds/index.tsx b/src/app/pages/StakingPage/Features/CommissionBounds/index.tsx
index 1523d56cb0..b087dbd9dc 100644
--- a/src/app/pages/StakingPage/Features/CommissionBounds/index.tsx
+++ b/src/app/pages/StakingPage/Features/CommissionBounds/index.tsx
@@ -14,7 +14,7 @@ interface CommissionBoundProps {
const CommissionBound = memo((props: CommissionBoundProps) => {
const { t } = useTranslation()
const epoch = useSelector(selectEpoch)
- if (!epoch) {
+ if (typeof epoch !== 'number') {
return null
}
const bound = props.bound
diff --git a/src/app/pages/StakingPage/Features/DelegationList/__tests__/DebondingDelegationList.test.tsx b/src/app/pages/StakingPage/Features/DelegationList/__tests__/DebondingDelegationList.test.tsx
index 2b5568f00b..b3ff81eb03 100644
--- a/src/app/pages/StakingPage/Features/DelegationList/__tests__/DebondingDelegationList.test.tsx
+++ b/src/app/pages/StakingPage/Features/DelegationList/__tests__/DebondingDelegationList.test.tsx
@@ -7,6 +7,7 @@ import { Provider } from 'react-redux'
import { DebondingDelegationList } from '../DebondingDelegationList'
import { configureAppStore } from 'store/configureStore'
import { stakingActions } from 'app/state/staking'
+import { NetworkState } from '../../../../../../app/state/network/types'
import { ThemeProvider } from '../../../../../../styles/theme/ThemeProvider'
import { MemoryRouter } from 'react-router-dom'
@@ -25,7 +26,12 @@ describe('', () => {
let store: ReturnType
beforeEach(() => {
- store = configureAppStore()
+ store = configureAppStore({
+ network: {
+ ticker: 'TEST',
+ epoch: 4,
+ } as NetworkState,
+ })
})
it('should match snapshot', () => {
diff --git a/src/app/pages/StakingPage/Features/DelegationList/__tests__/__snapshots__/ActiveDelegationList.test.tsx.snap b/src/app/pages/StakingPage/Features/DelegationList/__tests__/__snapshots__/ActiveDelegationList.test.tsx.snap
index 9725aefaa4..fd7e926c1c 100644
--- a/src/app/pages/StakingPage/Features/DelegationList/__tests__/__snapshots__/ActiveDelegationList.test.tsx.snap
+++ b/src/app/pages/StakingPage/Features/DelegationList/__tests__/__snapshots__/ActiveDelegationList.test.tsx.snap
@@ -608,7 +608,7 @@ exports[` should match snapshot 1`] = `
class="notranslate"
translate="no"
>
-
+ TEST
diff --git a/src/app/pages/StakingPage/Features/DelegationList/__tests__/__snapshots__/DebondingDelegationList.test.tsx.snap b/src/app/pages/StakingPage/Features/DelegationList/__tests__/__snapshots__/DebondingDelegationList.test.tsx.snap
index b9c2e4b30c..bcba34d80e 100644
--- a/src/app/pages/StakingPage/Features/DelegationList/__tests__/__snapshots__/DebondingDelegationList.test.tsx.snap
+++ b/src/app/pages/StakingPage/Features/DelegationList/__tests__/__snapshots__/DebondingDelegationList.test.tsx.snap
@@ -594,7 +594,7 @@ exports[` should match snapshot 1`] = `
class="notranslate"
translate="no"
>
-
+ TEST
diff --git a/src/app/state/network/saga.test.ts b/src/app/state/network/saga.test.ts
index abef73d2fa..de1ef676d6 100644
--- a/src/app/state/network/saga.test.ts
+++ b/src/app/state/network/saga.test.ts
@@ -1,6 +1,6 @@
import { expectSaga, testSaga } from 'redux-saga-test-plan'
import * as matchers from 'redux-saga-test-plan/matchers'
-import { getChainContext, getOasisNic, networkSaga, selectNetwork } from './saga'
+import { getChainContext, getEpoch, getOasisNic, networkSaga, selectNetwork } from './saga'
import { networkActions } from '.'
describe('Network Sagas', () => {
@@ -59,4 +59,40 @@ describe('Network Sagas', () => {
.run()
})
})
+
+ describe('getEpoch', () => {
+ const mockEpoch = 35337
+ const mockSelectedNetwork = 'testnet'
+ const mockNic = {
+ beaconGetEpoch: jest.fn().mockResolvedValue(mockEpoch),
+ }
+
+ it('should return existing epoch if available', () => {
+ return expectSaga(getEpoch)
+ .withState({
+ network: {
+ epoch: mockEpoch,
+ selectedNetwork: mockSelectedNetwork,
+ },
+ })
+ .returns(mockEpoch)
+ .run()
+ })
+
+ it('should fetch and return epoch when it is missing in state', () => {
+ return expectSaga(getEpoch)
+ .withState({
+ network: {
+ selectedNetwork: mockSelectedNetwork,
+ },
+ })
+ .provide([
+ [matchers.call.fn(getOasisNic), mockNic],
+ [matchers.call.fn(mockNic.beaconGetEpoch), mockEpoch],
+ ])
+ .put(networkActions.setEpoch(mockEpoch))
+ .returns(mockEpoch)
+ .run()
+ })
+ })
})
diff --git a/src/app/state/staking/saga.test.ts b/src/app/state/staking/saga.test.ts
index e497c46628..41a338e8e3 100644
--- a/src/app/state/staking/saga.test.ts
+++ b/src/app/state/staking/saga.test.ts
@@ -76,7 +76,11 @@ describe('Staking Sagas', () => {
nic.stakingAccount.mockResolvedValue({})
return expectSaga(stakingSaga)
- .withState({})
+ .withState({
+ network: {
+ epoch: 35337,
+ },
+ })
.provide(providers)
.dispatch(stakingActions.validatorSelected('oasis1qqzz2le7nua2hvrkjrc9kc6n08ycs9a80chejmr7'))
.put.actionType(stakingActions.updateValidatorDetails.type)
diff --git a/src/utils/__fixtures__/test-inputs.ts b/src/utils/__fixtures__/test-inputs.ts
index ebf8a3ceaa..65c24abba8 100644
--- a/src/utils/__fixtures__/test-inputs.ts
+++ b/src/utils/__fixtures__/test-inputs.ts
@@ -73,7 +73,7 @@ export const privateKeyUnlockedState = {
ticker: 'ROSE',
chainContext: '',
selectedNetwork: 'mainnet',
- epoch: 18372,
+ epoch: 0,
minimumStakingAmount: 100,
},
paraTimes: {
@@ -274,7 +274,7 @@ export const walletExtensionV0UnlockedState = {
chainContext: '',
ticker: 'ROSE',
selectedNetwork: 'mainnet',
- epoch: 27884,
+ epoch: 0,
minimumStakingAmount: 100,
},
paraTimes: {