Skip to content

Commit f42f240

Browse files
dSchurchDiego Schurch
andauthored
Migrate Move multiselection test to selenium (#5158)
* converted move multiselection to selenium test * deleted the time library * Remove move_multiselection Co-authored-by: Diego Schurch <[email protected]>
1 parent 4b9e9a4 commit f42f240

File tree

3 files changed

+48
-66
lines changed

3 files changed

+48
-66
lines changed

notebook/tests/notebook/move_multiselection.js

Lines changed: 0 additions & 64 deletions
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
INITIAL_CELLS = ['1', '2', '3', '4', '5', '6']
2+
def test_move_multiselection(prefill_notebook):
3+
notebook = prefill_notebook(INITIAL_CELLS)
4+
def assert_oder(pre_message, expected_state):
5+
for i in range(len(expected_state)):
6+
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)}"
7+
8+
# Select 3 first cells
9+
notebook.select_cell_range(0, 2)
10+
notebook.browser.execute_script(
11+
"Jupyter.notebook.move_selection_up();"
12+
)
13+
# Should not move up at top
14+
assert_oder('move up at top', ['1', '2', '3', '4', '5','6'])
15+
16+
# We do not need to reselect, move/up down should keep the selection.
17+
notebook.browser.execute_script(
18+
"Jupyter.notebook.move_selection_down();"
19+
)
20+
notebook.browser.execute_script(
21+
"Jupyter.notebook.move_selection_down();"
22+
)
23+
notebook.browser.execute_script(
24+
"Jupyter.notebook.move_selection_down();"
25+
)
26+
27+
# 3 times down should move the 3 selected cells to the bottom
28+
assert_oder("move down to bottom", ['4', '5', '6', '1', '2', '3'])
29+
notebook.browser.execute_script(
30+
"Jupyter.notebook.move_selection_down();"
31+
)
32+
33+
# They can't go any futher
34+
assert_oder("move down to bottom", ['4', '5', '6', '1', '2', '3'])
35+
36+
notebook.browser.execute_script(
37+
"Jupyter.notebook.move_selection_up();"
38+
)
39+
notebook.browser.execute_script(
40+
"Jupyter.notebook.move_selection_up();"
41+
)
42+
notebook.browser.execute_script(
43+
"Jupyter.notebook.move_selection_up();"
44+
)
45+
46+
# Bring them back on top
47+
assert_oder('move up at top', ['1', '2', '3', '4', '5','6'])

notebook/tests/selenium/test_multiselect_toggle.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
INITIAL_CELLS = ['print("a")', 'print("b")', 'print("c")']
21

2+
INITIAL_CELLS = ['print("a")', 'print("b")', 'print("c")']
33
def test_multiselect_toggle(prefill_notebook):
44
notebook = prefill_notebook(INITIAL_CELLS)
5-
65
def extend_selection_by(delta):
76
notebook.browser.execute_script(
87
"Jupyter.notebook.extend_selection_by(arguments[0]);", delta)

0 commit comments

Comments
 (0)