Skip to content

Commit

Permalink
Merge pull request #4142 from askerry/selenium_merge_cells
Browse files Browse the repository at this point in the history
Migrate test for merge cells api to selenium
  • Loading branch information
takluyver authored Nov 7, 2018
2 parents a7033b8 + 34cd352 commit a036ba2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 43 deletions.
43 changes: 0 additions & 43 deletions notebook/tests/notebook/merge_cells_api.js

This file was deleted.

32 changes: 32 additions & 0 deletions notebook/tests/selenium/test_merge_cells.py
Original file line number Diff line number Diff line change
@@ -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]

0 comments on commit a036ba2

Please sign in to comment.