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
Adapt tests to new rails based submenu of notification center
Henriette Dargeb118b1010135
diff --git a/app/components/open_project/common/submenu_component.html.erb b/app/components/open_project/common/submenu_component.html.erbindex 9517b3776f8..d26ac6efa56 100644--- a/app/components/open_project/common/submenu_component.html.erb+++ b/app/components/open_project/common/submenu_component.html.erb@@ -1,4 +1,4 @@-<div class="op-sidebar" data-controller="filter--filter-list" data-application-target="dynamic">+<div class="op-sidebar" data-controller="filter--filter-list" data-application-target="dynamic" data-test-selector="op-submenu"><% if @searchable %><div class="op-sidebar--search"><%= render Primer::Alpha::TextField.new(name: "search",@@ -37,7 +37,7 @@<% end %><span class="op-sidemenu--item-title"><%= menu_item.title %></span><% if menu_item.count %>- <span class="op-bubble op-bubble_alt_highlighting"><%= menu_item.count %></span>+ <span class="op-bubble op-bubble_alt_highlighting" data-test-selector="op-sidemenu--item-count"><%= menu_item.count %></span><% end %></a></li>@@ -76,7 +76,7 @@<% end %><% if child_item.count %>- <span class="op-bubble op-bubble_alt_highlighting"><%= child_item.count %></span>+ <span class="op-bubble op-bubble_alt_highlighting" data-test-selector="op-sidemenu--item-count"><%= child_item.count %></span><% end %></a></li>diff --git a/app/menus/notifications/menu.rb b/app/menus/notifications/menu.rbindex 55fa8af8b57..14b4d65bfa9 100644--- a/app/menus/notifications/menu.rb+++ b/app/menus/notifications/menu.rb@@ -63,7 +63,7 @@ module Notificationsdef reason_filters%w[mentioned assigned responsible watched date_alert shared].map do |reason|count = unread_by_reason[reason]- menu_item(title: I18n.t("mail.work_packages.reason.#{reason}"),+ menu_item(title: I18n.t("notifications.reasons.#{reason}"),icon_key: reason,count: count == 0 ? nil : count,query_params: query_params("reason", reason.camelize(:lower)))diff --git a/config/locales/en.yml b/config/locales/en.ymlindex 847ce253bfb..f8c7b48e3d8 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -1903,6 +1903,13 @@ en:unknown_storage: "Unknown storage"notifications:+ reasons:+ assigned: "Assignee"+ date_alert: "Date alert"+ mentioned: "Mentioned"+ responsible: "Accountable"+ shared: "Shared"+ watched: "Watcher"menu:by_project: "Unread by project"by_reason: "Reason"@@ -2593,7 +2600,6 @@ en:shared: "Shared"subscribed: "all"prefix: "Received because of the notification setting: %{reason}"- date_alert: "Date alert"date_alert_start_date: "Date alert"date_alert_due_date: "Date alert"see_all: "See all"diff --git a/spec/features/notifications/notification_center/notification_center_date_alerts_spec.rb b/spec/features/notifications/notification_center/notification_center_date_alerts_spec.rbindex 1a715001f3a..5e3399abc6a 100644--- a/spec/features/notifications/notification_center/notification_center_date_alerts_spec.rb+++ b/spec/features/notifications/notification_center/notification_center_date_alerts_spec.rb@@ -166,7 +166,7 @@ RSpec.describe "Notification center date alerts", :js, :with_cuprite,endlet(:center) { Pages::Notifications::Center.new }- let(:side_menu) { Components::Notifications::Sidemenu.new }+ let(:side_menu) { Components::Submenu.new }let(:toaster) { PageObjects::Notifications.new(page) }let(:activity_tab) { Components::WorkPackages::Activities.new(notification_wp_due_today) }diff --git a/spec/features/notifications/notification_center/notification_center_sidemenu_spec.rb b/spec/features/notifications/notification_center/notification_center_sidemenu_spec.rbindex 6237c57f976..b2aa07c520a 100644--- a/spec/features/notifications/notification_center/notification_center_sidemenu_spec.rb+++ b/spec/features/notifications/notification_center/notification_center_sidemenu_spec.rb@@ -79,7 +79,7 @@ RSpec.describe "Notification center sidemenu",endlet(:center) { Pages::Notifications::Center.new }- let(:side_menu) { Components::Notifications::Sidemenu.new }+ let(:side_menu) { Components::Submenu.new }before donotifications@@ -138,7 +138,7 @@ RSpec.describe "Notification center sidemenu",side_menu.expect_item_with_no_count "Watcher"# ... and show only those projects with a notification- side_menu.expect_item_not_visible project.name+ side_menu.expect_no_item project.nameside_menu.expect_item_with_count project2.name, 1side_menu.expect_item_with_count "... #{project3.name}", 4@@ -159,9 +159,9 @@ RSpec.describe "Notification center sidemenu",side_menu.expect_item_with_no_count "Date alert"side_menu.expect_item_with_no_count "Shared"- side_menu.expect_item_not_visible project.name- side_menu.expect_item_not_visible project2.name- side_menu.expect_item_not_visible "... #{project3.name}"+ side_menu.expect_no_item project.name+ side_menu.expect_no_item project2.name+ side_menu.expect_no_item "... #{project3.name}"endit "updates the content when a filter is clicked" dodiff --git a/spec/features/notifications/notification_center/notification_center_spec.rb b/spec/features/notifications/notification_center/notification_center_spec.rbindex 0e16e61a812..040fea93b4f 100644--- a/spec/features/notifications/notification_center/notification_center_spec.rb+++ b/spec/features/notifications/notification_center/notification_center_spec.rb@@ -34,7 +34,7 @@ RSpec.describe "Notification center", :js, :with_cuprite,endlet(:center) { Pages::Notifications::Center.new }- let(:side_menu) { Components::Notifications::Sidemenu.new }+ let(:side_menu) { Components::Submenu.new }let(:activity_tab) { Components::WorkPackages::Activities.new(work_package) }let(:split_screen) { Pages::SplitWorkPackage.new work_package }let(:split_screen2) { Pages::SplitWorkPackage.new work_package2 }diff --git a/spec/features/work_packages/share/notification_spec.rb b/spec/features/work_packages/share/notification_spec.rbindex dc5b3934218..7bb730cefe9 100644--- a/spec/features/work_packages/share/notification_spec.rb+++ b/spec/features/work_packages/share/notification_spec.rb@@ -60,7 +60,7 @@ RSpec.describe "Notifications sent on shared work packages",endlet(:center) { Pages::Notifications::Center.new }- let(:side_menu) { Components::Notifications::Sidemenu.new }+ let(:side_menu) { Components::Submenu.new }describe "notification for being mentioned" dobefore dodiff --git a/spec/support/components/common/sidemenu.rb b/spec/support/components/common/sidemenu.rbdeleted file mode 100644index fcaacd5c40d..00000000000--- a/spec/support/components/common/sidemenu.rb+++ /dev/null@@ -1,86 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) 2012-2024 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 Components- module Notifications- class Sidemenu- include Capybara::DSL- include Capybara::RSpecMatchers- include RSpec::Matchers-- def expect_open- expect(page).to have_css('[data-test-selector="op-sidemenu"]')- end-- def expect_item_not_visible(item)- expect(page).to have_no_selector(item_selector, text: item)- end-- def expect_item_with_count(item, count)- within item_action_selector(item) do- expect(page).to have_text item- expect_count(count)- end- end-- def expect_item_with_no_count(item)- within item_action_selector(item) do- expect(page).to have_text item- expect_no_count- end- end-- def click_item(item)- page.find(item_action_selector(item), text: item).click- end-- def finished_loading- wait_for_network_idle if using_cuprite?- expect(page).to have_no_css('[data-test-selector="op-ian-center--loading-indicator"]')- end-- private-- def expect_count(count)- expect(page).to have_css(".op-bubble", text: count)- end-- def expect_no_count- expect(page).to have_no_css(".op-bubble")- end-- def item_action_selector(item)- "[data-test-selector='op-sidemenu--item-action--#{item.delete(' ')}']"- end-- def item_selector- '[data-test-selector="op-sidemenu--item"]'- end- end- end-enddiff --git a/spec/support/components/common/submenu.rb b/spec/support/components/common/submenu.rbindex 2f9a7014e40..758a1d29c8b 100644--- a/spec/support/components/common/submenu.rb+++ b/spec/support/components/common/submenu.rb@@ -32,6 +32,10 @@ module Componentsinclude Capybara::RSpecMatchersinclude RSpec::Matchers+ def expect_open+ expect(page).to have_css('[data-test-selector="op-submenu"]')+ end+def expect_item(name, selected: false, favored: nil, visible: true)within "#main-menu" doselected_specifier = selected ? ".selected" : ":not(.selected)"@@ -56,6 +60,18 @@ module Componentsendend+ def expect_item_with_count(item, count)+ within page.find_test_selector("op-sidemenu--item-action", text: item) do+ expect_count count+ end+ end++ def expect_item_with_no_count(item)+ within page.find_test_selector("op-sidemenu--item-action", text: item) do+ expect_no_count+ end+ end+def click_item(name)within "#main-menu" doclick_on text: name@@ -74,10 +90,22 @@ module Componentsendend+ def finished_loading+ wait_for_network_idle if using_cuprite?+ end+def expect_no_results_textwithin "#main-menu" doexpect(page).to have_test_selector("op-sidebar--search-no-results", text: "No items found")endend++ def expect_count(count)+ expect(page).to have_test_selector("op-sidemenu--item-count", text: count)+ end++ def expect_no_count+ expect(page).not_to have_test_selector("op-sidemenu--item-count")+ endendend