@@ -3,7 +3,12 @@ import { screen, waitFor } from '@testing-library/react';
33import { mapRequestFromState } from '@/Components/CreateImageWizard/utilities/requestMapper' ;
44import { CreateBlueprintRequest } from '@/store/api/backend' ;
55import { server } from '@/test/mocks/server' ;
6- import { createTestStore , createUser , typeWithWait } from '@/test/testUtils' ;
6+ import {
7+ clickWithWait ,
8+ createTestStore ,
9+ createUser ,
10+ typeWithWait ,
11+ } from '@/test/testUtils' ;
712
813import {
914 removeRepo ,
@@ -101,7 +106,7 @@ describe('Repositories Component', () => {
101106 const toggle = await screen . findByRole ( 'button' , {
102107 name : / m e n u t o g g l e / i,
103108 } ) ;
104- await user . click ( toggle ) ;
109+ await clickWithWait ( user , toggle ) ;
105110
106111 // Should show repositories without typing
107112 expect (
@@ -123,7 +128,7 @@ describe('Repositories Component', () => {
123128 const toggle = await screen . findByRole ( 'button' , {
124129 name : / m e n u t o g g l e / i,
125130 } ) ;
126- await user . click ( toggle ) ;
131+ await clickWithWait ( user , toggle ) ;
127132
128133 expect (
129134 await screen . findByRole ( 'option' , {
@@ -135,7 +140,7 @@ describe('Repositories Component', () => {
135140 const searchInput = await screen . findByRole ( 'textbox' , {
136141 name : / f i l t e r r e p o s i t o r i e s / i,
137142 } ) ;
138- await user . type ( searchInput , 'nonexistent' ) ;
143+ await typeWithWait ( user , searchInput , 'nonexistent' ) ;
139144
140145 expect (
141146 await screen . findByRole ( 'option' , {
@@ -166,15 +171,15 @@ describe('Repositories Component', () => {
166171 const toggle = await screen . findByRole ( 'button' , {
167172 name : / m e n u t o g g l e / i,
168173 } ) ;
169- await user . click ( toggle ) ;
174+ await clickWithWait ( user , toggle ) ;
170175
171176 await screen . findByRole ( 'option' , { name : / n o r e p o s i t o r i e s a v a i l a b l e / i } ) ;
172177
173178 // Type to search - should use limit=50
174179 const searchInput = await screen . findByRole ( 'textbox' , {
175180 name : / f i l t e r r e p o s i t o r i e s / i,
176181 } ) ;
177- await user . type ( searchInput , 'test' ) ;
182+ await typeWithWait ( user , searchInput , 'test' ) ;
178183
179184 await screen . findByRole ( 'option' , {
180185 name : / n o r e p o s i t o r i e s f o u n d f o r " t e s t " / i,
@@ -295,14 +300,16 @@ describe('Repositories Component', () => {
295300 await selectRepo ( user , '01-test-valid-repo' ) ;
296301 await selectRepo ( user , '04-test-another-valid-repo' ) ;
297302
298- expect (
299- await screen . findByRole ( 'cell' , { name : / 0 1 - t e s t - v a l i d - r e p o / i } ) ,
300- ) . toBeInTheDocument ( ) ;
301- expect (
302- await screen . findByRole ( 'cell' , {
303- name : / 0 4 - t e s t - a n o t h e r - v a l i d - r e p o / i,
304- } ) ,
305- ) . toBeInTheDocument ( ) ;
303+ await waitFor ( ( ) => {
304+ expect (
305+ screen . getByRole ( 'cell' , { name : / 0 1 - t e s t - v a l i d - r e p o / i } ) ,
306+ ) . toBeInTheDocument ( ) ;
307+ expect (
308+ screen . getByRole ( 'cell' , {
309+ name : / 0 4 - t e s t - a n o t h e r - v a l i d - r e p o / i,
310+ } ) ,
311+ ) . toBeInTheDocument ( ) ;
312+ } ) ;
306313 } ) ;
307314 } ) ;
308315
0 commit comments