Skip to content

Commit

Permalink
Adapt tests to new rails based routing of notification center
Browse files Browse the repository at this point in the history
  • Loading branch information
HDinger committed Jul 25, 2024
1 parent 9b7c4ad commit b07c675
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 13 deletions.
2 changes: 2 additions & 0 deletions app/components/work_packages/details/tab_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/components/work_packages/split_view_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
}

Expand Down
7 changes: 4 additions & 3 deletions spec/features/notifications/navigation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 17 additions & 2 deletions spec/support/pages/work_packages/primerized_split_work_package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,33 @@ 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

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

0 comments on commit b07c675

Please sign in to comment.