@@ -52,32 +52,26 @@ describe(MultipleModeledMethodsPanel.name, () => {
5252 ) . toHaveValue ( "none" ) ;
5353 } ) ;
5454
55- it ( "disables all pagination" , ( ) => {
55+ it ( "disables all pagination" , async ( ) => {
5656 render ( ) ;
5757
58- expect (
59- screen
60- . getByLabelText ( "Previous modeling" )
61- . getElementsByTagName ( "input" ) [ 0 ] ,
62- ) . toBeDisabled ( ) ;
63- expect (
64- screen . getByLabelText ( "Next modeling" ) . getElementsByTagName ( "input" ) [ 0 ] ,
65- ) . toBeDisabled ( ) ;
58+ const prevButton = await screen . findByLabelText ( "Previous modeling" ) ;
59+ const nextButton = await screen . findByLabelText ( "Next modeling" ) ;
60+
61+ expect ( prevButton ) . toBeDisabled ( ) ;
62+ expect ( nextButton ) . toBeDisabled ( ) ;
6663 expect ( screen . queryByText ( "0/0" ) ) . not . toBeInTheDocument ( ) ;
6764 expect ( screen . queryByText ( "1/0" ) ) . not . toBeInTheDocument ( ) ;
6865 } ) ;
6966
70- it ( "cannot add or delete modeling" , ( ) => {
67+ it ( "cannot add or delete modeling" , async ( ) => {
7168 render ( ) ;
7269
73- expect (
74- screen
75- . getByLabelText ( "Delete modeling" )
76- . getElementsByTagName ( "input" ) [ 0 ] ,
77- ) . toBeDisabled ( ) ;
78- expect (
79- screen . getByLabelText ( "Add modeling" ) . getElementsByTagName ( "input" ) [ 0 ] ,
80- ) . toBeDisabled ( ) ;
70+ const deleteButton = await screen . findByLabelText ( "Delete modeling" ) ;
71+ const addButton = await screen . findByLabelText ( "Add modeling" ) ;
72+
73+ expect ( deleteButton ) . toBeDisabled ( ) ;
74+ expect ( addButton ) . toBeDisabled ( ) ;
8175 } ) ;
8276 } ) ;
8377
@@ -104,28 +98,22 @@ describe(MultipleModeledMethodsPanel.name, () => {
10498 ) . toHaveValue ( "sink" ) ;
10599 } ) ;
106100
107- it ( "disables all pagination" , ( ) => {
101+ it ( "disables all pagination" , async ( ) => {
108102 render ( ) ;
109103
110- expect (
111- screen
112- . getByLabelText ( "Previous modeling" )
113- . getElementsByTagName ( "input" ) [ 0 ] ,
114- ) . toBeDisabled ( ) ;
115- expect (
116- screen . getByLabelText ( "Next modeling" ) . getElementsByTagName ( "input" ) [ 0 ] ,
117- ) . toBeDisabled ( ) ;
104+ const prevButton = await screen . findByLabelText ( "Previous modeling" ) ;
105+ const nextButton = await screen . findByLabelText ( "Next modeling" ) ;
106+
107+ expect ( prevButton ) . toBeDisabled ( ) ;
108+ expect ( nextButton ) . toBeDisabled ( ) ;
118109 expect ( screen . queryByText ( "1/1" ) ) . not . toBeInTheDocument ( ) ;
119110 } ) ;
120111
121- it ( "cannot delete modeling" , ( ) => {
112+ it ( "cannot delete modeling" , async ( ) => {
122113 render ( ) ;
123114
124- expect (
125- screen
126- . getByLabelText ( "Delete modeling" )
127- . getElementsByTagName ( "input" ) [ 0 ] ,
128- ) . toBeDisabled ( ) ;
115+ const deleteButton = await screen . findByLabelText ( "Delete modeling" ) ;
116+ expect ( deleteButton ) . toBeDisabled ( ) ;
129117 } ) ;
130118
131119 it ( "can add modeling" , async ( ) => {
@@ -199,37 +187,26 @@ describe(MultipleModeledMethodsPanel.name, () => {
199187 it ( "disables the correct pagination" , async ( ) => {
200188 render ( ) ;
201189
202- expect (
203- screen
204- . getByLabelText ( "Previous modeling" )
205- . getElementsByTagName ( "input" ) [ 0 ] ,
206- ) . toBeDisabled ( ) ;
207- expect (
208- screen . getByLabelText ( "Next modeling" ) . getElementsByTagName ( "input" ) [ 0 ] ,
209- ) . toBeEnabled ( ) ;
190+ const prevButton = await screen . findByLabelText ( "Previous modeling" ) ;
191+ const nextButton = await screen . findByLabelText ( "Next modeling" ) ;
192+
193+ expect ( prevButton ) . toBeDisabled ( ) ;
194+ expect ( nextButton ) . toBeEnabled ( ) ;
210195 } ) ;
211196
212197 it ( "can use the pagination" , async ( ) => {
213198 render ( ) ;
214199
215- await userEvent . click ( screen . getByLabelText ( "Next modeling" ) ) ;
200+ const prevButton = await screen . findByLabelText ( "Previous modeling" ) ;
201+ const nextButton = await screen . findByLabelText ( "Next modeling" ) ;
216202
203+ await userEvent . click ( nextButton ) ;
217204 await waitFor ( ( ) => {
218- expect (
219- screen
220- . getByLabelText ( "Previous modeling" )
221- . getElementsByTagName ( "input" ) [ 0 ] ,
222- ) . toBeEnabled ( ) ;
205+ expect ( prevButton ) . toBeEnabled ( ) ;
223206 } ) ;
224207
225- expect (
226- screen
227- . getByLabelText ( "Previous modeling" )
228- . getElementsByTagName ( "input" ) [ 0 ] ,
229- ) . toBeEnabled ( ) ;
230- expect (
231- screen . getByLabelText ( "Next modeling" ) . getElementsByTagName ( "input" ) [ 0 ] ,
232- ) . toBeDisabled ( ) ;
208+ expect ( prevButton ) . toBeEnabled ( ) ;
209+ expect ( nextButton ) . toBeDisabled ( ) ;
233210 expect ( screen . getByText ( "2/2" ) ) . toBeInTheDocument ( ) ;
234211
235212 expect (
@@ -445,34 +422,20 @@ describe(MultipleModeledMethodsPanel.name, () => {
445422 it ( "can use the pagination" , async ( ) => {
446423 render ( ) ;
447424
448- expect (
449- screen
450- . getByLabelText ( "Previous modeling" )
451- . getElementsByTagName ( "input" ) [ 0 ] ,
452- ) . toBeDisabled ( ) ;
453- expect (
454- screen . getByLabelText ( "Next modeling" ) . getElementsByTagName ( "input" ) [ 0 ] ,
455- ) . toBeEnabled ( ) ;
425+ const prevButton = await screen . findByLabelText ( "Previous modeling" ) ;
426+ const nextButton = await screen . findByLabelText ( "Next modeling" ) ;
427+ expect ( prevButton ) . toBeDisabled ( ) ;
428+ expect ( nextButton ) . toBeEnabled ( ) ;
456429 expect ( screen . getByText ( "1/3" ) ) . toBeInTheDocument ( ) ;
457430
458- await userEvent . click ( screen . getByLabelText ( "Next modeling" ) ) ;
431+ await userEvent . click ( nextButton ) ;
459432
460433 await waitFor ( ( ) => {
461- expect (
462- screen
463- . getByLabelText ( "Previous modeling" )
464- . getElementsByTagName ( "input" ) [ 0 ] ,
465- ) . toBeEnabled ( ) ;
434+ expect ( prevButton ) . toBeEnabled ( ) ;
466435 } ) ;
467436
468- expect (
469- screen
470- . getByLabelText ( "Previous modeling" )
471- . getElementsByTagName ( "input" ) [ 0 ] ,
472- ) . toBeEnabled ( ) ;
473- expect (
474- screen . getByLabelText ( "Next modeling" ) . getElementsByTagName ( "input" ) [ 0 ] ,
475- ) . toBeEnabled ( ) ;
437+ expect ( prevButton ) . toBeEnabled ( ) ;
438+ expect ( nextButton ) . toBeEnabled ( ) ;
476439 expect ( screen . getByText ( "2/3" ) ) . toBeInTheDocument ( ) ;
477440
478441 expect (
@@ -481,16 +444,10 @@ describe(MultipleModeledMethodsPanel.name, () => {
481444 } ) ,
482445 ) . toHaveValue ( "source" ) ;
483446
484- await userEvent . click ( screen . getByLabelText ( "Next modeling" ) ) ;
447+ await userEvent . click ( nextButton ) ;
485448
486- expect (
487- screen
488- . getByLabelText ( "Previous modeling" )
489- . getElementsByTagName ( "input" ) [ 0 ] ,
490- ) . toBeEnabled ( ) ;
491- expect (
492- screen . getByLabelText ( "Next modeling" ) . getElementsByTagName ( "input" ) [ 0 ] ,
493- ) . toBeDisabled ( ) ;
449+ expect ( prevButton ) . toBeEnabled ( ) ;
450+ expect ( nextButton ) . toBeDisabled ( ) ;
494451 expect ( screen . getByText ( "3/3" ) ) . toBeInTheDocument ( ) ;
495452
496453 expect (
@@ -499,24 +456,14 @@ describe(MultipleModeledMethodsPanel.name, () => {
499456 } ) ,
500457 ) . toHaveValue ( "local" ) ;
501458
502- await userEvent . click ( screen . getByLabelText ( "Previous modeling" ) ) ;
459+ await userEvent . click ( prevButton ) ;
503460
504461 await waitFor ( ( ) => {
505- expect (
506- screen
507- . getByLabelText ( "Next modeling" )
508- . getElementsByTagName ( "input" ) [ 0 ] ,
509- ) . toBeEnabled ( ) ;
462+ expect ( nextButton ) . toBeEnabled ( ) ;
510463 } ) ;
511464
512- expect (
513- screen
514- . getByLabelText ( "Previous modeling" )
515- . getElementsByTagName ( "input" ) [ 0 ] ,
516- ) . toBeEnabled ( ) ;
517- expect (
518- screen . getByLabelText ( "Next modeling" ) . getElementsByTagName ( "input" ) [ 0 ] ,
519- ) . toBeEnabled ( ) ;
465+ expect ( prevButton ) . toBeEnabled ( ) ;
466+ expect ( nextButton ) . toBeEnabled ( ) ;
520467 expect ( screen . getByText ( "2/3" ) ) . toBeInTheDocument ( ) ;
521468
522469 expect (
@@ -574,12 +521,11 @@ describe(MultipleModeledMethodsPanel.name, () => {
574521
575522 const render = createRender ( modeledMethods ) ;
576523
577- it ( "can add modeling" , ( ) => {
524+ it ( "can add modeling" , async ( ) => {
578525 render ( ) ;
579526
580- expect (
581- screen . getByLabelText ( "Add modeling" ) . getElementsByTagName ( "input" ) [ 0 ] ,
582- ) . toBeEnabled ( ) ;
527+ const addButton = await screen . findByLabelText ( "Add modeling" ) ;
528+ expect ( addButton ) . toBeEnabled ( ) ;
583529 } ) ;
584530
585531 it ( "can delete first modeling" , async ( ) => {
0 commit comments