Ensure that specs restore default window size

This commit is contained in:
Maikel Linke
2023-06-08 11:59:56 +10:00
parent 241b307762
commit 7cf68cd33b
4 changed files with 25 additions and 33 deletions

View File

@@ -1,24 +1,30 @@
# frozen_string_literal: true
module UIComponentHelper
def browse_as_small
Capybara.current_session.current_window
.resize_to(640, 480)
def browse_as_small(&block)
browse_with_window_size(640, 480, &block)
end
def browse_as_medium
Capybara.current_session.current_window
.resize_to(1024, 768)
def browse_as_medium(&block)
browse_with_window_size(1024, 768, &block)
end
def browse_as_default
Capybara.current_session.current_window
.resize_to(1200, 800)
def browse_as_default(&block)
browse_with_window_size(1200, 800)
block&.call
end
def browse_as_large
def browse_as_large(&block)
browse_with_window_size(1280, 800, &block)
end
def browse_with_window_size(width, height, &block)
Capybara.current_session.current_window
.resize_to(1280, 800)
.resize_to(width, height)
return unless block
block.call
browse_as_default
end
def click_login_button

View File

@@ -25,8 +25,9 @@ describe "Authentication" do
visit root_path
end
describe "as large" do
around { |example| browse_as_large { example.run } }
before do
browse_as_large
open_login_modal
end
@@ -173,12 +174,8 @@ describe "Authentication" do
end
describe "as medium" do
before do
browse_as_medium
end
after do
browse_as_large
end
around { |example| browse_as_medium { example.run } }
it "showing login" do
open_off_canvas
open_login_modal

View File

@@ -100,7 +100,8 @@ describe 'Multilingual' do
end
describe "using the language switcher UI" do
before { browse_as_large }
around { |example| browse_as_large { example.run } }
context "when there is only one language available" do
before do
allow(ENV).to receive(:[]).and_call_original

View File

@@ -32,13 +32,7 @@ describe 'White label setting' do
shared_examples "hides the OFN navigation for mobile view as well" do
context "mobile view" do
before do
browse_as_small
end
after do
browse_as_default
end
around { |example| browse_as_small { example.run } }
it "hides OFN navigation" do
find("a.left-off-canvas-toggle").click
@@ -55,13 +49,7 @@ describe 'White label setting' do
shared_examples "does not hide the OFN navigation for mobile view as well" do
context "mobile view" do
before do
browse_as_small
end
after do
browse_as_default
end
around { |example| browse_as_small { example.run } }
it "does not hide OFN navigation" do
find("a.left-off-canvas-toggle").click