diff --git a/spec/system/page_objects/pages/search.rb b/spec/system/page_objects/pages/search.rb index 010314188c3..14d7eb38ef1 100644 --- a/spec/system/page_objects/pages/search.rb +++ b/spec/system/page_objects/pages/search.rb @@ -8,6 +8,15 @@ module PageObjects self end + def type_in_search_menu(input) + find("input#search-term").send_keys(input) + self + end + + def click_search_menu_link + find(".search-menu .results .search-link").click + end + def clear_search_input find("input.full-page-search").set("") self @@ -29,8 +38,16 @@ module PageObjects find(".d-header #search-button").click end + def click_first_topic + find(".topic-list-body tr:first-of-type").click + end + SEARCH_RESULT_SELECTOR = ".search-results .fps-result" + def has_topic_title_for_first_search_result?(title) + page.has_css?(".search-menu .results .search-result-topic", text: title) + end + def has_search_result? page.has_selector?(SEARCH_RESULT_SELECTOR) end diff --git a/spec/system/search_spec.rb b/spec/system/search_spec.rb index 00233f51001..623ba33da70 100644 --- a/spec/system/search_spec.rb +++ b/spec/system/search_spec.rb @@ -85,4 +85,26 @@ describe "Search", type: :system do expect(search_page).to have_warning_message end end + + describe "when search menu on desktop" do + before do + SearchIndexer.enable + SearchIndexer.index(topic, force: true) + SearchIndexer.index(topic2, force: true) + end + + after { SearchIndexer.disable } + + it "still displays last topic search results after navigating away, then back" do + visit("/") + search_page.click_search_icon + search_page.type_in_search_menu("test") + search_page.click_search_menu_link + expect(search_page).to have_topic_title_for_first_search_result(topic.title) + + search_page.click_first_topic + search_page.click_search_icon + expect(search_page).to have_topic_title_for_first_search_result(topic.title) + end + end end