@@ -9,7 +9,7 @@ import type { ReactElement, ReactNode } from 'react'
99 */
1010import type { AppListResponse } from '@/models/app'
1111import type { App } from '@/types/app'
12- import { fireEvent , render , screen } from '@testing-library/react'
12+ import { fireEvent , render , screen , waitFor } from '@testing-library/react'
1313import { beforeEach , describe , expect , it , vi } from 'vitest'
1414import { createSystemFeaturesWrapper } from '@/__tests__/utils/mock-system-features'
1515import List from '@/app/components/apps/list'
@@ -92,6 +92,9 @@ vi.mock('@tanstack/react-query', async (importOriginal) => {
9292 const actual = await importOriginal < typeof import ( '@tanstack/react-query' ) > ( )
9393 return {
9494 ...actual ,
95+ useQuery : ( ) => ( {
96+ data : [ ] ,
97+ } ) ,
9598 useInfiniteQuery : ( ) => ( {
9699 data : { pages : mockPages } ,
97100 isLoading : mockIsLoading ,
@@ -360,13 +363,18 @@ describe('App List Browsing Flow', () => {
360363 expect ( input ) . toBeInTheDocument ( )
361364 } )
362365
363- it ( 'should allow typing in search input' , ( ) => {
366+ it ( 'should update search query when typing in search input' , async ( ) => {
364367 mockPages = [ createPage ( [ createMockApp ( ) ] ) ]
365- renderList ( )
368+ const { onUrlUpdate } = renderList ( )
366369
367- const input = document . querySelector ( 'input' ) !
370+ const input = screen . getByPlaceholderText ( 'common.operation.search' )
368371 fireEvent . change ( input , { target : { value : 'test search' } } )
369- expect ( input . value ) . toBe ( 'test search' )
372+
373+ await waitFor ( ( ) => {
374+ expect ( onUrlUpdate ) . toHaveBeenCalled ( )
375+ } )
376+ const lastCall = onUrlUpdate . mock . calls [ onUrlUpdate . mock . calls . length - 1 ] ! [ 0 ]
377+ expect ( lastCall . searchParams . get ( 'keywords' ) ) . toBe ( 'test search' )
370378 } )
371379 } )
372380
0 commit comments