1
- import exp from 'constants' ;
2
1
import { Matcher , screen , userEvent } from './test-utils' ;
3
2
4
3
export async function selectCheckboxOption ( id : Matcher ) : Promise < void > {
@@ -14,6 +13,7 @@ export async function repeatNTimes(input: string, n: number, labelText: Matcher)
14
13
for ( let i = 0 ; i < n ; i ++ ) {
15
14
await userEvent . type ( screen . queryAllByLabelText ( labelText ) [ i ] , input ) ;
16
15
await clickButtonTimes ( / - r e p e a t - b u t t o n / i, 1 ) ;
16
+ await userEvent . type ( screen . queryAllByLabelText ( labelText ) [ i + 1 ] , input ) ;
17
17
}
18
18
}
19
19
export async function repeatDateTimeNTimes (
@@ -34,6 +34,7 @@ export async function repeatDateTimeNTimes(
34
34
const minutesInput = minutesElement . querySelector ( 'input' ) ;
35
35
36
36
await userEvent . type ( dateElement , dateString ) ;
37
+
37
38
if ( hoursInput && minutesInput ) {
38
39
await userEvent . type ( hoursInput , hoursString ) ;
39
40
await userEvent . type ( minutesInput , minutesString ) ;
@@ -76,9 +77,9 @@ export async function clickByLabelText(id: Matcher): Promise<void> {
76
77
expect ( elm ) . toBeInTheDocument ( ) ;
77
78
await userEvent . click ( elm ) ;
78
79
}
79
- export async function repeatCheckboxTimes ( id : Matcher , n : number ) : Promise < void > {
80
+ export async function repeatCheckboxTimes ( matcher : Matcher , n : number ) : Promise < void > {
80
81
for ( let i = 0 ; i < n ; i ++ ) {
81
- const elm = screen . getAllByLabelText ( id ) ;
82
+ const elm = screen . getAllByLabelText ( matcher ) ;
82
83
await userEvent . click ( elm [ i ] ) ;
83
84
await clickButtonTimes ( / - r e p e a t - b u t t o n / i, 1 ) ;
84
85
}
@@ -89,6 +90,9 @@ export async function repeatSliderTimes(linkId: string, n: number): Promise<void
89
90
const itemToClick = elm . querySelectorAll ( 'div.slider__track__step' ) [ 0 ] ;
90
91
await userEvent . click ( itemToClick ) ;
91
92
await clickButtonTimes ( / - r e p e a t - b u t t o n / i, 1 ) ;
93
+ const elm2 = await screen . findByTestId ( `item_${ linkId } ^${ i + 1 } -${ i + 1 } -slider-choice` ) ;
94
+ const itemToClick2 = elm2 . querySelectorAll ( 'div.slider__track__step' ) [ 0 ] ;
95
+ await userEvent . click ( itemToClick2 ) ;
92
96
}
93
97
}
94
98
export async function clickSliderValue ( linkId : Matcher , index : number , sliderItemIndex : undefined | number = 0 ) : Promise < void > {
@@ -104,6 +108,7 @@ export async function repeatDropDownTimes(
104
108
for ( let i = 0 ; i < n ; i ++ ) {
105
109
await userEvent . selectOptions ( screen . getAllByLabelText ( id ) [ i ] , screen . getAllByRole ( 'option' , { name : optionName } ) [ i ] ) ;
106
110
await clickButtonTimes ( / - r e p e a t - b u t t o n / i, 1 ) ;
111
+ await userEvent . selectOptions ( screen . getAllByLabelText ( id ) [ i + 1 ] , screen . getAllByRole ( 'option' , { name : optionName } ) [ i + 1 ] ) ;
107
112
}
108
113
}
109
114
export async function typeAndTabByLabelText ( id : Matcher , value : string ) : Promise < void > {
0 commit comments