diff --git a/app/components/work_packages/details/tab_component.html.erb b/app/components/work_packages/details/tab_component.html.erb index b1ed9590c52e..4540ec5ef575 100644 --- a/app/components/work_packages/details/tab_component.html.erb +++ b/app/components/work_packages/details/tab_component.html.erb @@ -22,6 +22,7 @@ href: work_package_path(work_package.id, full_screen_tab), target: "_top", scheme: :invisible, + test_selector: "wp-details-tab-component--full-screen", aria: { label: I18n.t("js.button_show_fullscreen") })) end @@ -30,6 +31,7 @@ tag: :a, href: url_helpers.send(base_route), scheme: :invisible, + test_selector: "wp-details-tab-component--close", aria: { label: I18n.t(:button_close) })) end end diff --git a/app/components/work_packages/split_view_component.html.erb b/app/components/work_packages/split_view_component.html.erb index 2d11e4c2816d..50d4b6128817 100644 --- a/app/components/work_packages/split_view_component.html.erb +++ b/app/components/work_packages/split_view_component.html.erb @@ -6,7 +6,7 @@ render(Primer::Beta::Blankslate.new(spacious: true)) do |component| component.with_visual_icon(icon: :inbox) component.with_heading(tag: :h2).with_content( - I18n.t(:error_work_package_id_not_found, id: @id) + I18n.t(:error_work_package_id_not_found) ) end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 49086db85b15..581864ba56f0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1688,7 +1688,7 @@ en: error_pdf_failed_to_export: "The PDF export could not be saved: %{error}" error_token_authenticity: "Unable to verify Cross-Site Request Forgery token. Did you try to submit data on multiple browsers or tabs? Please close all tabs and try again." error_work_package_not_found_in_project: "The work package was not found or does not belong to this project" - error_work_package_id_not_found: "The work package %{id} was not found." + error_work_package_id_not_found: "The work package was not found." error_must_be_project_member: "must be project member" error_migrations_are_pending: "Your OpenProject installation has pending database migrations. You have likely missed running the migrations on your last upgrade. Please check the upgrade guide to properly upgrade your installation." error_migrations_visit_upgrade_guides: "Please visit our upgrade guide documentation" diff --git a/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts b/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts index 0be6bd5d8774..c4a7bab5ac39 100644 --- a/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts +++ b/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts @@ -250,10 +250,7 @@ export class IanCenterService extends UntilDestroyedMixin { .pipe(take(1)) .subscribe((notifications:INotification[][]) => { if (notifications.length <= 0) { - void this.state.go( - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/restrict-template-expressions - `${this.state.current.data.baseRoute}`, - ); + window.location.href = this.pathHelper.notificationsPath(); return; } if (notifications[0][0]._links.resource || notifications[this.selectedNotificationIndex][0]._links.resource) { @@ -322,7 +319,7 @@ export class IanCenterService extends UntilDestroyedMixin { }, }); - if (!this.deviceService.isMobile && this.state.includes('**.details.*')) { + if (!this.deviceService.isMobile && window.location.href.includes('details')) { this.showNextNotification(); } diff --git a/spec/features/notifications/navigation_spec.rb b/spec/features/notifications/navigation_spec.rb index 911aecde3347..69438b1ad43d 100644 --- a/spec/features/notifications/navigation_spec.rb +++ b/spec/features/notifications/navigation_spec.rb @@ -49,9 +49,9 @@ # Navigate to full view and back wp_full = split_screen.switch_to_fullscreen - expect(page).to have_current_path "/work_packages/#{work_package.id}/relations" + expect(page).to have_current_path "/projects/#{project.identifier}/work_packages/#{work_package.id}/relations" - wp_full.go_back + page.execute_script("window.history.back()") expect(page).to have_current_path "/notifications/details/#{work_package.id}/relations" # Close the split screen @@ -63,7 +63,8 @@ it "opening a notification that does not exist returns to the center" do visit "/notifications/details/0" - expect(page).to have_current_path "/notifications" + expect(page).to have_current_path "/notifications/details/0" + expect(page).to have_text "The work package was not found." end it "deep linking to a notification details highlights it" do diff --git a/spec/features/notifications/notification_center/split_screen_spec.rb b/spec/features/notifications/notification_center/split_screen_spec.rb index b9f97a51eeb1..f90aab591abb 100644 --- a/spec/features/notifications/notification_center/split_screen_spec.rb +++ b/spec/features/notifications/notification_center/split_screen_spec.rb @@ -75,7 +75,7 @@ wp_full = split_screen.switch_to_fullscreen wp_full.expect_tab :relations - wp_full.go_back + page.execute_script("window.history.back()") split_screen.expect_tab :relations # The split screen can be closed diff --git a/spec/support/pages/work_packages/primerized_split_work_package.rb b/spec/support/pages/work_packages/primerized_split_work_package.rb index cd27ed032045..0d8da170c6a9 100644 --- a/spec/support/pages/work_packages/primerized_split_work_package.rb +++ b/spec/support/pages/work_packages/primerized_split_work_package.rb @@ -36,12 +36,21 @@ def in_split_view(&) def switch_to_tab(tab:) in_split_view do - click_link_or_button tab + page.find_test_selector(tab_selector(tab)).click end end + def switch_to_fullscreen + page.find_test_selector("wp-details-tab-component--full-screen").click + FullWorkPackage.new(work_package, project) + end + + def close + page.find_test_selector("wp-details-tab-component--close").click + end + def expect_tab(tab) - within_test_selector("wp-details-tab-component--tab-#{tab.downcase}") do |link| + within_test_selector(tab_selector(tab)) do |link| link["data-aria-current"] == "page" end end @@ -49,5 +58,11 @@ def expect_tab(tab) def within_active_tab(&) within(".work-packages--details-content", &) end + + private + + def tab_selector(tab) + "wp-details-tab-component--tab-#{tab.downcase}" + end end end