Fix up test failures in Chrome & Firefox

This commit is contained in:
James Mason 2018-10-25 16:16:56 -07:00
parent b72bb8a0ed
commit 1b9a12746d
29 changed files with 145 additions and 78 deletions

View file

@ -15,27 +15,30 @@ feature Commercial do
visit admin_conference_commercials_path(conference.short_title)
# Workaround to enable the 'Create Commercial' button
page.execute_script("$('#commercial_submit_action').prop('disabled', false)")
# Create valid commercial
fill_in 'commercial_url', with: 'https://www.youtube.com/watch?v=M9bq_alk-sw'
click_button 'Create Commercial'
page.find('#flash')
expect(flash).to eq('Commercial was successfully created.')
page.find('#flash .button.close').click
expect(conference.commercials.count).to eq(1)
commercial = conference.commercials.where(url: 'https://www.youtube.com/watch?v=M9bq_alk-sw').first
fill_in "commercial_url_#{commercial.id}", with: 'https://www.youtube.com/watch?v=VNkDJk5_9eU'
click_button 'Update'
page.find('#flash')
expect(flash).to eq('Commercial was successfully updated.')
page.find('#flash .button.close').click
expect(conference.commercials.count).to eq(1)
commercial.reload
expect(commercial.url).to eq 'https://www.youtube.com/watch?v=VNkDJk5_9eU'
# Delete commercial
click_link 'Delete'
page.accept_alert do
click_link 'Delete'
end
page.find('#flash')
expect(flash).to eq('Commercial was successfully destroyed.')
expect(conference.commercials.count).to eq(0)
end
@ -65,6 +68,7 @@ feature Commercial do
page.execute_script("$('#commercial_submit_action').prop('disabled', false)")
click_button 'Create Commercial'
page.find('#flash')
expect(flash).to eq('Commercial was successfully created.')
expect(event.commercials.count).to eq(1)
end
@ -73,14 +77,8 @@ feature Commercial do
visit edit_conference_program_proposal_path(conference.short_title, event.id)
click_link 'Commercials'
fill_in 'commercial_url', with: 'invalid_commercial_url'
# Workaround to enable the 'Create Commercial' button
page.execute_script("$('#commercial_submit_action').prop('disabled', false)")
click_button 'Create Commercial'
expect(flash).to include('An error prohibited this Commercial from being saved:')
expect(current_path).to eq edit_conference_program_proposal_path(conference.short_title, event.id)
expect(event.commercials.count).to eq(0)
expect(page).to have_content('No embeddable content')
expect(page).to have_css("button[type='submit']:disabled", text: 'Create Commercial')
end
scenario 'updates a commercial of an event', feature: true, versioning: true, js: true do
@ -91,13 +89,14 @@ feature Commercial do
click_link 'Commercials'
fill_in "commercial_url_#{commercial.id}", with: 'https://www.youtube.com/watch?v=M9bq_alk-sw'
click_button 'Update'
page.find('#flash')
expect(flash).to eq('Commercial was successfully updated.')
expect(event.commercials.count).to eq(1)
commercial.reload
expect(commercial.url).to eq('https://www.youtube.com/watch?v=M9bq_alk-sw')
end
scenario 'does not update a commercial of an event with invalid data', feature: true, versioning: true, js: true do
scenario 'does not update a commercial of an event with invalid data', feature: true, versioning: true do
commercial = create(:commercial,
commercialable_id: event.id,
commercialable_type: 'Event',
@ -106,8 +105,9 @@ feature Commercial do
click_link 'Commercials'
fill_in "commercial_url_#{commercial.id}", with: 'invalid_commercial_url'
click_button 'Update'
expect(flash).to include('An error prohibited this Commercial from being saved:')
find('#flash')
expect(current_path).to eq edit_conference_program_proposal_path(conference.short_title, event.id)
expect(flash).to include('An error prohibited this Commercial from being saved:')
commercial.reload
expect(commercial.url).to eq('https://www.youtube.com/watch?v=BTTygyxuGj8')
end
@ -118,8 +118,10 @@ feature Commercial do
commercialable_type: 'Event')
visit edit_conference_program_proposal_path(conference.short_title, event.id)
click_link 'Commercials'
click_link 'Delete'
page.driver.network_traffic
page.accept_alert do
click_link 'Delete'
end
page.find('#flash')
expect(flash).to eq('Commercial was successfully destroyed.')
expect(event.commercials.count).to eq(0)
end