Manybubbles has uploaded a new change for review.
https://gerrit.wikimedia.org/r/110218
Change subject: Test general ordering of results
......................................................................
Test general ordering of results
Make sure that title comes first, then redirect, then heading, then text.
Bug: 60045
Change-Id: Icb0cc42955490ba9b3dcf9b2b2694ce5c7d2745f
---
M tests/browser/features/full_text.feature
M tests/browser/features/step_definitions/search_steps.rb
M tests/browser/features/support/hooks.rb
M tests/browser/features/support/pages/search_results_page.rb
4 files changed, 42 insertions(+), 27 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch
refs/changes/18/110218/1
diff --git a/tests/browser/features/full_text.feature
b/tests/browser/features/full_text.feature
index 7218437..6210021 100644
--- a/tests/browser/features/full_text.feature
+++ b/tests/browser/features/full_text.feature
@@ -156,3 +156,11 @@
Scenario: When you search for a page by redirects having more unrelated
redirects doesn't penalize the score
When I search for incategory:ManyRedirectsTest Many Redirects Test
Then Manyredirectstarget is the first search result
+
+ @relevancy
+ Scenario: Results are sorted in roughly the order we expect
+ When I search for Relevancytest
+ Then Relevancytest is the first search result
+ And Relevancytestviaredirect is the second search result
+ And Relevancytestviaheading is the third search result
+ And Relevancytestviatext is the fourth search result
diff --git a/tests/browser/features/step_definitions/search_steps.rb
b/tests/browser/features/step_definitions/search_steps.rb
index 04497ce..9548e4b 100644
--- a/tests/browser/features/step_definitions/search_steps.rb
+++ b/tests/browser/features/step_definitions/search_steps.rb
@@ -95,19 +95,10 @@
Then(/^there is a search result$/) do
on(SearchResultsPage).first_result_element.should exist
end
-Then(/^(.*) is( in)? the first search result$/) do |title, in_ok|
+Then(/^(.+) is( in)? the ([^ ]+) search result$/) do |title, in_ok, index|
on(SearchResultsPage) do |page|
- if title == "none" then
- page.first_result_element.should_not exist
- page.first_image_result_element.should_not exist
- else
- page.first_result_element.should exist
- if in_ok then
- page.first_result_element.text.should include title
- else
- page.first_result_element.text.should == title
- end
- end
+ check_search_result(page.send("#{index}_result_wrapper_element"),
+ page.send("#{index}_result_element"), title, in_ok)
end
end
Then(/^(.*) is( in)? the first search imageresult$/) do |title, in_ok|
@@ -122,20 +113,6 @@
else
# You can't just use first_image_result.should == because that tries
to click the link....
page.first_image_result_element.text.should == title
- end
- end
- end
-end
-Then(/^(.*) is( in)? the second search result$/) do |title, in_ok|
- on(SearchResultsPage) do |page|
- if title == "none" then
- page.second_result_wrapper_element.should_not exist
- else
- page.second_result_element.should exist
- if in_ok then
- page.second_result_element.text.should include title
- else
- page.second_result_element.text.should == title
end
end
end
@@ -231,4 +208,17 @@
retry
end
end
-end
\ No newline at end of file
+end
+
+def check_search_result(wrapper_element, element, title, in_ok)
+ if title == "none" then
+ wrapper_element.should_not exist
+ else
+ element.should exist
+ if in_ok then
+ element.text.should include title
+ else
+ element.text.should == title
+ end
+ end
+end
diff --git a/tests/browser/features/support/hooks.rb
b/tests/browser/features/support/hooks.rb
index 8a1d4db..be6be71 100644
--- a/tests/browser/features/support/hooks.rb
+++ b/tests/browser/features/support/hooks.rb
@@ -331,3 +331,16 @@
end
$many_redirects = true
end
+
+Before("@relevancy") do
+ if !$relevancy
+ steps %Q{
+ Given a page named Relevancytest exists with contents not relevant
+ And a page named Relevancytestviaredirect exists with contents not
relevant
+ And a page named Relevancytest Redirect exists with contents #REDIRECT
[[Relevancytestviaredirect]]
+ And a page named Relevancytestviaheading exists with contents
==Relevancytest==
+ And a page named Relevancytestviatext exists with contents Relevancytest
+ }
+ end
+ $relevancy = true
+end
diff --git a/tests/browser/features/support/pages/search_results_page.rb
b/tests/browser/features/support/pages/search_results_page.rb
index 9c5994e..abd1ad6 100644
--- a/tests/browser/features/support/pages/search_results_page.rb
+++ b/tests/browser/features/support/pages/search_results_page.rb
@@ -14,6 +14,10 @@
link(:first_image_result){ table_element(:class =>
"searchResultImage").cell_element(:index => 1).link_element(:index => 0) }
li(:second_result_wrapper){ |page|
page.search_results_element.list_item_element(:index => 1) }
link(:second_result){ |page|
page.second_result_wrapper_element.div_element(:class =>
"mw-search-result-heading").link_element }
+ li(:third_result_wrapper){ |page|
page.search_results_element.list_item_element(:index => 2) }
+ link(:third_result){ |page|
page.third_result_wrapper_element.div_element(:class =>
"mw-search-result-heading").link_element }
+ li(:fourth_result_wrapper){ |page|
page.search_results_element.list_item_element(:index => 3) }
+ link(:fourth_result){ |page|
page.fourth_result_wrapper_element.div_element(:class =>
"mw-search-result-heading").link_element }
button(:simple_search_button, value: "Search")
text_field(:search_input, name: "search")
div(:suggestion_wrapper, class: "searchdidyoumean")
--
To view, visit https://gerrit.wikimedia.org/r/110218
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icb0cc42955490ba9b3dcf9b2b2694ce5c7d2745f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: Manybubbles <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits