HostJSTest: show action buttons fails intermittently to match flash
Occasional intermittent failures are occurring in this test:
HostJSTest::hosts index multiple actions.test_0001_show action buttons (from HostJSTest__hosts index multiple actions) Took 42 sec. Failed assertion, no message given. (Minitest::Assertion) /var/lib/workspace/workspace/test_develop_pr_core_integration_only/database/postgresql/label/fast/ruby/2.0.0/test/integration/host_js_test.rb:249
The assertion is:
assert has_selector?("div", :text => "Updated hosts: changed environment")
The danger with this selector is that it's trying to match a flash message sent after the request's completed, but it's attempting to match the flash before it's displayed when it's in the HTML:
<div class="flash hide notice">Updated hosts: changed environment</div>
When the notify JS runs to display the message, it deletes the element and temporarily creates a new div elsewhere in the document with a slightly different text.
<ul class="ui-autocomplete ui-front ui-menu ui-widget ui-widget-content ui-corner-all" id="ui-id-1" tabindex="0" style="display: none;"></ul><div class="jnotify-container"><div class="jnotify-notification jnotify-notification-success"><div class=""></div><div class="foreman-alert alert alert-success"><div></div><span class="pficon pficon-ok"></span><strong>Success: </strong>Updated hosts: changed environment</div></div></div></body></html>
And then when the flash disappears, so does the element and any trace of the message. It's probably best to test success and the flash in a different way.