@@ -167,3 +167,111 @@ def find_text(spec):
167
167
168
168
find_spinners ()
169
169
find_text ({1 : 1 , 2 : 1 , 3 : 1 , 4 : 1 })
170
+
171
+
172
+ def test_update_title_default (dash_duo ):
173
+ lock = Lock ()
174
+
175
+ app = dash .Dash (__name__ )
176
+
177
+ app .layout = html .Div (
178
+ children = [
179
+ html .H3 ("Press button see document title updating" ),
180
+ html .Div (id = "output" ),
181
+ html .Button ("Update" , id = "button" , n_clicks = 0 ),
182
+ ]
183
+ )
184
+
185
+ @app .callback (
186
+ Output ("output" , "children" ),
187
+ [Input ("button" , "n_clicks" )]
188
+ )
189
+ def update (n ):
190
+ with lock :
191
+ return n
192
+
193
+ with lock :
194
+ dash_duo .start_server (app )
195
+ dash_duo .find_element ("#button" ).click ()
196
+ assert dash_duo .driver .title == "Updating..."
197
+
198
+
199
+ def test_update_title_None (dash_duo ):
200
+ lock = Lock ()
201
+
202
+ app = dash .Dash (__name__ , update_title = None )
203
+
204
+ app .layout = html .Div (
205
+ children = [
206
+ html .H3 ("Press button see document title updating" ),
207
+ html .Div (id = "output" ),
208
+ html .Button ("Update" , id = "button" , n_clicks = 0 ),
209
+ ]
210
+ )
211
+
212
+ @app .callback (
213
+ Output ("output" , "children" ),
214
+ [Input ("button" , "n_clicks" )]
215
+ )
216
+ def update (n ):
217
+ with lock :
218
+ return n
219
+
220
+ with lock :
221
+ dash_duo .start_server (app )
222
+ dash_duo .find_element ("#button" ).click ()
223
+ assert dash_duo .driver .title == "Dash"
224
+
225
+
226
+ def test_update_title_empty (dash_duo ):
227
+ lock = Lock ()
228
+
229
+ app = dash .Dash (__name__ , update_title = "" )
230
+
231
+ app .layout = html .Div (
232
+ children = [
233
+ html .H3 ("Press button see document title updating" ),
234
+ html .Div (id = "output" ),
235
+ html .Button ("Update" , id = "button" , n_clicks = 0 ),
236
+ ]
237
+ )
238
+
239
+ @app .callback (
240
+ Output ("output" , "children" ),
241
+ [Input ("button" , "n_clicks" )]
242
+ )
243
+ def update (n ):
244
+ with lock :
245
+ return n
246
+
247
+ with lock :
248
+ dash_duo .start_server (app )
249
+ dash_duo .find_element ("#button" ).click ()
250
+ assert dash_duo .driver .title == "Dash"
251
+
252
+
253
+ def test_update_title_custom (dash_duo ):
254
+ lock = Lock ()
255
+
256
+ app = dash .Dash (__name__ , update_title = "Hello World" )
257
+
258
+ app .layout = html .Div (
259
+ children = [
260
+ html .H3 ("Press button see document title updating" ),
261
+ html .Div (id = "output" ),
262
+ html .Button ("Update" , id = "button" , n_clicks = 0 ),
263
+ ]
264
+ )
265
+
266
+ @app .callback (
267
+ Output ("output" , "children" ),
268
+ [Input ("button" , "n_clicks" )]
269
+ )
270
+ def update (n ):
271
+ with lock :
272
+ return n
273
+
274
+ with lock :
275
+ dash_duo .start_server (app )
276
+ dash_duo .find_element ("#button" ).click ()
277
+ assert dash_duo .driver .title == "Hello World"
0 commit comments