Add expectations after submit in attachments specs

There were cases where we clicked the button to submit the form and
immediately we visited a different page.

In the past, we've had similar code produce PG::ProtocolViolation errors
in similar situations. Since we've had these errors a few times in the
nested imageable specs, there's a chance they're related to the absence
of the expectation.

Although I'm not even remotely sure this will fix these issues, at least
we now follow the convention of making expectations after every request.

Note we're changing both the nested imageable and nested documentable
specs. Only the nested imageable would need to be changed because it's
the one where there's a `visit` inside the
`imageable_redirected_to_resource_show_or_navigate_to` method. I'm
changing both for consistency.
This commit is contained in:
Javi Martín
2022-03-29 21:17:02 +02:00
parent 5c317927c0
commit 4318b371b0
2 changed files with 8 additions and 0 deletions

View File

@@ -210,6 +210,8 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
documentable_attach_new_file(file_fixture("empty.pdf")) documentable_attach_new_file(file_fixture("empty.pdf"))
click_on submit_button click_on submit_button
expect(page).to have_content documentable_success_notice
documentable_redirected_to_resource_show_or_navigate_to documentable_redirected_to_resource_show_or_navigate_to
expect(page).to have_content "Documents" expect(page).to have_content "Documents"
@@ -232,6 +234,9 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
end end
click_on submit_button click_on submit_button
expect(page).to have_content documentable_success_notice
documentable_redirected_to_resource_show_or_navigate_to documentable_redirected_to_resource_show_or_navigate_to
expect(page).to have_content "Documents (#{documentable.class.max_documents_allowed})" expect(page).to have_content "Documents (#{documentable.class.max_documents_allowed})"

View File

@@ -184,6 +184,9 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
expect(page).to have_selector ".loading-bar.complete" expect(page).to have_selector ".loading-bar.complete"
click_on submit_button click_on submit_button
expect(page).to have_content imageable_success_notice
imageable_redirected_to_resource_show_or_navigate_to(imageable) imageable_redirected_to_resource_show_or_navigate_to(imageable)
expect(page).to have_selector "figure img" expect(page).to have_selector "figure img"