From 54935219d7c7a4f468d5ec8bc3713f93de5dd4e8 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Thu, 17 Oct 2024 22:28:02 +0900 Subject: [PATCH] DEV: fix flakey spec in sidebar (#29254) Technically we don't show the edit custom section button on mobile, but the button is present so I just fixed it so the finder works on mobile. We should probably remove this test or find a way to make the button visible on mobile. Also used `mobile: true` instead of manual url. --- spec/system/custom_sidebar_sections_spec.rb | 4 ++-- .../components/navigation_menu/base.rb | 16 +++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/spec/system/custom_sidebar_sections_spec.rb b/spec/system/custom_sidebar_sections_spec.rb index b6eb5416451..fde83b32123 100644 --- a/spec/system/custom_sidebar_sections_spec.rb +++ b/spec/system/custom_sidebar_sections_spec.rb @@ -251,7 +251,7 @@ describe "Custom sidebar sections", type: :system do ) end - it "does not allow to drag on mobile" do + it "does not allow to drag on mobile", mobile: true do sidebar_section = Fabricate(:sidebar_section, title: "My section", user: user) Fabricate(:sidebar_url, name: "Sidebar Tags", value: "/tags").tap do |sidebar_url| @@ -264,7 +264,7 @@ describe "Custom sidebar sections", type: :system do sign_in user - visit("/latest?mobile_view=1") + visit("/latest") sidebar.open_on_mobile sidebar.edit_custom_section("My section") diff --git a/spec/system/page_objects/components/navigation_menu/base.rb b/spec/system/page_objects/components/navigation_menu/base.rb index d4a76c6e395..86e2caf9a7d 100644 --- a/spec/system/page_objects/components/navigation_menu/base.rb +++ b/spec/system/page_objects/components/navigation_menu/base.rb @@ -190,11 +190,17 @@ module PageObjects def edit_custom_section(name) name = name.parameterize - find(".sidebar-section[data-section-name='#{name}']").hover - - find( - ".sidebar-section[data-section-name='#{name}'] button.sidebar-section-header-button", - ).click + if page.has_css?("html.mobile-view", wait: 0) + find( + ".sidebar-section[data-section-name='#{name}'] button.sidebar-section-header-button", + visible: false, + ).click + else + find(".sidebar-section[data-section-name='#{name}']").hover + find( + ".sidebar-section[data-section-name='#{name}'] button.sidebar-section-header-button", + ).click + end end private