Skip to content

Commit

Permalink
Merge pull request #2672 from sciencehistory/fix_flaky_oh_system_test_2
Browse files Browse the repository at this point in the history
Fix flaky test by retrying
  • Loading branch information
jrochkind authored Jul 11, 2024
2 parents a877008 + dbce942 commit c39cfb7
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions spec/system/oral_history_with_audio_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -410,16 +410,25 @@
click_on "Search"
end

expect(page).to have_selector("*[data-trigger='linkClipboardCopy']")
page.find("*[data-trigger='linkClipboardCopy']").click
copy_to_clipboard = "*[data-trigger='linkClipboardCopy']"
begin
expect(page).to have_selector(copy_to_clipboard, wait: 0.05)
rescue RSpec::Expectations::ExpectationNotMetError
# the "copy to clipboard" button sometimes fails to show up fast enough.
# Just click "search" again.
# See similar workaround below.
within("*[data-ohms-search-form]") { click_on "Search" }
expect(page).to have_selector(copy_to_clipboard)
end

page.find(copy_to_clipboard).click
expect(page).to have_content("Copied to clipboard")

# ToC tab should be selected as it is first tab with results from search
expect(page).to have_selector("#ohTocTab[aria-selected='true']")
expect(page).to have_content(%r{Table of Contents — 1 / 7}i)
expect(page).to have_selector("*[data-ohms-hitcount='index']", text: "7")
expect(page).to have_selector("*[data-ohms-hitcount='transcript']", text: "43")

click_on "Description"
# We expect the Description tab to be moved to, but for some reason sometimes
# the click doesn't work to change tabs... bootstrap tab wasn't ready for it for some reason?...
Expand Down

0 comments on commit c39cfb7

Please sign in to comment.