Skip to content

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

Add spec for global search hotkey

Benjamin Bädorfa218c33245b0
diff --git a/frontend/src/app/core/global_search/input/global-search-input.component.ts b/frontend/src/app/core/global_search/input/global-search-input.component.ts
index eff209b7689..ea6706369c6 100644
--- a/frontend/src/app/core/global_search/input/global-search-input.component.ts
+++ b/frontend/src/app/core/global_search/input/global-search-input.component.ts
@@ -426,6 +426,8 @@ export class GlobalSearchInputComponent implements AfterViewInit, OnDestroy {
}
private toggleTopMenuClass() {
- jQuery('.op-app-header').toggleClass('op-app-header_search-open', this.expanded);
+ const el = document.getElementsByClassName('op-app-header')[0] as HTMLElement;
+ el.classList.toggle('op-app-header_search-open', this.expanded);
+ el.dataset.qaSearchOpen = '1';
}
}
diff --git a/spec/features/search_spec.rb b/spec/features/search_spec.rb
index 441dc1c3c69..d736e8b8c39 100644
--- a/spec/features/search_spec.rb
+++ b/spec/features/search_spec.rb
@@ -447,4 +447,12 @@ describe 'Search', type: :feature, js: true, with_settings: { per_page_options:
table.expect_work_package_listed(wp_4)
end
end
+
+ describe 'search hotkey' do
+ it 'opens and focuses the global search when you press the [s] hotkey' do
+ visit home_path
+ page.find('body').send_keys('s')
+ expect(page).to have_selector '[data-qa-search-open="1"]', wait: 10
+ end
+ end
end