diff --git a/notebook/tests/notebook/merge_cells_api.js b/notebook/tests/notebook/merge_cells_api.js deleted file mode 100644 index 665a9d1ef9..0000000000 --- a/notebook/tests/notebook/merge_cells_api.js +++ /dev/null @@ -1,43 +0,0 @@ -// -// Test merging two notebook cells. -// -casper.notebook_test(function() { - var that = this; - var set_cells_text = function () { - that.evaluate(function() { - var cell_one = IPython.notebook.get_selected_cell(); - cell_one.set_text('a = 5'); - }); - - that.trigger_keydown('b'); - - that.evaluate(function() { - var cell_two = IPython.notebook.get_selected_cell(); - cell_two.set_text('print(a)'); - }); - }; - - this.evaluate(function () { - IPython.notebook.command_mode(); - }); - - // merge_cell_above() - set_cells_text(); - var output_above = this.evaluate(function () { - IPython.notebook.merge_cell_above(); - return IPython.notebook.get_selected_cell().get_text(); - }); - - // merge_cell_below() - set_cells_text(); - var output_below = this.evaluate(function() { - IPython.notebook.select(0); - IPython.notebook.merge_cell_below(); - return IPython.notebook.get_selected_cell().get_text(); - }); - - this.test.assertEquals(output_above, 'a = 5\n\nprint(a)', - 'Successful merge_cell_above().'); - this.test.assertEquals(output_below, 'a = 5\n\nprint(a)', - 'Successful merge_cell_below().'); -}); diff --git a/notebook/tests/selenium/test_merge_cells.py b/notebook/tests/selenium/test_merge_cells.py new file mode 100644 index 0000000000..1c3c68dd93 --- /dev/null +++ b/notebook/tests/selenium/test_merge_cells.py @@ -0,0 +1,32 @@ +"""Tests the merge cell api.""" + +def test_merge_cells(notebook): + # Add cells to notebook + a = "foo = 5" + b = "bar = 10" + c = "print(foo)" + d = "print(bar)" + notebook.edit_cell(index=0, content=a) + notebook.append(b, c, d) + + # Before merging, there are 4 separate cells + assert notebook.get_cells_contents() == [a, b, c, d] + + # Focus on the second cell and merge it with the cell above + notebook.focus_cell(1) + notebook.browser.execute_script("Jupyter.notebook.merge_cell_above();") + merged_a_b = "%s\n\n%s" % (a, b) + assert notebook.get_cells_contents() == [merged_a_b, c, d] + + # Focus on the second cell and merge it with the cell below + notebook.focus_cell(1) + notebook.browser.execute_script("Jupyter.notebook.merge_cell_below();") + merged_c_d = "%s\n\n%s" % (c, d) + assert notebook.get_cells_contents() == [merged_a_b, merged_c_d] + + # Merge everything down to a single cell + notebook.focus_cell(0) + notebook.browser.execute_script("Jupyter.notebook.merge_cell_below();") + merged_all = "%s\n\n%s" % (merged_a_b, merged_c_d) + assert notebook.get_cells_contents() == [merged_all] +