Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit 55f45d2

Browse files
committed
test some stuff about plotly.js vs Graph
also remove an old plotly.js bundle
1 parent 071b11c commit 55f45d2

File tree

2 files changed

+49
-7
lines changed

2 files changed

+49
-7
lines changed

dash_core_components/plotly-1.44.1.min.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

test/test_integration.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from multiprocessing import Lock
99
import time
1010
import json
11+
import re
1112

1213
import flask
1314
import pandas as pd
@@ -1184,6 +1185,54 @@ def on_click(n_clicks):
11841185
time.sleep(1)
11851186
self.snapshot("Tabs 2 rendered ")
11861187

1188+
# do some extra tests while we're here
1189+
# and have access to Graph and plotly.js
1190+
self.check_graph_config_shape()
1191+
self.check_plotlyjs()
1192+
1193+
def check_plotlyjs(self):
1194+
# find plotly.js files in the dist folder, check that there's only one
1195+
all_dist = os.listdir(dcc.__path__[0])
1196+
js_re = '^plotly-(.*)\.min\.js$'
1197+
plotlyjs_dist = [fn for fn in all_dist if re.match(js_re, fn)]
1198+
1199+
self.assertEqual(len(plotlyjs_dist), 1)
1200+
1201+
# check that the version matches what we see in the page
1202+
page_version = self.driver.execute_script('return Plotly.version;')
1203+
dist_version = re.match(js_re, plotlyjs_dist[0]).groups()[0]
1204+
self.assertEqual(page_version, dist_version)
1205+
1206+
def check_graph_config_shape(self):
1207+
config_schema = self.driver.execute_script(
1208+
'return Plotly.PlotSchema.get().config;'
1209+
)
1210+
with open(os.path.join(dcc.__path__[0], 'metadata.json')) as meta:
1211+
graph_meta = json.load(meta)['src/components/Graph.react.js']
1212+
config_prop_shape = graph_meta['props']['config']['type']['value']
1213+
1214+
ignored_config = [
1215+
'setBackground',
1216+
'showSources',
1217+
'logging',
1218+
'globalTransforms',
1219+
'role'
1220+
]
1221+
1222+
def crawl(schema, props):
1223+
for prop_name in props:
1224+
self.assertIn(prop_name, schema)
1225+
1226+
for item_name, item in schema.items():
1227+
if item_name in ignored_config:
1228+
continue
1229+
1230+
self.assertIn(item_name, props)
1231+
if 'valType' not in item:
1232+
crawl(item, props[item_name]['value'])
1233+
1234+
crawl(config_schema, config_prop_shape)
1235+
11871236
def test_tabs_without_value(self):
11881237
app = dash.Dash(__name__)
11891238

0 commit comments

Comments
 (0)