Skip to content

Commit cba4fb9

Browse files
committed
Still trying to fix the flap.
1 parent f6d3f08 commit cba4fb9

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

spec/features/admin_spec.rb

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,23 @@
77
login_user(@current_user)
88
end
99

10-
it "admins can view AI configuration" do
11-
visit "/"
10+
def open_user_menu
11+
within("#header") do
12+
find("[data-action='click->dropdown#toggle']").click
13+
end
14+
find("div[data-dropdown-target='menu']", visible: true)
15+
rescue Capybara::ElementNotFound
16+
# Retry once - Stimulus controller may not be connected yet
17+
sleep 0.5
1218
within("#header") do
13-
user_menu = find("[data-action='click->dropdown#toggle']")
14-
user_menu.click
19+
find("[data-action='click->dropdown#toggle']").click
1520
end
16-
menu = find("div[data-dropdown-target='menu']", visible: true)
21+
find("div[data-dropdown-target='menu']", visible: true)
22+
end
23+
24+
it "admins can view AI configuration" do
25+
visit "/"
26+
menu = open_user_menu
1727
within(menu) do
1828
expect(page).to have_content "My Sites"
1929
expect(page).to have_no_content "AI Settings"
@@ -24,11 +34,8 @@
2434
@current_user.is_site_admin = true
2535
@current_user.save
2636
visit "/"
27-
within("#header") do
28-
user_menu = find("[data-action='click->dropdown#toggle']")
29-
user_menu.click
30-
click_link("AI Settings")
31-
end
37+
open_user_menu
38+
click_link("AI Settings")
3239
expect(page).to have_current_path("/configuration/edit")
3340
expect(page).to have_content "AI Configuration Settings"
3441
end
@@ -38,11 +45,7 @@
3845

3946
it "view user admin pages" do
4047
visit "/"
41-
within("#header") do
42-
user_menu = find("[data-action='click->dropdown#toggle']")
43-
user_menu.click
44-
end
45-
menu = find("div[data-dropdown-target='menu']", visible: true)
48+
menu = open_user_menu
4649
within(menu) do
4750
expect(page).to have_content "My Sites"
4851
expect(page).to have_no_content "Admin Users"

0 commit comments

Comments
 (0)