Skip to content

Commit

Permalink
Don't use confirm dialog in admin homepage form
Browse files Browse the repository at this point in the history
In this case the confirmation dialog isn't really necessary since the
action to enable/disable the setting can easily be undone.

Furthermore, these tests were failing with Chrome 83, probably because
we use `confirm_dialog` and then we use `visit` without checking the
page in between.

In theory we shouldn't need to check the page in between because the
request generated by `confirm_dialog` is a synchronous one and so
`visit` isn't executed after the previous request has finished, but
apparently this behavior has changed in Chrome 83.

We could add an expectation before executing the `visit` method, but
that wouldn't improve the usability of the application.
  • Loading branch information
javierm committed May 25, 2020
1 parent 095abbf commit 5bf968d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions app/views/admin/homepage/_setting.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
value: (setting.enabled? ? "" : "active") %>
<%= f.submit(t("admin.settings.index.features.#{setting.enabled? ? "disable" : "enable"}"),
class: "button #{setting.enabled? ? "hollow alert" : "success"}",
data: { confirm: t("admin.actions.confirm") }) %>
class: "button #{setting.enabled? ? "hollow alert" : "success"}") %>
<% end %>
</div>
10 changes: 5 additions & 5 deletions spec/system/admin/homepage/homepage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

within("#widget_feed_#{proposals_feed.id}") do
select "1", from: "widget_feed_limit"
accept_confirm { click_button "Enable" }
click_button "Enable"
end

visit root_path
Expand All @@ -55,7 +55,7 @@
visit admin_homepage_path
within("#widget_feed_#{debates_feed.id}") do
select "2", from: "widget_feed_limit"
accept_confirm { click_button "Enable" }
click_button "Enable"
end

visit root_path
Expand All @@ -76,12 +76,12 @@

within("#widget_feed_#{proposals_feed.id}") do
select "3", from: "widget_feed_limit"
accept_confirm { click_button "Enable" }
click_button "Enable"
end

within("#widget_feed_#{debates_feed.id}") do
select "3", from: "widget_feed_limit"
accept_confirm { click_button "Enable" }
click_button "Enable"
end

visit root_path
Expand All @@ -106,7 +106,7 @@
visit admin_homepage_path
within("#widget_feed_#{processes_feed.id}") do
select "3", from: "widget_feed_limit"
accept_confirm { click_button "Enable" }
click_button "Enable"
end

visit root_path
Expand Down

0 comments on commit 5bf968d

Please sign in to comment.