Group tests to delete a document together

This way the tests are slightly faster, and we avoid a possible flaky
spec since in one test we were checking that a certain text was not
present, which didn't guarantee that the request to delete the document
had finished.
This commit is contained in:
Javi Martín
2025-03-12 21:30:02 +01:00
parent a39201e408
commit 368cf47adf

View File

@@ -97,28 +97,7 @@ shared_examples "documentable" do |documentable_factory_name, documentable_path,
end
expect(page).to have_content "Document was deleted successfully."
end
scenario "Should hide documents tab if there is no documents" do
login_as documentable.author
visit send(documentable_path, arguments)
within "#document_#{document.id}" do
accept_confirm { click_button "Delete document" }
end
expect(page).not_to have_content "Documents (0)"
end
scenario "Should redirect to documentable path after successful deletion" do
login_as documentable.author
visit send(documentable_path, arguments)
within "#document_#{document.id}" do
accept_confirm { click_button "Delete document" }
end
within "##{ActionView::RecordIdentifier.dom_id(documentable)}" do
expect(page).to have_css "h1", text: documentable.title