Simplify system tests using a small window

This commit is contained in:
Javi Martín
2021-05-06 17:28:20 +02:00
parent 99361a958a
commit f92008e91e
3 changed files with 12 additions and 33 deletions

View File

@@ -98,6 +98,15 @@ RSpec.configure do |config|
Delayed::Worker.delay_jobs = false
end
config.before(:each, :small_window) do
@window_size = Capybara.current_window.size
Capybara.current_window.resize_to(639, 479)
end
config.after(:each, :small_window) do
Capybara.current_window.resize_to(*@window_size)
end
config.before(:each, :remote_translations) do
allow(RemoteTranslations::Microsoft::AvailableLocales)
.to receive(:available_locales).and_return(I18n.available_locales.map(&:to_s))

View File

@@ -103,17 +103,7 @@ describe "Debates" do
end
end
context "On small devices" do
let!(:window_size) { Capybara.current_window.size }
before do
Capybara.current_window.resize_to(639, 479)
end
after do
Capybara.current_window.resize_to(*window_size)
end
context "On small devices", :small_window do
scenario "Shows links to share on telegram and whatsapp too" do
visit debate_path(create(:debate))

View File

@@ -148,17 +148,7 @@ describe "Proposals" do
end
end
context "On small devices" do
let!(:window_size) { Capybara.current_window.size }
before do
Capybara.current_window.resize_to(639, 479)
end
after do
Capybara.current_window.resize_to(*window_size)
end
context "On small devices", :small_window do
scenario "Shows links to share on telegram and whatsapp too" do
visit proposal_path(create(:proposal))
@@ -253,17 +243,7 @@ describe "Proposals" do
end
end
describe "Show sticky support button on mobile screens" do
let!(:window_size) { Capybara.current_window.size }
before do
Capybara.current_window.resize_to(640, 480)
end
after do
Capybara.current_window.resize_to(*window_size)
end
describe "Show sticky support button on small screens", :small_window do
scenario "On a first visit" do
proposal = create(:proposal)
visit proposal_path(proposal)