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 <dschurch@NSL-DSCHURCHs-MacBook-Pro.local>pull/4795/head
parent
4b9e9a4a45
commit
f42f2408b0
@ -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<expected_state.length; i++){
|
||||
that.test.assertEquals(that.get_cell_text(i), expected_state[i],
|
||||
pre_message+': Verify that cell `' + i + '` has for content: `'+ expected_state[i] + '` found : ' + that.get_cell_text(i)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.then(function () {
|
||||
// select 3 first cells
|
||||
this.select_cell(0);
|
||||
this.select_cell(2, false);
|
||||
|
||||
this.evaluate(function () {
|
||||
Jupyter.notebook.move_selection_up();
|
||||
});
|
||||
|
||||
// should not move up at top
|
||||
assert_order(this, 'move up at top', ['', '1', '2', '3', '4', '5','6'])
|
||||
|
||||
// we do not need to reselect, move/up down should keep the selection.
|
||||
this.evaluate(function () {
|
||||
Jupyter.notebook.move_selection_down();
|
||||
Jupyter.notebook.move_selection_down();
|
||||
Jupyter.notebook.move_selection_down();
|
||||
Jupyter.notebook.move_selection_down();
|
||||
});
|
||||
|
||||
// 4 times down should move to the 3 cells to the bottom
|
||||
assert_order(this, 'move down to bottom', [ '3', '4', '5','6', '', '1', '2'])
|
||||
|
||||
this.evaluate(function () {
|
||||
Jupyter.notebook.move_selection_down();
|
||||
});
|
||||
|
||||
// they can't go any further (test it)
|
||||
assert_order(this, 'move at to top', [ '3', '4', '5','6', '', '1', '2'])
|
||||
|
||||
this.evaluate(function () {
|
||||
Jupyter.notebook.move_selection_up();
|
||||
Jupyter.notebook.move_selection_up();
|
||||
Jupyter.notebook.move_selection_up();
|
||||
Jupyter.notebook.move_selection_up();
|
||||
});
|
||||
|
||||
// bring them back on top.
|
||||
assert_order(this, 'move up to top', ['', '1', '2', '3', '4', '5','6'])
|
||||
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,47 @@
|
||||
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'])
|
||||
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'])
|
||||
Loading…
Reference in new issue