Skip to content

A platform for community discussion. Free, open, simple.

DEV: fix flakey spec in sidebar (#29254)

Joffrey JAFFEUX54935219d7c7
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