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
check for toast after every query saving to fix flickering spec
ulfertsaaea282c0045
diff --git a/spec/features/views/shared_examples.rb b/spec/features/views/shared_examples.rbindex 1e4c9ac86bf..c984f2a4022 100644--- a/spec/features/views/shared_examples.rb+++ b/spec/features/views/shared_examples.rb@@ -56,8 +56,6 @@ RSpec.shared_examples 'module specific query view management' doquery_menu.expect_menu_entry 'My second query'query_menu.expect_menu_entry 'My first query'- module_page.expect_and_dismiss_toaster-# Rename a querysettings_menu.open_and_choose 'Rename view'expect(page).to have_focus_on('.editable-toolbar-title--input')diff --git a/spec/support/components/work_packages/settings_menu.rb b/spec/support/components/work_packages/settings_menu.rbindex 939c06c3c5a..051c8e20c8c 100644--- a/spec/support/components/work_packages/settings_menu.rb+++ b/spec/support/components/work_packages/settings_menu.rb@@ -26,12 +26,15 @@# See COPYRIGHT and LICENSE files for more details.#+++require_relative '../../toasts/expectations'+module Componentsmodule WorkPackagesclass SettingsMenuinclude Capybara::DSLinclude Capybara::RSpecMatchersinclude RSpec::Matchers+ include Toasts::Expectationsdef open_and_save_query(name)open_and_choose('Save')@@ -93,6 +96,7 @@ module Componentsenddef wait_for_save_completion+ expect_and_dismiss_toastermodal.expect_closedenddiff --git a/spec/support/pages/page.rb b/spec/support/pages/page.rbindex 2a36a758f37..91a96a14e38 100644--- a/spec/support/pages/page.rb+++ b/spec/support/pages/page.rb@@ -26,12 +26,15 @@# See COPYRIGHT and LICENSE files for more details.#+++require_relative '../toasts/expectations'+module Pagesclass Pageinclude Capybara::DSLinclude Capybara::RSpecMatchersinclude RSpec::Matchersinclude OpenProject::StaticRouting::UrlHelpers+ include Toasts::Expectationsdef current_page?URI.parse(current_url).path == path@@ -91,36 +94,6 @@ module Pagesexpect(page).to have_current_path expected_path, wait: 10end- def expect_toast(message:, type: :success)- if toast_type == :angular- expect(page).to have_selector(".op-toast.-#{type}", text: message, wait: 20)- elsif type == :error- expect(page).to have_selector(".errorExplanation", text: message)- elsif type == :success- expect(page).to have_selector(".op-toast.-success", text: message)- else- raise NotImplementedError- end- end-- def expect_and_dismiss_toaster(message: nil, type: :success)- expect_toast(type:, message:)- dismiss_toaster!- expect_no_toaster(type:, message:)- end-- def dismiss_toaster!- page.find('.op-toast--close').click- end-- def expect_no_toaster(type: :success, message: nil)- if type.nil?- expect(page).not_to have_selector(".op-toast")- else- expect(page).not_to have_selector(".op-toast.-#{type}", text: message)- end- end-def click_to_sort_by(header_name)within '.generic-table thead' doclick_link header_name@@ -180,10 +153,6 @@ module Pagesnilend- def toast_type- :angular- end-def navigate_to_modules_menu_item(link_title)visit root_pathdiff --git a/spec/support/toasts/expectations.rb b/spec/support/toasts/expectations.rbnew file mode 100644index 00000000000..9eae3a9a901--- /dev/null+++ b/spec/support/toasts/expectations.rb@@ -0,0 +1,37 @@+module Toasts+ module Expectations+ def expect_toast(message:, type: :success)+ if toast_type == :angular+ expect(page).to have_selector(".op-toast.-#{type}", text: message, wait: 20)+ elsif type == :error+ expect(page).to have_selector(".errorExplanation", text: message)+ elsif type == :success+ expect(page).to have_selector(".op-toast.-success", text: message)+ else+ raise NotImplementedError+ end+ end++ def expect_and_dismiss_toaster(message: nil, type: :success)+ expect_toast(type:, message:)+ dismiss_toaster!+ expect_no_toaster(type:, message:)+ end++ def dismiss_toaster!+ page.find('.op-toast--close').click+ end++ def expect_no_toaster(type: :success, message: nil)+ if type.nil?+ expect(page).not_to have_selector(".op-toast")+ else+ expect(page).not_to have_selector(".op-toast.-#{type}", text: message)+ end+ end++ def toast_type+ :angular+ end+ end+end