@@ -52,32 +52,26 @@ describe(MultipleModeledMethodsPanel.name, () => {
52
52
) . toHaveValue ( "none" ) ;
53
53
} ) ;
54
54
55
- it ( "disables all pagination" , ( ) => {
55
+ it ( "disables all pagination" , async ( ) => {
56
56
render ( ) ;
57
57
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 ( ) ;
66
63
expect ( screen . queryByText ( "0/0" ) ) . not . toBeInTheDocument ( ) ;
67
64
expect ( screen . queryByText ( "1/0" ) ) . not . toBeInTheDocument ( ) ;
68
65
} ) ;
69
66
70
- it ( "cannot add or delete modeling" , ( ) => {
67
+ it ( "cannot add or delete modeling" , async ( ) => {
71
68
render ( ) ;
72
69
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 ( ) ;
81
75
} ) ;
82
76
} ) ;
83
77
@@ -104,28 +98,22 @@ describe(MultipleModeledMethodsPanel.name, () => {
104
98
) . toHaveValue ( "sink" ) ;
105
99
} ) ;
106
100
107
- it ( "disables all pagination" , ( ) => {
101
+ it ( "disables all pagination" , async ( ) => {
108
102
render ( ) ;
109
103
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 ( ) ;
118
109
expect ( screen . queryByText ( "1/1" ) ) . not . toBeInTheDocument ( ) ;
119
110
} ) ;
120
111
121
- it ( "cannot delete modeling" , ( ) => {
112
+ it ( "cannot delete modeling" , async ( ) => {
122
113
render ( ) ;
123
114
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 ( ) ;
129
117
} ) ;
130
118
131
119
it ( "can add modeling" , async ( ) => {
@@ -199,37 +187,26 @@ describe(MultipleModeledMethodsPanel.name, () => {
199
187
it ( "disables the correct pagination" , async ( ) => {
200
188
render ( ) ;
201
189
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 ( ) ;
210
195
} ) ;
211
196
212
197
it ( "can use the pagination" , async ( ) => {
213
198
render ( ) ;
214
199
215
- await userEvent . click ( screen . getByLabelText ( "Next modeling" ) ) ;
200
+ const prevButton = await screen . findByLabelText ( "Previous modeling" ) ;
201
+ const nextButton = await screen . findByLabelText ( "Next modeling" ) ;
216
202
203
+ await userEvent . click ( nextButton ) ;
217
204
await waitFor ( ( ) => {
218
- expect (
219
- screen
220
- . getByLabelText ( "Previous modeling" )
221
- . getElementsByTagName ( "input" ) [ 0 ] ,
222
- ) . toBeEnabled ( ) ;
205
+ expect ( prevButton ) . toBeEnabled ( ) ;
223
206
} ) ;
224
207
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 ( ) ;
233
210
expect ( screen . getByText ( "2/2" ) ) . toBeInTheDocument ( ) ;
234
211
235
212
expect (
@@ -445,34 +422,20 @@ describe(MultipleModeledMethodsPanel.name, () => {
445
422
it ( "can use the pagination" , async ( ) => {
446
423
render ( ) ;
447
424
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 ( ) ;
456
429
expect ( screen . getByText ( "1/3" ) ) . toBeInTheDocument ( ) ;
457
430
458
- await userEvent . click ( screen . getByLabelText ( "Next modeling" ) ) ;
431
+ await userEvent . click ( nextButton ) ;
459
432
460
433
await waitFor ( ( ) => {
461
- expect (
462
- screen
463
- . getByLabelText ( "Previous modeling" )
464
- . getElementsByTagName ( "input" ) [ 0 ] ,
465
- ) . toBeEnabled ( ) ;
434
+ expect ( prevButton ) . toBeEnabled ( ) ;
466
435
} ) ;
467
436
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 ( ) ;
476
439
expect ( screen . getByText ( "2/3" ) ) . toBeInTheDocument ( ) ;
477
440
478
441
expect (
@@ -481,16 +444,10 @@ describe(MultipleModeledMethodsPanel.name, () => {
481
444
} ) ,
482
445
) . toHaveValue ( "source" ) ;
483
446
484
- await userEvent . click ( screen . getByLabelText ( "Next modeling" ) ) ;
447
+ await userEvent . click ( nextButton ) ;
485
448
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 ( ) ;
494
451
expect ( screen . getByText ( "3/3" ) ) . toBeInTheDocument ( ) ;
495
452
496
453
expect (
@@ -499,24 +456,14 @@ describe(MultipleModeledMethodsPanel.name, () => {
499
456
} ) ,
500
457
) . toHaveValue ( "local" ) ;
501
458
502
- await userEvent . click ( screen . getByLabelText ( "Previous modeling" ) ) ;
459
+ await userEvent . click ( prevButton ) ;
503
460
504
461
await waitFor ( ( ) => {
505
- expect (
506
- screen
507
- . getByLabelText ( "Next modeling" )
508
- . getElementsByTagName ( "input" ) [ 0 ] ,
509
- ) . toBeEnabled ( ) ;
462
+ expect ( nextButton ) . toBeEnabled ( ) ;
510
463
} ) ;
511
464
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 ( ) ;
520
467
expect ( screen . getByText ( "2/3" ) ) . toBeInTheDocument ( ) ;
521
468
522
469
expect (
@@ -574,12 +521,11 @@ describe(MultipleModeledMethodsPanel.name, () => {
574
521
575
522
const render = createRender ( modeledMethods ) ;
576
523
577
- it ( "can add modeling" , ( ) => {
524
+ it ( "can add modeling" , async ( ) => {
578
525
render ( ) ;
579
526
580
- expect (
581
- screen . getByLabelText ( "Add modeling" ) . getElementsByTagName ( "input" ) [ 0 ] ,
582
- ) . toBeEnabled ( ) ;
527
+ const addButton = await screen . findByLabelText ( "Add modeling" ) ;
528
+ expect ( addButton ) . toBeEnabled ( ) ;
583
529
} ) ;
584
530
585
531
it ( "can delete first modeling" , async ( ) => {
0 commit comments