From 0031d2964d653a7242043ab62c36aa73f9b0d70a Mon Sep 17 00:00:00 2001 From: Thomas Schmidt Date: Sun, 9 Feb 2025 15:03:25 +0100 Subject: [PATCH] fix mfix test for mobile view --- app/assets/stylesheets/modals.css | 6 ++++++ app/javascript/controllers/map/feature_modal_controller.js | 4 +--- app/views/maps/modals/_feature.haml | 4 ++-- spec/features/feature_details_spec.rb | 6 +++--- spec/rails_helper.rb | 7 +++++++ 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/app/assets/stylesheets/modals.css b/app/assets/stylesheets/modals.css index eeb9801f..477337fe 100644 --- a/app/assets/stylesheets/modals.css +++ b/app/assets/stylesheets/modals.css @@ -79,6 +79,12 @@ height 0.3s linear !important; } +@media (width > 574px) { + .modal-pull-up { + height: auto; + } +} + .modal-pull-up-half { height: 50% !important; transition: diff --git a/app/javascript/controllers/map/feature_modal_controller.js b/app/javascript/controllers/map/feature_modal_controller.js index 61c80145..17d81044 100644 --- a/app/javascript/controllers/map/feature_modal_controller.js +++ b/app/javascript/controllers/map/feature_modal_controller.js @@ -159,9 +159,7 @@ export default class extends Controller { pullUpModal (modal) { modal.classList.remove('modal-pull-down') // console.log('screen width: ' + screen.width) - if (screen.width <= 574) { - modal.classList.add('modal-pull-up') - } + modal.classList.add('modal-pull-up') } getFeature () { diff --git a/app/views/maps/modals/_feature.haml b/app/views/maps/modals/_feature.haml index 7a097b64..4fa26aab 100644 --- a/app/views/maps/modals/_feature.haml +++ b/app/views/maps/modals/_feature.haml @@ -10,8 +10,8 @@ %i.bi.bi-trash %h4#feature-details-header.flex-container - #feature-symbol{ 'data-action': "click->map--feature-modal#toggleModalSize"} - #feature-title{ 'data-action': "click->map--feature-modal#toggleModalSize"} + #feature-symbol + #feature-title = render 'maps/modals/feature/edit_ui' = render 'maps/modals/feature/edit_raw' diff --git a/spec/features/feature_details_spec.rb b/spec/features/feature_details_spec.rb index 086b5ce3..b8ea9b1f 100644 --- a/spec/features/feature_details_spec.rb +++ b/spec/features/feature_details_spec.rb @@ -17,15 +17,15 @@ expect(page).to have_css('#feature-details-modal') end - it 'can enlarge modal with pull-up button' do - page.current_window.resize_to(290, 523) + it 'can enlarge modal with pull-up button', :mobile do + # page.current_window.resize_to(290, 523) height = find('#feature-details-modal').native.style('height').sub('px', '').to_i expect(height).to be < 150 find('.modal-pull-button').click sleep(0.3) height = find('#feature-details-modal').native.style('height').sub('px', '').to_i expect(height).to be > 150 - page.current_window.resize_to(1024, 576) + # page.current_window.resize_to(1024, 576) end end end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 507e8df1..355990ac 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -48,6 +48,13 @@ end end + config.around(:each, :mobile) do |spec| + browser = Capybara.current_session.driver.browser + browser.manage.window.resize_to(290, 523) + spec.run + browser.manage.window.resize_to(1024, 576) + end + # raise on js console errors class JavaScriptError< StandardError; end RSpec.configure do |config|