From 1adf07176293e8dbeba507e618c7959512eea081 Mon Sep 17 00:00:00 2001 From: Diego Schurch Date: Tue, 14 Jan 2020 15:25:21 -0700 Subject: [PATCH 1/3] converted move multiselection to selenium test --- .../selenium/test_move_multiselection.py | 50 +++++++++++++++++++ .../tests/selenium/test_multiselect_toggle.py | 3 +- 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 notebook/tests/selenium/test_move_multiselection.py diff --git a/notebook/tests/selenium/test_move_multiselection.py b/notebook/tests/selenium/test_move_multiselection.py new file mode 100644 index 0000000000..d8545a89fb --- /dev/null +++ b/notebook/tests/selenium/test_move_multiselection.py @@ -0,0 +1,50 @@ +import time +INITIAL_CELLS = ['1', '2', '3', '4', '5', '6'] +def test_move_multiselection(prefill_notebook): + notebook = prefill_notebook(INITIAL_CELLS) + def assert_oder(pre_message, expected_state): + for i in range(len(expected_state)): + assert expected_state[i] == notebook.get_cell_contents(i), f"{pre_message}: Verify that cell {i} has for content: {expected_state[i]} found: {notebook.get_cell_contents(i)}" + + # Select 3 first cells + notebook.select_cell_range(0, 2) + notebook.browser.execute_script( + "Jupyter.notebook.move_selection_up();" + ) + # Should not move up at top + assert_oder('move up at top', ['1', '2', '3', '4', '5','6']) + + # We do not need to reselect, move/up down should keep the selection. + notebook.browser.execute_script( + "Jupyter.notebook.move_selection_down();" + ) + notebook.browser.execute_script( + "Jupyter.notebook.move_selection_down();" + ) + notebook.browser.execute_script( + "Jupyter.notebook.move_selection_down();" + ) + + # 3 times down should move the 3 selected cells to the bottom + assert_oder("move down to bottom", ['4', '5', '6', '1', '2', '3']) + time.sleep(5) + notebook.browser.execute_script( + "Jupyter.notebook.move_selection_down();" + ) + + # They can't go any futher + assert_oder("move down to bottom", ['4', '5', '6', '1', '2', '3']) + + notebook.browser.execute_script( + "Jupyter.notebook.move_selection_up();" + ) + notebook.browser.execute_script( + "Jupyter.notebook.move_selection_up();" + ) + notebook.browser.execute_script( + "Jupyter.notebook.move_selection_up();" + ) + + # Bring them back on top + assert_oder('move up at top', ['1', '2', '3', '4', '5','6']) + time.sleep(5) diff --git a/notebook/tests/selenium/test_multiselect_toggle.py b/notebook/tests/selenium/test_multiselect_toggle.py index 4ba6f667cc..14f51d0259 100644 --- a/notebook/tests/selenium/test_multiselect_toggle.py +++ b/notebook/tests/selenium/test_multiselect_toggle.py @@ -1,8 +1,7 @@ -INITIAL_CELLS = ['print("a")', 'print("b")', 'print("c")'] +INITIAL_CELLS = ['print("a")', 'print("b")', 'print("c")'] def test_multiselect_toggle(prefill_notebook): notebook = prefill_notebook(INITIAL_CELLS) - def extend_selection_by(delta): notebook.browser.execute_script( "Jupyter.notebook.extend_selection_by(arguments[0]);", delta) From b4bf975a1adda3e34433c8073faf5e431b862987 Mon Sep 17 00:00:00 2001 From: Diego Schurch Date: Tue, 14 Jan 2020 15:30:52 -0700 Subject: [PATCH 2/3] deleted the time library --- notebook/tests/selenium/test_move_multiselection.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/notebook/tests/selenium/test_move_multiselection.py b/notebook/tests/selenium/test_move_multiselection.py index d8545a89fb..7a07887b91 100644 --- a/notebook/tests/selenium/test_move_multiselection.py +++ b/notebook/tests/selenium/test_move_multiselection.py @@ -1,4 +1,3 @@ -import time INITIAL_CELLS = ['1', '2', '3', '4', '5', '6'] def test_move_multiselection(prefill_notebook): notebook = prefill_notebook(INITIAL_CELLS) @@ -27,7 +26,6 @@ def assert_oder(pre_message, expected_state): # 3 times down should move the 3 selected cells to the bottom assert_oder("move down to bottom", ['4', '5', '6', '1', '2', '3']) - time.sleep(5) notebook.browser.execute_script( "Jupyter.notebook.move_selection_down();" ) @@ -47,4 +45,3 @@ def assert_oder(pre_message, expected_state): # Bring them back on top assert_oder('move up at top', ['1', '2', '3', '4', '5','6']) - time.sleep(5) From 5caf11c6dd8d82685f49397ccdfce44f3eb93c8c Mon Sep 17 00:00:00 2001 From: Diego Schurch Date: Tue, 14 Jan 2020 15:55:06 -0700 Subject: [PATCH 3/3] Remove move_multiselection --- .../tests/notebook/move_multiselection.js | 64 ------------------- 1 file changed, 64 deletions(-) delete mode 100644 notebook/tests/notebook/move_multiselection.js diff --git a/notebook/tests/notebook/move_multiselection.js b/notebook/tests/notebook/move_multiselection.js deleted file mode 100644 index e2e1e61d4c..0000000000 --- a/notebook/tests/notebook/move_multiselection.js +++ /dev/null @@ -1,64 +0,0 @@ - - -// Test -casper.notebook_test(function () { - this.append_cell('1'); - this.append_cell('2'); - this.append_cell('3'); - this.append_cell('4'); - this.append_cell('5'); - this.append_cell('6'); - - function assert_order(that, pre_message, expected_state){ - - for (var i=1; i