From 7ef79e4873421c8fdd4157f980e16727a0e90abc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Mon, 23 Sep 2024 20:25:05 +0200 Subject: [PATCH 01/14] Primerize all backend flashes --- app/helpers/flash_messages_helper.rb | 58 +++++++++++++------------- app/helpers/primerized_flash_helper.rb | 43 ------------------- app/views/layouts/base.html.erb | 13 +++--- 3 files changed, 37 insertions(+), 77 deletions(-) delete mode 100644 app/helpers/primerized_flash_helper.rb diff --git a/app/helpers/flash_messages_helper.rb b/app/helpers/flash_messages_helper.rb index 0e8b668c935..8015199aaaf 100644 --- a/app/helpers/flash_messages_helper.rb +++ b/app/helpers/flash_messages_helper.rb @@ -37,44 +37,46 @@ module FlashMessagesHelper # Renders flash messages def render_flash_messages messages = flash - .reject { |k, _| k.to_s == "op_primer_flash" } .reject { |k, _| k.start_with? "_" } - .map do |k, v| - if k.to_sym == :modal - component = v[:type].constantize - component.new(**v.fetch(:parameters, {})).render_in(self) - else - render_flash_message(k, v) - end - end + .reject { |k, _| k.to_s == "modal" } + .map { |k, v| render_flash_content(k.to_sym, v) } safe_join messages, "\n" end - def render_flash_message(type, message, html_options = {}) # rubocop:disable Metrics/AbcSize - if type.to_s == "notice" - type = "success" + def render_flash_content(key, content) + case key + when :op_primer_flash + render_flash_message(content[:scheme] || :default, content[:message]) + else + render_flash_message(key, content) end + end - toast_css_classes = ["op-toast -#{type}", html_options.delete(:class)] + def render_flash_modal + content = flash[:modal] + return if content.blank? - # Add autohide class to notice flashes if configured - if type.to_s == "success" && User.current.pref.auto_hide_popups? - toast_css_classes << "autohide-toaster" + component = content[:type].constantize + component.new(**content.fetch(:parameters, {})).render_in(self) + end + + def mapped_flash_type(type) + case type + when :error + :danger + when :warning + :warning + when :notice + :success + else + :default end + end - html_options = { class: toast_css_classes.join(" "), role: "alert" }.merge(html_options) - close_button = content_tag :a, "", class: "op-toast--close icon-context icon-close", - title: I18n.t("js.close_popup_title"), - tabindex: "0" - toast = content_tag(:div, join_flash_messages(message), class: "op-toast--content") - content_tag :div, "", class: "op-toast--wrapper" do - content_tag :div, "", class: "op-toast--casing" do - content_tag :div, html_options do - concat(close_button) - concat(toast) - end - end + def render_flash_message(type, message) + render(OpPrimer::FlashComponent.new(scheme: mapped_flash_type(type))) do + join_flash_messages(message) end end end diff --git a/app/helpers/primerized_flash_helper.rb b/app/helpers/primerized_flash_helper.rb deleted file mode 100644 index ffe46356ab3..00000000000 --- a/app/helpers/primerized_flash_helper.rb +++ /dev/null @@ -1,43 +0,0 @@ -#-- copyright -# OpenProject is an open source project management software. -# Copyright (C) the OpenProject GmbH -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License version 3. -# -# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: -# Copyright (C) 2006-2013 Jean-Philippe Lang -# Copyright (C) 2010-2013 the ChiliProject Team -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# See COPYRIGHT and LICENSE files for more details. -#++ -# - -module PrimerizedFlashHelper - extend ActiveSupport::Concern - - def render_primerized_flash - return if flash[:op_primer_flash].blank? - - system_arguments = flash[:op_primer_flash] - message = system_arguments.delete(:message) - - render(OpPrimer::FlashComponent.new(**system_arguments)) do - message - end - end -end diff --git a/app/views/layouts/base.html.erb b/app/views/layouts/base.html.erb index b30d04035b0..5d1855a998b 100644 --- a/app/views/layouts/base.html.erb +++ b/app/views/layouts/base.html.erb @@ -118,13 +118,14 @@ See COPYRIGHT and LICENSE files for more details.
<%= content_tag :main, id: "content-wrapper", class: initial_classes, data: stimulus_content_data do %> <%# Primerized flash messages are being rendered separately %> -
- <%= render_primerized_flash %> -
- <%# Flash messages are being rendered using the old op-flash style %> - +
<%= render_flash_messages %> - +
+ <%# Flash modals render modal components %> + <%= render_flash_modal %> <% if show_onboarding_modal? %>
Date: Tue, 24 Sep 2024 14:24:47 +0200 Subject: [PATCH 02/14] Render all flashes as primerized --- app/components/op_primer/flash_component.rb | 2 +- app/helpers/flash_messages_helper.rb | 2 +- spec/support/primerized_flash/expectations.rb | 40 +++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 spec/support/primerized_flash/expectations.rb diff --git a/app/components/op_primer/flash_component.rb b/app/components/op_primer/flash_component.rb index 2c50edc45ac..c93edcae9a7 100644 --- a/app/components/op_primer/flash_component.rb +++ b/app/components/op_primer/flash_component.rb @@ -35,7 +35,7 @@ module OpPrimer def initialize(**system_arguments) @unique_key = system_arguments.delete(:unique_key) - system_arguments[:test_selector] ||= "primer-banner-message-component" + system_arguments[:test_selector] ||= "op-primer-flash-message" system_arguments[:dismiss_scheme] ||= :remove system_arguments[:dismiss_label] ||= I18n.t(:button_close) diff --git a/app/helpers/flash_messages_helper.rb b/app/helpers/flash_messages_helper.rb index 8015199aaaf..cf047b012ae 100644 --- a/app/helpers/flash_messages_helper.rb +++ b/app/helpers/flash_messages_helper.rb @@ -67,7 +67,7 @@ module FlashMessagesHelper :danger when :warning :warning - when :notice + when :success, :notice :success else :default diff --git a/spec/support/primerized_flash/expectations.rb b/spec/support/primerized_flash/expectations.rb new file mode 100644 index 00000000000..b431bf1bcb0 --- /dev/null +++ b/spec/support/primerized_flash/expectations.rb @@ -0,0 +1,40 @@ +module PrimerizedFlash + module Expectations + include FlashMessagesHelper + + def expect_primerized_flash(message:, type: :success, wait: 20) + mapped_scheme = mapped_flash_type(type) + expect(page).to have_css(".Banner--#{mapped_scheme}", text: message, wait:) + end + + def expect_and_dismiss_primerized_flash(message: nil, type: :success, wait: 20) + expect_primerized_flash(type:, message:, wait:) + dismiss_primerized_flash! + expect_no_primerized_flash(type:, message:, wait: 0.1) + end + + def dismiss_primerized_flash! + page.find(".Banner-close button").click # rubocop:disable Capybara/SpecificActions + end + + # Clears a toaster if there is one waiting 1 second max, but do not fail if there is none + def clear_primerized_flashes + if has_css?(".Banner-close button") + dismiss_primerized_flash! + end + end + + def expect_no_primerized_flash(type: :success, message: nil, wait: 10) + if type.nil? + expect(page).not_to have_test_selector("op-primer-flash-message") + else + mapped_scheme = mapped_flash_type(type) + expect(page).to have_no_css(".Banner--#{mapped_scheme}", text: message, wait:) + end + end + end +end + +RSpec.configure do |config| + config.include PrimerizedFlash::Expectations +end From da4ffd7f2faa43277094e3a4b811fb669271fafa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Tue, 24 Sep 2024 15:03:48 +0200 Subject: [PATCH 03/14] Replace common error and errorExplanation with banners --- app/helpers/error_message_helper.rb | 24 ++++++--- app/helpers/errors_helper.rb | 3 ++ app/views/common/error.html.erb | 8 --- app/views/layouts/_flashes.html.erb | 7 +++ app/views/layouts/base.html.erb | 8 +-- app/views/layouts/only_logo.html.erb | 5 +- .../spec/features/meetings_new_spec.rb | 24 +++++---- .../common/validation_error.html.erb_spec.rb | 54 ------------------- 8 files changed, 45 insertions(+), 88 deletions(-) create mode 100644 app/views/layouts/_flashes.html.erb delete mode 100644 spec/views/common/validation_error.html.erb_spec.rb diff --git a/app/helpers/error_message_helper.rb b/app/helpers/error_message_helper.rb index 0db5c3a59e2..cbff1ba5c0a 100644 --- a/app/helpers/error_message_helper.rb +++ b/app/helpers/error_message_helper.rb @@ -34,19 +34,29 @@ module ErrorMessageHelper object = convert_to_model(object) return unless object - render_error_messages_partial(object.errors, object) + assign_flash_error(object.errors, object) end - def render_error_messages_partial(errors, object) - return "" if errors.empty? + def assign_flash_error(errors, object) + return if errors.empty? base_error_messages = errors.full_messages_for(:base) fields_error_messages = errors.full_messages - base_error_messages - render partial: "common/validation_error", - locals: { base_error_messages:, - fields_error_messages:, - object_name: object.class.model_name.human } + flash[:error] = error_flash_content(object, base_error_messages, fields_error_messages) + end + + def error_flash_content(object, base_error_messages, fields_error_messages) + capture do + concat error_message_header(object.class.model_name.human, base_error_messages.count + fields_error_messages.count) + concat list_of_messages(base_error_messages) + concat text_header_invalid_fields(base_error_messages, fields_error_messages) + concat list_of_messages(fields_error_messages) + end + end + + def error_message_header(object_name, count) + t("activerecord.errors.template.header", model: object_name, count:) end def text_header_invalid_fields(base_error_messages, fields_error_messages) diff --git a/app/helpers/errors_helper.rb b/app/helpers/errors_helper.rb index ee22b9eddd8..f9cc42d21e0 100644 --- a/app/helpers/errors_helper.rb +++ b/app/helpers/errors_helper.rb @@ -94,6 +94,9 @@ module ErrorsHelper @message_details = arg[:message_details] respond_to do |format| format.html do + binding.pry + error_message = "[#{I18n.t(:error_code, code: @status)}] #{@message}\n#{@message_details}" + flash[:error] = error_message render template: "common/error", layout: use_layout, status: @status end format.any do diff --git a/app/views/common/error.html.erb b/app/views/common/error.html.erb index 521ad7f8b42..85f38b27a71 100644 --- a/app/views/common/error.html.erb +++ b/app/views/common/error.html.erb @@ -27,14 +27,6 @@ See COPYRIGHT and LICENSE files for more details. ++#%> -<% if @message_details %> - <% content_for :error_details do %> -

<%= @message_details %>

