Skip to content

Commit db0d5a5

Browse files
author
Marc-André Rivet
committed
Test the callback graph against a component with a width prop
1 parent 84f0db0 commit db0d5a5

File tree

3 files changed

+52
-3
lines changed

3 files changed

+52
-3
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import PropTypes from 'prop-types';
2+
import React, { Fragment } from 'react';
3+
4+
const WidthComponent = props => (<Fragment>
5+
{props.width}
6+
</Fragment>);
7+
8+
WidthComponent.propTypes = {
9+
id: PropTypes.string,
10+
width: PropTypes.number
11+
};
12+
13+
WidthComponent.defaultProps = {
14+
width: 0
15+
};
16+
17+
export default WidthComponent;

@plotly/dash-test-components/src/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import AsyncComponent from './components/AsyncComponent';
22
import CollapseComponent from './components/CollapseComponent';
33
import DelayedEventComponent from './components/DelayedEventComponent';
44
import FragmentComponent from './components/FragmentComponent';
5-
import StyledComponent from './components/StyledComponent';
65
import MyPersistedComponent from './components/MyPersistedComponent';
76
import MyPersistedComponentNested from './components/MyPersistedComponentNested';
8-
7+
import StyledComponent from './components/StyledComponent';
8+
import WidthComponent from './components/WidthComponent';
99

1010
export {
1111
AsyncComponent,
@@ -14,5 +14,6 @@ export {
1414
FragmentComponent,
1515
MyPersistedComponent,
1616
MyPersistedComponentNested,
17-
StyledComponent
17+
StyledComponent,
18+
WidthComponent
1819
};

tests/integration/devtools/test_devtools_ui.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
import dash_core_components as dcc
44
import dash_html_components as html
55
import dash
6+
from dash.dependencies import Input, Output
67
import dash.testing.wait as wait
78

9+
from dash_test_components import WidthComponent
810
from ...assets.todo_app import todo_app
911

1012

@@ -123,3 +125,32 @@ def test_dvui003_callback_graph(dash_duo):
123125
return pos.y;
124126
"""
125127
)
128+
129+
130+
def test_dvui004_width_props(dash_duo):
131+
app = dash.Dash(__name__)
132+
133+
app.layout = html.Div(
134+
[html.Button(["Click me!"], id="btn"), WidthComponent(id="width")]
135+
)
136+
137+
@app.callback(Output("width", "width"), Input("btn", "n_clicks"))
138+
def get_width(n_clicks):
139+
n_clicks = n_clicks if n_clicks is not None else 0
140+
141+
return (n_clicks + 1) * 10
142+
143+
dash_duo.start_server(
144+
app,
145+
debug=True,
146+
use_reloader=False,
147+
use_debugger=True,
148+
dev_tools_hot_reload=False,
149+
)
150+
151+
dash_duo.find_element(".dash-debug-menu").click()
152+
sleep(1) # wait for debug menu opening animation
153+
dash_duo.find_element(".dash-debug-menu__button--callbacks").click()
154+
sleep(3) # wait for callback graph to draw
155+
156+
assert dash_duo.get_logs() == []

0 commit comments

Comments
 (0)