Skip to content

Commit

Permalink
Merge pull request #16872 from opf/fix/remove-deprecated-toasts
Browse files Browse the repository at this point in the history
Remove deprecated toast methods
  • Loading branch information
HDinger authored Oct 7, 2024
2 parents b3b8af8 + 2136574 commit 945211a
Show file tree
Hide file tree
Showing 15 changed files with 12 additions and 66 deletions.
2 changes: 1 addition & 1 deletion modules/backlogs/spec/features/resolved_status_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
check status.name
click_button "Save"

settings_page.expect_toast(message: "Successful update")
expect_flash(type: :success, message: "Successful update")

expect(page)
.to have_checked_field(status.name)
Expand Down
4 changes: 0 additions & 4 deletions modules/backlogs/spec/support/pages/backlogs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,5 @@ def backlog_selector(backlog)
def story_selector(story)
"#story_#{story.id}"
end

def toast_type
:ruby
end
end
end
4 changes: 0 additions & 4 deletions modules/budgets/spec/support/pages/budget_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,5 @@ def unit_rows
def labor_rows
@labor_rows ||= 0
end

def toast_type
:rails
end
end
end
3 changes: 2 additions & 1 deletion modules/meeting/spec/features/meetings_participants_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@

edit_page.uninvite(viewer_user)
show_page = edit_page.click_save
show_page.expect_toast(message: "Successful update")

expect_flash(message: "Successful update")

show_page.expect_uninvited(viewer_user)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
end

it "can create a structured meeting and add agenda items" do
show_page.expect_toast(message: "Successful creation")
expect_flash(type: :success, message: "Successful creation")

# Does not send invitation mails by default
perform_enqueued_jobs
Expand Down Expand Up @@ -248,7 +248,7 @@
end

it "shows an error toast trying to update an outdated item" do
show_page.expect_toast(message: "Successful creation")
expect_flash(type: :success, message: "Successful creation")

# Can add and edit a single item
show_page.add_agenda_item do
Expand All @@ -271,7 +271,7 @@
end

it "can copy the meeting" do
show_page.expect_toast(message: "Successful creation")
expect_flash(type: :success, message: "Successful creation")

# Can add and edit a single item
show_page.add_agenda_item do
Expand Down Expand Up @@ -327,7 +327,7 @@

context "when starting with empty sections" do
it "can add, edit and delete sections" do
show_page.expect_toast(message: "Successful creation")
expect_flash(type: :success, message: "Successful creation")

# create the first section
show_page.add_section do
Expand Down
4 changes: 0 additions & 4 deletions modules/meeting/spec/support/pages/meetings/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,5 @@ class Base < Pages::Page
def initialize(project)
self.project = project
end

def toast_type
:rails
end
end
end
2 changes: 1 addition & 1 deletion spec/features/forums/message_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
create_page.set_subject "The message is"
create_page.click_save

create_page.expect_toast(type: :error, message: "Content can't be blank")
expect_flash(type: :error, message: "Content can't be blank")
SeleniumHubWaiter.wait
create_page.add_text "There is no message here"

Expand Down
2 changes: 1 addition & 1 deletion spec/features/projects/modules_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
check "Activity"
click_button "Save"

settings_page.expect_toast message: I18n.t(:notice_successful_update)
expect_flash type: :success, message: I18n.t(:notice_successful_update)

expect(page).to have_checked_field "Activity"
expect(page).to have_unchecked_field "Calendar"
Expand Down
4 changes: 0 additions & 4 deletions spec/support/pages/admin/system_settings/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@

module Pages::Admin::SystemSettings
class Page < ::Pages::Page
def toast_type
:rails
end

def press_save_button
scroll_to(:bottom)
click_button("Save")
Expand Down
3 changes: 0 additions & 3 deletions spec/support/pages/messages/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,5 @@

module Pages::Messages
class Base < ::Pages::Page
def toast_type
:rails
end
end
end
10 changes: 2 additions & 8 deletions spec/support/pages/my/password_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,18 @@ def change_password(old_password, new_password, confirmation = new_password)
end

def expect_password_reuse_error_message(count)
expect_toast(type: :error,
expect_flash(type: :error,
message: I18n.t(:"activerecord.errors.models.user.attributes.password.reused", count:))
end

def expect_password_weak_error_message
expect_toast(type: :error,
expect_flash(type: :error,
message: "Password Must contain characters of the following classes (at least 2 of 3): lowercase (e.g. 'a'), uppercase (e.g. 'A'), numeric (e.g. '1')")
end

def expect_password_updated_message
expect_and_dismiss_flash(type: :info, message: I18n.t(:notice_account_password_updated))
end

private

def toast_type
:rails
end
end
end
end
4 changes: 0 additions & 4 deletions spec/support/pages/projects/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ def fieldset_label

private

def toast_type
:rails
end

def path
project_settings_general_path(project)
end
Expand Down
4 changes: 0 additions & 4 deletions spec/support/pages/projects/show.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ def within_sidebar(&)
within("#menu-sidebar", &)
end

def toast_type
:rails
end

def visit_page
visit path
end
Expand Down
4 changes: 0 additions & 4 deletions spec/support/pages/types/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ def within_row(type)
def canonical_name(type)
type.respond_to?(:name) ? type.name : type
end

def toast_type
:rails
end
end
end
end
20 changes: 1 addition & 19 deletions spec/support/toasts/expectations.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
module Toasts
module Expectations
def expect_toast(message:, type: :success, wait: 20)
if toast_type == :angular
expect(page).to have_css(".op-toast.-#{type}", text: message, wait:)
elsif type == :error
ActiveSupport::Deprecation.warn(
"Use `expect_flash(type: :error, message: message)` instead of expect_toast with type: :error"
)
expect_flash(type: :error, message:)
elsif type == :success
ActiveSupport::Deprecation.warn(
"Use `expect_flash(type: :success, message:)` instead of expect_toast with type: :success"
)
expect_flash(message:)
else
raise NotImplementedError
end
expect(page).to have_css(".op-toast.-#{type}", text: message, wait:)
end

def expect_and_dismiss_toaster(message: nil, type: :success, wait: 20)
Expand Down Expand Up @@ -43,9 +29,5 @@ def expect_no_toaster(type: :success, message: nil, wait: 10)
expect(page).to have_no_css(".op-toast.-#{type}", text: message, wait:)
end
end

def toast_type
:angular
end
end
end

0 comments on commit 945211a

Please sign in to comment.