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.
This commit is contained in:
Joffrey JAFFEUX 2024-10-17 22:28:02 +09:00 committed by GitHub
parent af6788fd33
commit 54935219d7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 7 deletions

View File

@ -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")

View File

@ -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