diff --git a/spec/features/autocomplete_typeahead_spec.rb b/spec/features/autocomplete_typeahead_spec.rb index 70c5ba07d..8830cb947 100644 --- a/spec/features/autocomplete_typeahead_spec.rb +++ b/spec/features/autocomplete_typeahead_spec.rb @@ -45,9 +45,11 @@ # Open the multi-image selector and choose the last one click_link('Change') find('.thumbs-list li:last-child').click + sleep 1 expect(page).to have_css('.leaflet-container', visible: true) click_button 'Save changes' + sleep 1 expect(page).to have_content('The exhibit was successfully updated.') diff --git a/spec/features/javascript/blocks/solr_documents_block_spec.rb b/spec/features/javascript/blocks/solr_documents_block_spec.rb index 54e07ebbe..cb02c4116 100644 --- a/spec/features/javascript/blocks/solr_documents_block_spec.rb +++ b/spec/features/javascript/blocks/solr_documents_block_spec.rb @@ -86,18 +86,12 @@ it 'allows you to toggle visibility of solr documents', js: true do fill_in_solr_document_block_typeahead_field with: 'dq287tq6352' - # Flappy guard. Wait for the thumbnail src to be populated. - expect(page).to have_selector('li[data-resource-id="dq287tq6352"] .img-thumbnail[src^="http"]') - within(:css, '.card') do uncheck 'Display?' end fill_in_solr_document_block_typeahead_field with: 'gk446cj2442' - # Flappy guard. Wait for the thumbnail src to be populated. - expect(page).to have_selector('li[data-resource-id="gk446cj2442"] .img-thumbnail[src^="http"]') - # display the title as the primary caption within('.primary-caption') do check('Primary caption') @@ -111,6 +105,7 @@ expect(page).to have_no_content "L'AMERIQUE" visit spotlight.edit_exhibit_feature_page_path(exhibit, feature_page) + wait_for_sir_trevor # display the title as the primary caption within('.primary-caption') do uncheck('Primary caption') @@ -149,9 +144,6 @@ it 'allows you to optionally display a ZPR link with the image', js: true do fill_in_solr_document_block_typeahead_field with: 'gk446cj2442' - # Flappy guard. Wait for the thumbnail src to be populated. - expect(page).to have_selector('li[data-resource-id="gk446cj2442"] .img-thumbnail[src^="http"]') - check 'Offer "View larger" option' save_page_changes @@ -182,9 +174,6 @@ it 'allows you to choose which side the text will be on', js: true do fill_in_solr_document_block_typeahead_field with: 'dq287tq6352' - # Flappy guard. Wait for the thumbnail src to be populated. - expect(page).to have_selector('li[data-resource-id="dq287tq6352"] .img-thumbnail[src^="http"]') - # Select to align the text right choose 'Left' @@ -211,8 +200,6 @@ it 'toggles alt text input when marking an image as decorative', js: true do fill_in_solr_document_block_typeahead_field with: 'gk446cj2442' - # Flappy guard. Wait for the thumbnail src to be populated. - expect(page).to have_selector('li[data-resource-id="gk446cj2442"] .img-thumbnail[src^="http"]') fill_in 'Alternative text', with: 'custom alt text' check 'Decorative' @@ -223,13 +210,12 @@ it 'retains custom alt text after marking as decorative and saving', js: true do fill_in_solr_document_block_typeahead_field with: 'gk446cj2442' - # Flappy guard. Wait for the thumbnail src to be populated. - expect(page).to have_selector('li[data-resource-id="gk446cj2442"] .img-thumbnail[src^="http"]') fill_in 'Alternative text', with: 'custom alt text' check 'Decorative' save_page_changes click_on 'Edit' + wait_for_sir_trevor uncheck 'Decorative' expect(page).to have_field('Alternative text', type: 'textarea', disabled: false, with: 'custom alt text') end @@ -237,18 +223,12 @@ it 'round-trip data', js: true do fill_in_solr_document_block_typeahead_field with: 'dq287tq6352' - # Flappy guard. Wait for the thumbnail src to be populated. - expect(page).to have_selector('li[data-resource-id="dq287tq6352"] .img-thumbnail[src^="http"]') - within(:css, '.card') do uncheck 'Display?' end fill_in_solr_document_block_typeahead_field with: 'gk446cj2442' - # Flappy guard. Wait for the thumbnail src to be populated. - expect(page).to have_selector('li[data-resource-id="gk446cj2442"] .img-thumbnail[src^="http"]') - # display the title as the primary caption within('.primary-caption') do check('Primary caption') diff --git a/spec/support/features/test_features_helpers.rb b/spec/support/features/test_features_helpers.rb index 53db6a0fd..b7191fb13 100644 --- a/spec/support/features/test_features_helpers.rb +++ b/spec/support/features/test_features_helpers.rb @@ -5,19 +5,17 @@ module TestFeaturesHelpers def fill_in_typeahead_field(opts = {}) type = opts[:type] || 'default' - # This first click here is not needed in terms of user interaction, but it - # makes the test more reliable. Otherwise the fill_in can happen prior - # to auto-complete-element being fully initialized and the test will fail. - find("auto-complete [data-#{type}-typeahead]").click - find("auto-complete[open] [data-#{type}-typeahead]").fill_in(with: opts[:with]) + # Role=combobox indicates that the auto-complete is initialized + expect(page).to have_css("auto-complete [data-#{type}-typeahead][role='combobox']") + find("auto-complete [data-#{type}-typeahead]").fill_in(with: opts[:with]) find('auto-complete[open] [role="option"]', text: opts[:with], match: :first).click end # just like #fill_in_typeahead_field, but wait for the - # form fields to show up on the page too + # form fields/thumbnail preview to show up on the page too def fill_in_solr_document_block_typeahead_field(opts) fill_in_typeahead_field(opts) - expect(page).to have_css('li[data-resource-id="' + opts[:with] + '"]') + expect(page).to have_css('li[data-resource-id="' + opts[:with] + '"] .img-thumbnail[src^="http"]') end def add_widget(type) @@ -37,12 +35,17 @@ def click_add_widget first('.st-block-replacer').click end + def wait_for_sir_trevor + expect(page).to have_selector('.st-blocks.st-ready') + sleep 1 + end + def save_page_changes - page.execute_script <<-EOF - SirTrevor.getInstance().onFormSubmit(); - EOF + wait_for_sir_trevor click_button('Save changes') - # verify that the page was created + # Load bearing sleep. Remove or reduce at your own risk. Revisit if Sir Trevor is removed. + sleep 3 if ENV['CI'] + # verify that the page was created. expect(page).to have_no_selector('.alert-danger') expect(page).to have_selector('.alert-info', text: 'page was successfully updated') end