|
| 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']) |
0 commit comments