@@ -45,7 +45,24 @@ def create_app(dash_duo):
4545 "Node 5" : (277 , 236 ),
4646 "Node 6" : (168 , 283 ),
4747 }
48- return init_pos , actions
48+
49+ def calculate_edge_position (node_1 , node_2 ):
50+ x = round ((node_1 [0 ] + node_2 [0 ]) * 0.5 )
51+ y = round ((node_1 [1 ] + node_2 [1 ]) * 0.5 )
52+ return (x , y )
53+
54+ edges_positions = {
55+ "Edge from Node 1 to Node 2" : calculate_edge_position (
56+ init_pos ["Node 1" ], init_pos ["Node 2" ]
57+ ),
58+ "Edge from Node 2 to Node 4" : calculate_edge_position (
59+ init_pos ["Node 2" ], init_pos ["Node 4" ]
60+ ),
61+ "Edge from Node 5 to Node 1" : calculate_edge_position (
62+ init_pos ["Node 5" ], init_pos ["Node 1" ]
63+ ),
64+ }
65+ return init_pos , actions , edges_positions
4966
5067
5168def save_screenshot (dash_duo , dir_name , name ):
@@ -145,7 +162,7 @@ def perform_mouseover(
145162
146163
147164def test_cyin001_dragging (dash_duo ):
148- init_pos , actions = create_app (dash_duo )
165+ init_pos , actions , _ = create_app (dash_duo )
149166
150167 drag_error = "Unable to drag Cytoscape nodes properly"
151168
@@ -187,7 +204,7 @@ def test_cyin001_dragging(dash_duo):
187204
188205
189206def test_cyin002_clicking (dash_duo ):
190- init_pos , actions = create_app (dash_duo )
207+ init_pos , actions , _ = create_app (dash_duo )
191208 click_error = "Unable to click Cytoscape nodes properly"
192209
193210 # Select the JSON output element
@@ -201,8 +218,22 @@ def test_cyin002_clicking(dash_duo):
201218 ), click_error
202219
203220
204- def test_cyin003_mouseover (dash_duo ):
205- init_pos , actions = create_app (dash_duo )
221+ def test_cyin003_clicking_edges (dash_duo ):
222+ _ , actions , edges_positions = create_app (dash_duo )
223+
224+ # Select the JSON output element
225+ elem_tap = dash_duo .find_element ("pre#tap-edge-json-output" )
226+
227+ # Test clicking the edges
228+ for label in edges_positions .keys ():
229+ assert (
230+ perform_clicking (dash_duo , * edges_positions [label ], elem_tap , actions )
231+ == label
232+ )
233+
234+
235+ def test_cyin004_mouseover (dash_duo ):
236+ init_pos , actions , _ = create_app (dash_duo )
206237 mouseover_error = "Unable to mouseover Cytoscape nodes properly"
207238
208239 # Open the Mouseover JSON tab
@@ -222,8 +253,29 @@ def test_cyin003_mouseover(dash_duo):
222253 ), mouseover_error
223254
224255
225- def test_cyin004_mouseover_unhover (dash_duo ):
226- init_pos , actions = create_app (dash_duo )
256+ def test_cyin005_mouseover_edges (dash_duo ):
257+ _ , actions , edges_positions = create_app (dash_duo )
258+
259+ # Open the Mouseover JSON tab
260+ actions .move_to_element (dash_duo .find_element ("#tabs > div:nth-child(3)" ))
261+ actions .click ().perform ()
262+ time .sleep (1 )
263+
264+ # Select the JSON output element
265+ elem_mouseover = dash_duo .find_element ("pre#mouseover-edge-data-json-output" )
266+
267+ # Test mouseover the edges
268+ for label in edges_positions .keys ():
269+ assert (
270+ perform_mouseover (
271+ dash_duo , * edges_positions [label ], elem_mouseover , actions
272+ )
273+ == label
274+ )
275+
276+
277+ def test_cyin006_mouseover_unhover (dash_duo ):
278+ init_pos , actions , _ = create_app (dash_duo )
227279 mouseover_error = "Unable to mouseover Cytoscape nodes properly"
228280
229281 # Open the Mouseover JSON tab
@@ -262,8 +314,8 @@ def test_cyin004_mouseover_unhover(dash_duo):
262314 ), mouseover_error
263315
264316
265- def test_cyin005_click_twice (dash_duo ):
266- init_pos , actions = create_app (dash_duo )
317+ def test_cyin007_click_twice (dash_duo ):
318+ init_pos , actions , _ = create_app (dash_duo )
267319
268320 # Open the Tap Data JSON tab
269321 actions .move_to_element (dash_duo .find_element ("#tabs > div:nth-child(2)" ))
0 commit comments