demarches-normaliennes/spec/system/outdated_browser_spec.rb
Pierre de La Morinerie 9fd38cae5e specs: migrate from features to system specs
System specs have been available since Rails 5.1, and are better
integrated with the Rails framework.

- Rename `spec/features` to `spec/system`
- Rename `feature do` to `describe do`
- Configure Capybara for system specs

Steps mostly taken from https://medium.com/table-xi/a-quick-guide-to-rails-system-tests-in-rspec-b6e9e8a8b5f6
2021-10-26 12:24:46 +02:00

49 lines
1.7 KiB
Ruby

describe 'Outdated browsers support:' do
context 'when the user browser is outdated' do
before(:each) do
ie_10_user_agent = 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0; .NET4.0E; .NET4.0C; InfoPath.3)'
Capybara.page.driver.header('user-agent', ie_10_user_agent)
end
scenario 'a banner is displayed' do
visit new_user_session_path
expect(page).to have_content('Internet Explorer 10 est trop ancien')
end
scenario 'the banner can be dismissed' do
visit new_user_session_path
expect(page).to have_content('Internet Explorer 10 est trop ancien')
# The banner is hidden immediately
within '#outdated-browser-banner' do
click_on 'Ignorer'
end
expect(page).not_to have_content('Internet Explorer 10 est trop ancien')
expect(page).to have_current_path(new_user_session_path)
# The banner is hidden after a refresh
page.refresh
expect(page).not_to have_content('Internet Explorer 10 est trop ancien')
end
end
context 'when the user browser is about to be outdated' do
before(:each) do
ie_11_user_agent = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko'
Capybara.page.driver.header('user-agent', ie_11_user_agent)
end
scenario 'IE11 gets a dedicated depreciation banner for update before jan 31st 2021' do
visit new_user_session_path
expect(page).to have_content('31 janvier 2021')
expect(page).to have_content('Internet Explorer 11 est un navigateur trop ancien')
within '#outdated-browser-banner' do
click_on 'Ignorer'
end
page.refresh
expect(page).not_to have_content('Internet Explorer 11 est un navigateur trop ancien')
end
end
end