OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Render all flashes as primerized
Oliver Günther7e645a02c9b3
diff --git a/app/components/op_primer/flash_component.rb b/app/components/op_primer/flash_component.rbindex 2c50edc45ac..c93edcae9a7 100644--- a/app/components/op_primer/flash_component.rb+++ b/app/components/op_primer/flash_component.rb@@ -35,7 +35,7 @@ module OpPrimerdef 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] ||= :removesystem_arguments[:dismiss_label] ||= I18n.t(:button_close)diff --git a/app/helpers/flash_messages_helper.rb b/app/helpers/flash_messages_helper.rbindex 8015199aaaf..cf047b012ae 100644--- a/app/helpers/flash_messages_helper.rb+++ b/app/helpers/flash_messages_helper.rb@@ -67,7 +67,7 @@ module FlashMessagesHelper:dangerwhen :warning:warning- when :notice+ when :success, :notice:successelse:defaultdiff --git a/spec/support/primerized_flash/expectations.rb b/spec/support/primerized_flash/expectations.rbnew file mode 100644index 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