DEV: Add system test for soft loading topic search results (#25525)

Follow up to: https://github.com/discourse/discourse/pull/25504
This commit is contained in:
Isaac Janzen 2024-03-05 09:10:09 -07:00 committed by GitHub
parent 6791eb1a94
commit bf02657dbf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 39 additions and 0 deletions

View File

@ -8,6 +8,15 @@ module PageObjects
self self
end 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 def clear_search_input
find("input.full-page-search").set("") find("input.full-page-search").set("")
self self
@ -29,8 +38,16 @@ module PageObjects
find(".d-header #search-button").click find(".d-header #search-button").click
end end
def click_first_topic
find(".topic-list-body tr:first-of-type").click
end
SEARCH_RESULT_SELECTOR = ".search-results .fps-result" 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? def has_search_result?
page.has_selector?(SEARCH_RESULT_SELECTOR) page.has_selector?(SEARCH_RESULT_SELECTOR)
end end

View File

@ -85,4 +85,26 @@ describe "Search", type: :system do
expect(search_page).to have_warning_message expect(search_page).to have_warning_message
end end
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 end