Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: validator link on homepage in custom mode #859

Merged
merged 2 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/containers/Ledgers/Ledgers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { getAction, getCategory } from '../shared/components/Transaction'
import { TransactionActionIcon } from '../shared/components/TransactionActionIcon/TransactionActionIcon'
import { Legend } from './Legend'
import { RouteLink } from '../shared/routing'
import { LEDGER_ROUTE, TRANSACTION_ROUTE } from '../App/routes'
import { LEDGER_ROUTE, TRANSACTION_ROUTE, VALIDATOR_ROUTE } from '../App/routes'

class Ledgers extends Component {
constructor(props) {
Expand Down Expand Up @@ -71,13 +71,16 @@ class Ledgers extends Component {
renderSelected = () => {
const { validators, selected } = this.state
const v = validators[selected] || {}
const url = `/validators/${selected}`
return (
<div className="selected-validator">
{v.domain && <DomainLink domain={v.domain} />}
<a className="pubkey" href={url}>
<RouteLink
to={VALIDATOR_ROUTE}
params={{ identifier: selected }}
className="pubkey"
>
{selected}
</a>
</RouteLink>
</div>
)
}
Expand Down
21 changes: 14 additions & 7 deletions src/containers/Ledgers/test/LedgersPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ describe('Ledgers Page container', () => {
let client
const middlewares = [thunk]
const mockStore = configureMockStore(middlewares)
const createWrapper = (props = { network: 'main' }) => {
const createWrapper = (props = { network: 'main', path: '/' }) => {
const store = mockStore({ ...initialState })

return mount(
<Provider store={store}>
<SocketContext.Provider value={client}>
<NetworkContext.Provider value={props.network}>
<QuickHarness i18n={i18n}>
<QuickHarness i18n={i18n} initialEntries={[props.path]}>
<Ledgers msg={props.msg} />
</QuickHarness>
</NetworkContext.Provider>
Expand Down Expand Up @@ -200,11 +200,11 @@ describe('Ledgers Page container', () => {
validations.first().simulate('mouseLeave')
expect(wrapper.find('.tooltip').length).toBe(0)
validations.first().simulate('focus')
expect(wrapper.find('.selected-validator .pubkey').length).toBe(0)
expect(wrapper.find('.selected-validator a.pubkey').length).toBe(0)
validations.first().simulate('click') // set selected
expect(wrapper.find('.selected-validator .pubkey').length).toBe(1)
expect(wrapper.find('.selected-validator a.pubkey').length).toBe(1)
validations.first().simulate('click') // unset selected
expect(wrapper.find('.selected-validator .pubkey').length).toBe(0)
expect(wrapper.find('.selected-validator a.pubkey').length).toBe(0)

wrapper.unmount()

Expand Down Expand Up @@ -235,7 +235,10 @@ describe('Ledgers Page container', () => {
},
)

const wrapper = createWrapper({ network: customNetwork })
const wrapper = createWrapper({
network: customNetwork,
path: '/my.custom.com',
})

expect(wrapper.find('.ledger').length).toBe(0)
expect(wrapper.find('.validation').length).toBe(0)
Expand Down Expand Up @@ -289,7 +292,11 @@ describe('Ledgers Page container', () => {
validations.first().simulate('focus')
expect(wrapper.find('.selected-validator .pubkey').length).toBe(0)
validations.first().simulate('click') // set selected
expect(wrapper.find('.selected-validator .pubkey').length).toBe(1)
expect(wrapper.find('.selected-validator a.pubkey').length).toBe(1)
expect(wrapper.find('.selected-validator a.pubkey')).toHaveProp(
'href',
'/validators/n9KaxgJv69FucW5kkiaMhCqS6sAR1wUVxpZaZmLGVXxAcAse9YhR',
)
validations.first().simulate('click') // unset selected
expect(wrapper.find('.selected-validator .pubkey').length).toBe(0)

Expand Down