Use JavaScript in tests opening modal dialogs

This way we reproduce the user experience in the tests, and we can make
sure modal dialogs open when we expect it.
This commit is contained in:
Javi Martín
2021-03-29 13:28:41 +02:00
parent fbc78984dc
commit b2bc4d19f5
38 changed files with 221 additions and 178 deletions

View File

@@ -95,37 +95,37 @@ shared_examples "documentable" do |documentable_factory_name, documentable_path,
end
context "Destroy" do
scenario "Should show success notice after successful document upload" do
scenario "Should show success notice after successful document upload", :js do
login_as documentable.author
visit send(documentable_path, arguments)
within "#document_#{document.id}" do
click_on "Delete document"
accept_confirm { click_link "Delete document" }
end
expect(page).to have_content "Document was deleted successfully."
end
scenario "Should hide documents tab if there is no documents" do
scenario "Should hide documents tab if there is no documents", :js do
login_as documentable.author
visit send(documentable_path, arguments)
within "#document_#{document.id}" do
click_on "Delete document"
accept_confirm { click_link "Delete document" }
end
expect(page).not_to have_content "Documents (0)"
end
scenario "Should redirect to documentable path after successful deletion" do
scenario "Should redirect to documentable path after successful deletion", :js do
login_as documentable.author
visit send(documentable_path, arguments)
within "#document_#{document.id}" do
click_on "Delete document"
accept_confirm { click_link "Delete document" }
end
within "##{ActionView::RecordIdentifier.dom_id(documentable)}" do