A platform for community discussion. Free, open, simple.
DEV: Add system test for soft loading topic search results (#25525)
Isaac Janzenbf02657dbff8
diff --git a/spec/system/page_objects/pages/search.rb b/spec/system/page_objects/pages/search.rbindex 010314188c3..14d7eb38ef1 100644--- a/spec/system/page_objects/pages/search.rb+++ b/spec/system/page_objects/pages/search.rb@@ -8,6 +8,15 @@ module PageObjectsselfend+ 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_inputfind("input.full-page-search").set("")self@@ -29,8 +38,16 @@ module PageObjectsfind(".d-header #search-button").clickend+ 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)enddiff --git a/spec/system/search_spec.rb b/spec/system/search_spec.rbindex 00233f51001..623ba33da70 100644--- a/spec/system/search_spec.rb+++ b/spec/system/search_spec.rb@@ -85,4 +85,26 @@ describe "Search", type: :system doexpect(search_page).to have_warning_messageendend++ 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+ endend