1
+ import json
1
2
from multiprocessing import Value
2
3
import datetime
3
4
import itertools
@@ -322,6 +323,9 @@ def test_index_customization(self):
322
323
throw Error('could not find container to add');
323
324
}
324
325
elem.innerHTML = 'Got added';
326
+ var config = {};
327
+ fetch('/nonexist').then(r => r.json())
328
+ .then(r => config = r).catch(err => ({config}));
325
329
</script>
326
330
</body>
327
331
</html>
@@ -344,3 +348,51 @@ def test_index_customization(self):
344
348
self .assertEqual ('Got added' , add .text )
345
349
346
350
self .percy_snapshot ('custom-index' )
351
+
352
+ def test_assets (self ):
353
+ app = dash .Dash (assets_folder = 'tests/assets' )
354
+ app .index_string = '''
355
+ <!DOCTYPE html>
356
+ <html>
357
+ <head>
358
+ {metas}
359
+ <title>{title}</title>
360
+ {css}
361
+ </head>
362
+ <body>
363
+ <div id="tested"></div>
364
+ {app_entry}
365
+ <footer>
366
+ {config}
367
+ {scripts}
368
+ </footer>
369
+ </body>
370
+ </html>
371
+ '''
372
+
373
+ app .layout = html .Div ([
374
+ html .Div (id = 'content' ),
375
+ dcc .Input (id = 'test' )
376
+ ], id = 'layout' )
377
+
378
+ self .startServer (app )
379
+
380
+ body = self .driver .find_element_by_tag_name ('body' )
381
+
382
+ body_margin = body .value_of_css_property ('margin' )
383
+ self .assertEqual ('0px' , body_margin )
384
+
385
+ content = self .wait_for_element_by_id ('content' )
386
+ content_padding = content .value_of_css_property ('padding' )
387
+ self .assertEqual ('8px' , content_padding )
388
+
389
+ tested = self .wait_for_element_by_id ('tested' )
390
+ tested = json .loads (tested .text )
391
+ self .assertEqual (3 , len (tested ))
392
+
393
+ order = ('load_first' , 'load_after' , 'load_after1' )
394
+
395
+ for i in range (3 ):
396
+ self .assertEqual (order [i ], tested [i ])
397
+
398
+ self .percy_snapshot ('test assets includes' )
0 commit comments