@@ -83,35 +83,207 @@ def test_text_input_blur(page: Page, local_app: ShinyAppProc):
8383 output .expect_value (the_value )
8484
8585
86- # Add similar tests for textAreaInput(), numericInput(), and passwordInput()
87- # following the same pattern as above.
86+ def test_text_area_input_change ( page : Page , local_app : ShinyAppProc ):
87+ page . goto ( local_app . url )
8888
89+ input = controller .InputTextArea (page , "change-txtarea" )
90+ output = controller .OutputTextVerbatim (page , "change-value_txtarea" )
91+ update = controller .InputActionButton (page , "change-update_text_area" )
8992
90- def test_text_area_input_change (page : Page , local_app : ShinyAppProc ):
91- # Implement test for textAreaInput() with updateOn='change'
92- pass
93+ the_value = "Hello"
94+ input .set (the_value )
95+ output .expect_value (the_value )
96+
97+ input .loc .press ("End" )
98+ input .loc .type (", world" )
99+
100+ time .sleep (0.5 )
101+ the_value = "Hello, world"
102+ output .expect_value (the_value )
103+ expect (input .loc ).to_be_focused ()
104+
105+ click_action_button (page , update )
106+ the_value = "The old oak tree whispered secrets to the wind.\n Clouds painted shadows on the mountain peaks."
107+ output .expect_value (the_value )
93108
94109
95110def test_text_area_input_blur (page : Page , local_app : ShinyAppProc ):
96- # Implement test for textAreaInput() with updateOn='blur'
97- pass
111+ page .goto (local_app .url )
112+
113+ input = controller .InputTextArea (page , "blur-txtarea" )
114+ output = controller .OutputTextVerbatim (page , "blur-value_txtarea" )
115+ update = controller .InputActionButton (page , "blur-update_text_area" )
116+
117+ the_value = "Hello"
118+ input .set (the_value )
119+ input .loc .blur ()
120+ output .expect_value (the_value )
121+
122+ input .loc .focus ()
123+ input .loc .press ("End" )
124+ input .loc .type (", world" )
125+
126+ output .expect_value (the_value ) # has not changed yet!
127+
128+ the_value = "Hello, world"
129+ input .loc .blur ()
130+ output .expect_value (the_value ) # changes on blur
131+
132+ input .loc .focus ()
133+ input .loc .press ("End" )
134+ input .loc .type ("!" )
135+ output .expect_value (the_value ) # still hasn't changed yet
136+
137+ input .loc .press ("Enter" )
138+ output .expect_value (the_value ) # doesn't change on Enter for textAreaInput
139+
140+ the_value = "Hello, world!"
141+ input .loc .press ("Control+Enter" )
142+ output .expect_value (the_value ) # changes after Control+Enter
143+
144+ click_action_button (page , update )
145+ input .expect_value ("The old oak tree whispered secrets to the wind.\n Clouds painted shadows on the mountain peaks." )
146+ output .expect_value (the_value )
147+
148+ click_action_button (page , update )
149+ input .expect_value ("Clouds painted shadows on the mountain peaks.\n Stars danced across the midnight canvas." )
150+ output .expect_value (the_value )
151+
152+ the_value = "Clouds painted shadows on the mountain peaks.\n Stars danced across the midnight canvas."
153+ input .loc .press ("Control+Enter" )
154+ output .expect_value (the_value )
98155
99156
100157def test_numeric_input_change (page : Page , local_app : ShinyAppProc ):
101- # Implement test for numericInput() with updateOn='change'
102- pass
158+ page .goto (local_app .url )
159+
160+ input = controller .InputNumeric (page , "change-num" )
161+ output = controller .OutputTextVerbatim (page , "change-value_num" )
162+ update = controller .InputActionButton (page , "change-update_number" )
163+
164+ the_value = "10"
165+ input .set (the_value )
166+ output .expect_value (the_value )
167+
168+ input .loc .press ("ArrowUp" )
169+ the_value = "11"
170+ output .expect_value (the_value )
171+
172+ input .loc .press ("ArrowDown" )
173+ input .loc .press ("ArrowDown" )
174+ the_value = "9"
175+ output .expect_value (the_value )
176+
177+ click_action_button (page , update )
178+ the_value = "42"
179+ output .expect_value (the_value )
103180
104181
105182def test_numeric_input_blur (page : Page , local_app : ShinyAppProc ):
106- # Implement test for numericInput() with updateOn='blur'
107- pass
183+ page .goto (local_app .url )
184+
185+ input = controller .InputNumeric (page , "blur-num" )
186+ output = controller .OutputTextVerbatim (page , "blur-value_num" )
187+ update = controller .InputActionButton (page , "blur-update_number" )
188+
189+ the_value = "10"
190+ input .set (the_value )
191+ input .loc .blur ()
192+ output .expect_value (the_value )
193+
194+ input .loc .focus ()
195+ input .loc .press ("ArrowUp" )
196+ output .expect_value (the_value ) # has not changed yet!
197+
198+ input .loc .blur ()
199+ the_value = "11"
200+ output .expect_value (the_value ) # changes on blur
201+
202+ input .loc .focus ()
203+ input .loc .press ("ArrowDown" )
204+ input .loc .press ("ArrowDown" )
205+ output .expect_value (the_value ) # still hasn't changed yet
206+
207+ input .loc .press ("Enter" )
208+ the_value = "9"
209+ output .expect_value (the_value ) # changes after Enter
210+
211+ click_action_button (page , update )
212+ input .expect_value ("42" )
213+ output .expect_value (the_value )
214+
215+ click_action_button (page , update )
216+ input .expect_value ("3.14159" )
217+ output .expect_value (the_value )
218+
219+ the_value = "3.14159"
220+ input .loc .press ("Enter" )
221+ output .expect_value (the_value )
108222
109223
110224def test_password_input_change (page : Page , local_app : ShinyAppProc ):
111- # Implement test for passwordInput() with updateOn='change'
112- pass
225+ page .goto (local_app .url )
226+
227+ input = controller .InputPassword (page , "change-pwd" )
228+ output = controller .OutputTextVerbatim (page , "change-value_pwd" )
229+ update = controller .InputActionButton (page , "change-update_pwd" )
230+
231+ the_value = "H3ll0"
232+ input .set (the_value )
233+ output .expect_value (the_value )
234+
235+ input .loc .press ("End" )
236+ input .loc .type ("_w0r1d" )
237+
238+ time .sleep (0.5 )
239+ the_value = "H3ll0_w0r1d"
240+ output .expect_value (the_value )
241+ expect (input .loc ).to_be_focused ()
242+
243+ click_action_button (page , update )
244+ the_value = "Tr0ub4dor&3"
245+ output .expect_value (the_value )
113246
114247
115248def test_password_input_blur (page : Page , local_app : ShinyAppProc ):
116- # Implement test for passwordInput() with updateOn='blur'
117- pass
249+ page .goto (local_app .url )
250+
251+ input = controller .InputPassword (page , "blur-pwd" )
252+ output = controller .OutputTextVerbatim (page , "blur-value_pwd" )
253+ update = controller .InputActionButton (page , "blur-update_pwd" )
254+
255+ the_value = "H3ll0"
256+ input .set (the_value )
257+ input .loc .blur ()
258+ output .expect_value (the_value )
259+
260+ input .loc .focus ()
261+ input .loc .press ("End" )
262+ input .loc .type ("_w0r1d" )
263+
264+ output .expect_value (the_value ) # has not changed yet!
265+
266+ the_value = "H3ll0_w0r1d"
267+ input .loc .blur ()
268+ output .expect_value (the_value ) # changes on blur
269+
270+ input .loc .focus ()
271+ input .loc .press ("End" )
272+ input .loc .type ("!" )
273+ output .expect_value (the_value ) # still hasn't changed yet
274+
275+ the_value = "H3ll0_w0r1d!"
276+ input .loc .press ("Enter" )
277+ output .expect_value (the_value ) # changes after Enter
278+
279+ click_action_button (page , update )
280+ input .expect_value ("Tr0ub4dor&3" )
281+ output .expect_value (the_value )
282+
283+ click_action_button (page , update )
284+ input .expect_value ("P@ssw0rd123!" )
285+ output .expect_value (the_value )
286+
287+ the_value = "P@ssw0rd123!"
288+ input .loc .press ("Enter" )
289+ output .expect_value (the_value )
0 commit comments