Fix some flaky tests related to login with JS and tag wrangling with Elasticsearch

Description

There are a number of automated tests that fail intermittently. The goal of this issue is to make some of those tests pass more consistently. (Hopefully.)

features/works/work_create.feature:52

For this test, the HTML snapshot from cucumber seems to indicate that the user isn't logged-in, even though there's a step immediately beforehand which is supposed to make the user log in:

It seems like something about the log-in step may be causing it to fail:

It may be that after the "Log In" button is clicked, cucumber moves onto the next step and loads the next page before the request to log in has finished processing. If that's the case, it would result in the user sometimes failing to be treated as logged-in. It would be possible to fix this just by adding an extra step to the log-in step that checks whether the user sees the appropriate page after login (because this only occurs in tests tagged with @javascript, which means that if the browser doesn't immediately see the appropriate page, it will wait for the page to finish loading before declaring defeat).

This is a common issue that may also contribute to these intermittent failures:

features/tags_and_wrangling/tag_wrangling.feature:25

The line the failure typically occurs on is 235, the last line in this block of code:

If you look at the snapshot of HTML that cucumber prints out when this failure occurs, you can see that "Anubis Arc" is correctly listed as "Unwrangleable," which ought to mean that it doesn't show up on the "Unwrangled" page. But the "Unwrangleable" mark is determined from the SQL database; the choice of which tags to include is an Elasticsearch query. So it must be that Elasticsearch isn't up to date.

Tags automatically reindex themselves when the value of unwrangleable changes:

However, tags can't refresh Elasticsearch automatically. And because the tag automatically reindexes itself, the test doesn't currently include the joint reindex/refresh test step. So Elasticsearch isn't guaranteed to perform a refresh in between the change to unwrangleable and the page that performs the query. It may be that refreshing is all that's needed to fix this test.

Testing Instructions

This should be tested during the review phase by running the Travis builds enough times to see if the tests are less flaky than they used to be. Doesn't require any QA once it's deployed to staging.

Assignee

ticking instant

Reporter

ticking instant

Roadmap

Tag Wrangling

Priority

Medium

Affects versions

Fix versions

Components

AutomatedTests

Difficulty

Medium

Milestone

Internal 0.9
Configure