Skip to content

Commit

Permalink
Failing test of deep links on search results
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaw3d committed Mar 13, 2023
1 parent 7c2033d commit e02af0e
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { screen } from '@testing-library/react'
import { renderWithProviders } from '../../../utils/renderWithProviders'
import { SearchResultsView } from '../'
import { suggestedParsedAccount, suggestedParsedBlock } from '../../../utils/test-fixtures'

describe('SearchResultsView', () => {
beforeEach(() => {
jest.useFakeTimers()
jest.setSystemTime(new Date(2023, 1, 1))
})

afterEach(() => {
jest.useRealTimers()
})

it.todo('unskip tests') // TODO: fix deep links
it.skip('block should correctly link to transactions', () => {
renderWithProviders(
<SearchResultsView
searchQueries={{
emeraldBlockHeight: {
isLoading: false,
results: [suggestedParsedBlock],
},
emeraldTxHash: { isLoading: false, results: [] },
consensusAccount: { isLoading: false, results: [] },
evmBech32Account: { isLoading: false, results: [] },
}}
roseFiatValue={1}
/>,
)
expect(screen.getByText('1,396,255')).toBeInTheDocument()
expect(screen.getByRole('link', { name: '10 transactions' })).toBeInTheDocument()
expect(screen.getByRole('link', { name: '10 transactions' })).toHaveAttribute(
'href',
'/emerald/blocks/1396255#transactions',
)
})

it.skip('account should correctly link to erc-20 tokens', () => {
renderWithProviders(
<SearchResultsView
searchQueries={{
emeraldBlockHeight: { isLoading: false, results: [] },
emeraldTxHash: { isLoading: false, results: [] },
consensusAccount: { isLoading: false, results: [] },
evmBech32Account: { isLoading: false, results: [suggestedParsedAccount] },
}}
roseFiatValue={1}
/>,
)
expect(screen.getByText('EVM tokens')).toBeInTheDocument()
expect(screen.getByRole('link', { name: '337325.43837 FTP' })).toBeInTheDocument()
expect(screen.getByRole('link', { name: '337325.43837 FTP' })).toHaveAttribute(
'href',
'/emerald/account/0xBA504818FdD8D3dBA2Ef8fD9B4F4D5c71aD1d1D3/tokens/erc-20#oasis1qpssvkplnlpzdvwxpgmrhf9j5lkyvaylcvujhjhg',
)
})
})
35 changes: 34 additions & 1 deletion src/app/utils/test-fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RuntimeBlock } from '../../oasis-indexer/api'
import { RuntimeAccount, RuntimeBlock } from '../../oasis-indexer/api'

export const suggestedParsedBlock: RuntimeBlock = {
round: 1396255,
Expand All @@ -8,3 +8,36 @@ export const suggestedParsedBlock: RuntimeBlock = {
num_transactions: 10,
gas_used: 1482530,
}

export const suggestedParsedAccount: RuntimeAccount = {
address: 'oasis1qrvha284gfztn7wwq6z50c86ceu28jp7csqhpx9t',
address_preimage: {
address_data: 'ulBIGP3Y09ui74/ZtPTVxxrR0dM=',
context: 'oasis-runtime-sdk/address: secp256k1eth',
context_version: 0,
},
balances: [],
evm_balances: [
{
balance: '337325.438367711264207872',
token_contract_addr: 'oasis1qpssvkplnlpzdvwxpgmrhf9j5lkyvaylcvujhjhg',
token_decimals: 18,
token_name: 'FTP',
token_symbol: 'FTP',
token_type: 'ERC20',
},
{
balance: '-3372955.09999999999999995',
token_contract_addr: 'oasis1qqz8706pmf38wmptl6dkcaec8yykw0rvfv7ql6fc',
token_decimals: 18,
token_name: 'YUZU',
token_symbol: 'YUZU',
token_type: 'ERC20',
},
],
stats: {
num_txns: 55313,
total_received: '0',
total_sent: '0',
},
}

0 comments on commit e02af0e

Please sign in to comment.