Skip to content

Commit c39cfb7

Browse files
authored
Merge pull request #2672 from sciencehistory/fix_flaky_oh_system_test_2
Fix flaky test by retrying
2 parents a877008 + dbce942 commit c39cfb7

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

spec/system/oral_history_with_audio_spec.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,16 +410,25 @@
410410
click_on "Search"
411411
end
412412

413-
expect(page).to have_selector("*[data-trigger='linkClipboardCopy']")
414-
page.find("*[data-trigger='linkClipboardCopy']").click
413+
copy_to_clipboard = "*[data-trigger='linkClipboardCopy']"
414+
begin
415+
expect(page).to have_selector(copy_to_clipboard, wait: 0.05)
416+
rescue RSpec::Expectations::ExpectationNotMetError
417+
# the "copy to clipboard" button sometimes fails to show up fast enough.
418+
# Just click "search" again.
419+
# See similar workaround below.
420+
within("*[data-ohms-search-form]") { click_on "Search" }
421+
expect(page).to have_selector(copy_to_clipboard)
422+
end
423+
424+
page.find(copy_to_clipboard).click
415425
expect(page).to have_content("Copied to clipboard")
416426

417427
# ToC tab should be selected as it is first tab with results from search
418428
expect(page).to have_selector("#ohTocTab[aria-selected='true']")
419429
expect(page).to have_content(%r{Table of Contents — 1 / 7}i)
420430
expect(page).to have_selector("*[data-ohms-hitcount='index']", text: "7")
421431
expect(page).to have_selector("*[data-ohms-hitcount='transcript']", text: "43")
422-
423432
click_on "Description"
424433
# We expect the Description tab to be moved to, but for some reason sometimes
425434
# the click doesn't work to change tabs... bootstrap tab wasn't ready for it for some reason?...

0 commit comments

Comments
 (0)