File tree Expand file tree Collapse file tree 2 files changed +15
-8
lines changed
src/features/search/components Expand file tree Collapse file tree 2 files changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -86,14 +86,19 @@ describe('search', () => {
8686 return executeComponentTest (
8787 ( ) => render ( < Search /> , undefined , myStore ) ,
8888 async ( component , user ) => {
89- const input = component . getByPlaceholderText ( searchPlaceholderLabel )
90- await user . type ( input , id )
91- const results = ( await component . findAllByText ( label , undefined , { timeout : 1000 } ) ) . map ( ( result ) => result . parentElement )
92- const result = results . find ( ( result ) => result ! . textContent ! . includes ( type ) ) !
93- await user . click ( result )
94-
9589 await waitFor (
9690 async ( ) => {
91+ const input = component . getByPlaceholderText ( searchPlaceholderLabel )
92+ await user . type ( input , id )
93+
94+ const results = ( await component . findAllByText ( label , undefined , { timeout : 1000 } ) ) . map ( ( result ) => result . parentElement )
95+ results . forEach ( ( result ) => {
96+ const link = result ! . querySelector ( 'a' )
97+ expect ( link ) . toHaveTextContent ( label )
98+ } )
99+
100+ const result = results . find ( ( result ) => result ! . textContent ! . includes ( type ) ) !
101+ await user . click ( result )
97102 expect ( mockNavigate ) . toHaveBeenCalledWith ( `/localnet/${ type . toLowerCase ( ) } /${ id } ` )
98103 } ,
99104 { timeout : 10000 }
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import {
1010import { cn } from '@/features/common/utils'
1111import { useCallback , useEffect , useRef } from 'react'
1212import { RenderLoadable } from '@/features/common/components/render-loadable'
13- import { useNavigate } from 'react-router-dom'
13+ import { useNavigate , NavLink } from 'react-router-dom'
1414import { useSearch } from '../data'
1515import { Loader2 as Loader } from 'lucide-react'
1616import { useLocationChange } from '@/features/common/hooks/use-location-change'
@@ -93,7 +93,9 @@ export function Search() {
9393 { results . map ( ( result ) => {
9494 return (
9595 < CommandItem key = { `${ result . type } -${ result . id } ` } value = { result . url } onSelect = { handleSelection } >
96- < span > { result . label } </ span >
96+ < NavLink className = "truncate text-primary underline" to = { result . url } >
97+ { result . label }
98+ </ NavLink >
9799 < span className = { cn ( 'ml-auto text-xs' ) } > { result . type } </ span >
98100 </ CommandItem >
99101 )
You can’t perform that action at this time.
0 commit comments