- <% end %> -<% end %> - -<% error_message = "[#{I18n.t(:error_code, code: @status)}] #{@message}" %> -<%= render partial: "common/error_base", locals: { error_message: error_message } %> <%= call_hook(:view_common_error_details, { params: params, project: ((defined? @project) ? @project : nil) }) %> <% html_title h(@status) %> diff --git a/app/views/layouts/_flashes.html.erb b/app/views/layouts/_flashes.html.erb new file mode 100644 index 00000000000..c37aa9f0cff --- /dev/null +++ b/app/views/layouts/_flashes.html.erb @@ -0,0 +1,7 @@ +<%# Primerized flash messages are being rendered separately %> +
+ <%= render_flash_messages %> +
diff --git a/app/views/layouts/base.html.erb b/app/views/layouts/base.html.erb index 5d1855a998b..b864e15fb9f 100644 --- a/app/views/layouts/base.html.erb +++ b/app/views/layouts/base.html.erb @@ -117,13 +117,7 @@ See COPYRIGHT and LICENSE files for more details. <% end %>
<%= content_tag :main, id: "content-wrapper", class: initial_classes, data: stimulus_content_data do %> - <%# Primerized flash messages are being rendered separately %> -
- <%= render_flash_messages %> -
+ <%= render partial: "layouts/flashes" %> <%# Flash modals render modal components %> <%= render_flash_modal %> <% if show_onboarding_modal? %> diff --git a/app/views/layouts/only_logo.html.erb b/app/views/layouts/only_logo.html.erb index ca3bc3a0b1c..483582c89f5 100644 --- a/app/views/layouts/only_logo.html.erb +++ b/app/views/layouts/only_logo.html.erb @@ -44,7 +44,10 @@ See COPYRIGHT and LICENSE files for more details. <%= link_to(I18n.t('label_home'), home_url, class: 'op-logo--link') %> - <%= yield %> +
+ <%= render partial: "layouts/flashes" %> + <%= yield %> +
diff --git a/modules/meeting/spec/features/meetings_new_spec.rb b/modules/meeting/spec/features/meetings_new_spec.rb index fa7bc94c48f..9a3fb999168 100644 --- a/modules/meeting/spec/features/meetings_new_spec.rb +++ b/modules/meeting/spec/features/meetings_new_spec.rb @@ -97,7 +97,7 @@ RSpec.describe "Meetings new", :js, with_cuprite: false do show_page = new_page.click_create - show_page.expect_toast(message: "Successful creation") + expect_primerized_flash(message: "Successful creation.") show_page.expect_invited(user, other_user) @@ -143,8 +143,8 @@ RSpec.describe "Meetings new", :js, with_cuprite: false do it "renders a validation error" do new_page.click_create - new_page.expect_toast(message: "#{Project.model_name.human} #{I18n.t('activerecord.errors.messages.blank')}", - type: :error) + expect_primerized_flash(type: :error, + message: "#{Project.model_name.human} #{I18n.t('activerecord.errors.messages.blank')}") new_page.expect_project_dropdown end @@ -178,7 +178,7 @@ RSpec.describe "Meetings new", :js, with_cuprite: false do show_page = new_page.click_create - show_page.expect_toast(message: "Successful creation") + expect_primerized_flash(message: "Successful creation.") # Not sure if that is then intended behaviour but that is what is currently programmed show_page.expect_invited(admin) @@ -194,8 +194,10 @@ RSpec.describe "Meetings new", :js, with_cuprite: false do it "renders a validation error" do new_page.click_create - new_page.expect_toast(message: "#{Project.model_name.human} #{I18n.t('activerecord.errors.messages.blank')}", - type: :error) + expect_primerized_flash( + message: "#{Project.model_name.human} #{I18n.t('activerecord.errors.messages.blank')}", + type: :error + ) new_page.expect_project_dropdown end end @@ -254,7 +256,7 @@ RSpec.describe "Meetings new", :js, with_cuprite: false do show_page = new_page.click_create - show_page.expect_toast(message: "Successful creation") + expect_primerized_flash(message: "Successful creation.") show_page.expect_invited(user, other_user) @@ -315,7 +317,7 @@ RSpec.describe "Meetings new", :js, with_cuprite: false do show_page = new_page.click_create - show_page.expect_toast(message: "Successful creation") + expect_primerized_flash(message: "Successful creation.") # Not sure if that is then intended behaviour but that is what is currently programmed show_page.expect_invited(admin) @@ -342,9 +344,9 @@ RSpec.describe "Meetings new", :js, with_cuprite: false do new_page.set_title "Some title" new_page.set_type "Classic" - show_page = new_page.click_create + new_page.click_create - show_page.expect_toast(message: "Successful creation") + expect_primerized_flash(message: "Successful creation.") meeting = Meeting.last @@ -352,7 +354,7 @@ RSpec.describe "Meetings new", :js, with_cuprite: false do field.submit_by_enter - show_page.expect_and_dismiss_toaster message: "Successful update" + expect_primerized_flash(message: "Successful update") meeting.reload diff --git a/spec/views/common/validation_error.html.erb_spec.rb b/spec/views/common/validation_error.html.erb_spec.rb deleted file mode 100644 index 70b4340476f..00000000000 --- a/spec/views/common/validation_error.html.erb_spec.rb +++ /dev/null @@ -1,54 +0,0 @@ -#-- copyright -# OpenProject is an open source project management software. -# Copyright (C) the OpenProject GmbH -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License version 3. -# -# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: -# Copyright (C) 2006-2013 Jean-Philippe Lang -# Copyright (C) 2010-2013 the ChiliProject Team -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# See COPYRIGHT and LICENSE files for more details. -#++ - -require "spec_helper" - -RSpec.describe "common/_validation_error" do - let(:base_error_messages) { ["Something went completely wrong!"] } - let(:fields_error_messages) { ["This field is incorrect.", "This cannot be blank."] } - - before do - view.content_for(:error_details, "Clear this!") - - render partial: "common/validation_error", - locals: { base_error_messages:, - fields_error_messages:, - object_name: "Test" } - end - - it "flushes the buffer before rendering" do - # that means the same partial can be called multiple times without side effects - expect(rendered).not_to include("Clear this!") - end - - it "includes all given error messages" do - expect(rendered).to include("Something went completely wrong!") - expect(rendered).to include("This field is incorrect.") - expect(rendered).to include("This cannot be blank.") - end -end From 5f1a4005c719a989e03a98c9810aa09362c70bdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Tue, 24 Sep 2024 15:08:46 +0200 Subject: [PATCH 04/14] Allow dismiss none --- app/helpers/errors_helper.rb | 3 +- app/helpers/flash_messages_helper.rb | 6 +-- app/views/common/_error_base.html.erb | 53 --------------------- app/views/common/_validation_error.html.erb | 42 ---------------- 4 files changed, 4 insertions(+), 100 deletions(-) delete mode 100644 app/views/common/_error_base.html.erb delete mode 100644 app/views/common/_validation_error.html.erb diff --git a/app/helpers/errors_helper.rb b/app/helpers/errors_helper.rb index f9cc42d21e0..a41b5fb2101 100644 --- a/app/helpers/errors_helper.rb +++ b/app/helpers/errors_helper.rb @@ -94,9 +94,8 @@ module ErrorsHelper @message_details = arg[:message_details] respond_to do |format| format.html do - binding.pry error_message = "[#{I18n.t(:error_code, code: @status)}] #{@message}\n#{@message_details}" - flash[:error] = error_message + flash.now[:op_primer_flash] = { scheme: :danger, message: error_message, dismiss_scheme: :none } render template: "common/error", layout: use_layout, status: @status end format.any do diff --git a/app/helpers/flash_messages_helper.rb b/app/helpers/flash_messages_helper.rb index cf047b012ae..4cb83c8878e 100644 --- a/app/helpers/flash_messages_helper.rb +++ b/app/helpers/flash_messages_helper.rb @@ -47,7 +47,7 @@ module FlashMessagesHelper def render_flash_content(key, content) case key when :op_primer_flash - render_flash_message(content[:scheme] || :default, content[:message]) + render_flash_message(content[:scheme] || :default, content[:message], **content.except(:message)) else render_flash_message(key, content) end @@ -74,8 +74,8 @@ module FlashMessagesHelper end end - def render_flash_message(type, message) - render(OpPrimer::FlashComponent.new(scheme: mapped_flash_type(type))) do + def render_flash_message(type, message, **args) + render(OpPrimer::FlashComponent.new(scheme: mapped_flash_type(type), **args.except(:scheme))) do join_flash_messages(message) end end diff --git a/app/views/common/_error_base.html.erb b/app/views/common/_error_base.html.erb deleted file mode 100644 index ef3c0370018..00000000000 --- a/app/views/common/_error_base.html.erb +++ /dev/null @@ -1,53 +0,0 @@ -<%#-- copyright -OpenProject is an open source project management software. -Copyright (C) the OpenProject GmbH - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License version 3. - -OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: -Copyright (C) 2006-2013 Jean-Philippe Lang -Copyright (C) 2010-2013 the ChiliProject Team - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -See COPYRIGHT and LICENSE files for more details. - -++#%> - -
-
- -
-
diff --git a/app/views/common/_validation_error.html.erb b/app/views/common/_validation_error.html.erb deleted file mode 100644 index 109649f48f2..00000000000 --- a/app/views/common/_validation_error.html.erb +++ /dev/null @@ -1,42 +0,0 @@ -<%#-- copyright -OpenProject is an open source project management software. -Copyright (C) the OpenProject GmbH - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License version 3. - -OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: -Copyright (C) 2006-2013 Jean-Philippe Lang -Copyright (C) 2010-2013 the ChiliProject Team - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -See COPYRIGHT and LICENSE files for more details. - -++#%> - -<% content_for :error_details, flush: true do %> - <%= list_of_messages(base_error_messages) %> - <%= text_header_invalid_fields(base_error_messages, fields_error_messages) %> - <%= list_of_messages(fields_error_messages) %> -<% end %> - -<%= render partial: "common/error_base", - locals: { - error_message: t("activerecord.errors.template.header", - model: object_name, - count: base_error_messages.count + fields_error_messages.count) - } -%> From 13cb707ff1ee8dc20c5aa2558bb30f5569dafaf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Tue, 24 Sep 2024 16:42:44 +0200 Subject: [PATCH 05/14] Don't output anything to remain compatible with <%= error_message_for xyz %> --- app/helpers/error_message_helper.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/helpers/error_message_helper.rb b/app/helpers/error_message_helper.rb index cbff1ba5c0a..c35ec8865d8 100644 --- a/app/helpers/error_message_helper.rb +++ b/app/helpers/error_message_helper.rb @@ -35,6 +35,9 @@ module ErrorMessageHelper return unless object assign_flash_error(object.errors, object) + + # Don't output anything for compability + nil end def assign_flash_error(errors, object) From 1a0281858c305b38a1b219d303b9e57f09714365 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Tue, 24 Sep 2024 16:42:49 +0200 Subject: [PATCH 06/14] Fix expected flash --- spec/support/primerized_flash/expectations.rb | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/spec/support/primerized_flash/expectations.rb b/spec/support/primerized_flash/expectations.rb index b431bf1bcb0..e13e222bfa2 100644 --- a/spec/support/primerized_flash/expectations.rb +++ b/spec/support/primerized_flash/expectations.rb @@ -1,9 +1,7 @@ module PrimerizedFlash module Expectations - include FlashMessagesHelper - def expect_primerized_flash(message:, type: :success, wait: 20) - mapped_scheme = mapped_flash_type(type) + mapped_scheme = expected_flash_type(type) expect(page).to have_css(".Banner--#{mapped_scheme}", text: message, wait:) end @@ -28,10 +26,23 @@ module PrimerizedFlash if type.nil? expect(page).not_to have_test_selector("op-primer-flash-message") else - mapped_scheme = mapped_flash_type(type) + mapped_scheme = expected_flash_type(type) expect(page).to have_no_css(".Banner--#{mapped_scheme}", text: message, wait:) end end + + def expected_flash_type(type) + case type + when :error + :error # The class is error, but the scheme is danger + when :warning + :warning + when :success, :notice + :success + else + :default + end + end end end From 1cf49e2c9fa747f87a8c2dcff20976ccaa29dec5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Tue, 24 Sep 2024 14:24:49 +0200 Subject: [PATCH 07/14] Adapt specs --- app/helpers/flash_messages_helper.rb | 2 +- .../features/backlogs_in_backlog_view_spec.rb | 12 +-- .../features/bcf/api_authorization_spec.rb | 4 +- .../features/card_view/bulk_actions_spec.rb | 2 +- .../spec/features/model_management_spec.rb | 2 +- .../bim/spec/features/model_viewer_spec.rb | 5 +- .../spec/features/board_management_spec.rb | 4 +- .../features/boards_global_create_spec.rb | 5 +- .../spec/features/support/board_index_page.rb | 2 +- .../spec/features/support/board_page.rb | 2 +- .../spec/features/budgets/add_budget_spec.rb | 2 +- .../budgets/attachment_upload_spec.rb | 4 + .../spec/features/budgets/copy_budget_spec.rb | 2 +- .../features/budgets/update_budget_spec.rb | 8 +- .../cost_entries/add_cost_entry_spec.rb | 4 +- .../add_entry_without_rate_permission_spec.rb | 2 +- .../spec/features/administration_spec.rb | 4 +- .../controllers/meetings_controller_spec.rb | 12 +-- .../features/meetings_participants_spec.rb | 2 +- .../spec/features/meetings_show_spec.rb | 2 +- .../structured_meetings/history_spec.rb | 2 +- .../components/cost_reports_base_table.rb | 5 +- .../storages/admin/create_storage_spec.rb | 4 +- .../spec/features/account_activation_spec.rb | 4 +- .../admin_edit_two_factor_devices_spec.rb | 2 +- .../login_with_backup_code_spec.rb | 2 +- .../features/login/login_enforced_2fa_spec.rb | 2 +- .../features/login/login_with_2fa_spec.rb | 2 +- .../features/my_two_factor_devices_spec.rb | 6 +- .../login_with_remember_cookie_spec.rb | 2 +- .../spec/features/shared_2fa_examples.rb | 9 +-- .../spec/features/manage_webhooks_spec.rb | 6 +- spec/controllers/news_controller_spec.rb | 2 +- .../features/activities/wiki_activity_spec.rb | 3 +- .../admin/attribute_help_texts_spec.rb | 2 +- .../admin/enterprise/enterprise_spec.rb | 10 +-- .../admin/enterprise/enterprise_trial_spec.rb | 4 +- .../oauth_applications_management_spec.rb | 6 +- spec/features/admin/progress_tracking_spec.rb | 4 +- .../admin/test_mail_notification_spec.rb | 2 +- spec/features/admin/working_days_spec.rb | 12 ++- spec/features/auth/consent_auth_stage_spec.rb | 6 +- spec/features/auth/lost_password_spec.rb | 10 +-- .../custom_fields/reorder_options_spec.rb | 2 +- .../custom_styles/tabs_navigation_spec.rb | 6 +- spec/features/groups/groups_spec.rb | 2 +- spec/features/homescreen/index_spec.rb | 2 +- spec/features/ldap_auth_sources/crud_spec.rb | 6 +- spec/features/members/pagination_spec.rb | 2 +- .../oauth/authorization_code_flow_spec.rb | 2 +- .../features/placeholder_users/create_spec.rb | 2 +- .../features/placeholder_users/delete_spec.rb | 2 +- .../edit_placeholder_users_spec.rb | 2 +- .../principals/shared_memberships_examples.rb | 2 +- spec/features/projects/destroy_spec.rb | 2 +- spec/features/projects/modules_spec.rb | 10 +-- .../overview_page/dialog/permission_spec.rb | 2 +- spec/features/projects/projects_index_spec.rb | 4 +- .../projects/projects_portfolio_spec.rb | 2 +- spec/features/projects/template_spec.rb | 1 + .../repositories/create_repository_spec.rb | 6 +- .../repositories/repository_settings_spec.rb | 3 +- spec/features/roles/create_spec.rb | 10 +-- spec/features/types/crud_spec.rb | 7 +- .../types/form_configuration_query_spec.rb | 14 ++-- .../features/types/form_configuration_spec.rb | 8 +- .../types/reset_form_configuration_spec.rb | 2 +- spec/features/users/create_spec.rb | 2 +- spec/features/users/edit_users_spec.rb | 4 +- spec/features/users/password_change_spec.rb | 12 +-- spec/features/versions/delete_spec.rb | 4 +- .../wiki/adding_editing_history_spec.rb | 1 + spec/features/wiki/attachment_upload_spec.rb | 7 +- spec/features/wiki/edit_new_page_spec.rb | 2 +- .../bulk/copy_work_package_spec.rb | 40 ++-------- .../bulk/move_work_package_spec.rb | 34 +++------ .../bulk/update_work_package_spec.rb | 55 +++++--------- .../display_fields/work_display_spec.rb | 2 +- .../features/work_packages/navigation_spec.rb | 6 +- spec/features/wysiwyg/autosave_spec.rb | 7 +- spec/features/wysiwyg/bold_behavior_spec.rb | 2 +- spec/features/wysiwyg/html_encoding_spec.rb | 2 +- spec/features/wysiwyg/linking_spec.rb | 2 +- .../wysiwyg/macros/attribute_macros_spec.rb | 4 +- .../wysiwyg/macros/child_pages_spec.rb | 4 +- .../wysiwyg/macros/code_block_macro_spec.rb | 8 +- .../wysiwyg/macros/embedded_tables_spec.rb | 8 +- .../wysiwyg/macros/quicklink_macros_spec.rb | 6 ++ .../macros/work_package_button_spec.rb | 2 +- spec/features/wysiwyg/tables_spec.rb | 10 +-- .../wysiwyg/work_package_linking_spec.rb | 2 +- spec/helpers/error_message_helper_spec.rb | 73 ++++++++++++------- .../password_confirmation_dialog.rb | 6 +- .../pages/admin/system_settings/languages.rb | 2 +- spec/support/pages/my/password_page.rb | 3 +- spec/support/pages/page.rb | 2 + spec/support/pages/projects/settings.rb | 5 -- .../work_packages/work_packages_table.rb | 2 +- spec/support/primerized_flash/expectations.rb | 29 ++++++-- spec/support/toasts/expectations.rb | 8 +- 100 files changed, 317 insertions(+), 329 deletions(-) diff --git a/app/helpers/flash_messages_helper.rb b/app/helpers/flash_messages_helper.rb index 4cb83c8878e..4f74da65c59 100644 --- a/app/helpers/flash_messages_helper.rb +++ b/app/helpers/flash_messages_helper.rb @@ -63,7 +63,7 @@ module FlashMessagesHelper def mapped_flash_type(type) case type - when :error + when :error, :danger :danger when :warning :warning diff --git a/modules/backlogs/spec/features/backlogs_in_backlog_view_spec.rb b/modules/backlogs/spec/features/backlogs_in_backlog_view_spec.rb index e981effb14a..b583338c337 100644 --- a/modules/backlogs/spec/features/backlogs_in_backlog_view_spec.rb +++ b/modules/backlogs/spec/features/backlogs_in_backlog_view_spec.rb @@ -185,8 +185,7 @@ RSpec.describe "Backlogs in backlog view", :js, click_button "Save" - backlogs_page - .expect_and_dismiss_toaster(message: "Successful update.") + expect_and_dismiss_primerized_flash(message: "Successful update.") backlogs_page .expect_backlog(sprint) @@ -206,8 +205,7 @@ RSpec.describe "Backlogs in backlog view", :js, click_button "Save" - backlogs_page - .expect_and_dismiss_toaster(message: "Successful update.") + expect_and_dismiss_primerized_flash(message: "Successful update.") # Now works as a sprint instead of a backlog backlogs_page @@ -228,8 +226,7 @@ RSpec.describe "Backlogs in backlog view", :js, click_button "Save" - backlogs_page - .expect_and_dismiss_toaster(message: "Successful update.") + expect_and_dismiss_primerized_flash(message: "Successful update.") # the disabled backlog/sprint is no longer visible expect(page) @@ -250,8 +247,7 @@ RSpec.describe "Backlogs in backlog view", :js, click_button "Save" - backlogs_page - .expect_and_dismiss_toaster(message: "Successful update.") + expect_and_dismiss_primerized_flash(message: "Successful update.") # the disabled backlog/sprint is no longer visible expect(page) diff --git a/modules/bim/spec/features/bcf/api_authorization_spec.rb b/modules/bim/spec/features/bcf/api_authorization_spec.rb index 5ae2fc055fe..620127b5326 100644 --- a/modules/bim/spec/features/bcf/api_authorization_spec.rb +++ b/modules/bim/spec/features/bcf/api_authorization_spec.rb @@ -57,11 +57,11 @@ RSpec.describe "authorization for BCF api", :js, with_config: { edition: "bim" } fill_in "application_redirect_uri", with: "not a url!" click_on "Create" - expect(page).to have_css(".errorExplanation", text: "Redirect URI must be an absolute URI.") + expect(page).to have_text("Redirect URI must be an absolute URI.") fill_in "application_redirect_uri", with: "urn:ietf:wg:oauth:2.0:oob\nhttps://localhost/my/callback" click_on "Create" - expect(page).to have_css(".op-toast.-success", text: "Successful creation.") + expect_primerized_flash(message: "Successful creation.") expect(page).to have_css(".attributes-key-value--key", text: "Client ID") diff --git a/modules/bim/spec/features/card_view/bulk_actions_spec.rb b/modules/bim/spec/features/card_view/bulk_actions_spec.rb index d193548e266..a861c3a40e9 100644 --- a/modules/bim/spec/features/card_view/bulk_actions_spec.rb +++ b/modules/bim/spec/features/card_view/bulk_actions_spec.rb @@ -103,7 +103,7 @@ RSpec.describe "Copy work packages through Rails view", :js, :with_cuprite, with select budget.subject, from: "work_package_budget_id" click_on "Submit" - wp_table.expect_and_dismiss_toaster message: "Successful update." + expect_and_dismiss_primerized_flash message: "Successful update." expect(work_package.reload.budget_id).to eq(budget.id) expect(work_package2.reload.budget_id).to eq(budget.id) diff --git a/modules/bim/spec/features/model_management_spec.rb b/modules/bim/spec/features/model_management_spec.rb index 914d0dd5a52..7d8686a3ca5 100644 --- a/modules/bim/spec/features/model_management_spec.rb +++ b/modules/bim/spec/features/model_management_spec.rb @@ -130,7 +130,7 @@ RSpec.describe "model management", :js, with_config: { edition: "bim" } do it "I can't see any models and perform no actions" do expected = "[Error 403] You are not authorized to access this page." - expect(page).to have_css(".op-toast.-error", text: expected) + expect_primerized_error(expected) index_page.add_model_allowed false end diff --git a/modules/bim/spec/features/model_viewer_spec.rb b/modules/bim/spec/features/model_viewer_spec.rb index 432570b68d5..cda6ce1b769 100644 --- a/modules/bim/spec/features/model_viewer_spec.rb +++ b/modules/bim/spec/features/model_viewer_spec.rb @@ -45,6 +45,7 @@ RSpec.describe "model viewer", :js, with_config: { edition: "bim" } do uploader: user) end + let(:show_default_page) { Pages::IfcModels::ShowDefault.new(project) } let(:show_model_page) { Pages::IfcModels::Show.new(project, model.id) } let(:model_tree) { Components::XeokitModelTree.new } let(:card_view) { Pages::WorkPackageCards.new(project) } @@ -93,7 +94,7 @@ RSpec.describe "model viewer", :js, with_config: { edition: "bim" } do it "shows a warning that no IFC models exist yet" do login_as user visit defaults_bcf_project_ifc_models_path(project) - expect(page).to have_css(".op-toast.-info", text: I18n.t("js.ifc_models.empty_warning")) + show_default_page.expect_toast(type: :info, message: I18n.t("js.ifc_models.empty_warning")) end end end @@ -134,7 +135,7 @@ RSpec.describe "model viewer", :js, with_config: { edition: "bim" } do it "shows no viewer" do expected = "[Error 403] You are not authorized to access this page." - expect(page).to have_css(".op-toast.-error", text: expected) + expect_primerized_error(expected) show_model_page.model_viewer_visible false show_model_page.model_viewer_shows_a_toolbar false diff --git a/modules/boards/spec/features/board_management_spec.rb b/modules/boards/spec/features/board_management_spec.rb index 7b135a8dd8b..cbc2ad6ca2f 100644 --- a/modules/boards/spec/features/board_management_spec.rb +++ b/modules/boards/spec/features/board_management_spec.rb @@ -300,7 +300,7 @@ RSpec.describe "Board management spec", :js, with_ee: %i[board_view] do it "does not allow viewing of boards" do visit project_work_package_board_path(project, board_view) - expect(page).to have_css("#errorExplanation", text: I18n.t(:notice_not_authorized)) + expect_primerized_error(I18n.t(:notice_not_authorized)) board_index.expect_editable false end @@ -311,7 +311,7 @@ RSpec.describe "Board management spec", :js, with_ee: %i[board_view] do it "does not allow viewing of boards" do board_index.visit! - expect(page).to have_css("#errorExplanation", text: I18n.t(:notice_not_authorized)) + expect_primerized_error(I18n.t(:notice_not_authorized)) end end end diff --git a/modules/boards/spec/features/boards_global_create_spec.rb b/modules/boards/spec/features/boards_global_create_spec.rb index 53b4ec50557..4f89197bfe8 100644 --- a/modules/boards/spec/features/boards_global_create_spec.rb +++ b/modules/boards/spec/features/boards_global_create_spec.rb @@ -195,8 +195,9 @@ RSpec.describe "Boards", it "renders a required attribute validation error" do expect(Boards::Grid.all).to be_empty - new_board_page.expect_toast message: "Project #{I18n.t('activerecord.errors.messages.blank')}", - type: :error + expect_primerized_flash message: "Project #{I18n.t('activerecord.errors.messages.blank')}", + type: :error + new_board_page.expect_project_dropdown end end diff --git a/modules/boards/spec/features/support/board_index_page.rb b/modules/boards/spec/features/support/board_index_page.rb index 4f438e22ab6..a775e63c0a5 100644 --- a/modules/boards/spec/features/support/board_index_page.rb +++ b/modules/boards/spec/features/support/board_index_page.rb @@ -72,7 +72,7 @@ module Pages new_board_page.set_board_type action new_board_page.click_on_submit - new_board_page.expect_and_dismiss_toaster + expect_and_dismiss_primerized_flash(message: I18n.t(:notice_successful_create)) if expect_empty expect(page).to have_css(".boards-list--add-item-text", wait: 10) diff --git a/modules/boards/spec/features/support/board_page.rb b/modules/boards/spec/features/support/board_page.rb index 6594631e11d..41dc462def9 100644 --- a/modules/boards/spec/features/support/board_page.rb +++ b/modules/boards/spec/features/support/board_page.rb @@ -284,7 +284,7 @@ module Pages click_dropdown_entry "Delete" accept_alert_dialog! - expect_and_dismiss_toaster message: I18n.t("js.notice_successful_delete") + expect_and_dismiss_primerized_flash message: I18n.t("js.notice_successful_delete") end def back_to_index diff --git a/modules/budgets/spec/features/budgets/add_budget_spec.rb b/modules/budgets/spec/features/budgets/add_budget_spec.rb index 7468c4f6cec..31cb1db2ffe 100644 --- a/modules/budgets/spec/features/budgets/add_budget_spec.rb +++ b/modules/budgets/spec/features/budgets/add_budget_spec.rb @@ -122,7 +122,7 @@ RSpec.describe "adding a new budget", :js do new_budget_page.add_labor_costs! "0,5", user_name: user.name, comment: "attendance", expected_costs: "12,50 EUR" page.find('[data-test-selector="budgets-create-button"]').click - expect(page).to have_content(I18n.t(:notice_successful_create, locale: :de)) + expect_and_dismiss_primerized_flash(message: I18n.t(:notice_successful_create, locale: :de)) expect(new_budget_page.unit_costs_at(1)).to have_content "175,00 EUR" expect(new_budget_page.unit_costs_at(2)).to have_content "50.025,00 EUR" diff --git a/modules/budgets/spec/features/budgets/attachment_upload_spec.rb b/modules/budgets/spec/features/budgets/attachment_upload_spec.rb index d671a269af6..cc39d82dd9f 100644 --- a/modules/budgets/spec/features/budgets/attachment_upload_spec.rb +++ b/modules/budgets/spec/features/budgets/attachment_upload_spec.rb @@ -59,6 +59,8 @@ RSpec.describe "Upload attachment to budget", :js do click_on "Create" + expect_and_dismiss_primerized_flash(message: "Successful creation.") + expect(page).to have_css("#content img", count: 1) expect(page).to have_content("Image uploaded on creation") attachments_list.expect_attached("image.png") @@ -96,6 +98,8 @@ RSpec.describe "Upload attachment to budget", :js do click_on "Create" + expect_and_dismiss_primerized_flash(message: "Successful creation.") + attachments_list.expect_attached("image.png") within ".toolbar-items" do diff --git a/modules/budgets/spec/features/budgets/copy_budget_spec.rb b/modules/budgets/spec/features/budgets/copy_budget_spec.rb index ddd4cead7b8..6d327d4aef5 100644 --- a/modules/budgets/spec/features/budgets/copy_budget_spec.rb +++ b/modules/budgets/spec/features/budgets/copy_budget_spec.rb @@ -88,7 +88,7 @@ RSpec.describe "Copying a budget", :js do click_button "Create" - budget_page.expect_toast message: "Successful creation." + expect_primerized_flash message: "Successful creation." expect(page) .to have_css(".author", text: current_user.name) diff --git a/modules/budgets/spec/features/budgets/update_budget_spec.rb b/modules/budgets/spec/features/budgets/update_budget_spec.rb index 0826e0fe0e2..6f56ce8049a 100644 --- a/modules/budgets/spec/features/budgets/update_budget_spec.rb +++ b/modules/budgets/spec/features/budgets/update_budget_spec.rb @@ -181,7 +181,7 @@ RSpec.describe "updating a budget", :js do # Update first element budget_page.edit_planned_costs! material_budget_item.id, type: :material, costs: 123 - expect(budget_page).to have_content("Successful update") + expect_and_dismiss_primerized_flash(message: "Successful update") expect(page).to have_css("tbody td.currency", text: "123.00 EUR") click_on "Update" @@ -218,7 +218,7 @@ RSpec.describe "updating a budget", :js do # Update first element budget_page.edit_planned_costs! material_budget_item.id, type: :material, costs: 123 - expect(budget_page).to have_content("Successful update") + expect_and_dismiss_primerized_flash(message: "Successful update") expect(page).to have_css("tbody td.currency", text: "USD 123.00") click_on "Update" @@ -258,7 +258,7 @@ RSpec.describe "updating a budget", :js do # Update first element budget_page.edit_planned_costs! labor_budget_item.id, type: :labor, costs: 456 - expect(budget_page).to have_content("Successful update") + expect_and_dismiss_primerized_flash(message: "Successful update") expect(page).to have_css("tbody td.currency", text: "456.00 EUR") click_on "Update" @@ -295,7 +295,7 @@ RSpec.describe "updating a budget", :js do # Update first element budget_page.edit_planned_costs! labor_budget_item.id, type: :labor, costs: 456 - expect(budget_page).to have_content("Successful update") + expect_and_dismiss_primerized_flash(message: "Successful update") expect(page).to have_css("tbody td.currency", text: "USD 456.00") click_on "Update" diff --git a/modules/costs/spec/features/cost_entries/add_cost_entry_spec.rb b/modules/costs/spec/features/cost_entries/add_cost_entry_spec.rb index 45bb72287dc..de2b07cffda 100644 --- a/modules/costs/spec/features/cost_entries/add_cost_entry_spec.rb +++ b/modules/costs/spec/features/cost_entries/add_cost_entry_spec.rb @@ -99,7 +99,7 @@ RSpec.describe "Work Package cost fields", :js do click_on "Save" # Expect correct costs - expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_cost_logged_successfully)) + expect_primerized_flash(message: I18n.t(:notice_cost_logged_successfully)) entry = CostEntry.last expect(entry.cost_type_id).to eq(cost_type2.id) expect(entry.units).to eq(2.0) @@ -136,7 +136,7 @@ RSpec.describe "Work Package cost fields", :js do click_on I18n.t(:button_save) # Expect correct costs - expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_cost_logged_successfully)) + expect_primerized_flash(message: I18n.t(:notice_cost_logged_successfully)) entry = CostEntry.last expect(entry.cost_type_id).to eq(cost_type2.id) expect(entry.units).to eq(1.42) diff --git a/modules/costs/spec/features/cost_entries/add_entry_without_rate_permission_spec.rb b/modules/costs/spec/features/cost_entries/add_entry_without_rate_permission_spec.rb index 9251a61176d..ce5e0bc12df 100644 --- a/modules/costs/spec/features/cost_entries/add_entry_without_rate_permission_spec.rb +++ b/modules/costs/spec/features/cost_entries/add_entry_without_rate_permission_spec.rb @@ -77,7 +77,7 @@ RSpec.describe "Create cost entry without rate permissions", :js do click_on "Save" # Expect correct costs - expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_cost_logged_successfully)) + expect_primerized_flash(message: I18n.t(:notice_cost_logged_successfully)) entry = CostEntry.last expect(entry.cost_type_id).to eq(cost_type.id) expect(entry.units).to eq(1.0) diff --git a/modules/ldap_groups/spec/features/administration_spec.rb b/modules/ldap_groups/spec/features/administration_spec.rb index 98570a21c8d..fa2110dbe21 100644 --- a/modules/ldap_groups/spec/features/administration_spec.rb +++ b/modules/ldap_groups/spec/features/administration_spec.rb @@ -35,7 +35,7 @@ RSpec.describe "LDAP group sync administration spec", :js do check "synchronized_group_sync_users" click_on "Create" - expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_create)) + expect_primerized_flash(message: I18n.t(:notice_successful_create)) expect(page).to have_css("td.dn", text: "cn=foo,ou=groups,dc=example,dc=com") expect(page).to have_css("td.ldap_auth_source", text: "ldap") expect(page).to have_css("td.group", text: "foo") @@ -69,7 +69,7 @@ RSpec.describe "LDAP group sync administration spec", :js do SeleniumHubWaiter.wait click_on "Delete" - expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_delete)) + expect_primerized_flash(message: I18n.t(:notice_successful_delete)) expect(page).to have_css ".generic-table--empty-row" expect(LdapGroups::Membership.where(id: memberships)).to be_empty diff --git a/modules/meeting/spec/controllers/meetings_controller_spec.rb b/modules/meeting/spec/controllers/meetings_controller_spec.rb index 3f121a2cd39..3987e81a9f8 100644 --- a/modules/meeting/spec/controllers/meetings_controller_spec.rb +++ b/modules/meeting/spec/controllers/meetings_controller_spec.rb @@ -167,8 +167,7 @@ RSpec.describe MeetingsController do expect(response).to have_http_status :ok expect(response).to render_template :new expect(response.body) - .to have_css "#errorExplanation li", - text: "Date #{I18n.t('activerecord.errors.messages.not_an_iso_date')}" + .to have_text("Date #{I18n.t('activerecord.errors.messages.not_an_iso_date')}") end end @@ -181,8 +180,7 @@ RSpec.describe MeetingsController do expect(response).to have_http_status :ok expect(response).to render_template :new expect(response.body) - .to have_css "#errorExplanation li", - text: "Start time #{I18n.t('activerecord.errors.messages.invalid_time_format')}" + .to have_text("Start time #{I18n.t('activerecord.errors.messages.invalid_time_format')}") end end end @@ -194,8 +192,7 @@ RSpec.describe MeetingsController do expect(response).to have_http_status :ok expect(response).to render_template :new expect(response.body) - .to have_css "#errorExplanation li", - text: "Project #{I18n.t('activerecord.errors.messages.blank')}" + .to have_text("Project #{I18n.t('activerecord.errors.messages.blank')}") end end @@ -207,8 +204,7 @@ RSpec.describe MeetingsController do expect(response).to have_http_status :ok expect(response).to render_template :new expect(response.body) - .to have_css "#errorExplanation li", - text: "Project #{I18n.t('activerecord.errors.messages.blank')}" + .to have_text("Project #{I18n.t('activerecord.errors.messages.blank')}") end end end diff --git a/modules/meeting/spec/features/meetings_participants_spec.rb b/modules/meeting/spec/features/meetings_participants_spec.rb index 79de4ab783b..fb368810e16 100644 --- a/modules/meeting/spec/features/meetings_participants_spec.rb +++ b/modules/meeting/spec/features/meetings_participants_spec.rb @@ -64,7 +64,7 @@ RSpec.describe "Meetings participants" do edit_page.invite(viewer_user) show_page = edit_page.click_save - show_page.expect_toast(message: "Successful update") + expect_primerized_flash(message: "Successful update") show_page.expect_invited(viewer_user) diff --git a/modules/meeting/spec/features/meetings_show_spec.rb b/modules/meeting/spec/features/meetings_show_spec.rb index 061c2315186..467abb62ed8 100644 --- a/modules/meeting/spec/features/meetings_show_spec.rb +++ b/modules/meeting/spec/features/meetings_show_spec.rb @@ -126,7 +126,7 @@ RSpec.describe "Meetings", :js do field.submit_by_enter - show_page.expect_and_dismiss_toaster message: "Successful update" + expect_and_dismiss_primerized_flash(message: "Successful update") meeting.reload diff --git a/modules/meeting/spec/features/structured_meetings/history_spec.rb b/modules/meeting/spec/features/structured_meetings/history_spec.rb index 64c7e1047f9..ffafbdaea5e 100644 --- a/modules/meeting/spec/features/structured_meetings/history_spec.rb +++ b/modules/meeting/spec/features/structured_meetings/history_spec.rb @@ -355,6 +355,6 @@ RSpec.describe "history", visit history_meeting_path(meeting) expected = "[Error 403] You are not authorized to access this page." - expect(page).to have_css(".op-toast.-error", text: expected) + expect_primerized_error(expected) end end diff --git a/modules/reporting/spec/features/support/components/cost_reports_base_table.rb b/modules/reporting/spec/features/support/components/cost_reports_base_table.rb index cc8c3a5c3ba..aab032b1734 100644 --- a/modules/reporting/spec/features/support/components/cost_reports_base_table.rb +++ b/modules/reporting/spec/features/support/components/cost_reports_base_table.rb @@ -26,11 +26,14 @@ # See COPYRIGHT and LICENSE files for more details. #++ +require "support/primerized_flash/expectations" + module Components class CostReportsBaseTable include Capybara::DSL include Capybara::RSpecMatchers include RSpec::Matchers + include PrimerizedFlash::Expectations attr_reader :time_logging_modal @@ -78,7 +81,7 @@ module Components SeleniumHubWaiter.wait fill_in("cost_entry_units", with: new_value) click_button "Save" - expect(page).to have_css(".op-toast.-success") + expect_primerized_flash(message: "Successful update.") end def delete_entry(row) diff --git a/modules/storages/spec/features/storages/admin/create_storage_spec.rb b/modules/storages/spec/features/storages/admin/create_storage_spec.rb index bf5c1781c22..a59d19c7360 100644 --- a/modules/storages/spec/features/storages/admin/create_storage_spec.rb +++ b/modules/storages/spec/features/storages/admin/create_storage_spec.rb @@ -181,7 +181,7 @@ RSpec.describe "Admin Create a new file storage", expect(page).to have_current_path(edit_admin_settings_storage_path(Storages::Storage.last)) expect(page).to have_test_selector( - "primer-banner-message-component", + "op-primer-flash-message", text: "Storage connected successfully! Remember to activate the module and the specific " \ "storage in the project settings of each desired project to use it." ) @@ -318,7 +318,7 @@ RSpec.describe "Admin Create a new file storage", expect(page).to have_current_path(edit_admin_settings_storage_path(Storages::Storage.last)) wait_for { page }.to have_test_selector( - "primer-banner-message-component", + "op-primer-flash-message", text: "Storage connected successfully! Remember to activate the module and the specific " \ "storage in the project settings of each desired project to use it." ) diff --git a/modules/two_factor_authentication/spec/features/account_activation_spec.rb b/modules/two_factor_authentication/spec/features/account_activation_spec.rb index 7d1f3118bd5..111c2bf10e2 100644 --- a/modules/two_factor_authentication/spec/features/account_activation_spec.rb +++ b/modules/two_factor_authentication/spec/features/account_activation_spec.rb @@ -50,7 +50,7 @@ RSpec.describe "activating an invited account", :js, activate! - expect(page).to have_css(".op-toast.-success", text: "Developer strategy generated the following one-time password:") + expect_primerized_flash(message: "Developer strategy generated the following one-time password:") SeleniumHubWaiter.wait fill_in I18n.t(:field_otp), with: sms_token @@ -63,7 +63,7 @@ RSpec.describe "activating an invited account", :js, it "handles faulty user input on two factor authentication" do activate! - expect(page).to have_css(".op-toast.-success", text: "Developer strategy generated the following one-time password:") + expect_primerized_flash(message: "Developer strategy generated the following one-time password:") fill_in I18n.t(:field_otp), with: "asdf" # faulty token click_button I18n.t(:button_login) diff --git a/modules/two_factor_authentication/spec/features/admin_edit_two_factor_devices_spec.rb b/modules/two_factor_authentication/spec/features/admin_edit_two_factor_devices_spec.rb index 86c5d6230c3..6d868259c62 100644 --- a/modules/two_factor_authentication/spec/features/admin_edit_two_factor_devices_spec.rb +++ b/modules/two_factor_authentication/spec/features/admin_edit_two_factor_devices_spec.rb @@ -44,7 +44,7 @@ RSpec.describe "Admin 2FA management", :js, with_settings: { click_button I18n.t(:button_continue) # Enter valid phone number - expect(page).to have_css("#errorExplanation", text: "Phone number must be of format +XX XXXXXXXXX") + expect_primerized_error("Phone number must be of format +XX XXXXXXXXX") SeleniumHubWaiter.wait fill_in "device_phone_number", with: "+49 123456789" diff --git a/modules/two_factor_authentication/spec/features/backup_codes/login_with_backup_code_spec.rb b/modules/two_factor_authentication/spec/features/backup_codes/login_with_backup_code_spec.rb index 628c10f9e54..b2bfe0e6310 100644 --- a/modules/two_factor_authentication/spec/features/backup_codes/login_with_backup_code_spec.rb +++ b/modules/two_factor_authentication/spec/features/backup_codes/login_with_backup_code_spec.rb @@ -50,7 +50,7 @@ RSpec.describe "Login with 2FA backup code", :js, with_settings: { click_on "Submit" # Expect failure - expect(page).to have_css(".op-toast.-error", text: I18n.t("two_factor_authentication.error_invalid_backup_code")) + expect_primerized_error(I18n.t("two_factor_authentication.error_invalid_backup_code")) expect(page).to have_current_path signin_path # Try again! diff --git a/modules/two_factor_authentication/spec/features/login/login_enforced_2fa_spec.rb b/modules/two_factor_authentication/spec/features/login/login_enforced_2fa_spec.rb index 18f840fdacd..7af11b31c1f 100644 --- a/modules/two_factor_authentication/spec/features/login/login_enforced_2fa_spec.rb +++ b/modules/two_factor_authentication/spec/features/login/login_enforced_2fa_spec.rb @@ -36,7 +36,7 @@ RSpec.describe "Login with enforced 2FA", :js, with_settings: { first_login_step two_factor_step("whatever") - expect(page).to have_css(".op-toast.-error", text: I18n.t(:notice_account_otp_invalid)) + expect_primerized_error(I18n.t(:notice_account_otp_invalid)) expect(page).to have_current_path signin_path end end diff --git a/modules/two_factor_authentication/spec/features/login/login_with_2fa_spec.rb b/modules/two_factor_authentication/spec/features/login/login_with_2fa_spec.rb index 52a93882d14..75df63bbf05 100644 --- a/modules/two_factor_authentication/spec/features/login/login_with_2fa_spec.rb +++ b/modules/two_factor_authentication/spec/features/login/login_with_2fa_spec.rb @@ -35,7 +35,7 @@ RSpec.describe "Login with 2FA device", :js, with_settings: { first_login_step two_factor_step("whatever") - expect(page).to have_css(".op-toast.-error", text: I18n.t(:notice_account_otp_invalid)) + expect_primerized_error(I18n.t(:notice_account_otp_invalid)) expect(page).to have_current_path signin_path end end diff --git a/modules/two_factor_authentication/spec/features/my_two_factor_devices_spec.rb b/modules/two_factor_authentication/spec/features/my_two_factor_devices_spec.rb index 454362cc5a9..0271c7f9ec4 100644 --- a/modules/two_factor_authentication/spec/features/my_two_factor_devices_spec.rb +++ b/modules/two_factor_authentication/spec/features/my_two_factor_devices_spec.rb @@ -35,7 +35,7 @@ RSpec.describe "My Account 2FA configuration", :js, with_settings: { click_button I18n.t(:button_continue) # Enter valid phone number - expect(page).to have_css("#errorExplanation", text: "Phone number must be of format +XX XXXXXXXXX") + expect_primerized_error("Phone number must be of format +XX XXXXXXXXX") fill_in "device_phone_number", with: "+49 123456789" click_button I18n.t(:button_continue) @@ -55,8 +55,8 @@ RSpec.describe "My Account 2FA configuration", :js, with_settings: { expect(page).to have_css("h2", text: I18n.t("two_factor_authentication.devices.confirm_device")) expect(page).to have_css("input#otp") - expect(page).to have_css(".op-toast.-error", - text: I18n.t("two_factor_authentication.devices.registration_failed_token_invalid")) + + expect_primerized_error(I18n.t("two_factor_authentication.devices.registration_failed_token_invalid")) # Fill in correct token fill_in "otp", with: sms_token diff --git a/modules/two_factor_authentication/spec/features/remember_cookie/login_with_remember_cookie_spec.rb b/modules/two_factor_authentication/spec/features/remember_cookie/login_with_remember_cookie_spec.rb index dc11cfc1575..1d53df292ee 100644 --- a/modules/two_factor_authentication/spec/features/remember_cookie/login_with_remember_cookie_spec.rb +++ b/modules/two_factor_authentication/spec/features/remember_cookie/login_with_remember_cookie_spec.rb @@ -60,7 +60,7 @@ RSpec.describe "Login with 2FA remember cookie", :js, with_settings: { visit my_2fa_devices_path find(".two-factor-authentication--remove-remember-cookie-link").click - expect(page).to have_css(".op-toast.-success") + expect_primerized_flash(message: I18n.t("two_factor_authentication.remember.cookie_removed")) expect(page).to have_no_css(".two-factor-authentication--remove-remember-cookie-link") # Log out and in again diff --git a/modules/two_factor_authentication/spec/features/shared_2fa_examples.rb b/modules/two_factor_authentication/spec/features/shared_2fa_examples.rb index 461a35b159b..cad8428e776 100644 --- a/modules/two_factor_authentication/spec/features/shared_2fa_examples.rb +++ b/modules/two_factor_authentication/spec/features/shared_2fa_examples.rb @@ -35,8 +35,8 @@ end RSpec.shared_examples "create enforced sms device" do it do - expect(page).to have_css(".op-toast.-info", - text: I18n.t("two_factor_authentication.forced_registration.required_to_add_device")) + expect_primerized_flash(type: :info, + message: I18n.t("two_factor_authentication.forced_registration.required_to_add_device")) SeleniumHubWaiter.wait # Create SMS device @@ -46,7 +46,7 @@ RSpec.shared_examples "create enforced sms device" do click_on "Continue" # Expect error on invalid phone - expect(page).to have_css("#errorExplanation", text: "Phone number must be of format +XX XXXXXXXXX") + expect_primerized_error("Phone number must be of format +XX XXXXXXXXX") SeleniumHubWaiter.wait fill_in "device_phone_number", with: "+49 123456789" @@ -71,8 +71,7 @@ RSpec.shared_examples "create enforced sms device" do expect(page).to have_css("h2", text: I18n.t("two_factor_authentication.devices.confirm_device")) expect(page).to have_css("input#otp") - expect(page).to have_css(".op-toast.-error", - text: I18n.t("two_factor_authentication.devices.registration_failed_token_invalid")) + expect_primerized_error(I18n.t("two_factor_authentication.devices.registration_failed_token_invalid")) SeleniumHubWaiter.wait # Fill in wrong token diff --git a/modules/webhooks/spec/features/manage_webhooks_spec.rb b/modules/webhooks/spec/features/manage_webhooks_spec.rb index dad6fbf95bf..021974c191d 100644 --- a/modules/webhooks/spec/features/manage_webhooks_spec.rb +++ b/modules/webhooks/spec/features/manage_webhooks_spec.rb @@ -40,7 +40,7 @@ RSpec.describe "Manage webhooks through UI", :js do # 1st webhook created # - expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_create)) + expect_primerized_flash(message: I18n.t(:notice_successful_create)) expect(page).to have_css(".webhooks--outgoing-webhook-row .name", text: "My webhook") webhook = Webhooks::Webhook.last expect(webhook.event_names).to eq %w(work_package:created) @@ -65,7 +65,7 @@ RSpec.describe "Manage webhooks through UI", :js do find(".webhooks--selected-project-ids[value='#{project.id}']").set true click_on "Save" - expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_update)) + expect_primerized_flash(message: I18n.t(:notice_successful_update)) expect(page).to have_css(".webhooks--outgoing-webhook-row .name", text: "My webhook") webhook = Webhooks::Webhook.last expect(webhook.event_names).to eq %w(work_package:updated) @@ -77,7 +77,7 @@ RSpec.describe "Manage webhooks through UI", :js do find(".webhooks--outgoing-webhook-row-#{webhook.id} .icon-delete").click page.driver.browser.switch_to.alert.accept - expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_delete)) + expect_primerized_flash(message: I18n.t(:notice_successful_delete)) expect(page).to have_css(".generic-table--empty-row") end diff --git a/spec/controllers/news_controller_spec.rb b/spec/controllers/news_controller_spec.rb index 1152e039549..d4cc219016a 100644 --- a/spec/controllers/news_controller_spec.rb +++ b/spec/controllers/news_controller_spec.rb @@ -133,7 +133,7 @@ RSpec.describe NewsController do expect(assigns(:news)).not_to be_nil expect(assigns(:news)).to be_new_record - expect(response.body).to have_css("div.op-toast.-error", text: /1 error/) + expect(response.body).to have_text /1 error/ end end diff --git a/spec/features/activities/wiki_activity_spec.rb b/spec/features/activities/wiki_activity_spec.rb index 05db9c7e71e..5fa22673c09 100644 --- a/spec/features/activities/wiki_activity_spec.rb +++ b/spec/features/activities/wiki_activity_spec.rb @@ -52,7 +52,8 @@ RSpec.describe "Wiki Activity", :js, :with_cuprite do editor.set_markdown("First content") click_button "Save" - expect(page).to have_text("Successful creation") + + expect_and_dismiss_primerized_flash(message: "Successful creation.") # We mock letting some time pass by altering the timestamps Journal.last.update_columns(created_at: Time.now - 5.days, updated_at: Time.now - 5.days) diff --git a/spec/features/admin/attribute_help_texts_spec.rb b/spec/features/admin/attribute_help_texts_spec.rb index f9b0e0b08aa..ad855dc80af 100644 --- a/spec/features/admin/attribute_help_texts_spec.rb +++ b/spec/features/admin/attribute_help_texts_spec.rb @@ -113,7 +113,7 @@ RSpec.describe "Attribute help texts", :js, :with_cuprite do click_button "Save" # Handle errors - expect(page).to have_css("#errorExplanation", text: "Help text can't be blank.") + expect_primerized_error("Help text can't be blank.") SeleniumHubWaiter.wait editor.set_markdown("New**help**text") click_button "Save" diff --git a/spec/features/admin/enterprise/enterprise_spec.rb b/spec/features/admin/enterprise/enterprise_spec.rb index 671c6db311f..78e92e56d34 100644 --- a/spec/features/admin/enterprise/enterprise_spec.rb +++ b/spec/features/admin/enterprise/enterprise_spec.rb @@ -60,9 +60,7 @@ RSpec.describe "Enterprise token", :js, :with_cuprite do submit_button.click # Error output - expect(page).to have_css(".errorExplanation", - text: "Enterprise support token can't be read. " \ - "Are you sure it is a support token?") + expect_primerized_error("Enterprise support token can't be read. Are you sure it is a support token?") within "span.errorSpan" do expect(page).to have_css("#enterprise_token_encoded_token") @@ -78,7 +76,7 @@ RSpec.describe "Enterprise token", :js, :with_cuprite do textarea.set "foobar" submit_button.click - expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_update)) + expect_primerized_flash(message: I18n.t(:notice_successful_update)) expect(page).to have_test_selector("op-enterprise--active-token") expect(page.all(".attributes-key-value--key").map(&:text)) @@ -101,7 +99,7 @@ RSpec.describe "Enterprise token", :js, :with_cuprite do wait_for_reload - expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_update)) + expect_primerized_flash(message: I18n.t(:notice_successful_update)) # Assume next request RequestStore.clear! @@ -115,7 +113,7 @@ RSpec.describe "Enterprise token", :js, :with_cuprite do wait_for_reload - expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_delete)) + expect_primerized_flash(message: I18n.t(:notice_successful_delete)) # Assume next request RequestStore.clear! diff --git a/spec/features/admin/enterprise/enterprise_trial_spec.rb b/spec/features/admin/enterprise/enterprise_trial_spec.rb index 8d5034e4cac..5781161e192 100644 --- a/spec/features/admin/enterprise/enterprise_trial_spec.rb +++ b/spec/features/admin/enterprise/enterprise_trial_spec.rb @@ -257,7 +257,7 @@ RSpec.describe "Enterprise trial management", it "can confirm that trial regularly" do find_test_selector("op-ee-trial-waiting-resend-link", text: "Resend").click - expect(page).to have_css(".op-toast.-success", text: "Email has been resent.", wait: 20) + expect(page).to have_css(".op-toast", text: "Email has been resent.", wait: 20) expect(page).to have_text "foo@foocorp.example" expect(page).to have_text "email sent - waiting for confirmation" @@ -276,7 +276,7 @@ RSpec.describe "Enterprise trial management", # advance to close click_on "Continue" - expect(page).to have_css(".op-toast.-success", text: "Successful update.", wait: 10) + expect_and_dismiss_primerized_flash(message: "Successful update.") expect(page).to have_css(".attributes-key-value--value-container", text: "OpenProject Test") expect(page).to have_css(".attributes-key-value--value-container", text: "01/01/2020") expect(page).to have_css(".attributes-key-value--value-container", text: "01/02/2020") diff --git a/spec/features/admin/oauth/oauth_applications_management_spec.rb b/spec/features/admin/oauth/oauth_applications_management_spec.rb index 7d52221b373..63119d2e3a2 100644 --- a/spec/features/admin/oauth/oauth_applications_management_spec.rb +++ b/spec/features/admin/oauth/oauth_applications_management_spec.rb @@ -49,20 +49,20 @@ RSpec.describe "OAuth applications management", :js, :with_cuprite do fill_in "application_redirect_uri", with: "not a url!" click_on "Create" - expect(page).to have_css(".errorExplanation", text: "Redirect URI must be an absolute URI.") + expect_primerized_error("Redirect URI must be an absolute URI.") fill_in("application_redirect_uri", with: "") # Fill redirect_uri which does not provide a Secure Context fill_in "application_redirect_uri", with: "http://example.org" click_on "Create" - expect(page).to have_css(".errorExplanation", text: 'Redirect URI is not providing a "Secure Context"') + expect_primerized_error('Redirect URI is not providing a "Secure Context"') # Can create localhost without https (https://community.openproject.com/wp/34025) fill_in "application_redirect_uri", with: "urn:ietf:wg:oauth:2.0:oob\nhttp://localhost/my/callback" click_on "Create" - expect(page).to have_css(".op-toast.-success", text: "Successful creation.") + expect_primerized_flash(message: "Successful creation.") expect(page).to have_css(".attributes-key-value--key", text: "Client ID") expect(page).to have_css(".attributes-key-value--value", text: "urn:ietf:wg:oauth:2.0:oob\nhttp://localhost/my/callback") diff --git a/spec/features/admin/progress_tracking_spec.rb b/spec/features/admin/progress_tracking_spec.rb index 89eb989ee2e..647455b45f2 100644 --- a/spec/features/admin/progress_tracking_spec.rb +++ b/spec/features/admin/progress_tracking_spec.rb @@ -51,7 +51,7 @@ RSpec.describe "Progress tracking admin page", :js, :with_cuprite do expect(page).to have_text(expected_warning_text) click_on "Save" - expect_and_dismiss_toaster(message: "Successful update.") + expect_and_dismiss_primerized_flash(message: "Successful update.") expect(Setting.find_by(name: "work_package_done_ratio").value).to eq("status") # now change from status-based to work-based @@ -65,7 +65,7 @@ RSpec.describe "Progress tracking admin page", :js, :with_cuprite do expect(page).to have_text(expected_warning_text) click_on "Save" - expect_and_dismiss_toaster(message: "Successful update.") + expect_and_dismiss_primerized_flash(message: "Successful update.") expect(Setting.find_by(name: "work_package_done_ratio").value).to eq("field") end diff --git a/spec/features/admin/test_mail_notification_spec.rb b/spec/features/admin/test_mail_notification_spec.rb index a233bef9d23..97b2d3579ec 100644 --- a/spec/features/admin/test_mail_notification_spec.rb +++ b/spec/features/admin/test_mail_notification_spec.rb @@ -44,7 +44,7 @@ RSpec.describe "Test mail notification", :js, :with_cuprite do click_link "Send a test email" expected = "An error occurred while sending mail (#{error_message})" - expect(page).to have_css(".op-toast.-error", text: expected) + expect_primerized_error(expected) expect(page).to have_no_css(".op-toast.-error strong") end end diff --git a/spec/features/admin/working_days_spec.rb b/spec/features/admin/working_days_spec.rb index dc49660bf8b..67dcc545b13 100644 --- a/spec/features/admin/working_days_spec.rb +++ b/spec/features/admin/working_days_spec.rb @@ -101,7 +101,7 @@ RSpec.describe "Working Days", :js, :with_cuprite do dialog.confirm end - expect(page).to have_css(".op-toast.-success", text: "Successful update.") + expect_primerized_flash(message: "Successful update.") expect(page).to have_unchecked_field "Monday" expect(page).to have_unchecked_field "Friday" expect(page).to have_unchecked_field "Saturday" @@ -141,8 +141,7 @@ RSpec.describe "Working Days", :js, :with_cuprite do dialog.confirm end - expect(page).to have_css(".op-toast.-error", - text: "At least one day of the week must be defined as a working day.") + expect_primerized_error("At least one day of the week must be defined as a working day.") # Restore the checkboxes to their valid state expect(page).to have_checked_field "Monday" expect(page).to have_checked_field "Tuesday" @@ -172,8 +171,7 @@ RSpec.describe "Working Days", :js, :with_cuprite do # Not executing the background jobs dialog.confirm - expect(page).to have_css(".op-toast.-error", - text: "The previous changes to the working days configuration have not been applied yet.") + expect_primerized_error("The previous changes to the working days configuration have not been applied yet.") end end @@ -230,7 +228,7 @@ RSpec.describe "Working Days", :js, :with_cuprite do click_on "Apply changes" click_on "Save and reschedule" - expect(page).to have_css(".op-toast.-success", text: "Successful update.") + expect_primerized_flash(message: "Successful update.") nwd1 = NonWorkingDay.find_by(name: "My holiday") expect(nwd1.date).to eq date1 @@ -310,6 +308,6 @@ RSpec.describe "Working Days", :js, :with_cuprite do click_on "Apply changes" # No dialog and saved successfully - expect(page).to have_css(".op-toast.-success") + expect_primerized_flash(message: "Successful update.") end end diff --git a/spec/features/auth/consent_auth_stage_spec.rb b/spec/features/auth/consent_auth_stage_spec.rb index e58cd7e7f5e..2c4b968bad1 100644 --- a/spec/features/auth/consent_auth_stage_spec.rb +++ b/spec/features/auth/consent_auth_stage_spec.rb @@ -168,7 +168,7 @@ RSpec.describe "Authentication Stages" do find_by_id("toggle_consent_time").set(true) click_on "Save" - expect(page).to have_css(".op-toast.-success") + expect_primerized_flash(message: "Successful update.") Setting.clear_cache expect(Setting.consent_time).to be_present @@ -215,7 +215,7 @@ RSpec.describe "Authentication Stages" do check "consent_check" click_on I18n.t(:button_create) - expect(page).to have_css(".op-toast.-success") + expect_primerized_flash(message: I18n.t(:notice_account_registered_and_logged_in)) expect_logged_in("/?first_time_user=true") end @@ -256,7 +256,7 @@ RSpec.describe "Authentication Stages" do # Decline the consent click_on I18n.t(:button_decline) - expect(page).to have_css(".op-toast.-error", text: "foo@example.org") + expect_primerized_error("foo@example.org") end end end diff --git a/spec/features/auth/lost_password_spec.rb b/spec/features/auth/lost_password_spec.rb index dcfb91ce1b9..7bfd9be964d 100644 --- a/spec/features/auth/lost_password_spec.rb +++ b/spec/features/auth/lost_password_spec.rb @@ -39,14 +39,14 @@ RSpec.describe "Lost password" do fill_in "mail", with: "invalid mail" click_on "Submit" - expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_account_lost_email_sent)) + expect_primerized_flash(message: I18n.t(:notice_account_lost_email_sent)) perform_enqueued_jobs expect(ActionMailer::Base.deliveries.size).to be 0 fill_in "mail", with: user.mail click_on "Submit" - expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_account_lost_email_sent)) + expect_primerized_flash(message: I18n.t(:notice_account_lost_email_sent)) perform_enqueued_jobs expect(ActionMailer::Base.deliveries.size).to be 1 @@ -60,7 +60,7 @@ RSpec.describe "Lost password" do click_button "Save" - expect(page).to have_css(".op-toast.-info", text: I18n.t(:notice_account_password_updated)) + expect_primerized_flash(type: :info, message: I18n.t(:notice_account_password_updated)) login_with user.login, new_password @@ -79,7 +79,7 @@ RSpec.describe "Lost password" do fill_in "mail", with: user.mail click_on "Submit" - expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_account_lost_email_sent)) + expect_primerized_flash(message: I18n.t(:notice_account_lost_email_sent)) perform_enqueued_jobs expect(ActionMailer::Base.deliveries.size).to be 1 @@ -99,7 +99,7 @@ RSpec.describe "Lost password" do fill_in "mail", with: user.mail click_on "Submit" - expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_account_lost_email_sent)) + expect_primerized_flash(message: I18n.t(:notice_account_lost_email_sent)) perform_enqueued_jobs expect(ActionMailer::Base.deliveries.size).to be 1 diff --git a/spec/features/custom_fields/reorder_options_spec.rb b/spec/features/custom_fields/reorder_options_spec.rb index cd2274c5c3a..dc396d03047 100644 --- a/spec/features/custom_fields/reorder_options_spec.rb +++ b/spec/features/custom_fields/reorder_options_spec.rb @@ -38,7 +38,7 @@ RSpec.describe "Reordering custom options of a list custom field", :js do click_link "Reorder values alphabetically" cf_page.accept_alert_dialog! - expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_update)) + expect_primerized_flash(message: I18n.t(:notice_successful_update)) expect(custom_field.custom_options.order(:position).pluck(:value)) .to eq get_possible_values_reordered(200) end diff --git a/spec/features/custom_styles/tabs_navigation_spec.rb b/spec/features/custom_styles/tabs_navigation_spec.rb index 2017ef6c606..98b0e1bcdd1 100644 --- a/spec/features/custom_styles/tabs_navigation_spec.rb +++ b/spec/features/custom_styles/tabs_navigation_spec.rb @@ -60,7 +60,7 @@ RSpec.describe "Tabs navigation and content switching on the admin/design page" it "selects a color theme and redirect to the interface tab" do select("OpenProject Gray", from: "theme") find("[data-test-selector='color-theme-button']").click - expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_update)) + expect_primerized_flash(message: I18n.t(:notice_successful_update)) expect(page).to have_current_path custom_style_path(tab: "interface") end @@ -78,7 +78,7 @@ RSpec.describe "Tabs navigation and content switching on the admin/design page" # select a color theme and redirect to the branding tab select("OpenProject Navy Blue", from: "theme") find("[data-test-selector='color-theme-button']").click - expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_update)) + expect_primerized_flash(message: I18n.t(:notice_successful_update)) expect(page).to have_current_path custom_style_path(tab: "branding") # remove the logo and redirect to the branding tab @@ -94,7 +94,7 @@ RSpec.describe "Tabs navigation and content switching on the admin/design page" # select a color theme and redirect to the PDF export styles tab select("OpenProject (default)", from: "theme") find("[data-test-selector='color-theme-button']").click - expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_update)) + expect_primerized_flash(message: I18n.t(:notice_successful_update)) expect(page).to have_current_path custom_style_path(tab: "pdf_export_styles") # change export cover text color and redirect to the PDF export styles tab diff --git a/spec/features/groups/groups_spec.rb b/spec/features/groups/groups_spec.rb index b939d9bdc4c..a7a74cb93d9 100644 --- a/spec/features/groups/groups_spec.rb +++ b/spec/features/groups/groups_spec.rb @@ -45,7 +45,7 @@ RSpec.describe "group memberships through groups page", :js, :with_cuprite do groups_page.delete_group! "Bob's Team" - expect(page).to have_css(".op-toast.-info", text: I18n.t(:notice_deletion_scheduled)) + expect_primerized_flash(type: :info, message: I18n.t(:notice_deletion_scheduled)) expect(groups_page).to have_group "Bob's Team" perform_enqueued_jobs diff --git a/spec/features/homescreen/index_spec.rb b/spec/features/homescreen/index_spec.rb index c09c12cc267..451190d94b3 100644 --- a/spec/features/homescreen/index_spec.rb +++ b/spec/features/homescreen/index_spec.rb @@ -71,7 +71,7 @@ RSpec.describe "Homescreen", "index", :with_cuprite do welcome_text_editor.click_and_type_slowly("Hello! ") general_settings_page.press_save_button - general_settings_page.expect_and_dismiss_toaster + expect_and_dismiss_primerized_flash(message: "Successful update.") visit root_url expect(page) diff --git a/spec/features/ldap_auth_sources/crud_spec.rb b/spec/features/ldap_auth_sources/crud_spec.rb index b44c7a6b765..aec5715ade1 100644 --- a/spec/features/ldap_auth_sources/crud_spec.rb +++ b/spec/features/ldap_auth_sources/crud_spec.rb @@ -52,7 +52,7 @@ RSpec.describe "CRUD LDAP connections", :js, :with_cuprite do click_on "Create" - ldap_page.expect_and_dismiss_toaster message: "Successful creation." + expect_and_dismiss_primerized_flash message: "Successful creation." expect(page).to have_css("td.name", text: "My LDAP connection") expect(page).to have_css("td.host", text: "localhost") @@ -71,7 +71,7 @@ RSpec.describe "CRUD LDAP connections", :js, :with_cuprite do accept_prompt { click_on "Delete" } end - ldap_page.expect_and_dismiss_toaster message: "Successful deletion." + expect_and_dismiss_primerized_flash message: "Successful deletion." expect(page).to have_no_text "My LDAP connection" expect(page).to have_text "Admin connection" @@ -88,7 +88,7 @@ RSpec.describe "CRUD LDAP connections", :js, :with_cuprite do fill_in "ldap_auth_source_name", with: "Updated Admin connection" click_on "Save" - ldap_page.expect_and_dismiss_toaster message: "Successful update." + expect_primerized_flash(message: "Successful update.") expect(page).to have_css("td.name", text: "Updated Admin connection") end diff --git a/spec/features/members/pagination_spec.rb b/spec/features/members/pagination_spec.rb index 22af2711d58..9001110667a 100644 --- a/spec/features/members/pagination_spec.rb +++ b/spec/features/members/pagination_spec.rb @@ -84,7 +84,7 @@ RSpec.describe "members pagination", :js do members_page.visit! SeleniumHubWaiter.wait members_page.remove_user! "Alice Alison" - members_page.expect_and_dismiss_toaster + expect_and_dismiss_primerized_flash message: "Removed Alice Alison from project" expect(members_page).to have_user "Bob Bobbit" SeleniumHubWaiter.wait diff --git a/spec/features/oauth/authorization_code_flow_spec.rb b/spec/features/oauth/authorization_code_flow_spec.rb index 5b1c95963f6..0c00a5d7cdb 100644 --- a/spec/features/oauth/authorization_code_flow_spec.rb +++ b/spec/features/oauth/authorization_code_flow_spec.rb @@ -101,7 +101,7 @@ RSpec.describe "OAuth authorization code flow", :js do page.driver.browser.switch_to.alert.accept # Should be back on access_token path - expect(page).to have_css(".op-toast.-success") + expect_primerized_flash(message: "Revocation of application Cool API app! successful.") expect(page).to have_no_css("[id^=oauth-application-grant]") expect(page).to have_current_path /\/my\/access_token/ diff --git a/spec/features/placeholder_users/create_spec.rb b/spec/features/placeholder_users/create_spec.rb index 9bf3ae731cc..2c0669b038a 100644 --- a/spec/features/placeholder_users/create_spec.rb +++ b/spec/features/placeholder_users/create_spec.rb @@ -40,7 +40,7 @@ RSpec.describe "create placeholder users", :selenium do new_placeholder_user_page.submit! - expect(page).to have_css(".op-toast", text: "Successful creation.") + expect_primerized_flash(message: "Successful creation.") new_placeholder_user = PlaceholderUser.order(Arel.sql("id DESC")).first diff --git a/spec/features/placeholder_users/delete_spec.rb b/spec/features/placeholder_users/delete_spec.rb index fc5cd182d0c..59bc1762633 100644 --- a/spec/features/placeholder_users/delete_spec.rb +++ b/spec/features/placeholder_users/delete_spec.rb @@ -49,7 +49,7 @@ RSpec.describe "delete placeholder user", :js do expect(page).to have_css(".danger-zone--verification button:not([disabled])") click_on "Delete" - expect(page).to have_css(".op-toast.-info", text: I18n.t(:notice_deletion_scheduled)) + expect_primerized_flash(type: :info, message: I18n.t(:notice_deletion_scheduled)) # The user is still there placeholder_user.reload diff --git a/spec/features/placeholder_users/edit_placeholder_users_spec.rb b/spec/features/placeholder_users/edit_placeholder_users_spec.rb index aabffc35339..4d2fa380a89 100644 --- a/spec/features/placeholder_users/edit_placeholder_users_spec.rb +++ b/spec/features/placeholder_users/edit_placeholder_users_spec.rb @@ -41,7 +41,7 @@ RSpec.describe "edit placeholder users", :js do click_on "Save" - expect(page).to have_css(".op-toast.-success", text: "Successful update.") + expect_primerized_flash(message: "Successful update.") placeholder_user.reload diff --git a/spec/features/principals/shared_memberships_examples.rb b/spec/features/principals/shared_memberships_examples.rb index b326337add1..2dc6130e374 100644 --- a/spec/features/principals/shared_memberships_examples.rb +++ b/spec/features/principals/shared_memberships_examples.rb @@ -30,7 +30,7 @@ RSpec.shared_examples "principal membership management flows" do principal_page.expect_project(project.name) principal_page.edit_roles!(member, %w()) - expect(page).to have_css(".op-toast.-error", text: "Roles need to be assigned.") + expect_primerized_flash(type: :error, message: "Roles need to be assigned.") # Remove the user from the project principal_page.remove_from_project!(project.name) diff --git a/spec/features/projects/destroy_spec.rb b/spec/features/projects/destroy_spec.rb index 9b2481f75c0..c666f4afe17 100644 --- a/spec/features/projects/destroy_spec.rb +++ b/spec/features/projects/destroy_spec.rb @@ -53,7 +53,7 @@ RSpec.describe "Projects#destroy", :js, :with_cuprite do expect(danger_zone).not_to be_disabled danger_zone.danger_button.click - expect(page).to have_css ".op-toast.-success", text: I18n.t("projects.delete.scheduled") + expect_primerized_flash message: I18n.t("projects.delete.scheduled") expect(project.reload).to eq(project) perform_enqueued_jobs diff --git a/spec/features/projects/modules_spec.rb b/spec/features/projects/modules_spec.rb index 585cf33dee4..a84be7858ee 100644 --- a/spec/features/projects/modules_spec.rb +++ b/spec/features/projects/modules_spec.rb @@ -65,11 +65,11 @@ RSpec.describe "Projects module administration" do check "Calendar" click_button "Save" - expect(page) - .to have_css ".op-toast.-error", - text: I18n.t(:"activerecord.errors.models.project.attributes.enabled_modules.dependency_missing", - dependency: "Work packages", - module: "Calendars") + expect_primerized_error( + I18n.t(:"activerecord.errors.models.project.attributes.enabled_modules.dependency_missing", + dependency: "Work packages", + module: "Calendars") + ) expect(page).to have_no_xpath(project_work_packages_menu_link_selector) diff --git a/spec/features/projects/project_custom_fields/overview_page/dialog/permission_spec.rb b/spec/features/projects/project_custom_fields/overview_page/dialog/permission_spec.rb index 9953fa86e5b..14c9eb68528 100644 --- a/spec/features/projects/project_custom_fields/overview_page/dialog/permission_spec.rb +++ b/spec/features/projects/project_custom_fields/overview_page/dialog/permission_spec.rb @@ -117,7 +117,7 @@ RSpec.describe "Edit project custom fields on project overview page", :js do member_with_project_attributes_edit_permissions.reload dialog.submit - expect(page).to have_css("#errorExplanation", text: I18n.t(:notice_not_authorized)) + expect_primerized_error(I18n.t(:notice_not_authorized)) end end end diff --git a/spec/features/projects/projects_index_spec.rb b/spec/features/projects/projects_index_spec.rb index 9ddb9d5fecb..20e862d4ab1 100644 --- a/spec/features/projects/projects_index_spec.rb +++ b/spec/features/projects/projects_index_spec.rb @@ -274,9 +274,9 @@ RSpec.describe "Projects index page", :js, :with_cuprite, with_settings: { login error_text = "Orders > is not set to one of the allowed values. and does not exist." error_html = "Orders ><script src='/foobar js'></script> is not set to one of the allowed values. and does not exist." - expect(page).to have_css(".op-toast.-error", text: error_text) + expect_primerized_error(error_text) - error_container = page.find(".op-toast.-error") + error_container = find_primerized_flash(type: :error) expect(error_container["innerHTML"]).to include error_html end end diff --git a/spec/features/projects/projects_portfolio_spec.rb b/spec/features/projects/projects_portfolio_spec.rb index d5f805c233a..886c9fd62b5 100644 --- a/spec/features/projects/projects_portfolio_spec.rb +++ b/spec/features/projects/projects_portfolio_spec.rb @@ -115,7 +115,7 @@ RSpec.describe "Projects index page", :js, :with_cuprite, with_settings: { login # Save the page scroll_to_and_click(find(".button", text: "Save")) - expect(page).to have_css(".op-toast.-success", text: "Successful update.") + expect_primerized_flash(message: "Successful update.") RequestStore.clear! query = JSON.parse Setting.project_gantt_query diff --git a/spec/features/projects/template_spec.rb b/spec/features/projects/template_spec.rb index 2f07f26befe..39a7be290d6 100644 --- a/spec/features/projects/template_spec.rb +++ b/spec/features/projects/template_spec.rb @@ -44,6 +44,7 @@ RSpec.describe "Project templates", :js, :with_cuprite, # Make a template find(".button", text: "Set as template").click + expect_and_dismiss_primerized_flash(message: "Successful update.") expect(page).to have_css(".button", text: "Remove from templates") project.reload diff --git a/spec/features/repositories/create_repository_spec.rb b/spec/features/repositories/create_repository_spec.rb index 605f748f24d..6a7ff5c2163 100644 --- a/spec/features/repositories/create_repository_spec.rb +++ b/spec/features/repositories/create_repository_spec.rb @@ -149,8 +149,7 @@ RSpec.describe "Create repository", :js, :selenium do click_button(I18n.t(:button_create)) - expect(page).to have_css("div.op-toast.-success", - text: I18n.t("repositories.create_successful")) + expect_primerized_flash(message: I18n.t("repositories.create_successful")) expect(page).to have_css("a.icon-delete", text: I18n.t(:button_delete)) end end @@ -162,8 +161,7 @@ RSpec.describe "Create repository", :js, :selenium do click_button(I18n.t(:button_create)) - expect(page).to have_css("div.op-toast.-success", - text: I18n.t("repositories.create_successful")) + expect_primerized_flash(message: I18n.t("repositories.create_successful")) expect(page).to have_css('button[type="submit"]', text: I18n.t(:button_save)) expect(page).to have_css("a.icon-remove", text: I18n.t(:button_remove)) end diff --git a/spec/features/repositories/repository_settings_spec.rb b/spec/features/repositories/repository_settings_spec.rb index b9873f89b75..d31182f23a7 100644 --- a/spec/features/repositories/repository_settings_spec.rb +++ b/spec/features/repositories/repository_settings_spec.rb @@ -193,8 +193,7 @@ RSpec.describe "Repository Settings", :js do click_button(I18n.t(:button_save)) expect(page).to have_css('[name="repository[login]"][value="foobar"]') - expect(page).to have_css(".op-toast", - text: I18n.t("repositories.update_settings_successful")) + expect_primerized_flash(message: I18n.t("repositories.update_settings_successful")) end end end diff --git a/spec/features/roles/create_spec.rb b/spec/features/roles/create_spec.rb index 8aa9185a917..9ef403e7401 100644 --- a/spec/features/roles/create_spec.rb +++ b/spec/features/roles/create_spec.rb @@ -55,8 +55,7 @@ RSpec.describe "Role creation", :js, :with_cuprite do click_button "Create" - expect(page) - .to have_css(".errorExplanation", text: "Name has already been taken") + expect_primerized_error("Name has already been taken") fill_in "Name", with: "New role name" @@ -65,17 +64,14 @@ RSpec.describe "Role creation", :js, :with_cuprite do click_button "Create" - expect(page) - .to have_css(".errorExplanation", - text: "Permissions need to also include 'View members' as 'Manage members' is selected.") + expect_primerized_error("Permissions need to also include 'View members' as 'Manage members' is selected.") check "View members" select existing_role.name, from: "Copy workflow from" click_button "Create" - expect(page) - .to have_css(".-success", text: "Successful creation.") + expect_and_dismiss_primerized_flash(message: "Successful creation.") expect(page) .to have_current_path(roles_path) diff --git a/spec/features/types/crud_spec.rb b/spec/features/types/crud_spec.rb index 427fbb4e99a..37434bf3606 100644 --- a/spec/features/types/crud_spec.rb +++ b/spec/features/types/crud_spec.rb @@ -52,8 +52,7 @@ RSpec.describe "Types", :js, :with_cuprite do click_button "Create" - expect(page) - .to have_css(".errorExplanation", text: "Name has already been taken.") + expect_primerized_error("Name has already been taken.") # Values are retained expect(page) @@ -123,9 +122,7 @@ RSpec.describe "Types", :js, :with_cuprite do end it "renders an error message with links to the archived project in the projects list" do - within ".op-toast.-error" do - expect(page).to have_link(project.name) - end + expect_primerized_error project.name end end end diff --git a/spec/features/types/form_configuration_query_spec.rb b/spec/features/types/form_configuration_query_spec.rb index c777fbd811b..4c178f1bb72 100644 --- a/spec/features/types/form_configuration_query_spec.rb +++ b/spec/features/types/form_configuration_query_spec.rb @@ -93,7 +93,7 @@ RSpec.describe "form query configuration", :js, :with_cuprite do it "can save an empty query group" do form.add_query_group("Empty test", :children) form.save_changes - expect(page).to have_css(".op-toast.-success", text: "Successful update.", wait: 10) + expect_primerized_flash(message: "Successful update.") type_bug.reload query_group = type_bug.attribute_groups.detect { |x| x.is_a?(Type::QueryGroup) } @@ -105,7 +105,7 @@ RSpec.describe "form query configuration", :js, :with_cuprite do form.add_query_group("Subtasks", :children) # Save changed query form.save_changes - expect(page).to have_css(".op-toast.-success", text: "Successful update.", wait: 10) + expect_primerized_flash(message: "Successful update.") # Visit wp_table wp_table.visit! @@ -131,7 +131,7 @@ RSpec.describe "form query configuration", :js, :with_cuprite do form.add_query_group("Subtasks", :children) # Save changed query form.save_changes - expect(page).to have_css(".op-toast.-success", text: "Successful update.", wait: 10) + expect_primerized_flash(message: "Successful update.") # Visit new wp page visit new_project_work_packages_path(project) @@ -156,7 +156,7 @@ RSpec.describe "form query configuration", :js, :with_cuprite do filters.save form.save_changes - expect(page).to have_css(".op-toast.-success", text: "Successful update.", wait: 10) + expect_primerized_flash message: "Successful update." archived.update_attribute(:active, false) @@ -184,7 +184,7 @@ RSpec.describe "form query configuration", :js, :with_cuprite do # Save changed query form.save_changes - expect(page).to have_css(".op-toast.-success", text: "Successful update.", wait: 10) + expect_primerized_flash(message: "Successful update.") type_bug.reload query = type_bug.attribute_groups.detect { |x| x.key == "Columns Test" } @@ -206,7 +206,7 @@ RSpec.describe "form query configuration", :js, :with_cuprite do # Save changed query form.save_changes - expect(page).to have_css(".op-toast.-success", text: "Successful update.", wait: 10) + expect_primerized_flash(message: "Successful update.") type_bug.reload query = type_bug.attribute_groups.detect { |x| x.key == "Columns Test" } @@ -253,7 +253,7 @@ RSpec.describe "form query configuration", :js, :with_cuprite do filters.save form.save_changes - expect(page).to have_css(".op-toast.-success", text: "Successful update.", wait: 10) + expect_primerized_flash(message: "Successful update.") # Visit work package with that type wp_page.visit! diff --git a/spec/features/types/form_configuration_spec.rb b/spec/features/types/form_configuration_spec.rb index 837ab3b88d6..75b6c930b7d 100644 --- a/spec/features/types/form_configuration_spec.rb +++ b/spec/features/types/form_configuration_spec.rb @@ -91,7 +91,7 @@ RSpec.describe "form configuration", :js do # Save configuration form.save_changes - expect(page).to have_css(".op-toast.-success", text: "Successful update.", wait: 10) + expect_primerized_flash(message: "Successful update.") form.expect_empty @@ -171,7 +171,7 @@ RSpec.describe "form configuration", :js do # Save configuration form.save_changes - expect(page).to have_css(".op-toast.-success", text: "Successful update.", wait: 10) + expect_primerized_flash(message: "Successful update.") # Expect configuration to be correct now form.expect_no_attribute("assignee", "Cool Stuff") @@ -269,7 +269,7 @@ RSpec.describe "form configuration", :js do form.expect_attribute(key: cf_identifier) form.save_changes - expect(page).to have_css(".op-toast.-success", text: "Successful update.", wait: 10) + expect_primerized_flash(message: "Successful update.") end end @@ -299,7 +299,7 @@ RSpec.describe "form configuration", :js do form.expect_attribute(key: cf_identifier) form.save_changes - expect(page).to have_css(".op-toast.-success", text: "Successful update.", wait: 10) + expect_primerized_flash(message: "Successful update.") end context "if inactive in project" do diff --git a/spec/features/types/reset_form_configuration_spec.rb b/spec/features/types/reset_form_configuration_spec.rb index f5bab6ebb1a..43ac566757e 100644 --- a/spec/features/types/reset_form_configuration_spec.rb +++ b/spec/features/types/reset_form_configuration_spec.rb @@ -60,7 +60,7 @@ RSpec.describe "Reset form configuration", :js do form.expect_attribute(key: cf_identifier) form.save_changes - expect(page).to have_css(".op-toast.-success", text: "Successful update.", wait: 10) + expect_primerized_flash(message: "Successful update.") SeleniumHubWaiter.wait form.reset_button.click diff --git a/spec/features/users/create_spec.rb b/spec/features/users/create_spec.rb index 305898b5157..2027c2eac68 100644 --- a/spec/features/users/create_spec.rb +++ b/spec/features/users/create_spec.rb @@ -45,7 +45,7 @@ RSpec.describe "create users", :with_cuprite do shared_examples_for "successful user creation" do |redirect_to_edit_page: true| it "creates the user" do - expect(page).to have_css(".op-toast", text: "Successful creation.") + expect_primerized_flash(message: "Successful creation.") new_user = User.order(Arel.sql("id DESC")).first diff --git a/spec/features/users/edit_users_spec.rb b/spec/features/users/edit_users_spec.rb index 3bf3e54961b..650701e321f 100644 --- a/spec/features/users/edit_users_spec.rb +++ b/spec/features/users/edit_users_spec.rb @@ -127,7 +127,7 @@ RSpec.describe "edit users", :js, :with_cuprite do click_button "Save" - expect(page).to have_css(".op-toast.-success", text: "Successful update.") + expect_primerized_flash(message: "Successful update.") user.reload @@ -140,7 +140,7 @@ RSpec.describe "edit users", :js, :with_cuprite do click_on "Send invitation" - expect(page).to have_css(".op-toast.-success", text: "An invitation has been sent to foo@example.com") + expect_primerized_flash(message: "An invitation has been sent to foo@example.com") end it "can not edit attributes of an admin user" do diff --git a/spec/features/users/password_change_spec.rb b/spec/features/users/password_change_spec.rb index 9ca3dbb5930..1736832fa2b 100644 --- a/spec/features/users/password_change_spec.rb +++ b/spec/features/users/password_change_spec.rb @@ -60,7 +60,7 @@ RSpec.describe "random password generation", :js, :with_cuprite do click_on "Save" - expect(page).to have_css(".op-toast", text: I18n.t(:notice_successful_update)) + expect_primerized_flash(message: "Successful update.") expect(password).to be_present # Logout @@ -90,7 +90,7 @@ RSpec.describe "random password generation", :js, :with_cuprite do expect(Sessions::UserSession.for_user(user.id).count).to be >= 1 click_on "Save" - expect(page).to have_css(".op-toast.-info", text: I18n.t(:notice_account_password_updated)) + expect_primerized_flash(type: :info, message: I18n.t(:notice_account_password_updated)) # The old session is removed expect(Sessions::UserSession.find_by(session_id: "other")).to be_nil @@ -126,7 +126,7 @@ RSpec.describe "random password generation", :js, :with_cuprite do find_by_id("settings_password_min_adhered_rules").set 3 scroll_to_and_click(find(".button", text: "Save")) - expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_update)) + expect_primerized_flash(message: "Successful update.") Setting.clear_cache @@ -144,19 +144,19 @@ RSpec.describe "random password generation", :js, :with_cuprite do fill_in "user_password", with: "adminADMIN" fill_in "user_password_confirmation", with: "adminADMIN" scroll_to_and_click(find(".button", text: "Save")) - expect(page).to have_css(".errorExplanation", text: "Password Must contain characters of the following classes") + expect_primerized_error("Password Must contain characters of the following classes") # 2 of 3 classes fill_in "user_password", with: "adminADMIN123" fill_in "user_password_confirmation", with: "adminADMIN123" scroll_to_and_click(find(".button", text: "Save")) - expect(page).to have_css(".errorExplanation", text: "Password Must contain characters of the following classes") + expect_primerized_error("Password Must contain characters of the following classes") # All classes fill_in "user_password", with: "adminADMIN!" fill_in "user_password_confirmation", with: "adminADMIN!" scroll_to_and_click(find(".button", text: "Save")) - expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_update)) + expect_primerized_flash(message: I18n.t(:notice_successful_update)) end end diff --git a/spec/features/versions/delete_spec.rb b/spec/features/versions/delete_spec.rb index 5c345e46262..c93ef2882c1 100644 --- a/spec/features/versions/delete_spec.rb +++ b/spec/features/versions/delete_spec.rb @@ -53,7 +53,7 @@ RSpec.describe "version delete", :js, :with_cuprite do end end - expect(page).to have_css(".op-toast.-error", text: I18n.t(:error_can_not_delete_in_use_archived_undisclosed)) + expect_primerized_error(I18n.t(:error_can_not_delete_in_use_archived_undisclosed)) expect(page).to have_no_css("a", text: "Archived child") user.update!(admin: true) @@ -67,7 +67,7 @@ RSpec.describe "version delete", :js, :with_cuprite do end end - expect(page).to have_css(".op-toast.-error", text: "There are also work packages in archived projects.") + expect_primerized_error("There are also work packages in archived projects.") expect(page).to have_css("a", text: "Archived child") end end diff --git a/spec/features/wiki/adding_editing_history_spec.rb b/spec/features/wiki/adding_editing_history_spec.rb index c595fe079fa..d0ee5a97e58 100644 --- a/spec/features/wiki/adding_editing_history_spec.rb +++ b/spec/features/wiki/adding_editing_history_spec.rb @@ -82,6 +82,7 @@ RSpec.describe "wiki pages", :js, with_settings: { journal_aggregation_time_minu find(".ck-content").base.send_keys(content_first_version) click_button "Save" + expect_and_dismiss_primerized_flash(message: "Successful creation.") expect(page).to have_css(".title-container", text: "New page") expect(page).to have_css(".wiki-content", text: content_first_version) diff --git a/spec/features/wiki/attachment_upload_spec.rb b/spec/features/wiki/attachment_upload_spec.rb index 8b0e1122661..4af6efdc1fd 100644 --- a/spec/features/wiki/attachment_upload_spec.rb +++ b/spec/features/wiki/attachment_upload_spec.rb @@ -56,14 +56,11 @@ RSpec.describe "Upload attachment to wiki page", :js do click_on "Save" - expect(page).to have_text("Successful creation") + expect_and_dismiss_primerized_flash(message: "Successful creation") expect(page).to have_css("#content img", count: 1) expect(page).to have_content("Image uploaded the first time") attachments_list.expect_attached("image.png") - # required sleep otherwise clicking on the Edit button doesn't do anything - SeleniumHubWaiter.wait - within ".toolbar-items" do click_on "Edit" end @@ -116,7 +113,7 @@ RSpec.describe "Upload attachment to wiki page", :js do click_on "Save" - expect(page).to have_text("Successful creation") + expect_and_dismiss_primerized_flash(message: "Successful creation") attachments_list.expect_attached("image.png") # required sleep otherwise clicking on the Edit button doesn't do anything diff --git a/spec/features/wiki/edit_new_page_spec.rb b/spec/features/wiki/edit_new_page_spec.rb index fe11c6b9c3e..148edc1e2d2 100644 --- a/spec/features/wiki/edit_new_page_spec.rb +++ b/spec/features/wiki/edit_new_page_spec.rb @@ -41,6 +41,6 @@ RSpec.describe "Editing a new wiki page", :js do expect(page).to have_field "page_title", with: "Foobar" click_on "Save" - expect(page).to have_css(".op-toast.-success", text: "Successful creation.", wait: 10) + expect_primerized_flash(message: "Successful creation.", wait: 10) end end diff --git a/spec/features/work_packages/bulk/copy_work_package_spec.rb b/spec/features/work_packages/bulk/copy_work_package_spec.rb index 07a8605d259..ec6e7d24ba0 100644 --- a/spec/features/work_packages/bulk/copy_work_package_spec.rb +++ b/spec/features/work_packages/bulk/copy_work_package_spec.rb @@ -201,35 +201,13 @@ RSpec.describe "Copy work packages through Rails view", :js, :with_cuprite do it "fails, informing of the reasons" do click_on "Copy and follow" - expect(page) - .to have_css( - ".op-toast.-error", - text: I18n.t("work_packages.bulk.none_could_be_saved", total: 3) - ) - - expect(page) - .to have_css( - ".op-toast.-error", - text: I18n.t("work_packages.bulk.selected_because_descendants", total: 3, selected: 2) - ) - - expect(page) - .to have_css( - ".op-toast.-error", - text: "#{work_package.id}: Type #{I18n.t('activerecord.errors.messages.inclusion')}" - ) - - expect(page) - .to have_css( - ".op-toast.-error", - text: "#{work_package2.id}: Type #{I18n.t('activerecord.errors.messages.inclusion')}" - ) - - expect(page) - .to have_css( - ".op-toast.-error", - text: "#{child.id} (descendant of selected): Type #{I18n.t('activerecord.errors.messages.inclusion')}" - ) + expect_primerized_error(I18n.t("work_packages.bulk.none_could_be_saved", total: 3)) + expect_primerized_error(I18n.t("work_packages.bulk.selected_because_descendants", total: 3, selected: 2)) + expect_primerized_error("#{work_package.id}: Type #{I18n.t('activerecord.errors.messages.inclusion')}") + expect_primerized_error("#{work_package2.id}: Type #{I18n.t('activerecord.errors.messages.inclusion')}") + expect_primerized_error( + "#{child.id} (descendant of selected): Type #{I18n.t('activerecord.errors.messages.inclusion')}" + ) end context "when the limit to move in the frontend is 0", @@ -316,9 +294,7 @@ RSpec.describe "Copy work packages through Rails view", :js, :with_cuprite do click_on "Copy and follow" - expect(page) - .to have_css(".op-toast.-success", - text: I18n.t(:notice_successful_create)) + expect_primerized_flash(message: I18n.t(:notice_successful_create)) wp_page = Pages::FullWorkPackage.new(WorkPackage.last) diff --git a/spec/features/work_packages/bulk/move_work_package_spec.rb b/spec/features/work_packages/bulk/move_work_package_spec.rb index c4d0a903fab..49fa31633a5 100644 --- a/spec/features/work_packages/bulk/move_work_package_spec.rb +++ b/spec/features/work_packages/bulk/move_work_package_spec.rb @@ -140,10 +140,7 @@ RSpec.describe "Moving a work package through Rails view", :js do click_on "Move and follow" wait_for_reload - expect(page) - .to have_css(".op-toast.-error", - text: I18n.t(:"work_packages.bulk.none_could_be_saved", - total: 1)) + expect_primerized_error I18n.t(:"work_packages.bulk.none_could_be_saved", total: 1) # Should NOT have moved child_wp.reload @@ -170,10 +167,7 @@ RSpec.describe "Moving a work package through Rails view", :js do click_on "Move and follow" end - expect(page) - .to have_css(".op-toast.-error", - text: I18n.t(:"work_packages.bulk.none_could_be_saved", - total: 1)) + expect_primerized_error I18n.t(:"work_packages.bulk.none_could_be_saved", total: 1) child_wp.reload work_package.reload expect(work_package.project_id).to eq(project.id) @@ -215,23 +209,15 @@ RSpec.describe "Moving a work package through Rails view", :js do end it "displays an error message explaining which work package could not be moved and why" do - expect(page) - .to have_css(".op-toast.-error", - text: I18n.t("work_packages.bulk.could_not_be_saved"), - wait: 10) + expect_primerized_error(I18n.t("work_packages.bulk.could_not_be_saved")) + expect_primerized_error("#{work_package2.id}: Project #{I18n.t('activerecord.errors.messages.error_readonly')}") - expect(page) - .to have_css( - ".op-toast.-error", - text: "#{work_package2.id}: Project #{I18n.t('activerecord.errors.messages.error_readonly')}" - ) - - expect(page) - .to have_css(".op-toast.-error", - text: I18n.t("work_packages.bulk.x_out_of_y_could_be_saved", - failing: 1, - total: 2, - success: 1)) + expect_primerized_error( + I18n.t("work_packages.bulk.x_out_of_y_could_be_saved", + failing: 1, + total: 2, + success: 1) + ) expect(work_package.reload.project_id).to eq(project2.id) expect(work_package2.reload.project_id).to eq(project.id) diff --git a/spec/features/work_packages/bulk/update_work_package_spec.rb b/spec/features/work_packages/bulk/update_work_package_spec.rb index 6689aff8ae9..fe949ad54f2 100644 --- a/spec/features/work_packages/bulk/update_work_package_spec.rb +++ b/spec/features/work_packages/bulk/update_work_package_spec.rb @@ -111,27 +111,16 @@ RSpec.describe "Bulk update work packages through Rails view", :js, :with_cuprit fill_in "Parent", with: "-1" click_on "Submit" - expect(page) - .to have_css( - ".op-toast.-error", - text: I18n.t("work_packages.bulk.none_could_be_saved", total: 2) - ) + expect_primerized_error(I18n.t("work_packages.bulk.none_could_be_saved", total: 2)) + expect_primerized_error("#{work_package.id}: Parent #{I18n.t('activerecord.errors.messages.does_not_exist')}") - expect(page) - .to have_css( - ".op-toast.-error", - text: "#{work_package.id}: Parent #{I18n.t('activerecord.errors.messages.does_not_exist')}" - ) - - expect(page) - .to have_css( - ".op-toast.-error", - text: <<~MSG.squish - #{work_package2.id}: - Parent #{I18n.t('activerecord.errors.messages.does_not_exist')} - Status #{I18n.t('activerecord.errors.models.work_package.attributes.status_id.status_transition_invalid')} - MSG - ) + expect_primerized_error( + <<~MSG.squish + #{work_package2.id}: + Parent #{I18n.t('activerecord.errors.messages.does_not_exist')} + Status #{I18n.t('activerecord.errors.models.work_package.attributes.status_id.status_transition_invalid')} + MSG + ) # Should not update the status work_package2.reload @@ -153,21 +142,17 @@ RSpec.describe "Bulk update work packages through Rails view", :js, :with_cuprit fill_in custom_field.name, with: "Custom field text" click_on "Submit" - expect(page) - .to have_css( - ".op-toast.-error", - text: I18n.t("work_packages.bulk.x_out_of_y_could_be_saved", total: 2, failing: 1, success: 1) - ) + expect_primerized_error( + I18n.t("work_packages.bulk.x_out_of_y_could_be_saved", total: 2, failing: 1, success: 1) + ) - expect(page) - .to have_css( - ".op-toast.-error", - text: <<~MSG.squish - #{work_package2.id}: - #{custom_field.name} #{I18n.t('activerecord.errors.messages.error_readonly')} - #{I18n.t('activerecord.errors.models.work_package.readonly_status')} - MSG - ) + expect_primerized_error( + <<~MSG.squish + #{work_package2.id}: + #{custom_field.name} #{I18n.t('activerecord.errors.messages.error_readonly')} + #{I18n.t('activerecord.errors.models.work_package.readonly_status')} + MSG + ) # Should update 1 work package custom field only work_package.reload @@ -189,7 +174,7 @@ RSpec.describe "Bulk update work packages through Rails view", :js, :with_cuprit fill_in custom_field.name, with: "Custom field text" click_on "Submit" - expect(page).to have_css(".op-toast.-success", text: I18n.t(:notice_successful_update)) + expect_and_dismiss_primerized_flash(message: I18n.t(:notice_successful_update)) # Should update 2 work package custom fields work_package.reload diff --git a/spec/features/work_packages/display_fields/work_display_spec.rb b/spec/features/work_packages/display_fields/work_display_spec.rb index 1d345835f2c..f14e9c0a7e2 100644 --- a/spec/features/work_packages/display_fields/work_display_spec.rb +++ b/spec/features/work_packages/display_fields/work_display_spec.rb @@ -186,7 +186,7 @@ RSpec.describe "Work display", :js do visit admin_settings_working_days_and_hours_path select "Days and hours", from: "Duration format" click_on "Apply changes" - expect_and_dismiss_toaster(message: "Successful update.") + expect_and_dismiss_primerized_flash(message: "Successful update.") wp_table.visit_query query diff --git a/spec/features/work_packages/navigation_spec.rb b/spec/features/work_packages/navigation_spec.rb index 5094f8f6157..38443aeccdc 100644 --- a/spec/features/work_packages/navigation_spec.rb +++ b/spec/features/work_packages/navigation_spec.rb @@ -148,11 +148,11 @@ RSpec.describe "Work package navigation", :js, :selenium do it "loading an unknown work package ID" do visit "/work_packages/999999999" - page404 = Pages::Page.new - page404.expect_toast type: :error, message: I18n.t(:notice_file_not_found) + expect_primerized_flash type: :error, message: I18n.t(:notice_file_not_found) visit "/projects/#{project.identifier}/work_packages/999999999" - page404.expect_and_dismiss_toaster type: :error, message: I18n.t("api_v3.errors.not_found.work_package") + global_work_packages = Pages::WorkPackagesTable.new + global_work_packages.expect_toast type: :error, message: I18n.t("api_v3.errors.not_found.work_package") end # Regression #29994 diff --git a/spec/features/wysiwyg/autosave_spec.rb b/spec/features/wysiwyg/autosave_spec.rb index f67058c2d66..6c3e0a1141f 100644 --- a/spec/features/wysiwyg/autosave_spec.rb +++ b/spec/features/wysiwyg/autosave_spec.rb @@ -50,7 +50,8 @@ RSpec.describe "Wysiwyg autosave spec", editor.click_and_type_slowly "Initial version" click_on "Save" - expect(page).to have_css(".op-toast.-success") + expect_and_dismiss_primerized_flash(message: "Successful creation.") + within("#content") do expect(page).to have_text "Initial version" end @@ -69,7 +70,7 @@ RSpec.describe "Wysiwyg autosave spec", # Save wiki page click_on "Save" - expect(page).to have_css(".op-toast.-success") + expect_primerized_flash(message: "Successful update.") within("#content") do expect(page).to have_text "This should be saved" end @@ -79,6 +80,8 @@ RSpec.describe "Wysiwyg autosave spec", keys = page.evaluate_script "Object.keys(localStorage)" expect(keys).to include "op_ckeditor_rev_/api/v3/wiki_pages/#{wiki_page.id}_page[text]" + expect_and_dismiss_primerized_flash(message: "Successful update.") + # Edit again click_on "Edit" diff --git a/spec/features/wysiwyg/bold_behavior_spec.rb b/spec/features/wysiwyg/bold_behavior_spec.rb index e2e8204af2a..5521337ed5c 100644 --- a/spec/features/wysiwyg/bold_behavior_spec.rb +++ b/spec/features/wysiwyg/bold_behavior_spec.rb @@ -58,7 +58,7 @@ RSpec.describe "Wysiwyg bold behavior", :js, :with_cuprite do # Save wiki page click_on "Save" - expect(page).to have_css(".op-toast.-success") + expect_primerized_flash(message: "Successful creation.") within("#content") do expect(page).to have_css("p") { |node| diff --git a/spec/features/wysiwyg/html_encoding_spec.rb b/spec/features/wysiwyg/html_encoding_spec.rb index 230b1b80347..bb955207cdb 100644 --- a/spec/features/wysiwyg/html_encoding_spec.rb +++ b/spec/features/wysiwyg/html_encoding_spec.rb @@ -51,7 +51,7 @@ RSpec.describe "Wysiwyg escaping HTML entities (Regression #28906)", :js do # Save wiki page click_on "Save" - expect(page).to have_css(".op-toast.-success") + expect_primerized_flash(message: "Successful creation.") within("#content") do expect(page).to have_css("p", text: '') diff --git a/spec/features/wysiwyg/linking_spec.rb b/spec/features/wysiwyg/linking_spec.rb index 786bb10ac65..792a7ff9842 100644 --- a/spec/features/wysiwyg/linking_spec.rb +++ b/spec/features/wysiwyg/linking_spec.rb @@ -49,7 +49,7 @@ RSpec.describe "Wysiwyg linking", :js do # Save wiki page click_on "Save" - expect(page).to have_css(".op-toast.-success") + expect_primerized_flash(message: "Successful creation.") wiki_page = project.wiki.pages.first.reload diff --git a/spec/features/wysiwyg/macros/attribute_macros_spec.rb b/spec/features/wysiwyg/macros/attribute_macros_spec.rb index 5bbf1c05b60..7b7ad2aa55a 100644 --- a/spec/features/wysiwyg/macros/attribute_macros_spec.rb +++ b/spec/features/wysiwyg/macros/attribute_macros_spec.rb @@ -114,7 +114,7 @@ RSpec.describe "Wysiwyg attribute macros", :js do click_on "Save" - expect(page).to have_css(".op-toast.-success") + expect_and_dismiss_primerized_flash(message: "Successful creation.") # Expect output widget within("#content") do @@ -177,7 +177,7 @@ RSpec.describe "Wysiwyg attribute macros", :js do click_on "Save" - expect(page).to have_css(".op-toast.-success") + expect_primerized_flash(message: "Successful creation.") within("#content") do expect(page).to have_css(".custom-option", count: 6) diff --git a/spec/features/wysiwyg/macros/child_pages_spec.rb b/spec/features/wysiwyg/macros/child_pages_spec.rb index 9fe0fbb85db..9b3176a38b0 100644 --- a/spec/features/wysiwyg/macros/child_pages_spec.rb +++ b/spec/features/wysiwyg/macros/child_pages_spec.rb @@ -112,7 +112,7 @@ RSpec.describe "Wysiwyg child pages spec", :js do # Save wiki page click_on "Save" - expect(page).to have_css(".op-toast.-success") + expect_and_dismiss_primerized_flash(message: "Successful update.") within("#content") do expect(page).to have_css(".pages-hierarchy") @@ -145,7 +145,7 @@ RSpec.describe "Wysiwyg child pages spec", :js do # Save wiki page click_on "Save" - expect(page).to have_css(".op-toast.-success") + expect_and_dismiss_primerized_flash(message: "Successful update.") within("#content") do expect(page).to have_css(".pages-hierarchy") diff --git a/spec/features/wysiwyg/macros/code_block_macro_spec.rb b/spec/features/wysiwyg/macros/code_block_macro_spec.rb index 2893301d266..8b68df931f1 100644 --- a/spec/features/wysiwyg/macros/code_block_macro_spec.rb +++ b/spec/features/wysiwyg/macros/code_block_macro_spec.rb @@ -74,7 +74,7 @@ RSpec.describe "Wysiwyg code block macro", :js do end click_on "Save" - expect(page).to have_css(".op-toast.-success") + expect_and_dismiss_primerized_flash(message: "Successful creation.") # Expect output widget within("#content") do @@ -106,7 +106,7 @@ RSpec.describe "Wysiwyg code block macro", :js do expect(container).to have_css(".op-uc-code-block", text: "asdf") click_on "Save" - expect(page).to have_css(".op-toast.-success") + expect_and_dismiss_primerized_flash(message: "Successful creation.") wp = WikiPage.last expect(wp.text.gsub("\r\n", "\n")).to eq("```text\nasdf\n```") @@ -119,7 +119,7 @@ RSpec.describe "Wysiwyg code block macro", :js do end click_on "Save" - expect(page).to have_css(".op-toast.-success") + expect_and_dismiss_primerized_flash(message: "Successful update.") wp.reload # Regression added two newlines before fence here @@ -153,7 +153,7 @@ RSpec.describe "Wysiwyg code block macro", :js do # Save wiki page click_on "Save" - expect(page).to have_css(".op-toast.-success") + expect_and_dismiss_primerized_flash(message: "Successful creation.") wiki_page = project.wiki.find_page("wiki") text = wiki_page.text.gsub(/\r\n?/, "\n") diff --git a/spec/features/wysiwyg/macros/embedded_tables_spec.rb b/spec/features/wysiwyg/macros/embedded_tables_spec.rb index 9a2b198d4fe..7886562650c 100644 --- a/spec/features/wysiwyg/macros/embedded_tables_spec.rb +++ b/spec/features/wysiwyg/macros/embedded_tables_spec.rb @@ -28,7 +28,9 @@ require "spec_helper" -RSpec.describe "Wysiwyg embedded work package tables", :js do +RSpec.describe "Wysiwyg embedded work package tables", + :js, + :with_cuprite do shared_let(:admin) { create(:admin) } shared_let(:type_task) { create(:type_task) } shared_let(:type_bug) { create(:type_bug) } @@ -105,7 +107,7 @@ RSpec.describe "Wysiwyg embedded work package tables", :js do # Save wiki page click_on "Save" - expect(page).to have_css(".op-toast.-success") + expect_primerized_flash(message: "Successful creation.") embedded_table = Pages::EmbeddedWorkPackagesTable.new find(".wiki-content") embedded_table.expect_work_package_listed wp_task @@ -141,7 +143,7 @@ RSpec.describe "Wysiwyg embedded work package tables", :js do # Save wiki page click_on "Save" - expect(page).to have_css(".op-toast.-success") + expect_and_dismiss_primerized_flash(message: "Successful creation.") # Embedded queries wikipage = project.wiki.pages.last diff --git a/spec/features/wysiwyg/macros/quicklink_macros_spec.rb b/spec/features/wysiwyg/macros/quicklink_macros_spec.rb index c596579729e..45ed16b8d1b 100644 --- a/spec/features/wysiwyg/macros/quicklink_macros_spec.rb +++ b/spec/features/wysiwyg/macros/quicklink_macros_spec.rb @@ -50,6 +50,8 @@ RSpec.describe "Wysiwyg work package quicklink macros", :js do editor.set_markdown "##{work_package.id}" click_on "Save" + expect_and_dismiss_primerized_flash(message: "Successful creation.") + # Expect output widget within("#content") do expect(page).to have_link("##{work_package.id}") @@ -68,6 +70,8 @@ RSpec.describe "Wysiwyg work package quicklink macros", :js do editor.set_markdown "###{work_package.id}" click_on "Save" + expect_and_dismiss_primerized_flash(message: "Successful creation.") + # Expect output widget within("#content") do expected_macro_text = "#{work_package.type.name.upcase} ##{work_package.id}: My subject" @@ -89,6 +93,8 @@ RSpec.describe "Wysiwyg work package quicklink macros", :js do editor.set_markdown "####{work_package.id}" click_on "Save" + expect_and_dismiss_primerized_flash(message: "Successful creation.") + # Expect output widget within("#content") do expected_macro_text = "#{work_package.status.name}#{work_package.type.name.upcase} " \ diff --git a/spec/features/wysiwyg/macros/work_package_button_spec.rb b/spec/features/wysiwyg/macros/work_package_button_spec.rb index e133b726fc1..07d8b972c6d 100644 --- a/spec/features/wysiwyg/macros/work_package_button_spec.rb +++ b/spec/features/wysiwyg/macros/work_package_button_spec.rb @@ -85,7 +85,7 @@ RSpec.describe "Wysiwyg work package button spec", :js do # Save wiki page click_on "Save" - expect(page).to have_css(".op-toast.-success") + expect_primerized_flash(message: "Successful creation.") within("#content") do expect(page).to have_css("a[href=\"/projects/my-project/work_packages/new?type=#{type.id}\"]") diff --git a/spec/features/wysiwyg/tables_spec.rb b/spec/features/wysiwyg/tables_spec.rb index eb780e9cf55..7189168013f 100644 --- a/spec/features/wysiwyg/tables_spec.rb +++ b/spec/features/wysiwyg/tables_spec.rb @@ -67,7 +67,7 @@ RSpec.describe "Wysiwyg tables", :js do # Save wiki page click_on "Save" - expect(page).to have_css(".op-toast.-success") + expect_and_dismiss_primerized_flash(message: "Successful creation.") within("#content") do expect(page).to have_css("table td", text: "h1") @@ -116,7 +116,7 @@ RSpec.describe "Wysiwyg tables", :js do # Save wiki page click_on "Save" - expect(page).to have_css(".op-toast.-success") + expect_and_dismiss_primerized_flash(message: "Successful creation.") within("#content") do expect(page).to have_css("table th", text: "h1") @@ -181,7 +181,7 @@ RSpec.describe "Wysiwyg tables", :js do # Save wiki page click_on "Save" - expect(page).to have_css(".op-toast.-success") + expect_and_dismiss_primerized_flash(message: "Successful creation.") within("#content") do expect(page).to have_css('td[style*="background-color:#123456"]') @@ -232,7 +232,7 @@ RSpec.describe "Wysiwyg tables", :js do # Save wiki page click_on "Save" - expect(page).to have_css(".op-toast.-success") + expect_and_dismiss_primerized_flash(message: "Successful update.") within("#content") do # table height and width is set on figure @@ -297,7 +297,7 @@ RSpec.describe "Wysiwyg tables", :js do # Save wiki page click_on "Save" - expect(page).to have_css(".op-toast.-success") + expect_and_dismiss_primerized_flash(message: "Successful creation.") within("#content") do expect(page).to have_css('td[style*="width:250px"]') diff --git a/spec/features/wysiwyg/work_package_linking_spec.rb b/spec/features/wysiwyg/work_package_linking_spec.rb index 5b3d54bf381..b38ea0aea89 100644 --- a/spec/features/wysiwyg/work_package_linking_spec.rb +++ b/spec/features/wysiwyg/work_package_linking_spec.rb @@ -53,7 +53,7 @@ RSpec.describe "Wysiwyg work package linking", :js do # Save wiki page click_on "Save" - expect(page).to have_css(".op-toast.-success") + expect_primerized_flash(message: "Successful creation.") within("#content") do expect(page).to have_css("a.issue", count: 1) diff --git a/spec/helpers/error_message_helper_spec.rb b/spec/helpers/error_message_helper_spec.rb index 8beb03106e6..980171dca14 100644 --- a/spec/helpers/error_message_helper_spec.rb +++ b/spec/helpers/error_message_helper_spec.rb @@ -30,14 +30,21 @@ require "spec_helper" RSpec.describe ErrorMessageHelper do let(:model) { WikiPage.new } + let(:errors) { model.errors } def escape_html(array) array.map { CGI.escapeHTML _1 } end + subject { flash[:error] } + + before do + helper.instance_variable_set(:@wiki_page, model) + end + shared_examples "error messages rendering" do context "when no errors" do - it { expect(rendered).to eq("") } + it { expect(subject).to be_nil } end context "with one field error" do @@ -45,9 +52,13 @@ RSpec.describe ErrorMessageHelper do errors.add(:title, :blank) end - it { expect(rendered).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 1)) } - it { expect(rendered).to include(t("errors.header_invalid_fields", count: 1)) } - it { expect(rendered).to include(*escape_html(errors.full_messages)) } + it "adds the error messages", :aggregate_failures do + helper.error_messages_for("wiki_page") + + expect(subject).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 1)) + expect(subject).to include(t("errors.header_invalid_fields", count: 1)) + expect(subject).to include(*escape_html(errors.full_messages)) + end end context "with two field errors" do @@ -56,9 +67,13 @@ RSpec.describe ErrorMessageHelper do errors.add(:author, :blank) end - it { expect(rendered).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 2)) } - it { expect(rendered).to include(t("errors.header_invalid_fields", count: 2)) } - it { expect(rendered).to include(*escape_html(errors.full_messages)) } + it "adds both error messages", :aggregate_failures do + helper.error_messages_for("wiki_page") + + expect(subject).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 2)) + expect(subject).to include(t("errors.header_invalid_fields", count: 2)) + expect(subject).to include(*escape_html(errors.full_messages)) + end end context "with one base error" do @@ -66,10 +81,13 @@ RSpec.describe ErrorMessageHelper do errors.add(:base, :error_unauthorized) end - it { expect(rendered).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 1)) } - it { expect(rendered).not_to include(t("errors.header_invalid_fields", count: 1)) } - it { expect(rendered).not_to include(t("errors.header_additional_invalid_fields", count: 1)) } - it { expect(rendered).to include(*escape_html(errors.full_messages)) } + it "adds the one error message", :aggregate_failures do + helper.error_messages_for("wiki_page") + + expect(subject).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 1)) + expect(subject).not_to include(t("errors.header_additional_invalid_fields", count: 1)) + expect(subject).to include(*escape_html(errors.full_messages)) + end end context "with one base error and one field error" do @@ -78,9 +96,13 @@ RSpec.describe ErrorMessageHelper do errors.add(:title, :blank) end - it { expect(rendered).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 2)) } - it { expect(rendered).to include(t("errors.header_additional_invalid_fields", count: 1)) } - it { expect(rendered).to include(*escape_html(errors.full_messages)) } + it "adds both error messages", :aggregate_failures do + helper.error_messages_for("wiki_page") + + expect(subject).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 2)) + expect(subject).to include(t("errors.header_additional_invalid_fields", count: 1)) + expect(subject).to include(*escape_html(errors.full_messages)) + end end context "with two base errors and two field errors" do @@ -91,27 +113,28 @@ RSpec.describe ErrorMessageHelper do errors.add(:author, :blank) end - it { expect(rendered).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 4)) } - it { expect(rendered).to include(t("errors.header_additional_invalid_fields", count: 2)) } - it { expect(rendered).to include(*escape_html(errors.full_messages)) } + it "adds both error messages", :aggregate_failures do + helper.error_messages_for("wiki_page") + + expect(subject).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 4)) + expect(subject).to include(t("errors.header_additional_invalid_fields", count: 2)) + expect(subject).to include(*escape_html(errors.full_messages)) + end end end describe "#error_messages_for" do - let(:errors) { model.errors } - - subject(:rendered) { helper.error_messages_for(model) } - it "accesses the model from instance variables if a name is given" do - helper.instance_variable_set(:@wiki_page, model) model.errors.add(:base, :error_conflict) - expect(helper.error_messages_for("wiki_page")).to include(*escape_html(errors.full_messages)) + helper.error_messages_for("wiki_page") + expect(subject).to include(*escape_html(errors.full_messages)) end it "renders nothing if there is no instance variable with the given name" do - helper.instance_variable_set(:@wiki_page, model) model.errors.add(:base, :error_conflict) - expect(helper.error_messages_for("work_package")).to be_nil + helper.error_messages_for("work_package") + + expect(subject).to be_nil end include_examples "error messages rendering" diff --git a/spec/support/components/password_confirmation_dialog.rb b/spec/support/components/password_confirmation_dialog.rb index f488f806f86..1870544ff33 100644 --- a/spec/support/components/password_confirmation_dialog.rb +++ b/spec/support/components/password_confirmation_dialog.rb @@ -26,11 +26,14 @@ # See COPYRIGHT and LICENSE files for more details. #++ +require "support/primerized_flash/expectations" + module Components class PasswordConfirmationDialog include Capybara::DSL include Capybara::RSpecMatchers include RSpec::Matchers + include PrimerizedFlash::Expectations def confirm_flow_with(password, with_keyboard: false, should_fail: false) expect_open @@ -68,8 +71,7 @@ module Components end if should_fail - expect(page).to have_css(".op-toast.-error", - text: I18n.t(:notice_password_confirmation_failed)) + expect_primerized_error(I18n.t(:notice_password_confirmation_failed)) else expect(page).to have_no_css(".op-toast.-error") end diff --git a/spec/support/pages/admin/system_settings/languages.rb b/spec/support/pages/admin/system_settings/languages.rb index e31afc5ff47..456647b47b7 100644 --- a/spec/support/pages/admin/system_settings/languages.rb +++ b/spec/support/pages/admin/system_settings/languages.rb @@ -38,7 +38,7 @@ module Pages::Admin::SystemSettings def save press_save_button - expect_and_dismiss_toaster + expect_and_dismiss_primerized_flash(message: "Successful update.") end end end diff --git a/spec/support/pages/my/password_page.rb b/spec/support/pages/my/password_page.rb index 666edc34a3f..d5d052ac478 100644 --- a/spec/support/pages/my/password_page.rb +++ b/spec/support/pages/my/password_page.rb @@ -55,8 +55,7 @@ module Pages end def expect_password_updated_message - expect(page) - .to have_css(".op-toast.-info", text: I18n.t(:notice_account_password_updated)) + expect_and_dismiss_primerized_flash(type: :info, message: I18n.t(:notice_account_password_updated)) end private diff --git a/spec/support/pages/page.rb b/spec/support/pages/page.rb index fb624b11ed1..dfc03e770df 100644 --- a/spec/support/pages/page.rb +++ b/spec/support/pages/page.rb @@ -27,6 +27,7 @@ #++ require_relative "../toasts/expectations" +require_relative "../primerized_flash/expectations" module Pages class Page @@ -36,6 +37,7 @@ module Pages include RSpec::Matchers include OpenProject::StaticRouting::UrlHelpers include Toasts::Expectations + include PrimerizedFlash::Expectations def current_page? URI.parse(current_url).path == path diff --git a/spec/support/pages/projects/settings.rb b/spec/support/pages/projects/settings.rb index c4ea8fc847f..1482c6e1e99 100644 --- a/spec/support/pages/projects/settings.rb +++ b/spec/support/pages/projects/settings.rb @@ -43,11 +43,6 @@ module Pages visit "/projects/#{project.identifier}/settings/#{name}" end - # only notice is used as opposed to op-toast - def expect_toast(message:, type: :success) - expect(page).to have_css(".op-toast.-#{type}", text: message, wait: 10) - end - def expect_type_active(type) expect_type(type, true) end diff --git a/spec/support/pages/work_packages/work_packages_table.rb b/spec/support/pages/work_packages/work_packages_table.rb index 1b4fce19086..4d042339dd2 100644 --- a/spec/support/pages/work_packages/work_packages_table.rb +++ b/spec/support/pages/work_packages/work_packages_table.rb @@ -238,7 +238,7 @@ module Pages loading_indicator_saveguard # The 'id' column should have enough space to be clicked click_target = row(work_package).find(".inline-edit--display-field.id") - page.driver.browser.action.double_click(click_target.native).perform + click_target.double_click FullWorkPackage.new(work_package, project) end diff --git a/spec/support/primerized_flash/expectations.rb b/spec/support/primerized_flash/expectations.rb index e13e222bfa2..1ad9b32bd87 100644 --- a/spec/support/primerized_flash/expectations.rb +++ b/spec/support/primerized_flash/expectations.rb @@ -1,8 +1,17 @@ module PrimerizedFlash module Expectations + def expect_primerized_error(message) + expect_primerized_flash(message:, type: :error) + end + def expect_primerized_flash(message:, type: :success, wait: 20) - mapped_scheme = expected_flash_type(type) - expect(page).to have_css(".Banner--#{mapped_scheme}", text: message, wait:) + expected_css = expected_flash_css(type) + expect(page).to have_css(expected_css, text: message, wait:) + end + + def find_primerized_flash(type:) + expected_css = expected_flash_css(type) + page.find(expected_css) end def expect_and_dismiss_primerized_flash(message: nil, type: :success, wait: 20) @@ -26,12 +35,22 @@ module PrimerizedFlash if type.nil? expect(page).not_to have_test_selector("op-primer-flash-message") else - mapped_scheme = expected_flash_type(type) - expect(page).to have_no_css(".Banner--#{mapped_scheme}", text: message, wait:) + expected_css = expected_flash_css(type) + expect(page).to have_no_css(expected_css, text: message, wait:) end end - def expected_flash_type(type) + def expected_flash_css(type) + scheme = mapped_flash_type(type) + case scheme + when :default + %{[data-test-selector="op-primer-flash-message"].Banner} + else + %{[data-test-selector="op-primer-flash-message"].Banner--#{scheme}} + end + end + + def mapped_flash_type(type) case type when :error :error # The class is error, but the scheme is danger diff --git a/spec/support/toasts/expectations.rb b/spec/support/toasts/expectations.rb index c53065fb4cc..f27aee85311 100644 --- a/spec/support/toasts/expectations.rb +++ b/spec/support/toasts/expectations.rb @@ -4,9 +4,13 @@ module Toasts if toast_type == :angular expect(page).to have_css(".op-toast.-#{type}", text: message, wait:) elsif type == :error - expect(page).to have_css(".errorExplanation", text: message) + ActiveSupport::Deprecation.warn("Use `expect_primerized_error(message)` instead of expect_toast with type: :error") + expect_primerized_error(message) elsif type == :success - expect(page).to have_css(".op-toast.-success", text: message) + ActiveSupport::Deprecation.warn( + "Use `expect_primerized_flash(type: :success, message:)` instead of expect_toast with type: :success" + ) + expect_primerized_flash(message:) else raise NotImplementedError end From 7e6a923790fca562df064910ba8e00c7c724e44e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Thu, 26 Sep 2024 11:11:38 +0200 Subject: [PATCH 08/14] Remove instance variables in error helper and lint --- app/helpers/errors_helper.rb | 51 +++++++++++++++------------------ app/views/common/error.html.erb | 2 +- 2 files changed, 24 insertions(+), 29 deletions(-) diff --git a/app/helpers/errors_helper.rb b/app/helpers/errors_helper.rb index a41b5fb2101..507828b3fc9 100644 --- a/app/helpers/errors_helper.rb +++ b/app/helpers/errors_helper.rb @@ -27,34 +27,34 @@ #++ module ErrorsHelper - def render_400(options = {}) - @project = nil + def render_400(options = {}) # rubocop:disable Naming/VariableNumber + unset_template_magic render_error({ message: :notice_bad_request, status: 400 }.merge(options)) false end - def render_403(options = {}) - @project = nil + def render_403(options = {}) # rubocop:disable Naming/VariableNumber + unset_template_magic render_error({ message: :notice_not_authorized, status: 403 }.merge(options)) false end - def render_404(options = {}) + def render_404(options = {}) # rubocop:disable Naming/VariableNumber render_error({ message: :notice_file_not_found, status: 404 }.merge(options)) false end - def render_500(options = {}) - message = t(:notice_internal_server_error, app_title: Setting.app_title) - + def render_500(options = {}) # rubocop:disable Naming/VariableNumber unset_template_magic + message = t(:notice_internal_server_error, app_title: Setting.app_title) + # Append error information if current_user.admin? options[:message_details] = get_additional_message end - render_error({ message: }.merge(options)) + render_error({ message:, status: 500 }.merge(options)) false end @@ -80,39 +80,34 @@ module ErrorsHelper end # Renders an error response - def render_error(arg) + def render_error(arg) # rubocop:disable Metrics/AbcSize arg = { message: arg } unless arg.is_a?(Hash) - @status = arg[:status] || 500 - @message = arg[:message] + status = arg[:status] || 500 + message = arg[:message] - if @status >= 500 - op_handle_error(arg[:exception] || "[Error #@status] #@message", payload: arg[:payload]) + if status >= 500 + op_handle_error(arg[:exception] || "[Error #status] #message", payload: arg[:payload]) end - @message = I18n.t(@message) if @message.is_a?(Symbol) - @message_details = arg[:message_details] + message = I18n.t(message) if message.is_a?(Symbol) + message_details = arg[:message_details] respond_to do |format| format.html do - error_message = "[#{I18n.t(:error_code, code: @status)}] #{@message}\n#{@message_details}" + error_message = "[#{I18n.t(:error_code, code: status)}] #{message}\n#{message_details}" flash.now[:op_primer_flash] = { scheme: :danger, message: error_message, dismiss_scheme: :none } - render template: "common/error", layout: use_layout, status: @status + render template: "common/error", + layout: use_layout, + status:, + locals: { status:, params: } end format.any do - head @status + head status end end end def unset_template_magic - if $ERROR_INFO.is_a?(ActionView::ActionViewError) - @template.instance_variable_set(:@project, nil) - @template.instance_variable_set(:@status, 500) - @template.instance_variable_set(:@message, message) - else - @project = nil - end - rescue StandardError - # bad luck + @project = nil # rubocop:disable Rails/HelperInstanceVariable end end diff --git a/app/views/common/error.html.erb b/app/views/common/error.html.erb index 85f38b27a71..ea265ef425a 100644 --- a/app/views/common/error.html.erb +++ b/app/views/common/error.html.erb @@ -29,4 +29,4 @@ See COPYRIGHT and LICENSE files for more details. <%= call_hook(:view_common_error_details, { params: params, project: ((defined? @project) ? @project : nil) }) %> -<% html_title h(@status) %> +<% html_title h(status) %> From 23f12be1b38283d37f3193f4824a312e1f10c2c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Thu, 26 Sep 2024 11:20:32 +0200 Subject: [PATCH 09/14] Remove op_primer_flash as it is no longer needed --- app/controllers/my_controller.rb | 4 ++-- app/helpers/errors_helper.rb | 2 +- app/helpers/flash_messages_helper.rb | 12 +++++------ lookbook/docs/patterns/08-flash-banner.md.erb | 20 ++++++++++++++----- ...ally_managed_project_folders_controller.rb | 5 +---- .../admin/oauth_clients_controller.rb | 2 +- .../storages/admin/storages_controller.rb | 10 ++++------ 7 files changed, 30 insertions(+), 25 deletions(-) diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index e26217385d0..129cccccdf5 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -174,13 +174,13 @@ class MyController < ApplicationController # rubocop:disable Rails/ActionControllerFlashBeforeRender result.on_success do - flash[:op_primer_flash] = { message: t("my.access_token.notice_api_token_revoked") } + flash[:notice] = t("my.access_token.notice_api_token_revoked") end result.on_failure do |r| error = r.errors.map(&:message).join("; ") Rails.logger.error("Failed to revoke api token ##{current_user.id}: #{error}") - flash[:op_primer_flash] = { message: t("my.access_token.failed_to_revoke_token", error:), scheme: :danger } + flash[:error] = t("my.access_token.failed_to_revoke_token", error:) end # rubocop:enable Rails/ActionControllerFlashBeforeRender diff --git a/app/helpers/errors_helper.rb b/app/helpers/errors_helper.rb index 507828b3fc9..561164407ee 100644 --- a/app/helpers/errors_helper.rb +++ b/app/helpers/errors_helper.rb @@ -95,7 +95,7 @@ module ErrorsHelper respond_to do |format| format.html do error_message = "[#{I18n.t(:error_code, code: status)}] #{message}\n#{message_details}" - flash.now[:op_primer_flash] = { scheme: :danger, message: error_message, dismiss_scheme: :none } + flash.now[:error] = { message: error_message, dismiss_scheme: :none } render template: "common/error", layout: use_layout, status:, diff --git a/app/helpers/flash_messages_helper.rb b/app/helpers/flash_messages_helper.rb index 4f74da65c59..fa02f49912c 100644 --- a/app/helpers/flash_messages_helper.rb +++ b/app/helpers/flash_messages_helper.rb @@ -45,11 +45,11 @@ module FlashMessagesHelper end def render_flash_content(key, content) - case key - when :op_primer_flash - render_flash_message(content[:scheme] || :default, content[:message], **content.except(:message)) + case content + when Hash + render_flash_message(key, **content) else - render_flash_message(key, content) + render_flash_message(key, message: content) end end @@ -74,8 +74,8 @@ module FlashMessagesHelper end end - def render_flash_message(type, message, **args) - render(OpPrimer::FlashComponent.new(scheme: mapped_flash_type(type), **args.except(:scheme))) do + def render_flash_message(type, message:, **args) + render(OpPrimer::FlashComponent.new(scheme: mapped_flash_type(type), **args)) do join_flash_messages(message) end end diff --git a/lookbook/docs/patterns/08-flash-banner.md.erb b/lookbook/docs/patterns/08-flash-banner.md.erb index 29cd2c23249..667a37ab591 100644 --- a/lookbook/docs/patterns/08-flash-banner.md.erb +++ b/lookbook/docs/patterns/08-flash-banner.md.erb @@ -17,21 +17,31 @@ See below for available arguments. ## Render primer banner / flash from controllers In many views in OpenProject, you will find `flash[:notice], flash[:alert], flash[:error]` messages. -These are rendered using the previous `op-flash` styles, and are not yet primerized. +All of these are now rendered with primer banners by default. -So if you find yourself in need to render a primerized flash. You can use this pattern instead: +If you find the need to customize the rendering of the flash, you can also pass a hash to the flash: ```ruby -flash[:op_primer_flash] = { message: "Successful update", scheme: :success, icon: :check } +flash[:notice] = { message: "Successful update", icon: :check } ``` Or for an error: ```ruby -flash[:op_primer_flash] = { message: "Oh no! Something went wrong", scheme: :danger, icon: :alert } +flash[:error] = { message: "Oh no! Something went wrong", icon: :alert } ``` -These are rendered in the layout through the `render_banner_messages` helper using the `OpPrimer::FlashComponent`. +If you want to render multiple lines, `message` can also be an array that will be joined by breaklines for rendering: + +```ruby +flash[:error] = { message: ["Oh no! Something went wrong", "Some more details here"], icon: :alert } +``` + +If you want to make the flash non-dismissable, you can pass `dismiss_scheme: :none`: + +```ruby +flash[:error] = { message: "Oh noes!"], icon: :alert, dismiss_scheme: :none } +``` ## Usage in turbo streams diff --git a/modules/storages/app/controllers/storages/admin/automatically_managed_project_folders_controller.rb b/modules/storages/app/controllers/storages/admin/automatically_managed_project_folders_controller.rb index b11474c1eb1..3b1ec1ab1c3 100644 --- a/modules/storages/app/controllers/storages/admin/automatically_managed_project_folders_controller.rb +++ b/modules/storages/app/controllers/storages/admin/automatically_managed_project_folders_controller.rb @@ -73,10 +73,7 @@ class Storages::Admin::AutomaticallyManagedProjectFoldersController < Applicatio service_result = call_update_service if service_result.success? - flash[:op_primer_flash] = { - message: I18n.t(:"storages.notice_successful_storage_connection"), - scheme: :success - } + flash[:notice] = I18n.t(:"storages.notice_successful_storage_connection") redirect_to edit_admin_settings_storage_path(@storage) else respond_with_ampf_form_turbo_stream_or_edit_html diff --git a/modules/storages/app/controllers/storages/admin/oauth_clients_controller.rb b/modules/storages/app/controllers/storages/admin/oauth_clients_controller.rb index fbc7c485a41..9424e717d57 100644 --- a/modules/storages/app/controllers/storages/admin/oauth_clients_controller.rb +++ b/modules/storages/app/controllers/storages/admin/oauth_clients_controller.rb @@ -125,7 +125,7 @@ class Storages::Admin::OAuthClientsController < ApplicationController end def finish_setup - flash[:op_primer_flash] = { message: I18n.t(:"storages.notice_successful_storage_connection"), scheme: :success } + flash[:notice] = I18n.t(:"storages.notice_successful_storage_connection") redirect_to edit_admin_settings_storage_path(@storage) end diff --git a/modules/storages/app/controllers/storages/admin/storages_controller.rb b/modules/storages/app/controllers/storages/admin/storages_controller.rb index c3368842839..4891d9b8119 100644 --- a/modules/storages/app/controllers/storages/admin/storages_controller.rb +++ b/modules/storages/app/controllers/storages/admin/storages_controller.rb @@ -191,9 +191,7 @@ class Storages::Admin::StoragesController < ApplicationController update_via_turbo_stream(component: Storages::Admin::SidePanel::HealthNotificationsComponent.new(storage: @storage)) respond_with_turbo_streams else - flash.now[:op_primer_flash] = { - message: I18n.t("storages.health_email_notifications.error_could_not_be_saved"), scheme: :danger - } + flash.now[:error] = I18n.t("storages.health_email_notifications.error_could_not_be_saved") render :edit end end @@ -209,11 +207,11 @@ class Storages::Admin::StoragesController < ApplicationController # rubocop:disable Rails/ActionControllerFlashBeforeRender service_result.on_failure do - flash[:op_primer_flash] = { message: join_flash_messages(service_result.errors.full_messages), scheme: :danger } + flash[:error] = service_result.errors.full_messages end service_result.on_success do - flash[:op_primer_flash] = { message: I18n.t(:notice_successful_delete), scheme: :success } + flash[:notice] = I18n.t(:notice_successful_delete) end # rubocop:enable Rails/ActionControllerFlashBeforeRender @@ -265,7 +263,7 @@ class Storages::Admin::StoragesController < ApplicationController def ensure_valid_provider_type_selected short_provider_type = params[:provider] if short_provider_type.blank? || (@provider_type = ::Storages::Storage::PROVIDER_TYPE_SHORT_NAMES[short_provider_type]).blank? - flash[:op_primer_flash] = { message: I18n.t("storages.error_invalid_provider_type"), scheme: :danger } + flash[:error] = I18n.t("storages.error_invalid_provider_type") redirect_to admin_settings_storages_path end end From 5975e9ca25fe1706acf8f4a5aa91db0fcd35eda5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Thu, 26 Sep 2024 11:32:10 +0200 Subject: [PATCH 10/14] Add autohide controller to move code from legacy to stimulus --- app/components/op_primer/flash_component.erb | 6 ++++- app/components/op_primer/flash_component.rb | 2 ++ app/views/layouts/_flashes.html.erb | 3 +++ app/views/layouts/base.html.erb | 2 -- .../global-listeners/setup-server-response.ts | 18 -------------- .../stimulus/controllers/flash.controller.ts | 24 +++++++++++++++++++ frontend/src/stimulus/setup.ts | 2 ++ 7 files changed, 36 insertions(+), 21 deletions(-) create mode 100644 frontend/src/stimulus/controllers/flash.controller.ts diff --git a/app/components/op_primer/flash_component.erb b/app/components/op_primer/flash_component.erb index 4682dfebf99..2f2cb190f3a 100644 --- a/app/components/op_primer/flash_component.erb +++ b/app/components/op_primer/flash_component.erb @@ -31,7 +31,11 @@ See COPYRIGHT and LICENSE files for more details. render(Primer::BaseComponent.new( tag: :div, classes: "op-primer-flash--item", - data: { unique_key: @unique_key }.compact + data: { + "flash-target": "item", + "autohide": @autohide, + unique_key: @unique_key + }.compact )) do render_parent end diff --git a/app/components/op_primer/flash_component.rb b/app/components/op_primer/flash_component.rb index c93edcae9a7..fed84bf511f 100644 --- a/app/components/op_primer/flash_component.rb +++ b/app/components/op_primer/flash_component.rb @@ -39,6 +39,8 @@ module OpPrimer system_arguments[:dismiss_scheme] ||= :remove system_arguments[:dismiss_label] ||= I18n.t(:button_close) + @autohide = system_arguments[:scheme] == :success && system_arguments[:dismiss_scheme] != :none + super end end diff --git a/app/views/layouts/_flashes.html.erb b/app/views/layouts/_flashes.html.erb index c37aa9f0cff..8f9bcd92940 100644 --- a/app/views/layouts/_flashes.html.erb +++ b/app/views/layouts/_flashes.html.erb @@ -5,3 +5,6 @@ data-flash-autohide-value="<%= User.current.pref.auto_hide_popups? %>"> <%= render_flash_messages %> + +<%# Flash modals render modal components %> +<%= render_flash_modal %> diff --git a/app/views/layouts/base.html.erb b/app/views/layouts/base.html.erb index b864e15fb9f..0895f2c65f5 100644 --- a/app/views/layouts/base.html.erb +++ b/app/views/layouts/base.html.erb @@ -118,8 +118,6 @@ See COPYRIGHT and LICENSE files for more details.
<%= content_tag :main, id: "content-wrapper", class: initial_classes, data: stimulus_content_data do %> <%= render partial: "layouts/flashes" %> - <%# Flash modals render modal components %> - <%= render_flash_modal %> <% if show_onboarding_modal? %>
{ - jQuery('.op-toast.autohide-toaster').remove(); - }, 5000); -} - function addClickEventToAllErrorMessages() { jQuery('a.afocus').each(function () { const target = jQuery(this); diff --git a/frontend/src/stimulus/controllers/flash.controller.ts b/frontend/src/stimulus/controllers/flash.controller.ts new file mode 100644 index 00000000000..61178e1ca0a --- /dev/null +++ b/frontend/src/stimulus/controllers/flash.controller.ts @@ -0,0 +1,24 @@ +import { ApplicationController } from 'stimulus-use'; + +export const SUCCESS_AUTOHIDE_TIMEOUT = 5000; + +export default class FlashController extends ApplicationController { + static values = { + autohide: Boolean, + }; + + declare autohideValue:boolean; + + static targets = [ + 'item', + ]; + + declare readonly itemTargets:HTMLElement; + + itemTargetConnected(element:HTMLElement) { + const autohide = element.dataset.autohide === 'true'; + if (this.autohideValue && autohide) { + setTimeout(() => element.remove(), SUCCESS_AUTOHIDE_TIMEOUT); + } + } +} diff --git a/frontend/src/stimulus/setup.ts b/frontend/src/stimulus/setup.ts index e1789326e07..59fa7f5045b 100644 --- a/frontend/src/stimulus/setup.ts +++ b/frontend/src/stimulus/setup.ts @@ -10,6 +10,7 @@ import PollForChangesController from './controllers/poll-for-changes.controller' import TableHighlightingController from './controllers/table-highlighting.controller'; import OpShowWhenCheckedController from './controllers/show-when-checked.controller'; import OpShowWhenValueSelectedController from './controllers/show-when-value-selected.controller'; +import FlashController from './controllers/flash.controller'; declare global { interface Window { @@ -31,6 +32,7 @@ instance.register('menus--main', MainMenuController); instance.register('show-when-checked', OpShowWhenCheckedController); instance.register('disable-when-checked', OpDisableWhenCheckedController); instance.register('show-when-value-selected', OpShowWhenValueSelectedController); +instance.register('flash', FlashController); instance.register('print', PrintController); instance.register('refresh-on-form-changes', RefreshOnFormChangesController); instance.register('async-dialog', AsyncDialogController); From 930ffaf6129e404249c9a6986489e84f9cf3468d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Fri, 27 Sep 2024 13:13:58 +0200 Subject: [PATCH 11/14] Replace list with separate lines the list can not be rendered within primer --- app/helpers/error_message_helper.rb | 18 ++++++---- spec/helpers/error_message_helper_spec.rb | 42 ++++++++++++----------- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/app/helpers/error_message_helper.rb b/app/helpers/error_message_helper.rb index c35ec8865d8..2a9dd2485a6 100644 --- a/app/helpers/error_message_helper.rb +++ b/app/helpers/error_message_helper.rb @@ -46,12 +46,14 @@ module ErrorMessageHelper base_error_messages = errors.full_messages_for(:base) fields_error_messages = errors.full_messages - base_error_messages - flash[:error] = error_flash_content(object, base_error_messages, fields_error_messages) + flash[:error] = { + message: error_message_header(object.class.model_name.human, base_error_messages.count + fields_error_messages.count), + description: error_flash_description(object, base_error_messages, fields_error_messages) + } end - def error_flash_content(object, base_error_messages, fields_error_messages) + def error_flash_description(_object, base_error_messages, fields_error_messages) capture do - concat error_message_header(object.class.model_name.human, base_error_messages.count + fields_error_messages.count) concat list_of_messages(base_error_messages) concat text_header_invalid_fields(base_error_messages, fields_error_messages) concat list_of_messages(fields_error_messages) @@ -66,13 +68,17 @@ module ErrorMessageHelper return if fields_error_messages.blank? i18n_key = base_error_messages.present? ? "errors.header_additional_invalid_fields" : "errors.header_invalid_fields" - t(i18n_key, count: fields_error_messages.count) + out = "".html_safe + + out << t(i18n_key, count: fields_error_messages.count) + out << "
".html_safe + + out end def list_of_messages(messages) return if messages.blank? - messages = messages.map { |message| tag.li message } - tag.ul { safe_join(messages, "\n") } + safe_join(messages, "
".html_safe) end end diff --git a/spec/helpers/error_message_helper_spec.rb b/spec/helpers/error_message_helper_spec.rb index 980171dca14..d158f056df4 100644 --- a/spec/helpers/error_message_helper_spec.rb +++ b/spec/helpers/error_message_helper_spec.rb @@ -32,19 +32,21 @@ RSpec.describe ErrorMessageHelper do let(:model) { WikiPage.new } let(:errors) { model.errors } + let(:error_flash) { flash[:error] } + let(:message) { error_flash[:message] } + let(:description) { error_flash[:description] } + def escape_html(array) array.map { CGI.escapeHTML _1 } end - subject { flash[:error] } - before do helper.instance_variable_set(:@wiki_page, model) end shared_examples "error messages rendering" do context "when no errors" do - it { expect(subject).to be_nil } + it { expect(error_flash).to be_nil } end context "with one field error" do @@ -55,9 +57,9 @@ RSpec.describe ErrorMessageHelper do it "adds the error messages", :aggregate_failures do helper.error_messages_for("wiki_page") - expect(subject).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 1)) - expect(subject).to include(t("errors.header_invalid_fields", count: 1)) - expect(subject).to include(*escape_html(errors.full_messages)) + expect(message).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 1)) + expect(description).to include(t("errors.header_invalid_fields", count: 1)) + expect(description).to include(*escape_html(errors.full_messages)) end end @@ -70,9 +72,9 @@ RSpec.describe ErrorMessageHelper do it "adds both error messages", :aggregate_failures do helper.error_messages_for("wiki_page") - expect(subject).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 2)) - expect(subject).to include(t("errors.header_invalid_fields", count: 2)) - expect(subject).to include(*escape_html(errors.full_messages)) + expect(message).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 2)) + expect(description).to include(t("errors.header_invalid_fields", count: 2)) + expect(description).to include(*escape_html(errors.full_messages)) end end @@ -84,9 +86,9 @@ RSpec.describe ErrorMessageHelper do it "adds the one error message", :aggregate_failures do helper.error_messages_for("wiki_page") - expect(subject).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 1)) - expect(subject).not_to include(t("errors.header_additional_invalid_fields", count: 1)) - expect(subject).to include(*escape_html(errors.full_messages)) + expect(message).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 1)) + expect(description).not_to include(t("errors.header_additional_invalid_fields", count: 1)) + expect(description).to include(*escape_html(errors.full_messages)) end end @@ -99,9 +101,9 @@ RSpec.describe ErrorMessageHelper do it "adds both error messages", :aggregate_failures do helper.error_messages_for("wiki_page") - expect(subject).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 2)) - expect(subject).to include(t("errors.header_additional_invalid_fields", count: 1)) - expect(subject).to include(*escape_html(errors.full_messages)) + expect(message).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 2)) + expect(description).to include(t("errors.header_additional_invalid_fields", count: 1)) + expect(description).to include(*escape_html(errors.full_messages)) end end @@ -116,9 +118,9 @@ RSpec.describe ErrorMessageHelper do it "adds both error messages", :aggregate_failures do helper.error_messages_for("wiki_page") - expect(subject).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 4)) - expect(subject).to include(t("errors.header_additional_invalid_fields", count: 2)) - expect(subject).to include(*escape_html(errors.full_messages)) + expect(message).to include(t("activerecord.errors.template.header", model: "Wiki page", count: 4)) + expect(description).to include(t("errors.header_additional_invalid_fields", count: 2)) + expect(description).to include(*escape_html(errors.full_messages)) end end end @@ -127,14 +129,14 @@ RSpec.describe ErrorMessageHelper do it "accesses the model from instance variables if a name is given" do model.errors.add(:base, :error_conflict) helper.error_messages_for("wiki_page") - expect(subject).to include(*escape_html(errors.full_messages)) + expect(description).to include(*escape_html(errors.full_messages)) end it "renders nothing if there is no instance variable with the given name" do model.errors.add(:base, :error_conflict) helper.error_messages_for("work_package") - expect(subject).to be_nil + expect(error_flash).to be_nil end include_examples "error messages rendering" From 88c1a8264f531222570c4e2a40aef99bb1ddfae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Mon, 30 Sep 2024 16:25:46 +0200 Subject: [PATCH 12/14] Update lookbook/docs/patterns/08-flash-banner.md.erb Co-authored-by: Christophe Bliard --- lookbook/docs/patterns/08-flash-banner.md.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lookbook/docs/patterns/08-flash-banner.md.erb b/lookbook/docs/patterns/08-flash-banner.md.erb index 667a37ab591..f89b5e1e377 100644 --- a/lookbook/docs/patterns/08-flash-banner.md.erb +++ b/lookbook/docs/patterns/08-flash-banner.md.erb @@ -40,7 +40,7 @@ flash[:error] = { message: ["Oh no! Something went wrong", "Some more details he If you want to make the flash non-dismissable, you can pass `dismiss_scheme: :none`: ```ruby -flash[:error] = { message: "Oh noes!"], icon: :alert, dismiss_scheme: :none } +flash[:error] = { message: "Oh no!", icon: :alert, dismiss_scheme: :none } ``` ## Usage in turbo streams From 9cc3d98391a98ce59f028344cec3f414a2b303b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Mon, 30 Sep 2024 20:53:07 +0200 Subject: [PATCH 13/14] Replace expect_primerized_error -> expect_primerized_flash --- .../bim/spec/features/model_management_spec.rb | 2 +- modules/bim/spec/features/model_viewer_spec.rb | 2 +- .../spec/features/board_management_spec.rb | 4 ++-- .../structured_meetings/history_spec.rb | 2 +- .../components/cost_reports_base_table.rb | 2 +- .../admin_edit_two_factor_devices_spec.rb | 2 +- .../login_with_backup_code_spec.rb | 2 +- .../features/login/login_enforced_2fa_spec.rb | 2 +- .../spec/features/login/login_with_2fa_spec.rb | 2 +- .../features/my_two_factor_devices_spec.rb | 4 ++-- .../spec/features/shared_2fa_examples.rb | 4 ++-- .../admin/attribute_help_texts_spec.rb | 2 +- .../admin/enterprise/enterprise_spec.rb | 3 ++- .../oauth_applications_management_spec.rb | 4 ++-- .../admin/test_mail_notification_spec.rb | 2 +- spec/features/admin/working_days_spec.rb | 5 +++-- spec/features/auth/consent_auth_stage_spec.rb | 2 +- spec/features/projects/modules_spec.rb | 5 ++--- .../overview_page/dialog/permission_spec.rb | 2 +- spec/features/projects/projects_index_spec.rb | 2 +- spec/features/roles/create_spec.rb | 5 +++-- spec/features/types/crud_spec.rb | 4 ++-- spec/features/users/password_change_spec.rb | 4 ++-- spec/features/versions/delete_spec.rb | 4 ++-- .../bulk/copy_work_package_spec.rb | 18 +++++++++++------- .../bulk/move_work_package_spec.rb | 14 +++++++------- .../bulk/update_work_package_spec.rb | 14 +++++++------- .../components/password_confirmation_dialog.rb | 4 ++-- .../expectations.rb | 8 ++------ spec/support/pages/page.rb | 2 +- spec/support/toasts/expectations.rb | 4 ++-- 31 files changed, 69 insertions(+), 67 deletions(-) rename spec/support/{primerized_flash => flash}/expectations.rb (91%) diff --git a/modules/bim/spec/features/model_management_spec.rb b/modules/bim/spec/features/model_management_spec.rb index 7d8686a3ca5..919d9f9874a 100644 --- a/modules/bim/spec/features/model_management_spec.rb +++ b/modules/bim/spec/features/model_management_spec.rb @@ -130,7 +130,7 @@ RSpec.describe "model management", :js, with_config: { edition: "bim" } do it "I can't see any models and perform no actions" do expected = "[Error 403] You are not authorized to access this page." - expect_primerized_error(expected) + expect_primerized_flash(type: :error, message: expected) index_page.add_model_allowed false end diff --git a/modules/bim/spec/features/model_viewer_spec.rb b/modules/bim/spec/features/model_viewer_spec.rb index cda6ce1b769..4229b29e959 100644 --- a/modules/bim/spec/features/model_viewer_spec.rb +++ b/modules/bim/spec/features/model_viewer_spec.rb @@ -135,7 +135,7 @@ RSpec.describe "model viewer", :js, with_config: { edition: "bim" } do it "shows no viewer" do expected = "[Error 403] You are not authorized to access this page." - expect_primerized_error(expected) + expect_primerized_flash(type: :error, message: expected) show_model_page.model_viewer_visible false show_model_page.model_viewer_shows_a_toolbar false diff --git a/modules/boards/spec/features/board_management_spec.rb b/modules/boards/spec/features/board_management_spec.rb index cbc2ad6ca2f..2c1c691e155 100644 --- a/modules/boards/spec/features/board_management_spec.rb +++ b/modules/boards/spec/features/board_management_spec.rb @@ -300,7 +300,7 @@ RSpec.describe "Board management spec", :js, with_ee: %i[board_view] do it "does not allow viewing of boards" do visit project_work_package_board_path(project, board_view) - expect_primerized_error(I18n.t(:notice_not_authorized)) + expect_primerized_flash(type: :error, message: I18n.t(:notice_not_authorized)) board_index.expect_editable false end @@ -311,7 +311,7 @@ RSpec.describe "Board management spec", :js, with_ee: %i[board_view] do it "does not allow viewing of boards" do board_index.visit! - expect_primerized_error(I18n.t(:notice_not_authorized)) + expect_primerized_flash(type: :error, message: I18n.t(:notice_not_authorized)) end end end diff --git a/modules/meeting/spec/features/structured_meetings/history_spec.rb b/modules/meeting/spec/features/structured_meetings/history_spec.rb index ffafbdaea5e..e2fb2aac866 100644 --- a/modules/meeting/spec/features/structured_meetings/history_spec.rb +++ b/modules/meeting/spec/features/structured_meetings/history_spec.rb @@ -355,6 +355,6 @@ RSpec.describe "history", visit history_meeting_path(meeting) expected = "[Error 403] You are not authorized to access this page." - expect_primerized_error(expected) + expect_primerized_flash(type: :error, message: expected) end end diff --git a/modules/reporting/spec/features/support/components/cost_reports_base_table.rb b/modules/reporting/spec/features/support/components/cost_reports_base_table.rb index aab032b1734..d2ce032bc97 100644 --- a/modules/reporting/spec/features/support/components/cost_reports_base_table.rb +++ b/modules/reporting/spec/features/support/components/cost_reports_base_table.rb @@ -33,7 +33,7 @@ module Components include Capybara::DSL include Capybara::RSpecMatchers include RSpec::Matchers - include PrimerizedFlash::Expectations + include Flash::Expectations attr_reader :time_logging_modal diff --git a/modules/two_factor_authentication/spec/features/admin_edit_two_factor_devices_spec.rb b/modules/two_factor_authentication/spec/features/admin_edit_two_factor_devices_spec.rb index 6d868259c62..68ad1f662a9 100644 --- a/modules/two_factor_authentication/spec/features/admin_edit_two_factor_devices_spec.rb +++ b/modules/two_factor_authentication/spec/features/admin_edit_two_factor_devices_spec.rb @@ -44,7 +44,7 @@ RSpec.describe "Admin 2FA management", :js, with_settings: { click_button I18n.t(:button_continue) # Enter valid phone number - expect_primerized_error("Phone number must be of format +XX XXXXXXXXX") + expect_primerized_flash(type: :error, message: "Phone number must be of format +XX XXXXXXXXX") SeleniumHubWaiter.wait fill_in "device_phone_number", with: "+49 123456789" diff --git a/modules/two_factor_authentication/spec/features/backup_codes/login_with_backup_code_spec.rb b/modules/two_factor_authentication/spec/features/backup_codes/login_with_backup_code_spec.rb index b2bfe0e6310..d678b2ea783 100644 --- a/modules/two_factor_authentication/spec/features/backup_codes/login_with_backup_code_spec.rb +++ b/modules/two_factor_authentication/spec/features/backup_codes/login_with_backup_code_spec.rb @@ -50,7 +50,7 @@ RSpec.describe "Login with 2FA backup code", :js, with_settings: { click_on "Submit" # Expect failure - expect_primerized_error(I18n.t("two_factor_authentication.error_invalid_backup_code")) + expect_primerized_flash(type: :error, message: I18n.t("two_factor_authentication.error_invalid_backup_code")) expect(page).to have_current_path signin_path # Try again! diff --git a/modules/two_factor_authentication/spec/features/login/login_enforced_2fa_spec.rb b/modules/two_factor_authentication/spec/features/login/login_enforced_2fa_spec.rb index 7af11b31c1f..d09c7a613ae 100644 --- a/modules/two_factor_authentication/spec/features/login/login_enforced_2fa_spec.rb +++ b/modules/two_factor_authentication/spec/features/login/login_enforced_2fa_spec.rb @@ -36,7 +36,7 @@ RSpec.describe "Login with enforced 2FA", :js, with_settings: { first_login_step two_factor_step("whatever") - expect_primerized_error(I18n.t(:notice_account_otp_invalid)) + expect_primerized_flash(type: :error, message: I18n.t(:notice_account_otp_invalid)) expect(page).to have_current_path signin_path end end diff --git a/modules/two_factor_authentication/spec/features/login/login_with_2fa_spec.rb b/modules/two_factor_authentication/spec/features/login/login_with_2fa_spec.rb index 75df63bbf05..dac190b4907 100644 --- a/modules/two_factor_authentication/spec/features/login/login_with_2fa_spec.rb +++ b/modules/two_factor_authentication/spec/features/login/login_with_2fa_spec.rb @@ -35,7 +35,7 @@ RSpec.describe "Login with 2FA device", :js, with_settings: { first_login_step two_factor_step("whatever") - expect_primerized_error(I18n.t(:notice_account_otp_invalid)) + expect_primerized_flash(type: :error, message: I18n.t(:notice_account_otp_invalid)) expect(page).to have_current_path signin_path end end diff --git a/modules/two_factor_authentication/spec/features/my_two_factor_devices_spec.rb b/modules/two_factor_authentication/spec/features/my_two_factor_devices_spec.rb index 0271c7f9ec4..39ebe5139e5 100644 --- a/modules/two_factor_authentication/spec/features/my_two_factor_devices_spec.rb +++ b/modules/two_factor_authentication/spec/features/my_two_factor_devices_spec.rb @@ -35,7 +35,7 @@ RSpec.describe "My Account 2FA configuration", :js, with_settings: { click_button I18n.t(:button_continue) # Enter valid phone number - expect_primerized_error("Phone number must be of format +XX XXXXXXXXX") + expect_primerized_flash(type: :error, message: "Phone number must be of format +XX XXXXXXXXX") fill_in "device_phone_number", with: "+49 123456789" click_button I18n.t(:button_continue) @@ -56,7 +56,7 @@ RSpec.describe "My Account 2FA configuration", :js, with_settings: { expect(page).to have_css("h2", text: I18n.t("two_factor_authentication.devices.confirm_device")) expect(page).to have_css("input#otp") - expect_primerized_error(I18n.t("two_factor_authentication.devices.registration_failed_token_invalid")) + expect_primerized_flash(type: :error, message: I18n.t("two_factor_authentication.devices.registration_failed_token_invalid")) # Fill in correct token fill_in "otp", with: sms_token diff --git a/modules/two_factor_authentication/spec/features/shared_2fa_examples.rb b/modules/two_factor_authentication/spec/features/shared_2fa_examples.rb index cad8428e776..d4d29eb0f8d 100644 --- a/modules/two_factor_authentication/spec/features/shared_2fa_examples.rb +++ b/modules/two_factor_authentication/spec/features/shared_2fa_examples.rb @@ -46,7 +46,7 @@ RSpec.shared_examples "create enforced sms device" do click_on "Continue" # Expect error on invalid phone - expect_primerized_error("Phone number must be of format +XX XXXXXXXXX") + expect_primerized_flash(type: :error, message: "Phone number must be of format +XX XXXXXXXXX") SeleniumHubWaiter.wait fill_in "device_phone_number", with: "+49 123456789" @@ -71,7 +71,7 @@ RSpec.shared_examples "create enforced sms device" do expect(page).to have_css("h2", text: I18n.t("two_factor_authentication.devices.confirm_device")) expect(page).to have_css("input#otp") - expect_primerized_error(I18n.t("two_factor_authentication.devices.registration_failed_token_invalid")) + expect_primerized_flash(type: :error, message: I18n.t("two_factor_authentication.devices.registration_failed_token_invalid")) SeleniumHubWaiter.wait # Fill in wrong token diff --git a/spec/features/admin/attribute_help_texts_spec.rb b/spec/features/admin/attribute_help_texts_spec.rb index ad855dc80af..fdbdf4f49e7 100644 --- a/spec/features/admin/attribute_help_texts_spec.rb +++ b/spec/features/admin/attribute_help_texts_spec.rb @@ -113,7 +113,7 @@ RSpec.describe "Attribute help texts", :js, :with_cuprite do click_button "Save" # Handle errors - expect_primerized_error("Help text can't be blank.") + expect_primerized_flash(type: :error, message: "Help text can't be blank.") SeleniumHubWaiter.wait editor.set_markdown("New**help**text") click_button "Save" diff --git a/spec/features/admin/enterprise/enterprise_spec.rb b/spec/features/admin/enterprise/enterprise_spec.rb index 78e92e56d34..5c60ca726d8 100644 --- a/spec/features/admin/enterprise/enterprise_spec.rb +++ b/spec/features/admin/enterprise/enterprise_spec.rb @@ -60,7 +60,8 @@ RSpec.describe "Enterprise token", :js, :with_cuprite do submit_button.click # Error output - expect_primerized_error("Enterprise support token can't be read. Are you sure it is a support token?") + expect_primerized_flash(type: :error, + message: "Enterprise support token can't be read. Are you sure it is a support token?") within "span.errorSpan" do expect(page).to have_css("#enterprise_token_encoded_token") diff --git a/spec/features/admin/oauth/oauth_applications_management_spec.rb b/spec/features/admin/oauth/oauth_applications_management_spec.rb index 63119d2e3a2..30dddbbfa25 100644 --- a/spec/features/admin/oauth/oauth_applications_management_spec.rb +++ b/spec/features/admin/oauth/oauth_applications_management_spec.rb @@ -49,14 +49,14 @@ RSpec.describe "OAuth applications management", :js, :with_cuprite do fill_in "application_redirect_uri", with: "not a url!" click_on "Create" - expect_primerized_error("Redirect URI must be an absolute URI.") + expect_primerized_flash(type: :error, message: "Redirect URI must be an absolute URI.") fill_in("application_redirect_uri", with: "") # Fill redirect_uri which does not provide a Secure Context fill_in "application_redirect_uri", with: "http://example.org" click_on "Create" - expect_primerized_error('Redirect URI is not providing a "Secure Context"') + expect_primerized_flash(type: :error, message: 'Redirect URI is not providing a "Secure Context"') # Can create localhost without https (https://community.openproject.com/wp/34025) fill_in "application_redirect_uri", with: "urn:ietf:wg:oauth:2.0:oob\nhttp://localhost/my/callback" diff --git a/spec/features/admin/test_mail_notification_spec.rb b/spec/features/admin/test_mail_notification_spec.rb index 97b2d3579ec..5cb2ceedb3d 100644 --- a/spec/features/admin/test_mail_notification_spec.rb +++ b/spec/features/admin/test_mail_notification_spec.rb @@ -44,7 +44,7 @@ RSpec.describe "Test mail notification", :js, :with_cuprite do click_link "Send a test email" expected = "An error occurred while sending mail (#{error_message})" - expect_primerized_error(expected) + expect_primerized_flash(type: :error, message: expected) expect(page).to have_no_css(".op-toast.-error strong") end end diff --git a/spec/features/admin/working_days_spec.rb b/spec/features/admin/working_days_spec.rb index 67dcc545b13..81b9d1724bc 100644 --- a/spec/features/admin/working_days_spec.rb +++ b/spec/features/admin/working_days_spec.rb @@ -141,7 +141,7 @@ RSpec.describe "Working Days", :js, :with_cuprite do dialog.confirm end - expect_primerized_error("At least one day of the week must be defined as a working day.") + expect_primerized_flash(type: :error, message: "At least one day of the week must be defined as a working day.") # Restore the checkboxes to their valid state expect(page).to have_checked_field "Monday" expect(page).to have_checked_field "Tuesday" @@ -171,7 +171,8 @@ RSpec.describe "Working Days", :js, :with_cuprite do # Not executing the background jobs dialog.confirm - expect_primerized_error("The previous changes to the working days configuration have not been applied yet.") + expect_primerized_flash(type: :error, + message: "The previous changes to the working days configuration have not been applied yet.") end end diff --git a/spec/features/auth/consent_auth_stage_spec.rb b/spec/features/auth/consent_auth_stage_spec.rb index 2c4b968bad1..04751d2e80f 100644 --- a/spec/features/auth/consent_auth_stage_spec.rb +++ b/spec/features/auth/consent_auth_stage_spec.rb @@ -256,7 +256,7 @@ RSpec.describe "Authentication Stages" do # Decline the consent click_on I18n.t(:button_decline) - expect_primerized_error("foo@example.org") + expect_primerized_flash(type: :error, message: "foo@example.org") end end end diff --git a/spec/features/projects/modules_spec.rb b/spec/features/projects/modules_spec.rb index a84be7858ee..a15fcb1dee4 100644 --- a/spec/features/projects/modules_spec.rb +++ b/spec/features/projects/modules_spec.rb @@ -65,11 +65,10 @@ RSpec.describe "Projects module administration" do check "Calendar" click_button "Save" - expect_primerized_error( + expect_primerized_flash(type: :error, message: I18n.t(:"activerecord.errors.models.project.attributes.enabled_modules.dependency_missing", dependency: "Work packages", - module: "Calendars") - ) + module: "Calendars")) expect(page).to have_no_xpath(project_work_packages_menu_link_selector) diff --git a/spec/features/projects/project_custom_fields/overview_page/dialog/permission_spec.rb b/spec/features/projects/project_custom_fields/overview_page/dialog/permission_spec.rb index 14c9eb68528..97a901455c3 100644 --- a/spec/features/projects/project_custom_fields/overview_page/dialog/permission_spec.rb +++ b/spec/features/projects/project_custom_fields/overview_page/dialog/permission_spec.rb @@ -117,7 +117,7 @@ RSpec.describe "Edit project custom fields on project overview page", :js do member_with_project_attributes_edit_permissions.reload dialog.submit - expect_primerized_error(I18n.t(:notice_not_authorized)) + expect_primerized_flash(type: :error, message: I18n.t(:notice_not_authorized)) end end end diff --git a/spec/features/projects/projects_index_spec.rb b/spec/features/projects/projects_index_spec.rb index 20e862d4ab1..d3635a0dc3c 100644 --- a/spec/features/projects/projects_index_spec.rb +++ b/spec/features/projects/projects_index_spec.rb @@ -274,7 +274,7 @@ RSpec.describe "Projects index page", :js, :with_cuprite, with_settings: { login error_text = "Orders > is not set to one of the allowed values. and does not exist." error_html = "Orders ><script src='/foobar js'></script> is not set to one of the allowed values. and does not exist." - expect_primerized_error(error_text) + expect_primerized_flash(type: :error, message: error_text) error_container = find_primerized_flash(type: :error) expect(error_container["innerHTML"]).to include error_html diff --git a/spec/features/roles/create_spec.rb b/spec/features/roles/create_spec.rb index 9ef403e7401..0ceeb15f38e 100644 --- a/spec/features/roles/create_spec.rb +++ b/spec/features/roles/create_spec.rb @@ -55,7 +55,7 @@ RSpec.describe "Role creation", :js, :with_cuprite do click_button "Create" - expect_primerized_error("Name has already been taken") + expect_primerized_flash(type: :error, message: "Name has already been taken") fill_in "Name", with: "New role name" @@ -64,7 +64,8 @@ RSpec.describe "Role creation", :js, :with_cuprite do click_button "Create" - expect_primerized_error("Permissions need to also include 'View members' as 'Manage members' is selected.") + expect_primerized_flash(type: :error, + message: "Permissions need to also include 'View members' as 'Manage members' is selected.") check "View members" select existing_role.name, from: "Copy workflow from" diff --git a/spec/features/types/crud_spec.rb b/spec/features/types/crud_spec.rb index 37434bf3606..dd6b1f6f4c7 100644 --- a/spec/features/types/crud_spec.rb +++ b/spec/features/types/crud_spec.rb @@ -52,7 +52,7 @@ RSpec.describe "Types", :js, :with_cuprite do click_button "Create" - expect_primerized_error("Name has already been taken.") + expect_primerized_flash(type: :error, message: "Name has already been taken.") # Values are retained expect(page) @@ -122,7 +122,7 @@ RSpec.describe "Types", :js, :with_cuprite do end it "renders an error message with links to the archived project in the projects list" do - expect_primerized_error project.name + expect_primerized_flash type: :error, message: project.name end end end diff --git a/spec/features/users/password_change_spec.rb b/spec/features/users/password_change_spec.rb index 1736832fa2b..0c905a6f36d 100644 --- a/spec/features/users/password_change_spec.rb +++ b/spec/features/users/password_change_spec.rb @@ -144,13 +144,13 @@ RSpec.describe "random password generation", :js, :with_cuprite do fill_in "user_password", with: "adminADMIN" fill_in "user_password_confirmation", with: "adminADMIN" scroll_to_and_click(find(".button", text: "Save")) - expect_primerized_error("Password Must contain characters of the following classes") + expect_primerized_flash(type: :error, message: "Password Must contain characters of the following classes") # 2 of 3 classes fill_in "user_password", with: "adminADMIN123" fill_in "user_password_confirmation", with: "adminADMIN123" scroll_to_and_click(find(".button", text: "Save")) - expect_primerized_error("Password Must contain characters of the following classes") + expect_primerized_flash(type: :error, message: "Password Must contain characters of the following classes") # All classes fill_in "user_password", with: "adminADMIN!" diff --git a/spec/features/versions/delete_spec.rb b/spec/features/versions/delete_spec.rb index c93ef2882c1..b2204174197 100644 --- a/spec/features/versions/delete_spec.rb +++ b/spec/features/versions/delete_spec.rb @@ -53,7 +53,7 @@ RSpec.describe "version delete", :js, :with_cuprite do end end - expect_primerized_error(I18n.t(:error_can_not_delete_in_use_archived_undisclosed)) + expect_primerized_flash(type: :error, message: I18n.t(:error_can_not_delete_in_use_archived_undisclosed)) expect(page).to have_no_css("a", text: "Archived child") user.update!(admin: true) @@ -67,7 +67,7 @@ RSpec.describe "version delete", :js, :with_cuprite do end end - expect_primerized_error("There are also work packages in archived projects.") + expect_primerized_flash(type: :error, message: "There are also work packages in archived projects.") expect(page).to have_css("a", text: "Archived child") end end diff --git a/spec/features/work_packages/bulk/copy_work_package_spec.rb b/spec/features/work_packages/bulk/copy_work_package_spec.rb index ec6e7d24ba0..13f34af8785 100644 --- a/spec/features/work_packages/bulk/copy_work_package_spec.rb +++ b/spec/features/work_packages/bulk/copy_work_package_spec.rb @@ -201,13 +201,17 @@ RSpec.describe "Copy work packages through Rails view", :js, :with_cuprite do it "fails, informing of the reasons" do click_on "Copy and follow" - expect_primerized_error(I18n.t("work_packages.bulk.none_could_be_saved", total: 3)) - expect_primerized_error(I18n.t("work_packages.bulk.selected_because_descendants", total: 3, selected: 2)) - expect_primerized_error("#{work_package.id}: Type #{I18n.t('activerecord.errors.messages.inclusion')}") - expect_primerized_error("#{work_package2.id}: Type #{I18n.t('activerecord.errors.messages.inclusion')}") - expect_primerized_error( - "#{child.id} (descendant of selected): Type #{I18n.t('activerecord.errors.messages.inclusion')}" - ) + expect_primerized_flash(type: :error, message: I18n.t("work_packages.bulk.none_could_be_saved", total: 3)) + expect_primerized_flash(type: :error, + message: I18n.t( + "work_packages.bulk.selected_because_descendants", total: 3, selected: 2 + )) + expect_primerized_flash(type: :error, + message: "#{work_package.id}: Type #{I18n.t('activerecord.errors.messages.inclusion')}") + expect_primerized_flash(type: :error, + message: "#{work_package2.id}: Type #{I18n.t('activerecord.errors.messages.inclusion')}") + expect_primerized_flash(type: :error, message: + "#{child.id} (descendant of selected): Type #{I18n.t('activerecord.errors.messages.inclusion')}") end context "when the limit to move in the frontend is 0", diff --git a/spec/features/work_packages/bulk/move_work_package_spec.rb b/spec/features/work_packages/bulk/move_work_package_spec.rb index 49fa31633a5..0e73db0be38 100644 --- a/spec/features/work_packages/bulk/move_work_package_spec.rb +++ b/spec/features/work_packages/bulk/move_work_package_spec.rb @@ -140,7 +140,7 @@ RSpec.describe "Moving a work package through Rails view", :js do click_on "Move and follow" wait_for_reload - expect_primerized_error I18n.t(:"work_packages.bulk.none_could_be_saved", total: 1) + expect_primerized_flash type: :error, message: I18n.t(:"work_packages.bulk.none_could_be_saved", total: 1) # Should NOT have moved child_wp.reload @@ -167,7 +167,7 @@ RSpec.describe "Moving a work package through Rails view", :js do click_on "Move and follow" end - expect_primerized_error I18n.t(:"work_packages.bulk.none_could_be_saved", total: 1) + expect_primerized_flash type: :error, message: I18n.t(:"work_packages.bulk.none_could_be_saved", total: 1) child_wp.reload work_package.reload expect(work_package.project_id).to eq(project.id) @@ -209,15 +209,15 @@ RSpec.describe "Moving a work package through Rails view", :js do end it "displays an error message explaining which work package could not be moved and why" do - expect_primerized_error(I18n.t("work_packages.bulk.could_not_be_saved")) - expect_primerized_error("#{work_package2.id}: Project #{I18n.t('activerecord.errors.messages.error_readonly')}") + expect_primerized_flash(type: :error, message: I18n.t("work_packages.bulk.could_not_be_saved")) + expect_primerized_flash(type: :error, + message: "#{work_package2.id}: Project #{I18n.t('activerecord.errors.messages.error_readonly')}") - expect_primerized_error( + expect_primerized_flash(type: :error, message: I18n.t("work_packages.bulk.x_out_of_y_could_be_saved", failing: 1, total: 2, - success: 1) - ) + success: 1)) expect(work_package.reload.project_id).to eq(project2.id) expect(work_package2.reload.project_id).to eq(project.id) diff --git a/spec/features/work_packages/bulk/update_work_package_spec.rb b/spec/features/work_packages/bulk/update_work_package_spec.rb index fe949ad54f2..8381b71454c 100644 --- a/spec/features/work_packages/bulk/update_work_package_spec.rb +++ b/spec/features/work_packages/bulk/update_work_package_spec.rb @@ -111,10 +111,11 @@ RSpec.describe "Bulk update work packages through Rails view", :js, :with_cuprit fill_in "Parent", with: "-1" click_on "Submit" - expect_primerized_error(I18n.t("work_packages.bulk.none_could_be_saved", total: 2)) - expect_primerized_error("#{work_package.id}: Parent #{I18n.t('activerecord.errors.messages.does_not_exist')}") + expect_primerized_flash(type: :error, message: I18n.t("work_packages.bulk.none_could_be_saved", total: 2)) + expect_primerized_flash(type: :error, + message: "#{work_package.id}: Parent #{I18n.t('activerecord.errors.messages.does_not_exist')}") - expect_primerized_error( + expect_primerized_flash(type: :error, message: <<~MSG.squish #{work_package2.id}: Parent #{I18n.t('activerecord.errors.messages.does_not_exist')} @@ -142,11 +143,10 @@ RSpec.describe "Bulk update work packages through Rails view", :js, :with_cuprit fill_in custom_field.name, with: "Custom field text" click_on "Submit" - expect_primerized_error( - I18n.t("work_packages.bulk.x_out_of_y_could_be_saved", total: 2, failing: 1, success: 1) - ) + expect_primerized_flash(type: :error, message: + I18n.t("work_packages.bulk.x_out_of_y_could_be_saved", total: 2, failing: 1, success: 1)) - expect_primerized_error( + expect_primerized_flash(type: :error, message: <<~MSG.squish #{work_package2.id}: #{custom_field.name} #{I18n.t('activerecord.errors.messages.error_readonly')} diff --git a/spec/support/components/password_confirmation_dialog.rb b/spec/support/components/password_confirmation_dialog.rb index 1870544ff33..cab61adf830 100644 --- a/spec/support/components/password_confirmation_dialog.rb +++ b/spec/support/components/password_confirmation_dialog.rb @@ -33,7 +33,7 @@ module Components include Capybara::DSL include Capybara::RSpecMatchers include RSpec::Matchers - include PrimerizedFlash::Expectations + include Flash::Expectations def confirm_flow_with(password, with_keyboard: false, should_fail: false) expect_open @@ -71,7 +71,7 @@ module Components end if should_fail - expect_primerized_error(I18n.t(:notice_password_confirmation_failed)) + expect_primerized_flash(type: :error, message: I18n.t(:notice_password_confirmation_failed)) else expect(page).to have_no_css(".op-toast.-error") end diff --git a/spec/support/primerized_flash/expectations.rb b/spec/support/flash/expectations.rb similarity index 91% rename from spec/support/primerized_flash/expectations.rb rename to spec/support/flash/expectations.rb index 1ad9b32bd87..daa1ca69ea5 100644 --- a/spec/support/primerized_flash/expectations.rb +++ b/spec/support/flash/expectations.rb @@ -1,9 +1,5 @@ -module PrimerizedFlash +module Flash module Expectations - def expect_primerized_error(message) - expect_primerized_flash(message:, type: :error) - end - def expect_primerized_flash(message:, type: :success, wait: 20) expected_css = expected_flash_css(type) expect(page).to have_css(expected_css, text: message, wait:) @@ -66,5 +62,5 @@ module PrimerizedFlash end RSpec.configure do |config| - config.include PrimerizedFlash::Expectations + config.include Flash::Expectations end diff --git a/spec/support/pages/page.rb b/spec/support/pages/page.rb index dfc03e770df..91fe9504fc0 100644 --- a/spec/support/pages/page.rb +++ b/spec/support/pages/page.rb @@ -37,7 +37,7 @@ module Pages include RSpec::Matchers include OpenProject::StaticRouting::UrlHelpers include Toasts::Expectations - include PrimerizedFlash::Expectations + include Flash::Expectations def current_page? URI.parse(current_url).path == path diff --git a/spec/support/toasts/expectations.rb b/spec/support/toasts/expectations.rb index f27aee85311..47baac2be88 100644 --- a/spec/support/toasts/expectations.rb +++ b/spec/support/toasts/expectations.rb @@ -4,8 +4,8 @@ module Toasts if toast_type == :angular expect(page).to have_css(".op-toast.-#{type}", text: message, wait:) elsif type == :error - ActiveSupport::Deprecation.warn("Use `expect_primerized_error(message)` instead of expect_toast with type: :error") - expect_primerized_error(message) + ActiveSupport::Deprecation.warn("Use `expect_primerized_flash(type: :error, message: message)` instead of expect_toast with type: :error") + expect_primerized_flash(type: :error, message:) elsif type == :success ActiveSupport::Deprecation.warn( "Use `expect_primerized_flash(type: :success, message:)` instead of expect_toast with type: :success" From cd2d0f0e1a1c337ef1e80895153bf6656f687fcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Mon, 30 Sep 2024 20:56:18 +0200 Subject: [PATCH 14/14] Remove primerized_flash prefix in methods --- .../features/backlogs_in_backlog_view_spec.rb | 8 +++---- .../features/bcf/api_authorization_spec.rb | 2 +- .../features/card_view/bulk_actions_spec.rb | 2 +- .../spec/features/model_management_spec.rb | 2 +- .../bim/spec/features/model_viewer_spec.rb | 2 +- .../spec/features/board_management_spec.rb | 4 ++-- .../features/boards_global_create_spec.rb | 4 ++-- .../spec/features/support/board_index_page.rb | 2 +- .../spec/features/support/board_page.rb | 2 +- .../spec/features/budgets/add_budget_spec.rb | 2 +- .../budgets/attachment_upload_spec.rb | 4 ++-- .../spec/features/budgets/copy_budget_spec.rb | 2 +- .../features/budgets/update_budget_spec.rb | 8 +++---- .../cost_entries/add_cost_entry_spec.rb | 4 ++-- .../add_entry_without_rate_permission_spec.rb | 2 +- .../spec/features/administration_spec.rb | 4 ++-- .../spec/features/meetings_new_spec.rb | 18 +++++++-------- .../features/meetings_participants_spec.rb | 2 +- .../spec/features/meetings_show_spec.rb | 2 +- .../structured_meetings/history_spec.rb | 2 +- .../components/cost_reports_base_table.rb | 4 ++-- .../spec/features/account_activation_spec.rb | 4 ++-- .../admin_edit_two_factor_devices_spec.rb | 2 +- .../login_with_backup_code_spec.rb | 2 +- .../features/login/login_enforced_2fa_spec.rb | 2 +- .../features/login/login_with_2fa_spec.rb | 2 +- .../features/my_two_factor_devices_spec.rb | 4 ++-- .../login_with_remember_cookie_spec.rb | 2 +- .../spec/features/shared_2fa_examples.rb | 10 ++++---- .../spec/features/manage_webhooks_spec.rb | 6 ++--- .../features/activities/wiki_activity_spec.rb | 2 +- .../admin/attribute_help_texts_spec.rb | 2 +- .../admin/enterprise/enterprise_spec.rb | 10 ++++---- .../admin/enterprise/enterprise_trial_spec.rb | 2 +- .../oauth_applications_management_spec.rb | 6 ++--- spec/features/admin/progress_tracking_spec.rb | 4 ++-- .../admin/test_mail_notification_spec.rb | 2 +- spec/features/admin/working_days_spec.rb | 12 +++++----- spec/features/auth/consent_auth_stage_spec.rb | 6 ++--- spec/features/auth/lost_password_spec.rb | 10 ++++---- .../custom_fields/reorder_options_spec.rb | 2 +- .../custom_styles/tabs_navigation_spec.rb | 6 ++--- spec/features/groups/groups_spec.rb | 2 +- spec/features/homescreen/index_spec.rb | 2 +- spec/features/ldap_auth_sources/crud_spec.rb | 6 ++--- spec/features/members/pagination_spec.rb | 2 +- .../oauth/authorization_code_flow_spec.rb | 2 +- .../features/placeholder_users/create_spec.rb | 2 +- .../features/placeholder_users/delete_spec.rb | 2 +- .../edit_placeholder_users_spec.rb | 2 +- .../principals/shared_memberships_examples.rb | 2 +- spec/features/projects/destroy_spec.rb | 2 +- spec/features/projects/modules_spec.rb | 2 +- .../overview_page/dialog/permission_spec.rb | 2 +- spec/features/projects/projects_index_spec.rb | 4 ++-- .../projects/projects_portfolio_spec.rb | 2 +- spec/features/projects/template_spec.rb | 2 +- .../repositories/create_repository_spec.rb | 4 ++-- .../repositories/repository_settings_spec.rb | 2 +- spec/features/roles/create_spec.rb | 8 +++---- spec/features/types/crud_spec.rb | 4 ++-- .../types/form_configuration_query_spec.rb | 14 +++++------ .../features/types/form_configuration_spec.rb | 8 +++---- .../types/reset_form_configuration_spec.rb | 2 +- spec/features/users/create_spec.rb | 2 +- spec/features/users/edit_users_spec.rb | 4 ++-- spec/features/users/password_change_spec.rb | 12 +++++----- spec/features/versions/delete_spec.rb | 4 ++-- .../wiki/adding_editing_history_spec.rb | 2 +- spec/features/wiki/attachment_upload_spec.rb | 4 ++-- spec/features/wiki/edit_new_page_spec.rb | 2 +- .../bulk/copy_work_package_spec.rb | 22 +++++++++--------- .../bulk/move_work_package_spec.rb | 13 ++++++----- .../bulk/update_work_package_spec.rb | 14 +++++------ .../display_fields/work_display_spec.rb | 2 +- .../features/work_packages/navigation_spec.rb | 2 +- spec/features/wysiwyg/autosave_spec.rb | 6 ++--- spec/features/wysiwyg/bold_behavior_spec.rb | 2 +- spec/features/wysiwyg/html_encoding_spec.rb | 2 +- spec/features/wysiwyg/linking_spec.rb | 2 +- .../wysiwyg/macros/attribute_macros_spec.rb | 4 ++-- .../wysiwyg/macros/child_pages_spec.rb | 4 ++-- .../wysiwyg/macros/code_block_macro_spec.rb | 8 +++---- .../wysiwyg/macros/embedded_tables_spec.rb | 4 ++-- .../wysiwyg/macros/quicklink_macros_spec.rb | 6 ++--- .../macros/work_package_button_spec.rb | 2 +- spec/features/wysiwyg/tables_spec.rb | 10 ++++---- .../wysiwyg/work_package_linking_spec.rb | 2 +- .../password_confirmation_dialog.rb | 4 ++-- spec/support/flash/expectations.rb | 23 +++++++------------ .../pages/admin/system_settings/languages.rb | 2 +- spec/support/pages/my/password_page.rb | 2 +- spec/support/pages/page.rb | 2 +- spec/support/toasts/expectations.rb | 10 ++++---- 94 files changed, 216 insertions(+), 220 deletions(-) diff --git a/modules/backlogs/spec/features/backlogs_in_backlog_view_spec.rb b/modules/backlogs/spec/features/backlogs_in_backlog_view_spec.rb index b583338c337..b1492fbfafd 100644 --- a/modules/backlogs/spec/features/backlogs_in_backlog_view_spec.rb +++ b/modules/backlogs/spec/features/backlogs_in_backlog_view_spec.rb @@ -185,7 +185,7 @@ RSpec.describe "Backlogs in backlog view", :js, click_button "Save" - expect_and_dismiss_primerized_flash(message: "Successful update.") + expect_and_dismiss_flash(message: "Successful update.") backlogs_page .expect_backlog(sprint) @@ -205,7 +205,7 @@ RSpec.describe "Backlogs in backlog view", :js, click_button "Save" - expect_and_dismiss_primerized_flash(message: "Successful update.") + expect_and_dismiss_flash(message: "Successful update.") # Now works as a sprint instead of a backlog backlogs_page @@ -226,7 +226,7 @@ RSpec.describe "Backlogs in backlog view", :js, click_button "Save" - expect_and_dismiss_primerized_flash(message: "Successful update.") + expect_and_dismiss_flash(message: "Successful update.") # the disabled backlog/sprint is no longer visible expect(page) @@ -247,7 +247,7 @@ RSpec.describe "Backlogs in backlog view", :js, click_button "Save" - expect_and_dismiss_primerized_flash(message: "Successful update.") + expect_and_dismiss_flash(message: "Successful update.") # the disabled backlog/sprint is no longer visible expect(page) diff --git a/modules/bim/spec/features/bcf/api_authorization_spec.rb b/modules/bim/spec/features/bcf/api_authorization_spec.rb index 620127b5326..735022ec53f 100644 --- a/modules/bim/spec/features/bcf/api_authorization_spec.rb +++ b/modules/bim/spec/features/bcf/api_authorization_spec.rb @@ -61,7 +61,7 @@ RSpec.describe "authorization for BCF api", :js, with_config: { edition: "bim" } fill_in "application_redirect_uri", with: "urn:ietf:wg:oauth:2.0:oob\nhttps://localhost/my/callback" click_on "Create" - expect_primerized_flash(message: "Successful creation.") + expect_flash(message: "Successful creation.") expect(page).to have_css(".attributes-key-value--key", text: "Client ID") diff --git a/modules/bim/spec/features/card_view/bulk_actions_spec.rb b/modules/bim/spec/features/card_view/bulk_actions_spec.rb index a861c3a40e9..58b66be2ef3 100644 --- a/modules/bim/spec/features/card_view/bulk_actions_spec.rb +++ b/modules/bim/spec/features/card_view/bulk_actions_spec.rb @@ -103,7 +103,7 @@ RSpec.describe "Copy work packages through Rails view", :js, :with_cuprite, with select budget.subject, from: "work_package_budget_id" click_on "Submit" - expect_and_dismiss_primerized_flash message: "Successful update." + expect_and_dismiss_flash message: "Successful update." expect(work_package.reload.budget_id).to eq(budget.id) expect(work_package2.reload.budget_id).to eq(budget.id) diff --git a/modules/bim/spec/features/model_management_spec.rb b/modules/bim/spec/features/model_management_spec.rb index 919d9f9874a..e484c9e9bd7 100644 --- a/modules/bim/spec/features/model_management_spec.rb +++ b/modules/bim/spec/features/model_management_spec.rb @@ -130,7 +130,7 @@ RSpec.describe "model management", :js, with_config: { edition: "bim" } do it "I can't see any models and perform no actions" do expected = "[Error 403] You are not authorized to access this page." - expect_primerized_flash(type: :error, message: expected) + expect_flash(type: :error, message: expected) index_page.add_model_allowed false end diff --git a/modules/bim/spec/features/model_viewer_spec.rb b/modules/bim/spec/features/model_viewer_spec.rb index 4229b29e959..7fb1247de58 100644 --- a/modules/bim/spec/features/model_viewer_spec.rb +++ b/modules/bim/spec/features/model_viewer_spec.rb @@ -135,7 +135,7 @@ RSpec.describe "model viewer", :js, with_config: { edition: "bim" } do it "shows no viewer" do expected = "[Error 403] You are not authorized to access this page." - expect_primerized_flash(type: :error, message: expected) + expect_flash(type: :error, message: expected) show_model_page.model_viewer_visible false show_model_page.model_viewer_shows_a_toolbar false diff --git a/modules/boards/spec/features/board_management_spec.rb b/modules/boards/spec/features/board_management_spec.rb index 2c1c691e155..b9b2acf501c 100644 --- a/modules/boards/spec/features/board_management_spec.rb +++ b/modules/boards/spec/features/board_management_spec.rb @@ -300,7 +300,7 @@ RSpec.describe "Board management spec", :js, with_ee: %i[board_view] do it "does not allow viewing of boards" do visit project_work_package_board_path(project, board_view) - expect_primerized_flash(type: :error, message: I18n.t(:notice_not_authorized)) + expect_flash(type: :error, message: I18n.t(:notice_not_authorized)) board_index.expect_editable false end @@ -311,7 +311,7 @@ RSpec.describe "Board management spec", :js, with_ee: %i[board_view] do it "does not allow viewing of boards" do board_index.visit! - expect_primerized_flash(type: :error, message: I18n.t(:notice_not_authorized)) + expect_flash(type: :error, message: I18n.t(:notice_not_authorized)) end end end diff --git a/modules/boards/spec/features/boards_global_create_spec.rb b/modules/boards/spec/features/boards_global_create_spec.rb index 4f89197bfe8..c0cee1e483c 100644 --- a/modules/boards/spec/features/boards_global_create_spec.rb +++ b/modules/boards/spec/features/boards_global_create_spec.rb @@ -195,8 +195,8 @@ RSpec.describe "Boards", it "renders a required attribute validation error" do expect(Boards::Grid.all).to be_empty - expect_primerized_flash message: "Project #{I18n.t('activerecord.errors.messages.blank')}", - type: :error + expect_flash message: "Project #{I18n.t('activerecord.errors.messages.blank')}", + type: :error new_board_page.expect_project_dropdown end diff --git a/modules/boards/spec/features/support/board_index_page.rb b/modules/boards/spec/features/support/board_index_page.rb index a775e63c0a5..96083f2371c 100644 --- a/modules/boards/spec/features/support/board_index_page.rb +++ b/modules/boards/spec/features/support/board_index_page.rb @@ -72,7 +72,7 @@ module Pages new_board_page.set_board_type action new_board_page.click_on_submit - expect_and_dismiss_primerized_flash(message: I18n.t(:notice_successful_create)) + expect_and_dismiss_flash(message: I18n.t(:notice_successful_create)) if expect_empty expect(page).to have_css(".boards-list--add-item-text", wait: 10) diff --git a/modules/boards/spec/features/support/board_page.rb b/modules/boards/spec/features/support/board_page.rb index 41dc462def9..9afae1daade 100644 --- a/modules/boards/spec/features/support/board_page.rb +++ b/modules/boards/spec/features/support/board_page.rb @@ -284,7 +284,7 @@ module Pages click_dropdown_entry "Delete" accept_alert_dialog! - expect_and_dismiss_primerized_flash message: I18n.t("js.notice_successful_delete") + expect_and_dismiss_flash message: I18n.t("js.notice_successful_delete") end def back_to_index diff --git a/modules/budgets/spec/features/budgets/add_budget_spec.rb b/modules/budgets/spec/features/budgets/add_budget_spec.rb index 31cb1db2ffe..683cd8c45ac 100644 --- a/modules/budgets/spec/features/budgets/add_budget_spec.rb +++ b/modules/budgets/spec/features/budgets/add_budget_spec.rb @@ -122,7 +122,7 @@ RSpec.describe "adding a new budget", :js do new_budget_page.add_labor_costs! "0,5", user_name: user.name, comment: "attendance", expected_costs: "12,50 EUR" page.find('[data-test-selector="budgets-create-button"]').click - expect_and_dismiss_primerized_flash(message: I18n.t(:notice_successful_create, locale: :de)) + expect_and_dismiss_flash(message: I18n.t(:notice_successful_create, locale: :de)) expect(new_budget_page.unit_costs_at(1)).to have_content "175,00 EUR" expect(new_budget_page.unit_costs_at(2)).to have_content "50.025,00 EUR" diff --git a/modules/budgets/spec/features/budgets/attachment_upload_spec.rb b/modules/budgets/spec/features/budgets/attachment_upload_spec.rb index cc39d82dd9f..54b5f8068e7 100644 --- a/modules/budgets/spec/features/budgets/attachment_upload_spec.rb +++ b/modules/budgets/spec/features/budgets/attachment_upload_spec.rb @@ -59,7 +59,7 @@ RSpec.describe "Upload attachment to budget", :js do click_on "Create" - expect_and_dismiss_primerized_flash(message: "Successful creation.") + expect_and_dismiss_flash(message: "Successful creation.") expect(page).to have_css("#content img", count: 1) expect(page).to have_content("Image uploaded on creation") @@ -98,7 +98,7 @@ RSpec.describe "Upload attachment to budget", :js do click_on "Create" - expect_and_dismiss_primerized_flash(message: "Successful creation.") + expect_and_dismiss_flash(message: "Successful creation.") attachments_list.expect_attached("image.png") diff --git a/modules/budgets/spec/features/budgets/copy_budget_spec.rb b/modules/budgets/spec/features/budgets/copy_budget_spec.rb index 6d327d4aef5..44022d90ad7 100644 --- a/modules/budgets/spec/features/budgets/copy_budget_spec.rb +++ b/modules/budgets/spec/features/budgets/copy_budget_spec.rb @@ -88,7 +88,7 @@ RSpec.describe "Copying a budget", :js do click_button "Create" - expect_primerized_flash message: "Successful creation." + expect_flash message: "Successful creation." expect(page) .to have_css(".author", text: current_user.name) diff --git a/modules/budgets/spec/features/budgets/update_budget_spec.rb b/modules/budgets/spec/features/budgets/update_budget_spec.rb index 6f56ce8049a..8958488a8d4 100644 --- a/modules/budgets/spec/features/budgets/update_budget_spec.rb +++ b/modules/budgets/spec/features/budgets/update_budget_spec.rb @@ -181,7 +181,7 @@ RSpec.describe "updating a budget", :js do # Update first element budget_page.edit_planned_costs! material_budget_item.id, type: :material, costs: 123 - expect_and_dismiss_primerized_flash(message: "Successful update") + expect_and_dismiss_flash(message: "Successful update") expect(page).to have_css("tbody td.currency", text: "123.00 EUR") click_on "Update" @@ -218,7 +218,7 @@ RSpec.describe "updating a budget", :js do # Update first element budget_page.edit_planned_costs! material_budget_item.id, type: :material, costs: 123 - expect_and_dismiss_primerized_flash(message: "Successful update") + expect_and_dismiss_flash(message: "Successful update") expect(page).to have_css("tbody td.currency", text: "USD 123.00") click_on "Update" @@ -258,7 +258,7 @@ RSpec.describe "updating a budget", :js do # Update first element budget_page.edit_planned_costs! labor_budget_item.id, type: :labor, costs: 456 - expect_and_dismiss_primerized_flash(message: "Successful update") + expect_and_dismiss_flash(message: "Successful update") expect(page).to have_css("tbody td.currency", text: "456.00 EUR") click_on "Update" @@ -295,7 +295,7 @@ RSpec.describe "updating a budget", :js do # Update first element budget_page.edit_planned_costs! labor_budget_item.id, type: :labor, costs: 456 - expect_and_dismiss_primerized_flash(message: "Successful update") + expect_and_dismiss_flash(message: "Successful update") expect(page).to have_css("tbody td.currency", text: "USD 456.00") click_on "Update" diff --git a/modules/costs/spec/features/cost_entries/add_cost_entry_spec.rb b/modules/costs/spec/features/cost_entries/add_cost_entry_spec.rb index de2b07cffda..ed6e6b39dd1 100644 --- a/modules/costs/spec/features/cost_entries/add_cost_entry_spec.rb +++ b/modules/costs/spec/features/cost_entries/add_cost_entry_spec.rb @@ -99,7 +99,7 @@ RSpec.describe "Work Package cost fields", :js do click_on "Save" # Expect correct costs - expect_primerized_flash(message: I18n.t(:notice_cost_logged_successfully)) + expect_flash(message: I18n.t(:notice_cost_logged_successfully)) entry = CostEntry.last expect(entry.cost_type_id).to eq(cost_type2.id) expect(entry.units).to eq(2.0) @@ -136,7 +136,7 @@ RSpec.describe "Work Package cost fields", :js do click_on I18n.t(:button_save) # Expect correct costs - expect_primerized_flash(message: I18n.t(:notice_cost_logged_successfully)) + expect_flash(message: I18n.t(:notice_cost_logged_successfully)) entry = CostEntry.last expect(entry.cost_type_id).to eq(cost_type2.id) expect(entry.units).to eq(1.42) diff --git a/modules/costs/spec/features/cost_entries/add_entry_without_rate_permission_spec.rb b/modules/costs/spec/features/cost_entries/add_entry_without_rate_permission_spec.rb index ce5e0bc12df..2b1b59cd0ca 100644 --- a/modules/costs/spec/features/cost_entries/add_entry_without_rate_permission_spec.rb +++ b/modules/costs/spec/features/cost_entries/add_entry_without_rate_permission_spec.rb @@ -77,7 +77,7 @@ RSpec.describe "Create cost entry without rate permissions", :js do click_on "Save" # Expect correct costs - expect_primerized_flash(message: I18n.t(:notice_cost_logged_successfully)) + expect_flash(message: I18n.t(:notice_cost_logged_successfully)) entry = CostEntry.last expect(entry.cost_type_id).to eq(cost_type.id) expect(entry.units).to eq(1.0) diff --git a/modules/ldap_groups/spec/features/administration_spec.rb b/modules/ldap_groups/spec/features/administration_spec.rb index fa2110dbe21..0f5b5eb6f70 100644 --- a/modules/ldap_groups/spec/features/administration_spec.rb +++ b/modules/ldap_groups/spec/features/administration_spec.rb @@ -35,7 +35,7 @@ RSpec.describe "LDAP group sync administration spec", :js do check "synchronized_group_sync_users" click_on "Create" - expect_primerized_flash(message: I18n.t(:notice_successful_create)) + expect_flash(message: I18n.t(:notice_successful_create)) expect(page).to have_css("td.dn", text: "cn=foo,ou=groups,dc=example,dc=com") expect(page).to have_css("td.ldap_auth_source", text: "ldap") expect(page).to have_css("td.group", text: "foo") @@ -69,7 +69,7 @@ RSpec.describe "LDAP group sync administration spec", :js do SeleniumHubWaiter.wait click_on "Delete" - expect_primerized_flash(message: I18n.t(:notice_successful_delete)) + expect_flash(message: I18n.t(:notice_successful_delete)) expect(page).to have_css ".generic-table--empty-row" expect(LdapGroups::Membership.where(id: memberships)).to be_empty diff --git a/modules/meeting/spec/features/meetings_new_spec.rb b/modules/meeting/spec/features/meetings_new_spec.rb index 9a3fb999168..27c78bcf99f 100644 --- a/modules/meeting/spec/features/meetings_new_spec.rb +++ b/modules/meeting/spec/features/meetings_new_spec.rb @@ -97,7 +97,7 @@ RSpec.describe "Meetings new", :js, with_cuprite: false do show_page = new_page.click_create - expect_primerized_flash(message: "Successful creation.") + expect_flash(message: "Successful creation.") show_page.expect_invited(user, other_user) @@ -143,8 +143,8 @@ RSpec.describe "Meetings new", :js, with_cuprite: false do it "renders a validation error" do new_page.click_create - expect_primerized_flash(type: :error, - message: "#{Project.model_name.human} #{I18n.t('activerecord.errors.messages.blank')}") + expect_flash(type: :error, + message: "#{Project.model_name.human} #{I18n.t('activerecord.errors.messages.blank')}") new_page.expect_project_dropdown end @@ -178,7 +178,7 @@ RSpec.describe "Meetings new", :js, with_cuprite: false do show_page = new_page.click_create - expect_primerized_flash(message: "Successful creation.") + expect_flash(message: "Successful creation.") # Not sure if that is then intended behaviour but that is what is currently programmed show_page.expect_invited(admin) @@ -194,7 +194,7 @@ RSpec.describe "Meetings new", :js, with_cuprite: false do it "renders a validation error" do new_page.click_create - expect_primerized_flash( + expect_flash( message: "#{Project.model_name.human} #{I18n.t('activerecord.errors.messages.blank')}", type: :error ) @@ -256,7 +256,7 @@ RSpec.describe "Meetings new", :js, with_cuprite: false do show_page = new_page.click_create - expect_primerized_flash(message: "Successful creation.") + expect_flash(message: "Successful creation.") show_page.expect_invited(user, other_user) @@ -317,7 +317,7 @@ RSpec.describe "Meetings new", :js, with_cuprite: false do show_page = new_page.click_create - expect_primerized_flash(message: "Successful creation.") + expect_flash(message: "Successful creation.") # Not sure if that is then intended behaviour but that is what is currently programmed show_page.expect_invited(admin) @@ -346,7 +346,7 @@ RSpec.describe "Meetings new", :js, with_cuprite: false do new_page.click_create - expect_primerized_flash(message: "Successful creation.") + expect_flash(message: "Successful creation.") meeting = Meeting.last @@ -354,7 +354,7 @@ RSpec.describe "Meetings new", :js, with_cuprite: false do field.submit_by_enter - expect_primerized_flash(message: "Successful update") + expect_flash(message: "Successful update") meeting.reload diff --git a/modules/meeting/spec/features/meetings_participants_spec.rb b/modules/meeting/spec/features/meetings_participants_spec.rb index fb368810e16..df46446df81 100644 --- a/modules/meeting/spec/features/meetings_participants_spec.rb +++ b/modules/meeting/spec/features/meetings_participants_spec.rb @@ -64,7 +64,7 @@ RSpec.describe "Meetings participants" do edit_page.invite(viewer_user) show_page = edit_page.click_save - expect_primerized_flash(message: "Successful update") + expect_flash(message: "Successful update") show_page.expect_invited(viewer_user) diff --git a/modules/meeting/spec/features/meetings_show_spec.rb b/modules/meeting/spec/features/meetings_show_spec.rb index 467abb62ed8..b44313f9d6d 100644 --- a/modules/meeting/spec/features/meetings_show_spec.rb +++ b/modules/meeting/spec/features/meetings_show_spec.rb @@ -126,7 +126,7 @@ RSpec.describe "Meetings", :js do field.submit_by_enter - expect_and_dismiss_primerized_flash(message: "Successful update") + expect_and_dismiss_flash(message: "Successful update") meeting.reload diff --git a/modules/meeting/spec/features/structured_meetings/history_spec.rb b/modules/meeting/spec/features/structured_meetings/history_spec.rb index e2fb2aac866..cebda965037 100644 --- a/modules/meeting/spec/features/structured_meetings/history_spec.rb +++ b/modules/meeting/spec/features/structured_meetings/history_spec.rb @@ -355,6 +355,6 @@ RSpec.describe "history", visit history_meeting_path(meeting) expected = "[Error 403] You are not authorized to access this page." - expect_primerized_flash(type: :error, message: expected) + expect_flash(type: :error, message: expected) end end diff --git a/modules/reporting/spec/features/support/components/cost_reports_base_table.rb b/modules/reporting/spec/features/support/components/cost_reports_base_table.rb index d2ce032bc97..88611e39871 100644 --- a/modules/reporting/spec/features/support/components/cost_reports_base_table.rb +++ b/modules/reporting/spec/features/support/components/cost_reports_base_table.rb @@ -26,7 +26,7 @@ # See COPYRIGHT and LICENSE files for more details. #++ -require "support/primerized_flash/expectations" +require "support/flash/expectations" module Components class CostReportsBaseTable @@ -81,7 +81,7 @@ module Components SeleniumHubWaiter.wait fill_in("cost_entry_units", with: new_value) click_button "Save" - expect_primerized_flash(message: "Successful update.") + expect_flash(message: "Successful update.") end def delete_entry(row) diff --git a/modules/two_factor_authentication/spec/features/account_activation_spec.rb b/modules/two_factor_authentication/spec/features/account_activation_spec.rb index 111c2bf10e2..78c2a665a0a 100644 --- a/modules/two_factor_authentication/spec/features/account_activation_spec.rb +++ b/modules/two_factor_authentication/spec/features/account_activation_spec.rb @@ -50,7 +50,7 @@ RSpec.describe "activating an invited account", :js, activate! - expect_primerized_flash(message: "Developer strategy generated the following one-time password:") + expect_flash(message: "Developer strategy generated the following one-time password:") SeleniumHubWaiter.wait fill_in I18n.t(:field_otp), with: sms_token @@ -63,7 +63,7 @@ RSpec.describe "activating an invited account", :js, it "handles faulty user input on two factor authentication" do activate! - expect_primerized_flash(message: "Developer strategy generated the following one-time password:") + expect_flash(message: "Developer strategy generated the following one-time password:") fill_in I18n.t(:field_otp), with: "asdf" # faulty token click_button I18n.t(:button_login) diff --git a/modules/two_factor_authentication/spec/features/admin_edit_two_factor_devices_spec.rb b/modules/two_factor_authentication/spec/features/admin_edit_two_factor_devices_spec.rb index 68ad1f662a9..1166c3987a9 100644 --- a/modules/two_factor_authentication/spec/features/admin_edit_two_factor_devices_spec.rb +++ b/modules/two_factor_authentication/spec/features/admin_edit_two_factor_devices_spec.rb @@ -44,7 +44,7 @@ RSpec.describe "Admin 2FA management", :js, with_settings: { click_button I18n.t(:button_continue) # Enter valid phone number - expect_primerized_flash(type: :error, message: "Phone number must be of format +XX XXXXXXXXX") + expect_flash(type: :error, message: "Phone number must be of format +XX XXXXXXXXX") SeleniumHubWaiter.wait fill_in "device_phone_number", with: "+49 123456789" diff --git a/modules/two_factor_authentication/spec/features/backup_codes/login_with_backup_code_spec.rb b/modules/two_factor_authentication/spec/features/backup_codes/login_with_backup_code_spec.rb index d678b2ea783..3d97bc10120 100644 --- a/modules/two_factor_authentication/spec/features/backup_codes/login_with_backup_code_spec.rb +++ b/modules/two_factor_authentication/spec/features/backup_codes/login_with_backup_code_spec.rb @@ -50,7 +50,7 @@ RSpec.describe "Login with 2FA backup code", :js, with_settings: { click_on "Submit" # Expect failure - expect_primerized_flash(type: :error, message: I18n.t("two_factor_authentication.error_invalid_backup_code")) + expect_flash(type: :error, message: I18n.t("two_factor_authentication.error_invalid_backup_code")) expect(page).to have_current_path signin_path # Try again! diff --git a/modules/two_factor_authentication/spec/features/login/login_enforced_2fa_spec.rb b/modules/two_factor_authentication/spec/features/login/login_enforced_2fa_spec.rb index d09c7a613ae..effabe6acc2 100644 --- a/modules/two_factor_authentication/spec/features/login/login_enforced_2fa_spec.rb +++ b/modules/two_factor_authentication/spec/features/login/login_enforced_2fa_spec.rb @@ -36,7 +36,7 @@ RSpec.describe "Login with enforced 2FA", :js, with_settings: { first_login_step two_factor_step("whatever") - expect_primerized_flash(type: :error, message: I18n.t(:notice_account_otp_invalid)) + expect_flash(type: :error, message: I18n.t(:notice_account_otp_invalid)) expect(page).to have_current_path signin_path end end diff --git a/modules/two_factor_authentication/spec/features/login/login_with_2fa_spec.rb b/modules/two_factor_authentication/spec/features/login/login_with_2fa_spec.rb index dac190b4907..c1ea5473179 100644 --- a/modules/two_factor_authentication/spec/features/login/login_with_2fa_spec.rb +++ b/modules/two_factor_authentication/spec/features/login/login_with_2fa_spec.rb @@ -35,7 +35,7 @@ RSpec.describe "Login with 2FA device", :js, with_settings: { first_login_step two_factor_step("whatever") - expect_primerized_flash(type: :error, message: I18n.t(:notice_account_otp_invalid)) + expect_flash(type: :error, message: I18n.t(:notice_account_otp_invalid)) expect(page).to have_current_path signin_path end end diff --git a/modules/two_factor_authentication/spec/features/my_two_factor_devices_spec.rb b/modules/two_factor_authentication/spec/features/my_two_factor_devices_spec.rb index 39ebe5139e5..c7bb9cd65f3 100644 --- a/modules/two_factor_authentication/spec/features/my_two_factor_devices_spec.rb +++ b/modules/two_factor_authentication/spec/features/my_two_factor_devices_spec.rb @@ -35,7 +35,7 @@ RSpec.describe "My Account 2FA configuration", :js, with_settings: { click_button I18n.t(:button_continue) # Enter valid phone number - expect_primerized_flash(type: :error, message: "Phone number must be of format +XX XXXXXXXXX") + expect_flash(type: :error, message: "Phone number must be of format +XX XXXXXXXXX") fill_in "device_phone_number", with: "+49 123456789" click_button I18n.t(:button_continue) @@ -56,7 +56,7 @@ RSpec.describe "My Account 2FA configuration", :js, with_settings: { expect(page).to have_css("h2", text: I18n.t("two_factor_authentication.devices.confirm_device")) expect(page).to have_css("input#otp") - expect_primerized_flash(type: :error, message: I18n.t("two_factor_authentication.devices.registration_failed_token_invalid")) + expect_flash(type: :error, message: I18n.t("two_factor_authentication.devices.registration_failed_token_invalid")) # Fill in correct token fill_in "otp", with: sms_token diff --git a/modules/two_factor_authentication/spec/features/remember_cookie/login_with_remember_cookie_spec.rb b/modules/two_factor_authentication/spec/features/remember_cookie/login_with_remember_cookie_spec.rb index 1d53df292ee..159404baa86 100644 --- a/modules/two_factor_authentication/spec/features/remember_cookie/login_with_remember_cookie_spec.rb +++ b/modules/two_factor_authentication/spec/features/remember_cookie/login_with_remember_cookie_spec.rb @@ -60,7 +60,7 @@ RSpec.describe "Login with 2FA remember cookie", :js, with_settings: { visit my_2fa_devices_path find(".two-factor-authentication--remove-remember-cookie-link").click - expect_primerized_flash(message: I18n.t("two_factor_authentication.remember.cookie_removed")) + expect_flash(message: I18n.t("two_factor_authentication.remember.cookie_removed")) expect(page).to have_no_css(".two-factor-authentication--remove-remember-cookie-link") # Log out and in again diff --git a/modules/two_factor_authentication/spec/features/shared_2fa_examples.rb b/modules/two_factor_authentication/spec/features/shared_2fa_examples.rb index d4d29eb0f8d..65443b9b57c 100644 --- a/modules/two_factor_authentication/spec/features/shared_2fa_examples.rb +++ b/modules/two_factor_authentication/spec/features/shared_2fa_examples.rb @@ -35,8 +35,8 @@ end RSpec.shared_examples "create enforced sms device" do it do - expect_primerized_flash(type: :info, - message: I18n.t("two_factor_authentication.forced_registration.required_to_add_device")) + expect_flash(type: :info, + message: I18n.t("two_factor_authentication.forced_registration.required_to_add_device")) SeleniumHubWaiter.wait # Create SMS device @@ -46,7 +46,7 @@ RSpec.shared_examples "create enforced sms device" do click_on "Continue" # Expect error on invalid phone - expect_primerized_flash(type: :error, message: "Phone number must be of format +XX XXXXXXXXX") + expect_flash(type: :error, message: "Phone number must be of format +XX XXXXXXXXX") SeleniumHubWaiter.wait fill_in "device_phone_number", with: "+49 123456789" @@ -63,7 +63,7 @@ RSpec.shared_examples "create enforced sms device" do # Log token for next access sms_token = nil allow_any_instance_of(OpenProject::TwoFactorAuthentication::TokenStrategy::Developer) - .to receive(:create_mobile_otp).and_wrap_original do |m| + .to receive(:create_mobile_otp).and_wrap_original do |m| sms_token = m.call end @@ -71,7 +71,7 @@ RSpec.shared_examples "create enforced sms device" do expect(page).to have_css("h2", text: I18n.t("two_factor_authentication.devices.confirm_device")) expect(page).to have_css("input#otp") - expect_primerized_flash(type: :error, message: I18n.t("two_factor_authentication.devices.registration_failed_token_invalid")) + expect_flash(type: :error, message: I18n.t("two_factor_authentication.devices.registration_failed_token_invalid")) SeleniumHubWaiter.wait # Fill in wrong token diff --git a/modules/webhooks/spec/features/manage_webhooks_spec.rb b/modules/webhooks/spec/features/manage_webhooks_spec.rb index 021974c191d..9df3b63b348 100644 --- a/modules/webhooks/spec/features/manage_webhooks_spec.rb +++ b/modules/webhooks/spec/features/manage_webhooks_spec.rb @@ -40,7 +40,7 @@ RSpec.describe "Manage webhooks through UI", :js do # 1st webhook created # - expect_primerized_flash(message: I18n.t(:notice_successful_create)) + expect_flash(message: I18n.t(:notice_successful_create)) expect(page).to have_css(".webhooks--outgoing-webhook-row .name", text: "My webhook") webhook = Webhooks::Webhook.last expect(webhook.event_names).to eq %w(work_package:created) @@ -65,7 +65,7 @@ RSpec.describe "Manage webhooks through UI", :js do find(".webhooks--selected-project-ids[value='#{project.id}']").set true click_on "Save" - expect_primerized_flash(message: I18n.t(:notice_successful_update)) + expect_flash(message: I18n.t(:notice_successful_update)) expect(page).to have_css(".webhooks--outgoing-webhook-row .name", text: "My webhook") webhook = Webhooks::Webhook.last expect(webhook.event_names).to eq %w(work_package:updated) @@ -77,7 +77,7 @@ RSpec.describe "Manage webhooks through UI", :js do find(".webhooks--outgoing-webhook-row-#{webhook.id} .icon-delete").click page.driver.browser.switch_to.alert.accept - expect_primerized_flash(message: I18n.t(:notice_successful_delete)) + expect_flash(message: I18n.t(:notice_successful_delete)) expect(page).to have_css(".generic-table--empty-row") end diff --git a/spec/features/activities/wiki_activity_spec.rb b/spec/features/activities/wiki_activity_spec.rb index 5fa22673c09..a25c5eb8226 100644 --- a/spec/features/activities/wiki_activity_spec.rb +++ b/spec/features/activities/wiki_activity_spec.rb @@ -53,7 +53,7 @@ RSpec.describe "Wiki Activity", :js, :with_cuprite do click_button "Save" - expect_and_dismiss_primerized_flash(message: "Successful creation.") + expect_and_dismiss_flash(message: "Successful creation.") # We mock letting some time pass by altering the timestamps Journal.last.update_columns(created_at: Time.now - 5.days, updated_at: Time.now - 5.days) diff --git a/spec/features/admin/attribute_help_texts_spec.rb b/spec/features/admin/attribute_help_texts_spec.rb index fdbdf4f49e7..76384e96855 100644 --- a/spec/features/admin/attribute_help_texts_spec.rb +++ b/spec/features/admin/attribute_help_texts_spec.rb @@ -113,7 +113,7 @@ RSpec.describe "Attribute help texts", :js, :with_cuprite do click_button "Save" # Handle errors - expect_primerized_flash(type: :error, message: "Help text can't be blank.") + expect_flash(type: :error, message: "Help text can't be blank.") SeleniumHubWaiter.wait editor.set_markdown("New**help**text") click_button "Save" diff --git a/spec/features/admin/enterprise/enterprise_spec.rb b/spec/features/admin/enterprise/enterprise_spec.rb index 5c60ca726d8..dc04edbdbde 100644 --- a/spec/features/admin/enterprise/enterprise_spec.rb +++ b/spec/features/admin/enterprise/enterprise_spec.rb @@ -60,8 +60,8 @@ RSpec.describe "Enterprise token", :js, :with_cuprite do submit_button.click # Error output - expect_primerized_flash(type: :error, - message: "Enterprise support token can't be read. Are you sure it is a support token?") + expect_flash(type: :error, + message: "Enterprise support token can't be read. Are you sure it is a support token?") within "span.errorSpan" do expect(page).to have_css("#enterprise_token_encoded_token") @@ -77,7 +77,7 @@ RSpec.describe "Enterprise token", :js, :with_cuprite do textarea.set "foobar" submit_button.click - expect_primerized_flash(message: I18n.t(:notice_successful_update)) + expect_flash(message: I18n.t(:notice_successful_update)) expect(page).to have_test_selector("op-enterprise--active-token") expect(page.all(".attributes-key-value--key").map(&:text)) @@ -100,7 +100,7 @@ RSpec.describe "Enterprise token", :js, :with_cuprite do wait_for_reload - expect_primerized_flash(message: I18n.t(:notice_successful_update)) + expect_flash(message: I18n.t(:notice_successful_update)) # Assume next request RequestStore.clear! @@ -114,7 +114,7 @@ RSpec.describe "Enterprise token", :js, :with_cuprite do wait_for_reload - expect_primerized_flash(message: I18n.t(:notice_successful_delete)) + expect_flash(message: I18n.t(:notice_successful_delete)) # Assume next request RequestStore.clear! diff --git a/spec/features/admin/enterprise/enterprise_trial_spec.rb b/spec/features/admin/enterprise/enterprise_trial_spec.rb index 5781161e192..4676affa9e7 100644 --- a/spec/features/admin/enterprise/enterprise_trial_spec.rb +++ b/spec/features/admin/enterprise/enterprise_trial_spec.rb @@ -276,7 +276,7 @@ RSpec.describe "Enterprise trial management", # advance to close click_on "Continue" - expect_and_dismiss_primerized_flash(message: "Successful update.") + expect_and_dismiss_flash(message: "Successful update.") expect(page).to have_css(".attributes-key-value--value-container", text: "OpenProject Test") expect(page).to have_css(".attributes-key-value--value-container", text: "01/01/2020") expect(page).to have_css(".attributes-key-value--value-container", text: "01/02/2020") diff --git a/spec/features/admin/oauth/oauth_applications_management_spec.rb b/spec/features/admin/oauth/oauth_applications_management_spec.rb index 30dddbbfa25..a6e1ad3a4ad 100644 --- a/spec/features/admin/oauth/oauth_applications_management_spec.rb +++ b/spec/features/admin/oauth/oauth_applications_management_spec.rb @@ -49,20 +49,20 @@ RSpec.describe "OAuth applications management", :js, :with_cuprite do fill_in "application_redirect_uri", with: "not a url!" click_on "Create" - expect_primerized_flash(type: :error, message: "Redirect URI must be an absolute URI.") + expect_flash(type: :error, message: "Redirect URI must be an absolute URI.") fill_in("application_redirect_uri", with: "") # Fill redirect_uri which does not provide a Secure Context fill_in "application_redirect_uri", with: "http://example.org" click_on "Create" - expect_primerized_flash(type: :error, message: 'Redirect URI is not providing a "Secure Context"') + expect_flash(type: :error, message: 'Redirect URI is not providing a "Secure Context"') # Can create localhost without https (https://community.openproject.com/wp/34025) fill_in "application_redirect_uri", with: "urn:ietf:wg:oauth:2.0:oob\nhttp://localhost/my/callback" click_on "Create" - expect_primerized_flash(message: "Successful creation.") + expect_flash(message: "Successful creation.") expect(page).to have_css(".attributes-key-value--key", text: "Client ID") expect(page).to have_css(".attributes-key-value--value", text: "urn:ietf:wg:oauth:2.0:oob\nhttp://localhost/my/callback") diff --git a/spec/features/admin/progress_tracking_spec.rb b/spec/features/admin/progress_tracking_spec.rb index 647455b45f2..b32ea6c739e 100644 --- a/spec/features/admin/progress_tracking_spec.rb +++ b/spec/features/admin/progress_tracking_spec.rb @@ -51,7 +51,7 @@ RSpec.describe "Progress tracking admin page", :js, :with_cuprite do expect(page).to have_text(expected_warning_text) click_on "Save" - expect_and_dismiss_primerized_flash(message: "Successful update.") + expect_and_dismiss_flash(message: "Successful update.") expect(Setting.find_by(name: "work_package_done_ratio").value).to eq("status") # now change from status-based to work-based @@ -65,7 +65,7 @@ RSpec.describe "Progress tracking admin page", :js, :with_cuprite do expect(page).to have_text(expected_warning_text) click_on "Save" - expect_and_dismiss_primerized_flash(message: "Successful update.") + expect_and_dismiss_flash(message: "Successful update.") expect(Setting.find_by(name: "work_package_done_ratio").value).to eq("field") end diff --git a/spec/features/admin/test_mail_notification_spec.rb b/spec/features/admin/test_mail_notification_spec.rb index 5cb2ceedb3d..3acced02cf5 100644 --- a/spec/features/admin/test_mail_notification_spec.rb +++ b/spec/features/admin/test_mail_notification_spec.rb @@ -44,7 +44,7 @@ RSpec.describe "Test mail notification", :js, :with_cuprite do click_link "Send a test email" expected = "An error occurred while sending mail (#{error_message})" - expect_primerized_flash(type: :error, message: expected) + expect_flash(type: :error, message: expected) expect(page).to have_no_css(".op-toast.-error strong") end end diff --git a/spec/features/admin/working_days_spec.rb b/spec/features/admin/working_days_spec.rb index 81b9d1724bc..cfddfaad9ed 100644 --- a/spec/features/admin/working_days_spec.rb +++ b/spec/features/admin/working_days_spec.rb @@ -101,7 +101,7 @@ RSpec.describe "Working Days", :js, :with_cuprite do dialog.confirm end - expect_primerized_flash(message: "Successful update.") + expect_flash(message: "Successful update.") expect(page).to have_unchecked_field "Monday" expect(page).to have_unchecked_field "Friday" expect(page).to have_unchecked_field "Saturday" @@ -141,7 +141,7 @@ RSpec.describe "Working Days", :js, :with_cuprite do dialog.confirm end - expect_primerized_flash(type: :error, message: "At least one day of the week must be defined as a working day.") + expect_flash(type: :error, message: "At least one day of the week must be defined as a working day.") # Restore the checkboxes to their valid state expect(page).to have_checked_field "Monday" expect(page).to have_checked_field "Tuesday" @@ -171,8 +171,8 @@ RSpec.describe "Working Days", :js, :with_cuprite do # Not executing the background jobs dialog.confirm - expect_primerized_flash(type: :error, - message: "The previous changes to the working days configuration have not been applied yet.") + expect_flash(type: :error, + message: "The previous changes to the working days configuration have not been applied yet.") end end @@ -229,7 +229,7 @@ RSpec.describe "Working Days", :js, :with_cuprite do click_on "Apply changes" click_on "Save and reschedule" - expect_primerized_flash(message: "Successful update.") + expect_flash(message: "Successful update.") nwd1 = NonWorkingDay.find_by(name: "My holiday") expect(nwd1.date).to eq date1 @@ -309,6 +309,6 @@ RSpec.describe "Working Days", :js, :with_cuprite do click_on "Apply changes" # No dialog and saved successfully - expect_primerized_flash(message: "Successful update.") + expect_flash(message: "Successful update.") end end diff --git a/spec/features/auth/consent_auth_stage_spec.rb b/spec/features/auth/consent_auth_stage_spec.rb index 04751d2e80f..5839c19f495 100644 --- a/spec/features/auth/consent_auth_stage_spec.rb +++ b/spec/features/auth/consent_auth_stage_spec.rb @@ -168,7 +168,7 @@ RSpec.describe "Authentication Stages" do find_by_id("toggle_consent_time").set(true) click_on "Save" - expect_primerized_flash(message: "Successful update.") + expect_flash(message: "Successful update.") Setting.clear_cache expect(Setting.consent_time).to be_present @@ -215,7 +215,7 @@ RSpec.describe "Authentication Stages" do check "consent_check" click_on I18n.t(:button_create) - expect_primerized_flash(message: I18n.t(:notice_account_registered_and_logged_in)) + expect_flash(message: I18n.t(:notice_account_registered_and_logged_in)) expect_logged_in("/?first_time_user=true") end @@ -256,7 +256,7 @@ RSpec.describe "Authentication Stages" do # Decline the consent click_on I18n.t(:button_decline) - expect_primerized_flash(type: :error, message: "foo@example.org") + expect_flash(type: :error, message: "foo@example.org") end end end diff --git a/spec/features/auth/lost_password_spec.rb b/spec/features/auth/lost_password_spec.rb index 7bfd9be964d..f7652f67207 100644 --- a/spec/features/auth/lost_password_spec.rb +++ b/spec/features/auth/lost_password_spec.rb @@ -39,14 +39,14 @@ RSpec.describe "Lost password" do fill_in "mail", with: "invalid mail" click_on "Submit" - expect_primerized_flash(message: I18n.t(:notice_account_lost_email_sent)) + expect_flash(message: I18n.t(:notice_account_lost_email_sent)) perform_enqueued_jobs expect(ActionMailer::Base.deliveries.size).to be 0 fill_in "mail", with: user.mail click_on "Submit" - expect_primerized_flash(message: I18n.t(:notice_account_lost_email_sent)) + expect_flash(message: I18n.t(:notice_account_lost_email_sent)) perform_enqueued_jobs expect(ActionMailer::Base.deliveries.size).to be 1 @@ -60,7 +60,7 @@ RSpec.describe "Lost password" do click_button "Save" - expect_primerized_flash(type: :info, message: I18n.t(:notice_account_password_updated)) + expect_flash(type: :info, message: I18n.t(:notice_account_password_updated)) login_with user.login, new_password @@ -79,7 +79,7 @@ RSpec.describe "Lost password" do fill_in "mail", with: user.mail click_on "Submit" - expect_primerized_flash(message: I18n.t(:notice_account_lost_email_sent)) + expect_flash(message: I18n.t(:notice_account_lost_email_sent)) perform_enqueued_jobs expect(ActionMailer::Base.deliveries.size).to be 1 @@ -99,7 +99,7 @@ RSpec.describe "Lost password" do fill_in "mail", with: user.mail click_on "Submit" - expect_primerized_flash(message: I18n.t(:notice_account_lost_email_sent)) + expect_flash(message: I18n.t(:notice_account_lost_email_sent)) perform_enqueued_jobs expect(ActionMailer::Base.deliveries.size).to be 1 diff --git a/spec/features/custom_fields/reorder_options_spec.rb b/spec/features/custom_fields/reorder_options_spec.rb index dc396d03047..1ff0bc2e541 100644 --- a/spec/features/custom_fields/reorder_options_spec.rb +++ b/spec/features/custom_fields/reorder_options_spec.rb @@ -38,7 +38,7 @@ RSpec.describe "Reordering custom options of a list custom field", :js do click_link "Reorder values alphabetically" cf_page.accept_alert_dialog! - expect_primerized_flash(message: I18n.t(:notice_successful_update)) + expect_flash(message: I18n.t(:notice_successful_update)) expect(custom_field.custom_options.order(:position).pluck(:value)) .to eq get_possible_values_reordered(200) end diff --git a/spec/features/custom_styles/tabs_navigation_spec.rb b/spec/features/custom_styles/tabs_navigation_spec.rb index 98b0e1bcdd1..40dc6ea58ba 100644 --- a/spec/features/custom_styles/tabs_navigation_spec.rb +++ b/spec/features/custom_styles/tabs_navigation_spec.rb @@ -60,7 +60,7 @@ RSpec.describe "Tabs navigation and content switching on the admin/design page" it "selects a color theme and redirect to the interface tab" do select("OpenProject Gray", from: "theme") find("[data-test-selector='color-theme-button']").click - expect_primerized_flash(message: I18n.t(:notice_successful_update)) + expect_flash(message: I18n.t(:notice_successful_update)) expect(page).to have_current_path custom_style_path(tab: "interface") end @@ -78,7 +78,7 @@ RSpec.describe "Tabs navigation and content switching on the admin/design page" # select a color theme and redirect to the branding tab select("OpenProject Navy Blue", from: "theme") find("[data-test-selector='color-theme-button']").click - expect_primerized_flash(message: I18n.t(:notice_successful_update)) + expect_flash(message: I18n.t(:notice_successful_update)) expect(page).to have_current_path custom_style_path(tab: "branding") # remove the logo and redirect to the branding tab @@ -94,7 +94,7 @@ RSpec.describe "Tabs navigation and content switching on the admin/design page" # select a color theme and redirect to the PDF export styles tab select("OpenProject (default)", from: "theme") find("[data-test-selector='color-theme-button']").click - expect_primerized_flash(message: I18n.t(:notice_successful_update)) + expect_flash(message: I18n.t(:notice_successful_update)) expect(page).to have_current_path custom_style_path(tab: "pdf_export_styles") # change export cover text color and redirect to the PDF export styles tab diff --git a/spec/features/groups/groups_spec.rb b/spec/features/groups/groups_spec.rb index a7a74cb93d9..7ecae788f24 100644 --- a/spec/features/groups/groups_spec.rb +++ b/spec/features/groups/groups_spec.rb @@ -45,7 +45,7 @@ RSpec.describe "group memberships through groups page", :js, :with_cuprite do groups_page.delete_group! "Bob's Team" - expect_primerized_flash(type: :info, message: I18n.t(:notice_deletion_scheduled)) + expect_flash(type: :info, message: I18n.t(:notice_deletion_scheduled)) expect(groups_page).to have_group "Bob's Team" perform_enqueued_jobs diff --git a/spec/features/homescreen/index_spec.rb b/spec/features/homescreen/index_spec.rb index 451190d94b3..af7e97e83c7 100644 --- a/spec/features/homescreen/index_spec.rb +++ b/spec/features/homescreen/index_spec.rb @@ -71,7 +71,7 @@ RSpec.describe "Homescreen", "index", :with_cuprite do welcome_text_editor.click_and_type_slowly("Hello! ") general_settings_page.press_save_button - expect_and_dismiss_primerized_flash(message: "Successful update.") + expect_and_dismiss_flash(message: "Successful update.") visit root_url expect(page) diff --git a/spec/features/ldap_auth_sources/crud_spec.rb b/spec/features/ldap_auth_sources/crud_spec.rb index aec5715ade1..8cd3985fbfa 100644 --- a/spec/features/ldap_auth_sources/crud_spec.rb +++ b/spec/features/ldap_auth_sources/crud_spec.rb @@ -52,7 +52,7 @@ RSpec.describe "CRUD LDAP connections", :js, :with_cuprite do click_on "Create" - expect_and_dismiss_primerized_flash message: "Successful creation." + expect_and_dismiss_flash message: "Successful creation." expect(page).to have_css("td.name", text: "My LDAP connection") expect(page).to have_css("td.host", text: "localhost") @@ -71,7 +71,7 @@ RSpec.describe "CRUD LDAP connections", :js, :with_cuprite do accept_prompt { click_on "Delete" } end - expect_and_dismiss_primerized_flash message: "Successful deletion." + expect_and_dismiss_flash message: "Successful deletion." expect(page).to have_no_text "My LDAP connection" expect(page).to have_text "Admin connection" @@ -88,7 +88,7 @@ RSpec.describe "CRUD LDAP connections", :js, :with_cuprite do fill_in "ldap_auth_source_name", with: "Updated Admin connection" click_on "Save" - expect_primerized_flash(message: "Successful update.") + expect_flash(message: "Successful update.") expect(page).to have_css("td.name", text: "Updated Admin connection") end diff --git a/spec/features/members/pagination_spec.rb b/spec/features/members/pagination_spec.rb index 9001110667a..d9b972ed8c7 100644 --- a/spec/features/members/pagination_spec.rb +++ b/spec/features/members/pagination_spec.rb @@ -84,7 +84,7 @@ RSpec.describe "members pagination", :js do members_page.visit! SeleniumHubWaiter.wait members_page.remove_user! "Alice Alison" - expect_and_dismiss_primerized_flash message: "Removed Alice Alison from project" + expect_and_dismiss_flash message: "Removed Alice Alison from project" expect(members_page).to have_user "Bob Bobbit" SeleniumHubWaiter.wait diff --git a/spec/features/oauth/authorization_code_flow_spec.rb b/spec/features/oauth/authorization_code_flow_spec.rb index 0c00a5d7cdb..84ffc46df8e 100644 --- a/spec/features/oauth/authorization_code_flow_spec.rb +++ b/spec/features/oauth/authorization_code_flow_spec.rb @@ -101,7 +101,7 @@ RSpec.describe "OAuth authorization code flow", :js do page.driver.browser.switch_to.alert.accept # Should be back on access_token path - expect_primerized_flash(message: "Revocation of application Cool API app! successful.") + expect_flash(message: "Revocation of application Cool API app! successful.") expect(page).to have_no_css("[id^=oauth-application-grant]") expect(page).to have_current_path /\/my\/access_token/ diff --git a/spec/features/placeholder_users/create_spec.rb b/spec/features/placeholder_users/create_spec.rb index 2c0669b038a..78df219f3d5 100644 --- a/spec/features/placeholder_users/create_spec.rb +++ b/spec/features/placeholder_users/create_spec.rb @@ -40,7 +40,7 @@ RSpec.describe "create placeholder users", :selenium do new_placeholder_user_page.submit! - expect_primerized_flash(message: "Successful creation.") + expect_flash(message: "Successful creation.") new_placeholder_user = PlaceholderUser.order(Arel.sql("id DESC")).first diff --git a/spec/features/placeholder_users/delete_spec.rb b/spec/features/placeholder_users/delete_spec.rb index 59bc1762633..d295b16dd02 100644 --- a/spec/features/placeholder_users/delete_spec.rb +++ b/spec/features/placeholder_users/delete_spec.rb @@ -49,7 +49,7 @@ RSpec.describe "delete placeholder user", :js do expect(page).to have_css(".danger-zone--verification button:not([disabled])") click_on "Delete" - expect_primerized_flash(type: :info, message: I18n.t(:notice_deletion_scheduled)) + expect_flash(type: :info, message: I18n.t(:notice_deletion_scheduled)) # The user is still there placeholder_user.reload diff --git a/spec/features/placeholder_users/edit_placeholder_users_spec.rb b/spec/features/placeholder_users/edit_placeholder_users_spec.rb index 4d2fa380a89..4c3545e45ae 100644 --- a/spec/features/placeholder_users/edit_placeholder_users_spec.rb +++ b/spec/features/placeholder_users/edit_placeholder_users_spec.rb @@ -41,7 +41,7 @@ RSpec.describe "edit placeholder users", :js do click_on "Save" - expect_primerized_flash(message: "Successful update.") + expect_flash(message: "Successful update.") placeholder_user.reload diff --git a/spec/features/principals/shared_memberships_examples.rb b/spec/features/principals/shared_memberships_examples.rb index 2dc6130e374..0657a15bf0c 100644 --- a/spec/features/principals/shared_memberships_examples.rb +++ b/spec/features/principals/shared_memberships_examples.rb @@ -30,7 +30,7 @@ RSpec.shared_examples "principal membership management flows" do principal_page.expect_project(project.name) principal_page.edit_roles!(member, %w()) - expect_primerized_flash(type: :error, message: "Roles need to be assigned.") + expect_flash(type: :error, message: "Roles need to be assigned.") # Remove the user from the project principal_page.remove_from_project!(project.name) diff --git a/spec/features/projects/destroy_spec.rb b/spec/features/projects/destroy_spec.rb index c666f4afe17..cc06c5b0a73 100644 --- a/spec/features/projects/destroy_spec.rb +++ b/spec/features/projects/destroy_spec.rb @@ -53,7 +53,7 @@ RSpec.describe "Projects#destroy", :js, :with_cuprite do expect(danger_zone).not_to be_disabled danger_zone.danger_button.click - expect_primerized_flash message: I18n.t("projects.delete.scheduled") + expect_flash message: I18n.t("projects.delete.scheduled") expect(project.reload).to eq(project) perform_enqueued_jobs diff --git a/spec/features/projects/modules_spec.rb b/spec/features/projects/modules_spec.rb index a15fcb1dee4..f6df8dbcb02 100644 --- a/spec/features/projects/modules_spec.rb +++ b/spec/features/projects/modules_spec.rb @@ -65,7 +65,7 @@ RSpec.describe "Projects module administration" do check "Calendar" click_button "Save" - expect_primerized_flash(type: :error, message: + expect_flash(type: :error, message: I18n.t(:"activerecord.errors.models.project.attributes.enabled_modules.dependency_missing", dependency: "Work packages", module: "Calendars")) diff --git a/spec/features/projects/project_custom_fields/overview_page/dialog/permission_spec.rb b/spec/features/projects/project_custom_fields/overview_page/dialog/permission_spec.rb index 97a901455c3..df7bc3a8464 100644 --- a/spec/features/projects/project_custom_fields/overview_page/dialog/permission_spec.rb +++ b/spec/features/projects/project_custom_fields/overview_page/dialog/permission_spec.rb @@ -117,7 +117,7 @@ RSpec.describe "Edit project custom fields on project overview page", :js do member_with_project_attributes_edit_permissions.reload dialog.submit - expect_primerized_flash(type: :error, message: I18n.t(:notice_not_authorized)) + expect_flash(type: :error, message: I18n.t(:notice_not_authorized)) end end end diff --git a/spec/features/projects/projects_index_spec.rb b/spec/features/projects/projects_index_spec.rb index d3635a0dc3c..886d00deb45 100644 --- a/spec/features/projects/projects_index_spec.rb +++ b/spec/features/projects/projects_index_spec.rb @@ -274,9 +274,9 @@ RSpec.describe "Projects index page", :js, :with_cuprite, with_settings: { login error_text = "Orders > is not set to one of the allowed values. and does not exist." error_html = "Orders ><script src='/foobar js'></script> is not set to one of the allowed values. and does not exist." - expect_primerized_flash(type: :error, message: error_text) + expect_flash(type: :error, message: error_text) - error_container = find_primerized_flash(type: :error) + error_container = find_flash_element(type: :error) expect(error_container["innerHTML"]).to include error_html end end diff --git a/spec/features/projects/projects_portfolio_spec.rb b/spec/features/projects/projects_portfolio_spec.rb index 886c9fd62b5..62ed2eeb595 100644 --- a/spec/features/projects/projects_portfolio_spec.rb +++ b/spec/features/projects/projects_portfolio_spec.rb @@ -115,7 +115,7 @@ RSpec.describe "Projects index page", :js, :with_cuprite, with_settings: { login # Save the page scroll_to_and_click(find(".button", text: "Save")) - expect_primerized_flash(message: "Successful update.") + expect_flash(message: "Successful update.") RequestStore.clear! query = JSON.parse Setting.project_gantt_query diff --git a/spec/features/projects/template_spec.rb b/spec/features/projects/template_spec.rb index 39a7be290d6..50bb5b0bc2c 100644 --- a/spec/features/projects/template_spec.rb +++ b/spec/features/projects/template_spec.rb @@ -44,7 +44,7 @@ RSpec.describe "Project templates", :js, :with_cuprite, # Make a template find(".button", text: "Set as template").click - expect_and_dismiss_primerized_flash(message: "Successful update.") + expect_and_dismiss_flash(message: "Successful update.") expect(page).to have_css(".button", text: "Remove from templates") project.reload diff --git a/spec/features/repositories/create_repository_spec.rb b/spec/features/repositories/create_repository_spec.rb index 6a7ff5c2163..41d8d60cbc7 100644 --- a/spec/features/repositories/create_repository_spec.rb +++ b/spec/features/repositories/create_repository_spec.rb @@ -149,7 +149,7 @@ RSpec.describe "Create repository", :js, :selenium do click_button(I18n.t(:button_create)) - expect_primerized_flash(message: I18n.t("repositories.create_successful")) + expect_flash(message: I18n.t("repositories.create_successful")) expect(page).to have_css("a.icon-delete", text: I18n.t(:button_delete)) end end @@ -161,7 +161,7 @@ RSpec.describe "Create repository", :js, :selenium do click_button(I18n.t(:button_create)) - expect_primerized_flash(message: I18n.t("repositories.create_successful")) + expect_flash(message: I18n.t("repositories.create_successful")) expect(page).to have_css('button[type="submit"]', text: I18n.t(:button_save)) expect(page).to have_css("a.icon-remove", text: I18n.t(:button_remove)) end diff --git a/spec/features/repositories/repository_settings_spec.rb b/spec/features/repositories/repository_settings_spec.rb index d31182f23a7..4932ce5be88 100644 --- a/spec/features/repositories/repository_settings_spec.rb +++ b/spec/features/repositories/repository_settings_spec.rb @@ -193,7 +193,7 @@ RSpec.describe "Repository Settings", :js do click_button(I18n.t(:button_save)) expect(page).to have_css('[name="repository[login]"][value="foobar"]') - expect_primerized_flash(message: I18n.t("repositories.update_settings_successful")) + expect_flash(message: I18n.t("repositories.update_settings_successful")) end end end diff --git a/spec/features/roles/create_spec.rb b/spec/features/roles/create_spec.rb index 0ceeb15f38e..23bfe0afebf 100644 --- a/spec/features/roles/create_spec.rb +++ b/spec/features/roles/create_spec.rb @@ -55,7 +55,7 @@ RSpec.describe "Role creation", :js, :with_cuprite do click_button "Create" - expect_primerized_flash(type: :error, message: "Name has already been taken") + expect_flash(type: :error, message: "Name has already been taken") fill_in "Name", with: "New role name" @@ -64,15 +64,15 @@ RSpec.describe "Role creation", :js, :with_cuprite do click_button "Create" - expect_primerized_flash(type: :error, - message: "Permissions need to also include 'View members' as 'Manage members' is selected.") + expect_flash(type: :error, + message: "Permissions need to also include 'View members' as 'Manage members' is selected.") check "View members" select existing_role.name, from: "Copy workflow from" click_button "Create" - expect_and_dismiss_primerized_flash(message: "Successful creation.") + expect_and_dismiss_flash(message: "Successful creation.") expect(page) .to have_current_path(roles_path) diff --git a/spec/features/types/crud_spec.rb b/spec/features/types/crud_spec.rb index dd6b1f6f4c7..ba957d2be9e 100644 --- a/spec/features/types/crud_spec.rb +++ b/spec/features/types/crud_spec.rb @@ -52,7 +52,7 @@ RSpec.describe "Types", :js, :with_cuprite do click_button "Create" - expect_primerized_flash(type: :error, message: "Name has already been taken.") + expect_flash(type: :error, message: "Name has already been taken.") # Values are retained expect(page) @@ -122,7 +122,7 @@ RSpec.describe "Types", :js, :with_cuprite do end it "renders an error message with links to the archived project in the projects list" do - expect_primerized_flash type: :error, message: project.name + expect_flash type: :error, message: project.name end end end diff --git a/spec/features/types/form_configuration_query_spec.rb b/spec/features/types/form_configuration_query_spec.rb index 4c178f1bb72..3ccc66207d8 100644 --- a/spec/features/types/form_configuration_query_spec.rb +++ b/spec/features/types/form_configuration_query_spec.rb @@ -93,7 +93,7 @@ RSpec.describe "form query configuration", :js, :with_cuprite do it "can save an empty query group" do form.add_query_group("Empty test", :children) form.save_changes - expect_primerized_flash(message: "Successful update.") + expect_flash(message: "Successful update.") type_bug.reload query_group = type_bug.attribute_groups.detect { |x| x.is_a?(Type::QueryGroup) } @@ -105,7 +105,7 @@ RSpec.describe "form query configuration", :js, :with_cuprite do form.add_query_group("Subtasks", :children) # Save changed query form.save_changes - expect_primerized_flash(message: "Successful update.") + expect_flash(message: "Successful update.") # Visit wp_table wp_table.visit! @@ -131,7 +131,7 @@ RSpec.describe "form query configuration", :js, :with_cuprite do form.add_query_group("Subtasks", :children) # Save changed query form.save_changes - expect_primerized_flash(message: "Successful update.") + expect_flash(message: "Successful update.") # Visit new wp page visit new_project_work_packages_path(project) @@ -156,7 +156,7 @@ RSpec.describe "form query configuration", :js, :with_cuprite do filters.save form.save_changes - expect_primerized_flash message: "Successful update." + expect_flash message: "Successful update." archived.update_attribute(:active, false) @@ -184,7 +184,7 @@ RSpec.describe "form query configuration", :js, :with_cuprite do # Save changed query form.save_changes - expect_primerized_flash(message: "Successful update.") + expect_flash(message: "Successful update.") type_bug.reload query = type_bug.attribute_groups.detect { |x| x.key == "Columns Test" } @@ -206,7 +206,7 @@ RSpec.describe "form query configuration", :js, :with_cuprite do # Save changed query form.save_changes - expect_primerized_flash(message: "Successful update.") + expect_flash(message: "Successful update.") type_bug.reload query = type_bug.attribute_groups.detect { |x| x.key == "Columns Test" } @@ -253,7 +253,7 @@ RSpec.describe "form query configuration", :js, :with_cuprite do filters.save form.save_changes - expect_primerized_flash(message: "Successful update.") + expect_flash(message: "Successful update.") # Visit work package with that type wp_page.visit! diff --git a/spec/features/types/form_configuration_spec.rb b/spec/features/types/form_configuration_spec.rb index 75b6c930b7d..5e6fc5ed76f 100644 --- a/spec/features/types/form_configuration_spec.rb +++ b/spec/features/types/form_configuration_spec.rb @@ -91,7 +91,7 @@ RSpec.describe "form configuration", :js do # Save configuration form.save_changes - expect_primerized_flash(message: "Successful update.") + expect_flash(message: "Successful update.") form.expect_empty @@ -171,7 +171,7 @@ RSpec.describe "form configuration", :js do # Save configuration form.save_changes - expect_primerized_flash(message: "Successful update.") + expect_flash(message: "Successful update.") # Expect configuration to be correct now form.expect_no_attribute("assignee", "Cool Stuff") @@ -269,7 +269,7 @@ RSpec.describe "form configuration", :js do form.expect_attribute(key: cf_identifier) form.save_changes - expect_primerized_flash(message: "Successful update.") + expect_flash(message: "Successful update.") end end @@ -299,7 +299,7 @@ RSpec.describe "form configuration", :js do form.expect_attribute(key: cf_identifier) form.save_changes - expect_primerized_flash(message: "Successful update.") + expect_flash(message: "Successful update.") end context "if inactive in project" do diff --git a/spec/features/types/reset_form_configuration_spec.rb b/spec/features/types/reset_form_configuration_spec.rb index 43ac566757e..93ee119f1a0 100644 --- a/spec/features/types/reset_form_configuration_spec.rb +++ b/spec/features/types/reset_form_configuration_spec.rb @@ -60,7 +60,7 @@ RSpec.describe "Reset form configuration", :js do form.expect_attribute(key: cf_identifier) form.save_changes - expect_primerized_flash(message: "Successful update.") + expect_flash(message: "Successful update.") SeleniumHubWaiter.wait form.reset_button.click diff --git a/spec/features/users/create_spec.rb b/spec/features/users/create_spec.rb index 2027c2eac68..b24ac2a4b4a 100644 --- a/spec/features/users/create_spec.rb +++ b/spec/features/users/create_spec.rb @@ -45,7 +45,7 @@ RSpec.describe "create users", :with_cuprite do shared_examples_for "successful user creation" do |redirect_to_edit_page: true| it "creates the user" do - expect_primerized_flash(message: "Successful creation.") + expect_flash(message: "Successful creation.") new_user = User.order(Arel.sql("id DESC")).first diff --git a/spec/features/users/edit_users_spec.rb b/spec/features/users/edit_users_spec.rb index 650701e321f..55f21d170de 100644 --- a/spec/features/users/edit_users_spec.rb +++ b/spec/features/users/edit_users_spec.rb @@ -127,7 +127,7 @@ RSpec.describe "edit users", :js, :with_cuprite do click_button "Save" - expect_primerized_flash(message: "Successful update.") + expect_flash(message: "Successful update.") user.reload @@ -140,7 +140,7 @@ RSpec.describe "edit users", :js, :with_cuprite do click_on "Send invitation" - expect_primerized_flash(message: "An invitation has been sent to foo@example.com") + expect_flash(message: "An invitation has been sent to foo@example.com") end it "can not edit attributes of an admin user" do diff --git a/spec/features/users/password_change_spec.rb b/spec/features/users/password_change_spec.rb index 0c905a6f36d..ecc1daa41ad 100644 --- a/spec/features/users/password_change_spec.rb +++ b/spec/features/users/password_change_spec.rb @@ -60,7 +60,7 @@ RSpec.describe "random password generation", :js, :with_cuprite do click_on "Save" - expect_primerized_flash(message: "Successful update.") + expect_flash(message: "Successful update.") expect(password).to be_present # Logout @@ -90,7 +90,7 @@ RSpec.describe "random password generation", :js, :with_cuprite do expect(Sessions::UserSession.for_user(user.id).count).to be >= 1 click_on "Save" - expect_primerized_flash(type: :info, message: I18n.t(:notice_account_password_updated)) + expect_flash(type: :info, message: I18n.t(:notice_account_password_updated)) # The old session is removed expect(Sessions::UserSession.find_by(session_id: "other")).to be_nil @@ -126,7 +126,7 @@ RSpec.describe "random password generation", :js, :with_cuprite do find_by_id("settings_password_min_adhered_rules").set 3 scroll_to_and_click(find(".button", text: "Save")) - expect_primerized_flash(message: "Successful update.") + expect_flash(message: "Successful update.") Setting.clear_cache @@ -144,19 +144,19 @@ RSpec.describe "random password generation", :js, :with_cuprite do fill_in "user_password", with: "adminADMIN" fill_in "user_password_confirmation", with: "adminADMIN" scroll_to_and_click(find(".button", text: "Save")) - expect_primerized_flash(type: :error, message: "Password Must contain characters of the following classes") + expect_flash(type: :error, message: "Password Must contain characters of the following classes") # 2 of 3 classes fill_in "user_password", with: "adminADMIN123" fill_in "user_password_confirmation", with: "adminADMIN123" scroll_to_and_click(find(".button", text: "Save")) - expect_primerized_flash(type: :error, message: "Password Must contain characters of the following classes") + expect_flash(type: :error, message: "Password Must contain characters of the following classes") # All classes fill_in "user_password", with: "adminADMIN!" fill_in "user_password_confirmation", with: "adminADMIN!" scroll_to_and_click(find(".button", text: "Save")) - expect_primerized_flash(message: I18n.t(:notice_successful_update)) + expect_flash(message: I18n.t(:notice_successful_update)) end end diff --git a/spec/features/versions/delete_spec.rb b/spec/features/versions/delete_spec.rb index b2204174197..6f6cdffd3be 100644 --- a/spec/features/versions/delete_spec.rb +++ b/spec/features/versions/delete_spec.rb @@ -53,7 +53,7 @@ RSpec.describe "version delete", :js, :with_cuprite do end end - expect_primerized_flash(type: :error, message: I18n.t(:error_can_not_delete_in_use_archived_undisclosed)) + expect_flash(type: :error, message: I18n.t(:error_can_not_delete_in_use_archived_undisclosed)) expect(page).to have_no_css("a", text: "Archived child") user.update!(admin: true) @@ -67,7 +67,7 @@ RSpec.describe "version delete", :js, :with_cuprite do end end - expect_primerized_flash(type: :error, message: "There are also work packages in archived projects.") + expect_flash(type: :error, message: "There are also work packages in archived projects.") expect(page).to have_css("a", text: "Archived child") end end diff --git a/spec/features/wiki/adding_editing_history_spec.rb b/spec/features/wiki/adding_editing_history_spec.rb index d0ee5a97e58..d30970bd251 100644 --- a/spec/features/wiki/adding_editing_history_spec.rb +++ b/spec/features/wiki/adding_editing_history_spec.rb @@ -82,7 +82,7 @@ RSpec.describe "wiki pages", :js, with_settings: { journal_aggregation_time_minu find(".ck-content").base.send_keys(content_first_version) click_button "Save" - expect_and_dismiss_primerized_flash(message: "Successful creation.") + expect_and_dismiss_flash(message: "Successful creation.") expect(page).to have_css(".title-container", text: "New page") expect(page).to have_css(".wiki-content", text: content_first_version) diff --git a/spec/features/wiki/attachment_upload_spec.rb b/spec/features/wiki/attachment_upload_spec.rb index 4af6efdc1fd..0184c6f4f34 100644 --- a/spec/features/wiki/attachment_upload_spec.rb +++ b/spec/features/wiki/attachment_upload_spec.rb @@ -56,7 +56,7 @@ RSpec.describe "Upload attachment to wiki page", :js do click_on "Save" - expect_and_dismiss_primerized_flash(message: "Successful creation") + expect_and_dismiss_flash(message: "Successful creation") expect(page).to have_css("#content img", count: 1) expect(page).to have_content("Image uploaded the first time") attachments_list.expect_attached("image.png") @@ -113,7 +113,7 @@ RSpec.describe "Upload attachment to wiki page", :js do click_on "Save" - expect_and_dismiss_primerized_flash(message: "Successful creation") + expect_and_dismiss_flash(message: "Successful creation") attachments_list.expect_attached("image.png") # required sleep otherwise clicking on the Edit button doesn't do anything diff --git a/spec/features/wiki/edit_new_page_spec.rb b/spec/features/wiki/edit_new_page_spec.rb index 148edc1e2d2..4b5c5f044cf 100644 --- a/spec/features/wiki/edit_new_page_spec.rb +++ b/spec/features/wiki/edit_new_page_spec.rb @@ -41,6 +41,6 @@ RSpec.describe "Editing a new wiki page", :js do expect(page).to have_field "page_title", with: "Foobar" click_on "Save" - expect_primerized_flash(message: "Successful creation.", wait: 10) + expect_flash(message: "Successful creation.", wait: 10) end end diff --git a/spec/features/work_packages/bulk/copy_work_package_spec.rb b/spec/features/work_packages/bulk/copy_work_package_spec.rb index 13f34af8785..0c595b4f967 100644 --- a/spec/features/work_packages/bulk/copy_work_package_spec.rb +++ b/spec/features/work_packages/bulk/copy_work_package_spec.rb @@ -201,16 +201,16 @@ RSpec.describe "Copy work packages through Rails view", :js, :with_cuprite do it "fails, informing of the reasons" do click_on "Copy and follow" - expect_primerized_flash(type: :error, message: I18n.t("work_packages.bulk.none_could_be_saved", total: 3)) - expect_primerized_flash(type: :error, - message: I18n.t( - "work_packages.bulk.selected_because_descendants", total: 3, selected: 2 - )) - expect_primerized_flash(type: :error, - message: "#{work_package.id}: Type #{I18n.t('activerecord.errors.messages.inclusion')}") - expect_primerized_flash(type: :error, - message: "#{work_package2.id}: Type #{I18n.t('activerecord.errors.messages.inclusion')}") - expect_primerized_flash(type: :error, message: + expect_flash(type: :error, message: I18n.t("work_packages.bulk.none_could_be_saved", total: 3)) + expect_flash(type: :error, + message: I18n.t( + "work_packages.bulk.selected_because_descendants", total: 3, selected: 2 + )) + expect_flash(type: :error, + message: "#{work_package.id}: Type #{I18n.t('activerecord.errors.messages.inclusion')}") + expect_flash(type: :error, + message: "#{work_package2.id}: Type #{I18n.t('activerecord.errors.messages.inclusion')}") + expect_flash(type: :error, message: "#{child.id} (descendant of selected): Type #{I18n.t('activerecord.errors.messages.inclusion')}") end @@ -298,7 +298,7 @@ RSpec.describe "Copy work packages through Rails view", :js, :with_cuprite do click_on "Copy and follow" - expect_primerized_flash(message: I18n.t(:notice_successful_create)) + expect_flash(message: I18n.t(:notice_successful_create)) wp_page = Pages::FullWorkPackage.new(WorkPackage.last) diff --git a/spec/features/work_packages/bulk/move_work_package_spec.rb b/spec/features/work_packages/bulk/move_work_package_spec.rb index 0e73db0be38..271b9f1a0db 100644 --- a/spec/features/work_packages/bulk/move_work_package_spec.rb +++ b/spec/features/work_packages/bulk/move_work_package_spec.rb @@ -140,7 +140,7 @@ RSpec.describe "Moving a work package through Rails view", :js do click_on "Move and follow" wait_for_reload - expect_primerized_flash type: :error, message: I18n.t(:"work_packages.bulk.none_could_be_saved", total: 1) + expect_flash type: :error, message: I18n.t(:"work_packages.bulk.none_could_be_saved", total: 1) # Should NOT have moved child_wp.reload @@ -167,7 +167,7 @@ RSpec.describe "Moving a work package through Rails view", :js do click_on "Move and follow" end - expect_primerized_flash type: :error, message: I18n.t(:"work_packages.bulk.none_could_be_saved", total: 1) + expect_flash type: :error, message: I18n.t(:"work_packages.bulk.none_could_be_saved", total: 1) child_wp.reload work_package.reload expect(work_package.project_id).to eq(project.id) @@ -209,11 +209,12 @@ RSpec.describe "Moving a work package through Rails view", :js do end it "displays an error message explaining which work package could not be moved and why" do - expect_primerized_flash(type: :error, message: I18n.t("work_packages.bulk.could_not_be_saved")) - expect_primerized_flash(type: :error, - message: "#{work_package2.id}: Project #{I18n.t('activerecord.errors.messages.error_readonly')}") + expect_flash(type: :error, + message: I18n.t("work_packages.bulk.could_not_be_saved")) + expect_flash(type: :error, + message: "#{work_package2.id}: Project #{I18n.t('activerecord.errors.messages.error_readonly')}") - expect_primerized_flash(type: :error, message: + expect_flash(type: :error, message: I18n.t("work_packages.bulk.x_out_of_y_could_be_saved", failing: 1, total: 2, diff --git a/spec/features/work_packages/bulk/update_work_package_spec.rb b/spec/features/work_packages/bulk/update_work_package_spec.rb index 8381b71454c..3f329baab07 100644 --- a/spec/features/work_packages/bulk/update_work_package_spec.rb +++ b/spec/features/work_packages/bulk/update_work_package_spec.rb @@ -111,11 +111,11 @@ RSpec.describe "Bulk update work packages through Rails view", :js, :with_cuprit fill_in "Parent", with: "-1" click_on "Submit" - expect_primerized_flash(type: :error, message: I18n.t("work_packages.bulk.none_could_be_saved", total: 2)) - expect_primerized_flash(type: :error, - message: "#{work_package.id}: Parent #{I18n.t('activerecord.errors.messages.does_not_exist')}") + expect_flash(type: :error, message: I18n.t("work_packages.bulk.none_could_be_saved", total: 2)) + expect_flash(type: :error, + message: "#{work_package.id}: Parent #{I18n.t('activerecord.errors.messages.does_not_exist')}") - expect_primerized_flash(type: :error, message: + expect_flash(type: :error, message: <<~MSG.squish #{work_package2.id}: Parent #{I18n.t('activerecord.errors.messages.does_not_exist')} @@ -143,10 +143,10 @@ RSpec.describe "Bulk update work packages through Rails view", :js, :with_cuprit fill_in custom_field.name, with: "Custom field text" click_on "Submit" - expect_primerized_flash(type: :error, message: + expect_flash(type: :error, message: I18n.t("work_packages.bulk.x_out_of_y_could_be_saved", total: 2, failing: 1, success: 1)) - expect_primerized_flash(type: :error, message: + expect_flash(type: :error, message: <<~MSG.squish #{work_package2.id}: #{custom_field.name} #{I18n.t('activerecord.errors.messages.error_readonly')} @@ -174,7 +174,7 @@ RSpec.describe "Bulk update work packages through Rails view", :js, :with_cuprit fill_in custom_field.name, with: "Custom field text" click_on "Submit" - expect_and_dismiss_primerized_flash(message: I18n.t(:notice_successful_update)) + expect_and_dismiss_flash(message: I18n.t(:notice_successful_update)) # Should update 2 work package custom fields work_package.reload diff --git a/spec/features/work_packages/display_fields/work_display_spec.rb b/spec/features/work_packages/display_fields/work_display_spec.rb index f14e9c0a7e2..014af5765a5 100644 --- a/spec/features/work_packages/display_fields/work_display_spec.rb +++ b/spec/features/work_packages/display_fields/work_display_spec.rb @@ -186,7 +186,7 @@ RSpec.describe "Work display", :js do visit admin_settings_working_days_and_hours_path select "Days and hours", from: "Duration format" click_on "Apply changes" - expect_and_dismiss_primerized_flash(message: "Successful update.") + expect_and_dismiss_flash(message: "Successful update.") wp_table.visit_query query diff --git a/spec/features/work_packages/navigation_spec.rb b/spec/features/work_packages/navigation_spec.rb index 38443aeccdc..7e6240e7d7b 100644 --- a/spec/features/work_packages/navigation_spec.rb +++ b/spec/features/work_packages/navigation_spec.rb @@ -148,7 +148,7 @@ RSpec.describe "Work package navigation", :js, :selenium do it "loading an unknown work package ID" do visit "/work_packages/999999999" - expect_primerized_flash type: :error, message: I18n.t(:notice_file_not_found) + expect_flash type: :error, message: I18n.t(:notice_file_not_found) visit "/projects/#{project.identifier}/work_packages/999999999" global_work_packages = Pages::WorkPackagesTable.new diff --git a/spec/features/wysiwyg/autosave_spec.rb b/spec/features/wysiwyg/autosave_spec.rb index 6c3e0a1141f..5d1edb79240 100644 --- a/spec/features/wysiwyg/autosave_spec.rb +++ b/spec/features/wysiwyg/autosave_spec.rb @@ -50,7 +50,7 @@ RSpec.describe "Wysiwyg autosave spec", editor.click_and_type_slowly "Initial version" click_on "Save" - expect_and_dismiss_primerized_flash(message: "Successful creation.") + expect_and_dismiss_flash(message: "Successful creation.") within("#content") do expect(page).to have_text "Initial version" @@ -70,7 +70,7 @@ RSpec.describe "Wysiwyg autosave spec", # Save wiki page click_on "Save" - expect_primerized_flash(message: "Successful update.") + expect_flash(message: "Successful update.") within("#content") do expect(page).to have_text "This should be saved" end @@ -80,7 +80,7 @@ RSpec.describe "Wysiwyg autosave spec", keys = page.evaluate_script "Object.keys(localStorage)" expect(keys).to include "op_ckeditor_rev_/api/v3/wiki_pages/#{wiki_page.id}_page[text]" - expect_and_dismiss_primerized_flash(message: "Successful update.") + expect_and_dismiss_flash(message: "Successful update.") # Edit again click_on "Edit" diff --git a/spec/features/wysiwyg/bold_behavior_spec.rb b/spec/features/wysiwyg/bold_behavior_spec.rb index 5521337ed5c..37374ff5416 100644 --- a/spec/features/wysiwyg/bold_behavior_spec.rb +++ b/spec/features/wysiwyg/bold_behavior_spec.rb @@ -58,7 +58,7 @@ RSpec.describe "Wysiwyg bold behavior", :js, :with_cuprite do # Save wiki page click_on "Save" - expect_primerized_flash(message: "Successful creation.") + expect_flash(message: "Successful creation.") within("#content") do expect(page).to have_css("p") { |node| diff --git a/spec/features/wysiwyg/html_encoding_spec.rb b/spec/features/wysiwyg/html_encoding_spec.rb index bb955207cdb..e21e8fa79a1 100644 --- a/spec/features/wysiwyg/html_encoding_spec.rb +++ b/spec/features/wysiwyg/html_encoding_spec.rb @@ -51,7 +51,7 @@ RSpec.describe "Wysiwyg escaping HTML entities (Regression #28906)", :js do # Save wiki page click_on "Save" - expect_primerized_flash(message: "Successful creation.") + expect_flash(message: "Successful creation.") within("#content") do expect(page).to have_css("p", text: '') diff --git a/spec/features/wysiwyg/linking_spec.rb b/spec/features/wysiwyg/linking_spec.rb index 792a7ff9842..38dcd4424c3 100644 --- a/spec/features/wysiwyg/linking_spec.rb +++ b/spec/features/wysiwyg/linking_spec.rb @@ -49,7 +49,7 @@ RSpec.describe "Wysiwyg linking", :js do # Save wiki page click_on "Save" - expect_primerized_flash(message: "Successful creation.") + expect_flash(message: "Successful creation.") wiki_page = project.wiki.pages.first.reload diff --git a/spec/features/wysiwyg/macros/attribute_macros_spec.rb b/spec/features/wysiwyg/macros/attribute_macros_spec.rb index 7b7ad2aa55a..fe9f06f06c8 100644 --- a/spec/features/wysiwyg/macros/attribute_macros_spec.rb +++ b/spec/features/wysiwyg/macros/attribute_macros_spec.rb @@ -114,7 +114,7 @@ RSpec.describe "Wysiwyg attribute macros", :js do click_on "Save" - expect_and_dismiss_primerized_flash(message: "Successful creation.") + expect_and_dismiss_flash(message: "Successful creation.") # Expect output widget within("#content") do @@ -177,7 +177,7 @@ RSpec.describe "Wysiwyg attribute macros", :js do click_on "Save" - expect_primerized_flash(message: "Successful creation.") + expect_flash(message: "Successful creation.") within("#content") do expect(page).to have_css(".custom-option", count: 6) diff --git a/spec/features/wysiwyg/macros/child_pages_spec.rb b/spec/features/wysiwyg/macros/child_pages_spec.rb index 9b3176a38b0..d0bbcdbfce6 100644 --- a/spec/features/wysiwyg/macros/child_pages_spec.rb +++ b/spec/features/wysiwyg/macros/child_pages_spec.rb @@ -112,7 +112,7 @@ RSpec.describe "Wysiwyg child pages spec", :js do # Save wiki page click_on "Save" - expect_and_dismiss_primerized_flash(message: "Successful update.") + expect_and_dismiss_flash(message: "Successful update.") within("#content") do expect(page).to have_css(".pages-hierarchy") @@ -145,7 +145,7 @@ RSpec.describe "Wysiwyg child pages spec", :js do # Save wiki page click_on "Save" - expect_and_dismiss_primerized_flash(message: "Successful update.") + expect_and_dismiss_flash(message: "Successful update.") within("#content") do expect(page).to have_css(".pages-hierarchy") diff --git a/spec/features/wysiwyg/macros/code_block_macro_spec.rb b/spec/features/wysiwyg/macros/code_block_macro_spec.rb index 8b68df931f1..eb5626d1f47 100644 --- a/spec/features/wysiwyg/macros/code_block_macro_spec.rb +++ b/spec/features/wysiwyg/macros/code_block_macro_spec.rb @@ -74,7 +74,7 @@ RSpec.describe "Wysiwyg code block macro", :js do end click_on "Save" - expect_and_dismiss_primerized_flash(message: "Successful creation.") + expect_and_dismiss_flash(message: "Successful creation.") # Expect output widget within("#content") do @@ -106,7 +106,7 @@ RSpec.describe "Wysiwyg code block macro", :js do expect(container).to have_css(".op-uc-code-block", text: "asdf") click_on "Save" - expect_and_dismiss_primerized_flash(message: "Successful creation.") + expect_and_dismiss_flash(message: "Successful creation.") wp = WikiPage.last expect(wp.text.gsub("\r\n", "\n")).to eq("```text\nasdf\n```") @@ -119,7 +119,7 @@ RSpec.describe "Wysiwyg code block macro", :js do end click_on "Save" - expect_and_dismiss_primerized_flash(message: "Successful update.") + expect_and_dismiss_flash(message: "Successful update.") wp.reload # Regression added two newlines before fence here @@ -153,7 +153,7 @@ RSpec.describe "Wysiwyg code block macro", :js do # Save wiki page click_on "Save" - expect_and_dismiss_primerized_flash(message: "Successful creation.") + expect_and_dismiss_flash(message: "Successful creation.") wiki_page = project.wiki.find_page("wiki") text = wiki_page.text.gsub(/\r\n?/, "\n") diff --git a/spec/features/wysiwyg/macros/embedded_tables_spec.rb b/spec/features/wysiwyg/macros/embedded_tables_spec.rb index 7886562650c..fd632db5f54 100644 --- a/spec/features/wysiwyg/macros/embedded_tables_spec.rb +++ b/spec/features/wysiwyg/macros/embedded_tables_spec.rb @@ -107,7 +107,7 @@ RSpec.describe "Wysiwyg embedded work package tables", # Save wiki page click_on "Save" - expect_primerized_flash(message: "Successful creation.") + expect_flash(message: "Successful creation.") embedded_table = Pages::EmbeddedWorkPackagesTable.new find(".wiki-content") embedded_table.expect_work_package_listed wp_task @@ -143,7 +143,7 @@ RSpec.describe "Wysiwyg embedded work package tables", # Save wiki page click_on "Save" - expect_and_dismiss_primerized_flash(message: "Successful creation.") + expect_and_dismiss_flash(message: "Successful creation.") # Embedded queries wikipage = project.wiki.pages.last diff --git a/spec/features/wysiwyg/macros/quicklink_macros_spec.rb b/spec/features/wysiwyg/macros/quicklink_macros_spec.rb index 45ed16b8d1b..d487d2ad5e1 100644 --- a/spec/features/wysiwyg/macros/quicklink_macros_spec.rb +++ b/spec/features/wysiwyg/macros/quicklink_macros_spec.rb @@ -50,7 +50,7 @@ RSpec.describe "Wysiwyg work package quicklink macros", :js do editor.set_markdown "##{work_package.id}" click_on "Save" - expect_and_dismiss_primerized_flash(message: "Successful creation.") + expect_and_dismiss_flash(message: "Successful creation.") # Expect output widget within("#content") do @@ -70,7 +70,7 @@ RSpec.describe "Wysiwyg work package quicklink macros", :js do editor.set_markdown "###{work_package.id}" click_on "Save" - expect_and_dismiss_primerized_flash(message: "Successful creation.") + expect_and_dismiss_flash(message: "Successful creation.") # Expect output widget within("#content") do @@ -93,7 +93,7 @@ RSpec.describe "Wysiwyg work package quicklink macros", :js do editor.set_markdown "####{work_package.id}" click_on "Save" - expect_and_dismiss_primerized_flash(message: "Successful creation.") + expect_and_dismiss_flash(message: "Successful creation.") # Expect output widget within("#content") do diff --git a/spec/features/wysiwyg/macros/work_package_button_spec.rb b/spec/features/wysiwyg/macros/work_package_button_spec.rb index 07d8b972c6d..1359d8d462f 100644 --- a/spec/features/wysiwyg/macros/work_package_button_spec.rb +++ b/spec/features/wysiwyg/macros/work_package_button_spec.rb @@ -85,7 +85,7 @@ RSpec.describe "Wysiwyg work package button spec", :js do # Save wiki page click_on "Save" - expect_primerized_flash(message: "Successful creation.") + expect_flash(message: "Successful creation.") within("#content") do expect(page).to have_css("a[href=\"/projects/my-project/work_packages/new?type=#{type.id}\"]") diff --git a/spec/features/wysiwyg/tables_spec.rb b/spec/features/wysiwyg/tables_spec.rb index 7189168013f..576a196297d 100644 --- a/spec/features/wysiwyg/tables_spec.rb +++ b/spec/features/wysiwyg/tables_spec.rb @@ -67,7 +67,7 @@ RSpec.describe "Wysiwyg tables", :js do # Save wiki page click_on "Save" - expect_and_dismiss_primerized_flash(message: "Successful creation.") + expect_and_dismiss_flash(message: "Successful creation.") within("#content") do expect(page).to have_css("table td", text: "h1") @@ -116,7 +116,7 @@ RSpec.describe "Wysiwyg tables", :js do # Save wiki page click_on "Save" - expect_and_dismiss_primerized_flash(message: "Successful creation.") + expect_and_dismiss_flash(message: "Successful creation.") within("#content") do expect(page).to have_css("table th", text: "h1") @@ -181,7 +181,7 @@ RSpec.describe "Wysiwyg tables", :js do # Save wiki page click_on "Save" - expect_and_dismiss_primerized_flash(message: "Successful creation.") + expect_and_dismiss_flash(message: "Successful creation.") within("#content") do expect(page).to have_css('td[style*="background-color:#123456"]') @@ -232,7 +232,7 @@ RSpec.describe "Wysiwyg tables", :js do # Save wiki page click_on "Save" - expect_and_dismiss_primerized_flash(message: "Successful update.") + expect_and_dismiss_flash(message: "Successful update.") within("#content") do # table height and width is set on figure @@ -297,7 +297,7 @@ RSpec.describe "Wysiwyg tables", :js do # Save wiki page click_on "Save" - expect_and_dismiss_primerized_flash(message: "Successful creation.") + expect_and_dismiss_flash(message: "Successful creation.") within("#content") do expect(page).to have_css('td[style*="width:250px"]') diff --git a/spec/features/wysiwyg/work_package_linking_spec.rb b/spec/features/wysiwyg/work_package_linking_spec.rb index b38ea0aea89..718b615307d 100644 --- a/spec/features/wysiwyg/work_package_linking_spec.rb +++ b/spec/features/wysiwyg/work_package_linking_spec.rb @@ -53,7 +53,7 @@ RSpec.describe "Wysiwyg work package linking", :js do # Save wiki page click_on "Save" - expect_primerized_flash(message: "Successful creation.") + expect_flash(message: "Successful creation.") within("#content") do expect(page).to have_css("a.issue", count: 1) diff --git a/spec/support/components/password_confirmation_dialog.rb b/spec/support/components/password_confirmation_dialog.rb index cab61adf830..d7373000f22 100644 --- a/spec/support/components/password_confirmation_dialog.rb +++ b/spec/support/components/password_confirmation_dialog.rb @@ -26,7 +26,7 @@ # See COPYRIGHT and LICENSE files for more details. #++ -require "support/primerized_flash/expectations" +require "support/flash/expectations" module Components class PasswordConfirmationDialog @@ -71,7 +71,7 @@ module Components end if should_fail - expect_primerized_flash(type: :error, message: I18n.t(:notice_password_confirmation_failed)) + expect_flash(type: :error, message: I18n.t(:notice_password_confirmation_failed)) else expect(page).to have_no_css(".op-toast.-error") end diff --git a/spec/support/flash/expectations.rb b/spec/support/flash/expectations.rb index daa1ca69ea5..5176aa334c9 100644 --- a/spec/support/flash/expectations.rb +++ b/spec/support/flash/expectations.rb @@ -1,33 +1,26 @@ module Flash module Expectations - def expect_primerized_flash(message:, type: :success, wait: 20) + def expect_flash(message:, type: :success, wait: 20) expected_css = expected_flash_css(type) expect(page).to have_css(expected_css, text: message, wait:) end - def find_primerized_flash(type:) + def find_flash_element(type:) expected_css = expected_flash_css(type) page.find(expected_css) end - def expect_and_dismiss_primerized_flash(message: nil, type: :success, wait: 20) - expect_primerized_flash(type:, message:, wait:) - dismiss_primerized_flash! - expect_no_primerized_flash(type:, message:, wait: 0.1) + def expect_and_dismiss_flash(message: nil, type: :success, wait: 20) + expect_flash(type:, message:, wait:) + dismiss_flash! + expect_no_flash(type:, message:, wait: 0.1) end - def dismiss_primerized_flash! + def dismiss_flash! page.find(".Banner-close button").click # rubocop:disable Capybara/SpecificActions end - # Clears a toaster if there is one waiting 1 second max, but do not fail if there is none - def clear_primerized_flashes - if has_css?(".Banner-close button") - dismiss_primerized_flash! - end - end - - def expect_no_primerized_flash(type: :success, message: nil, wait: 10) + def expect_no_flash(type: :success, message: nil, wait: 10) if type.nil? expect(page).not_to have_test_selector("op-primer-flash-message") else diff --git a/spec/support/pages/admin/system_settings/languages.rb b/spec/support/pages/admin/system_settings/languages.rb index 456647b47b7..da1dc652f91 100644 --- a/spec/support/pages/admin/system_settings/languages.rb +++ b/spec/support/pages/admin/system_settings/languages.rb @@ -38,7 +38,7 @@ module Pages::Admin::SystemSettings def save press_save_button - expect_and_dismiss_primerized_flash(message: "Successful update.") + expect_and_dismiss_flash(message: "Successful update.") end end end diff --git a/spec/support/pages/my/password_page.rb b/spec/support/pages/my/password_page.rb index d5d052ac478..227db085f50 100644 --- a/spec/support/pages/my/password_page.rb +++ b/spec/support/pages/my/password_page.rb @@ -55,7 +55,7 @@ module Pages end def expect_password_updated_message - expect_and_dismiss_primerized_flash(type: :info, message: I18n.t(:notice_account_password_updated)) + expect_and_dismiss_flash(type: :info, message: I18n.t(:notice_account_password_updated)) end private diff --git a/spec/support/pages/page.rb b/spec/support/pages/page.rb index 91fe9504fc0..ac75b11a920 100644 --- a/spec/support/pages/page.rb +++ b/spec/support/pages/page.rb @@ -27,7 +27,7 @@ #++ require_relative "../toasts/expectations" -require_relative "../primerized_flash/expectations" +require_relative "../flash/expectations" module Pages class Page diff --git a/spec/support/toasts/expectations.rb b/spec/support/toasts/expectations.rb index 47baac2be88..4ed7f4fd945 100644 --- a/spec/support/toasts/expectations.rb +++ b/spec/support/toasts/expectations.rb @@ -4,13 +4,15 @@ module Toasts if toast_type == :angular expect(page).to have_css(".op-toast.-#{type}", text: message, wait:) elsif type == :error - ActiveSupport::Deprecation.warn("Use `expect_primerized_flash(type: :error, message: message)` instead of expect_toast with type: :error") - expect_primerized_flash(type: :error, message:) + 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_primerized_flash(type: :success, message:)` instead of expect_toast with type: :success" + "Use `expect_flash(type: :success, message:)` instead of expect_toast with type: :success" ) - expect_primerized_flash(message:) + expect_flash(message:) else raise NotImplementedError end