From eb6b188c3d3052b101243bf868dfcf97cbf9c1db Mon Sep 17 00:00:00 2001 From: outdatedpizzatech <1538122+eric-eye@users.noreply.github.com> Date: Sat, 21 Dec 2024 23:23:55 -0500 Subject: [PATCH] disable_animation also disables view transitions --- lib/capybara/server/animation_disabler.rb | 2 +- .../spec/views/with_view_transition.erb | 43 +++++++++++++++++++ spec/shared_selenium_session.rb | 22 ++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 lib/capybara/spec/views/with_view_transition.erb diff --git a/lib/capybara/server/animation_disabler.rb b/lib/capybara/server/animation_disabler.rb index 7e81368c2..58153b702 100644 --- a/lib/capybara/server/animation_disabler.rb +++ b/lib/capybara/server/animation_disabler.rb @@ -62,7 +62,7 @@ def directive_nonces(headers) end DISABLE_CSS_MARKUP_TEMPLATE = <<~CSS - %s, %s::before, %s::after { + %s, %s::before, %s::after, ::view-transition-group(*) { transition: none !important; animation-duration: 0s !important; animation-delay: 0s !important; diff --git a/lib/capybara/spec/views/with_view_transition.erb b/lib/capybara/spec/views/with_view_transition.erb new file mode 100644 index 000000000..1940639e8 --- /dev/null +++ b/lib/capybara/spec/views/with_view_transition.erb @@ -0,0 +1,43 @@ + + + + + with_view_transition + + + + + + + click me to show a form input + + Button clicked + + diff --git a/spec/shared_selenium_session.rb b/spec/shared_selenium_session.rb index df20246be..39ace0bdc 100644 --- a/spec/shared_selenium_session.rb +++ b/spec/shared_selenium_session.rb @@ -383,6 +383,17 @@ @animation_session = Capybara::Session.new(session.mode, TestApp.new) end + it 'should disable view transitions' do + @animation_session.visit('with_view_transition') + sleep 1 + @animation_session.click_link('click me to show a form input') + + expect do + @animation_session.click_button("button") + end.not_to raise_error + expect(@animation_session).to have_content("Button clicked") + end + it 'should add CSS to the element' do @animation_session.visit('with_animation') @@ -479,6 +490,17 @@ @animation_session_with_matching_css.click_link('animate me away') expect(@animation_session_with_matching_css).to have_no_link('animate me away', wait: 0.5) end + + it 'should disable view transitions' do + @animation_session_with_matching_css.visit('with_view_transition') + sleep 1 + @animation_session_with_matching_css.click_link('click me to show a form input') + + expect do + @animation_session_with_matching_css.click_button("button") + end.not_to raise_error + expect(@animation_session_with_matching_css).to have_content("Button clicked") + end end context 'if we pass in css that does not match elements' do