Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nbclassic/tests/end_to_end/test_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_save(notebook_frontend):
checkpoints = notebook_frontend.evaluate("() => Jupyter.notebook.checkpoints", page=EDITOR_PAGE)
assert len(checkpoints) == 1

notebook_frontend.try_click_selector('#ipython_notebook a', page=EDITOR_PAGE)
notebook_frontend.try_click_selector('#ipython_notebook', page=EDITOR_PAGE)
notebook_frontend.wait_for_selector('.item_link', page=EDITOR_PAGE)

hrefs_nonmatch = []
Expand Down
19 changes: 12 additions & 7 deletions nbclassic/tests/end_to_end/test_save_as_notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def set_notebook_name(nb, name):
def test_save_notebook_as(notebook_frontend):
set_notebook_name(notebook_frontend, name="nb1.ipynb")

notebook_frontend.locate('#notebook_name', page=EDITOR_PAGE)
notebook_frontend.wait_for_selector('#notebook_name', page=EDITOR_PAGE)

assert get_notebook_name(notebook_frontend) == "nb1.ipynb"

Expand All @@ -30,13 +30,18 @@ def test_save_notebook_as(notebook_frontend):
notebook_frontend.wait_for_selector('.save-message', page=EDITOR_PAGE)

# TODO: Add a function for locator assertions to FrontendElement
locator_element = notebook_frontend.locate_and_focus('//input[@data-testid="save-as"]', page=EDITOR_PAGE)
locator_element.wait_for('visible')
dialog_element = notebook_frontend.locate_and_focus(".modal-footer", page=EDITOR_PAGE)
save_element = dialog_element.locate('text=Save')
save_element.wait_for('visible')

notebook_frontend.insert_text('new_notebook.ipynb', page=EDITOR_PAGE)
notebook_frontend.try_click_selector('//html//body//div[8]//div//div//div[3]//button[2]', page=EDITOR_PAGE)

locator_element.expect_not_to_be_visible()
name_input_element = notebook_frontend.locate('.modal-body', page=EDITOR_PAGE).locate('.form-control')
name_input_element.click()

name_input_element.evaluate(f'(elem) => {{ elem.value = "new_notebook.ipynb"; return elem.value; }}')
# notebook_frontend.insert_text('new_notebook.ipynb', page=EDITOR_PAGE)
save_element.click()

save_element.expect_not_to_be_visible()

assert get_notebook_name(notebook_frontend) == "new_notebook.ipynb"
assert "new_notebook.ipynb" in notebook_frontend.get_page_url(page=EDITOR_PAGE)
37 changes: 22 additions & 15 deletions nbclassic/tests/end_to_end/test_save_readonly_as.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,31 @@ def test_save_readonly_as(notebook_frontend):
# Wait for Save As modal, save
save_as(notebook_frontend)

# Wait for modal to pop up
notebook_frontend.wait_for_selector('//input[@data-testid="save-as"]', page=EDITOR_PAGE)
# # Wait for modal to pop up
# notebook_frontend.wait_for_selector('//input[@data-testid="save-as"]', page=EDITOR_PAGE)

# TODO: Add a function for locator assertions to FrontendElement
locator_element = notebook_frontend.locate_and_focus('//input[@data-testid="save-as"]', page=EDITOR_PAGE)
locator_element.wait_for('visible')
dialog_element = notebook_frontend.wait_for_selector(".modal-footer", page=EDITOR_PAGE)
dialog_element.focus()
save_element = dialog_element.locate('text=Save')
save_element.wait_for('visible')
# locator_element = notebook_frontend.locate_and_focus('//input[@data-testid="save-as"]', page=EDITOR_PAGE)
# locator_element.wait_for('visible')

name_input_element = notebook_frontend.wait_for_selector('.modal-body .form-control', page=EDITOR_PAGE)
name_input_element.focus()
name_input_element.click()
print('::::NAME1')
print(name_input_element.evaluate(f'(elem) => {{ return elem.value; }}'))
name_input_element.evaluate(f'(elem) => {{ elem.value = "new_notebook.ipynb"; return elem.value; }}')
print('::::NAME2')
print(name_input_element.evaluate(f'(elem) => {{ return elem.value; }}'))
# notebook_frontend.insert_text('new_notebook.ipynb', page=EDITOR_PAGE)

save_element.wait_for('visible')
save_element.focus()
save_element.click()

modal_footer = notebook_frontend.locate('.modal-footer', page=EDITOR_PAGE)
modal_footer.wait_for('visible')

notebook_frontend.insert_text('new_notebook.ipynb', page=EDITOR_PAGE)

save_btn = modal_footer.locate('text=Save')
save_btn.wait_for('visible')
save_btn.click()
# notebook_frontend.try_click_selector('//html//body//div[8]//div//div//div[3]//button[2]', page=EDITOR_PAGE)

# locator_element.expect_not_to_be_visible()
notebook_frontend.wait_for_condition(
lambda: get_notebook_name(notebook_frontend) == "new_notebook.ipynb", timeout=120, period=5
)
Expand Down