EBernhardson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/207898
Change subject: Convert remaining relevancy tests to api
......................................................................
Convert remaining relevancy tests to api
Change-Id: I357b04705bccd6e5b20a669961c264f0dfda9637
---
M tests/browser/features/relevancy_api.feature
D tests/browser/features/relevancy_browser.feature
M tests/browser/features/step_definitions/search_steps.rb
3 files changed, 64 insertions(+), 59 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch
refs/changes/98/207898/1
diff --git a/tests/browser/features/relevancy_api.feature
b/tests/browser/features/relevancy_api.feature
index d92aefc..4488786 100644
--- a/tests/browser/features/relevancy_api.feature
+++ b/tests/browser/features/relevancy_api.feature
@@ -23,3 +23,49 @@
When I api search for Relevancyredirecttest
Then Relevancyredirecttest Larger is the first api search result
And Relevancyredirecttest Smaller is the second api search result
+
+ Scenario: Results are sorted based on what part of the page matches: title,
redirect, category, etc
+ When I api search with disabled incoming link weighting for Relevancytest
+ Then Relevancytest is the first api search result
+ And Relevancytestviaredirect is the second api search result
+ And Relevancytestviacategory is the third api search result
+ And Relevancytestviaheading is the fourth api search result
+ And Relevancytestviaopening is the fifth api search result
+ And Relevancytestviatext is the sixth or seventh api search result
+ And Relevancytestviaauxtext is the sixth or seventh api search result
+
+ Scenario: Results are sorted based on what part of the page matches: title,
redirect, category, etc
+ When I api search with disabled incoming link weighting for
"Relevancytestphrase phrase"
+ Then Relevancytestphrase phrase is the first api search result
+ And Relevancytestphraseviaredirect is the second api search result
+ And Relevancytestphraseviacategory is the third api search result
+ And Relevancytestphraseviaheading is the fourth api search result
+ And Relevancytestphraseviaopening is the fifth api search result
+ And Relevancytestphraseviatext is the sixth or seventh api search result
+ And Relevancytestphraseviaauxtext is the sixth or seventh api search
result
+
+ Scenario: When the user has a language results are sorted with user language
ahead of wiki language ahead of other languages
+ When I api search in the ja language for Relevancylanguagetest
+ Then Relevancylanguagetest/ja is the first api search result
+ And Relevancylanguagetest/en is the second api search result
+ And Relevancylanguagetest/ar is the third api search result
+
+ Scenario: Incoming links count in page weight
+ When I api search for Relevancylinktest -intitle:link
+ Then Relevancylinktest Larger Extraword is the first api search result
+ And Relevancylinktest Smaller is the second api search result
+ When I api search with disabled incoming link weighting for
Relevancylinktest -intitle:link
+ Then Relevancylinktest Smaller is the first api search result
+ And Relevancylinktest Larger Extraword is the second api search result
+
+ Scenario: Results are sorted based on how close the match is
+ When I api search with disabled incoming link weighting for
Relevancyclosetest Foô
+ Then Relevancyclosetest Foô is the first api search result
+ And Relevancyclosetest Foo is the second api search result
+ And Foo Relevancyclosetest is the third api search result
+
+ Scenario: Results are sorted based on how close the match is (backwards this
time)
+ When I api search with disabled incoming link weighting for
Relevancyclosetest Foo
+ Then Relevancyclosetest Foo is the first api search result
+ And Relevancyclosetest Foô is the second api search result
+ And Foo Relevancyclosetest is the third api search result
diff --git a/tests/browser/features/relevancy_browser.feature
b/tests/browser/features/relevancy_browser.feature
deleted file mode 100644
index 4ede41c..0000000
--- a/tests/browser/features/relevancy_browser.feature
+++ /dev/null
@@ -1,55 +0,0 @@
-@clean @phantomjs @relevancy
-Feature: Results are ordered from most relevant to least.
- Background:
- Given I am at a random page
-
- Scenario: Results are sorted based on what part of the page matches: title,
redirect, category, etc
- When I search for Relevancytest
- And I disable incoming links in the weighting
- Then Relevancytest is the first search result
- And Relevancytestviaredirect is the second search result
- And Relevancytestviacategory is the third search result
- And Relevancytestviaheading is the fourth search result
- And Relevancytestviaopening is the fifth search result
- And Relevancytestviatext is the sixth or seventh search result
- And Relevancytestviaauxtext is the sixth or seventh search result
-
- Scenario: Results are sorted based on what part of the page matches: title,
redirect, category, etc
- When I search for "Relevancytestphrase phrase"
- And I disable incoming links in the weighting
- Then Relevancytestphrase phrase is the first search result
- And Relevancytestphraseviaredirect is the second search result
- And Relevancytestphraseviacategory is the third search result
- And Relevancytestphraseviaheading is the fourth search result
- And Relevancytestphraseviaopening is the fifth search result
- And Relevancytestphraseviatext is the sixth or seventh search result
- And Relevancytestphraseviaauxtext is the sixth or seventh search result
-
- Scenario: When the user has a language results are sorted with user language
ahead of wiki language ahead of other languages
- When I api search for Relevancylanguagetest
- And I switch the language to ja
- Then Relevancylanguagetest/ja is the first api search result
- And Relevancylanguagetest/en is the second api search result
- And Relevancylanguagetest/ar is the third api search result
-
- Scenario: Incoming links count in page weight
- When I search for Relevancylinktest -intitle:link
- Then Relevancylinktest Larger Extraword is the first search result
- And Relevancylinktest Smaller is the second search result
- When I disable incoming links in the weighting
- Then Relevancylinktest Smaller is the first search result
- And Relevancylinktest Larger Extraword is the second search result
-
- Scenario: Results are sorted based on how close the match is
- When I search for Relevancyclosetest Foô
- And I disable incoming links in the weighting
- Then Relevancyclosetest Foô is the first search result
- And Relevancyclosetest Foo is the second search result
- And Foo Relevancyclosetest is the third search result
-
- Scenario: Results are sorted based on how close the match is (backwards this
time)
- When I search for Relevancyclosetest Foo
- And I disable incoming links in the weighting
- Then Relevancyclosetest Foo is the first search result
- And Relevancyclosetest Foô is the second search result
- And Foo Relevancyclosetest is the third search result
diff --git a/tests/browser/features/step_definitions/search_steps.rb
b/tests/browser/features/step_definitions/search_steps.rb
index 7da9ccf..ecdf375 100644
--- a/tests/browser/features/step_definitions/search_steps.rb
+++ b/tests/browser/features/step_definitions/search_steps.rb
@@ -6,9 +6,14 @@
When(/^I go search for (.*)$/) do |search|
visit(SearchResultsPage, using_params: { search: search })
end
-When(/^I api search(?: with offset (\d+))? for (.*)?$/) do |offset, search|
+When(/^I api search( with disabled incoming link weighting)?(?: with offset
(\d+))?(?: in the (.*) language)? for (.*)$/) do |incoming_links, offset, lang,
search|
begin
- @api_result = search_for(search, sroffset: offset)
+ @api_result = search_for(
+ search,
+ sroffset: offset,
+ uselang: lang,
+ cirrusBoostLinks: incoming_links ? "no" : "yes"
+ )
rescue MediawikiApi::ApiError => e
@api_error = e
end
@@ -193,12 +198,19 @@
found.should == true
end
end
-Then(/^(.+) is( in)? the ((?:[^ ])+(?: or (?:[^ ])+)*) api search result$/) do
|title, in_ok, indexes|
+Then(/^(.+) is( in)? the ([^ ]+) api search result$/) do |title, in_ok, index|
+ pos = %w(first second third fourth fifth sixth seventh eighth ninth
tenth).index index
+ check_api_search_result(
+ @api_result["search"].length > pos ? @api_result["search"][pos] : {},
+ title,
+ in_ok)
+end
+Then(/^(.+) is( in)? the ((?:[^ ])+(?: or (?:[^ ])+)+) api search result$/) do
|title, in_ok, indexes|
found = indexes.split(/ or /).any? do |index|
begin
pos = %w(first second third fourth fifth sixth seventh eighth ninth
tenth).index index
check_api_search_result(
- @api_result["search"].length > pos ? @api_result["search"][pos] : [],
+ @api_result["search"].length > pos ? @api_result["search"][pos] : {},
title,
in_ok)
true
@@ -379,6 +391,8 @@
block.call
rescue RSpec::Expectations::ExpectationNotMetError => e
raise e if Time.new > end_time
+ # api searches are pretty quick, lets pause a second to not hit it so fast
+ sleep 1
retry
end
end
--
To view, visit https://gerrit.wikimedia.org/r/207898
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I357b04705bccd6e5b20a669961c264f0dfda9637
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits