Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce conflicting queries/requests in system tests #4849

Merged
merged 5 commits into from
Jun 7, 2022

Conversation

javierm
Copy link
Member

@javierm javierm commented Jun 2, 2022

References

Objectives

  • Reduce the number of possible sources which are causing PG::ProtocolViolation exceptions when running our test suite

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.
We were doing a `mappable.map_location` call in an `expect` which might
result in a database queries. Doing database queries in a test after the
process running the browser has started might result in exceptions while
running our test suite.
We were clicking on the "Sign in" link right after clicking on the "Sign
out" link, which might result in simultaneous requests and exceptions
when running our test suite.

So we're adding an expectation to make sure the first request has
finished before starting the following one.
Furthermore, using `Poll.all` results in a database query, and doing so
after the process running the browser has started might result in
failures when running our test suite.
When we perform database queries in tests after the process running the
browser has started, we sometimes get failures in our test suite due to
both the tests and the browser accessing the database at the same time.
@javierm javierm self-assigned this Jun 2, 2022
@javierm javierm added this to Reviewing in Consul Democracy via automation Jun 2, 2022
@javierm javierm changed the title Reduce conflicting database queries in system tests Reduce conflicting queries/requests in system tests Jun 2, 2022
@javierm javierm added the 1.5 label Jun 2, 2022
do_login_for mappable.author, management: management

visit send(mappable_edit_path, id: mappable.id)

expect(page).to have_content "Navigate the map to the location and place the marker."
validate_latitude_longitude(mappable, mappable_factory_name)
expect(page).to have_field "#{mappable_factory_name}_map_location_attributes_latitude", type: :hidden, with: "51.48"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/LineLength: Line is too long. [122/110] (https://rubystyle.guide#max-line-length)

do_login_for mappable.author, management: management

visit send(mappable_edit_path, id: mappable.id)

expect(page).to have_content "Navigate the map to the location and place the marker."
validate_latitude_longitude(mappable, mappable_factory_name)
expect(page).to have_field "#{mappable_factory_name}_map_location_attributes_latitude", type: :hidden, with: "51.48"
expect(page).to have_field "#{mappable_factory_name}_map_location_attributes_longitude", type: :hidden, with: "0.0"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/LineLength: Line is too long. [121/110] (https://rubystyle.guide#max-line-length)

@taitus taitus self-assigned this Jun 7, 2022
Consul Democracy automation moved this from Reviewing to Testing Jun 7, 2022
@javierm javierm merged commit 9938ab0 into master Jun 7, 2022
Consul Democracy automation moved this from Testing to Release 1.5.0 Jun 7, 2022
@javierm javierm deleted the more_browser_tests_database branch June 7, 2022 11:48
@javierm javierm removed the 1.5 label Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants