Skip to content

Commit

Permalink
Change 'callback' to 'window.callback' per Prusse's suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoddemus committed Dec 9, 2022
1 parent 8d8175e commit d15922e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
8 changes: 6 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ def __init__(self, selenium, host):
' window.__added__.push.apply(window.__added__, cellIds);'
'}'
)
self.eval_js_function('api.registerCellsAddedHandler', qmxgraph.js.Variable('callback'))
self.eval_js_function(
'api.registerCellsAddedHandler', qmxgraph.js.Variable('window.callback')
)

selenium.execute_script(
'callback = function(cellId, newLabel, oldLabel) {'
Expand All @@ -310,7 +312,9 @@ def __init__(self, selenium, host):
' window.__labels__.push({cellId: cellId, newLabel: newLabel, oldLabel: oldLabel});' # noqa
'}'
)
self.eval_js_function('api.registerLabelChangedHandler', qmxgraph.js.Variable('callback'))
self.eval_js_function(
'api.registerLabelChangedHandler', qmxgraph.js.Variable('window.callback')
)

def get_container(self):
"""
Expand Down
14 changes: 9 additions & 5 deletions tests/test_js_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ def test_on_cells_removed(graph_cases) -> None:
graph = graph_cases('2v_1e')

graph.selenium.execute_script('callback = function(cellIds) {window.cellIds = cellIds;}')
graph.eval_js_function('api.registerCellsRemovedHandler', js.Variable('callback'))
graph.eval_js_function('api.registerCellsRemovedHandler', js.Variable('window.callback'))

cell_ids = [
graph.get_id(graph.get_vertices()[0]),
Expand Down Expand Up @@ -899,7 +899,7 @@ def test_insert_with_tags(graph_cases, cell_type) -> None:
' );'
'}'
)
graph.eval_js_function('api.registerCellsAddedHandler', js.Variable('callback'))
graph.eval_js_function('api.registerCellsAddedHandler', js.Variable('window.callback'))
tags = {'tagTest': '1'}

cell_id = insert_by_parametrized_type(graph, cell_type, tags=tags)
Expand Down Expand Up @@ -1194,7 +1194,9 @@ def test_set_double_click_handler(graph_cases) -> None:
' window.__dblClick__.push(cellId);'
'}'
)
graph.eval_js_function('api.registerDoubleClickHandler', qmxgraph.js.Variable('callback'))
graph.eval_js_function(
'api.registerDoubleClickHandler', qmxgraph.js.Variable('window.callback')
)

actions = ActionChains(graph.selenium)
actions.double_click(graph.get_vertex())
Expand All @@ -1220,7 +1222,9 @@ def test_add_selection_change_handler(graph_cases) -> None:
' window.__selectionChange__.push(cellIds);'
'}'
)
graph.eval_js_function('api.registerSelectionChangedHandler', qmxgraph.js.Variable('callback'))
graph.eval_js_function(
'api.registerSelectionChangedHandler', qmxgraph.js.Variable('window.callback')
)

# Select all cells.
actions = ActionChains(graph.selenium)
Expand Down Expand Up @@ -1271,7 +1275,7 @@ def test_set_popup_menu_handler(graph_cases) -> None:
' window.__popupMenu__.push([cellId, x, y]);'
'}'
)
graph.eval_js_function('api.registerPopupMenuHandler', qmxgraph.js.Variable('callback'))
graph.eval_js_function('api.registerPopupMenuHandler', qmxgraph.js.Variable('window.callback'))

vertex_label_el = graph.get_label_element(graph.get_vertex())
actions = ActionChains(graph.selenium)
Expand Down

0 comments on commit d15922e

Please sign in to comment.