@@ -172,15 +172,21 @@ def find_text(spec):
172
172
173
173
174
174
@pytest .mark .parametrize (
175
- "kwargs, expected_update_title" ,
175
+ "kwargs, expected_update_title, clientside_title " ,
176
176
[
177
- ({}, "Updating..." ),
178
- ({"update_title" : None }, "Dash" ),
179
- ({"update_title" : "" }, "Dash" ),
180
- ({"update_title" : "Hello World" }, "Hello World" ),
181
- ]
177
+ ({}, "Updating..." , False ),
178
+ ({"update_title" : None }, "Dash" , False ), # fail
179
+ ({"update_title" : "" }, "Dash" , False ), # fail
180
+ ({"update_title" : "Hello World" }, "Hello World" , False ),
181
+ ({}, "Updating..." , True ), # fail
182
+ ({"update_title" : None }, "Dash" , True ), # fail
183
+ ({"update_title" : "" }, "Dash" , True ), # fail
184
+ ({"update_title" : "Hello World" }, "Hello World" , True ), # fail
185
+ ],
182
186
)
183
- def test_rdls003_update_title (dash_duo , kwargs , expected_update_title ):
187
+ def test_rdls003_update_title (
188
+ dash_duo , kwargs , expected_update_title , clientside_title
189
+ ):
184
190
app = dash .Dash ("Dash" , ** kwargs )
185
191
lock = Lock ()
186
192
@@ -189,13 +195,23 @@ def test_rdls003_update_title(dash_duo, kwargs, expected_update_title):
189
195
html .H3 ("Press button see document title updating" ),
190
196
html .Div (id = "output" ),
191
197
html .Button ("Update" , id = "button" , n_clicks = 0 ),
198
+ html .Button ("Update Page" , id = "page" , n_clicks = 0 ),
199
+ html .Div (id = "dummy" ),
192
200
]
193
201
)
202
+ if clientside_title :
203
+ app .clientside_callback (
204
+ """
205
+ function(n_clicks) {
206
+ document.title = 'Page ' + n_clicks;
207
+ return n_clicks;
208
+ }
209
+ """ ,
210
+ Output ("dummy" , "children" ),
211
+ [Input ("page" , "n_clicks" )],
212
+ )
194
213
195
- @app .callback (
196
- Output ("output" , "children" ),
197
- [Input ("button" , "n_clicks" )]
198
- )
214
+ @app .callback (Output ("output" , "children" ), [Input ("button" , "n_clicks" )])
199
215
def update (n ):
200
216
with lock :
201
217
return n
@@ -206,9 +222,22 @@ def update(n):
206
222
until (lambda : dash_duo .driver .title == expected_update_title , timeout = 1 )
207
223
208
224
# check for original title after loading
209
- until (lambda : dash_duo .driver .title == "Dash" , timeout = 1 )
225
+ until (lambda : dash_duo .driver .title == "Page 0" if clientside_title else " Dash" , timeout = 1 )
210
226
211
227
with lock :
212
228
dash_duo .find_element ("#button" ).click ()
213
229
# check for update-title while processing callback
214
230
until (lambda : dash_duo .driver .title == expected_update_title , timeout = 1 )
231
+
232
+ dash_duo .find_element ("#page" ).click ()
233
+ dash_duo .wait_for_text_to_equal ("dummy" , "1" )
234
+ if clientside_title :
235
+ until (lambda : dash_duo .driver .title == "Page 1" , timeout = 1 )
236
+ else :
237
+ until (lambda : dash_duo .driver .title == "Dash" , timeout = 1 )
238
+
239
+ dash_duo .find_element ("#button" ).click ()
240
+ if clientside_title :
241
+ until (lambda : dash_duo .driver .title == "Page 2" , timeout = 1 )
242
+ else :
243
+ until (lambda : dash_duo .driver .title == "Dash" , timeout = 1 )
0 commit comments