refactor: unify document sessions close policy and resource parsing
This commit is contained in:
@@ -101,6 +101,22 @@ def test_close_does_not_recover_draft_that_user_already_undid(editing, monkeypat
|
||||
assert str(path) not in window.editor_drafts
|
||||
|
||||
|
||||
@pytest.mark.parametrize("operation", ["tab", "all", "project"])
|
||||
def test_all_close_routes_use_save_discard_cancel(editing, monkeypatch, operation):
|
||||
window, editor, path = editing
|
||||
editor.replace_source_undoable("pending changes")
|
||||
actions = {"tab": lambda: window._close_tab(window.tabs.indexOf(editor)),
|
||||
"all": window._close_all_tabs, "project": window.close_project_folder}
|
||||
monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.StandardButton.Cancel)
|
||||
actions[operation]()
|
||||
assert window.tabs.indexOf(editor) >= 0 and path.read_text() == "# Original"
|
||||
assert window.editor_drafts[str(path)]["source"] == "pending changes"
|
||||
monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.StandardButton.Save)
|
||||
actions[operation]()
|
||||
assert window.tabs.indexOf(editor) == -1 and path.read_text() == "pending changes"
|
||||
assert not window.editor_drafts
|
||||
|
||||
|
||||
def test_save_as_changes_draft_ownership_only_after_success(editing, monkeypatch, tmp_path):
|
||||
window, editor, original = editing
|
||||
target = tmp_path / "elsewhere" / "copy.md"
|
||||
|
||||
Reference in New Issue
Block a user