EBernhardson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/207918
Change subject: Convert remaining update_general features to api usage
......................................................................
Convert remaining update_general features to api usage
Change-Id: Ibc03dcbf075cf5affccdf52f06191aaf4b6c2464
---
M tests/browser/features/step_definitions/page_steps.rb
M tests/browser/features/step_definitions/search_steps.rb
M tests/browser/features/support/cirrus_search_api_helper.rb
M tests/browser/features/update_general_api.feature
D tests/browser/features/update_general_browser.feature
5 files changed, 74 insertions(+), 44 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch
refs/changes/18/207918/1
diff --git a/tests/browser/features/step_definitions/page_steps.rb
b/tests/browser/features/step_definitions/page_steps.rb
index 6f74b8f..abf0f45 100644
--- a/tests/browser/features/step_definitions/page_steps.rb
+++ b/tests/browser/features/step_definitions/page_steps.rb
@@ -58,6 +58,23 @@
page.change_visibility_of_selected
end
end
+When(/^I delete the second most recent revision via api of (.*)$/) do |title|
+ # find the revision id
+ result = api.prop(
+ :revisions,
+ titles: title,
+ rvlimit: 2
+ )
+ second_rev_id = result["query"].values[0].values[0]["revisions"][1]["revid"]
+ # delete its text
+ api.action(
+ :revisiondelete,
+ type: "revision",
+ ids: [second_rev_id],
+ hide: "content",
+ token_type: "edit"
+ )
+end
When(/^I go to (.*)$/) do |title|
visit(ArticlePage, using_params: { page_name: title })
end
@@ -73,7 +90,14 @@
page.move
end
end
-
+When(/^I move (.*) to (.*) and (do not )?leave a redirect via api$/) do |from,
to, no_redirect|
+ api.action(
+ :move,
+ from: from,
+ to: to,
+ noredirect: no_redirect ? 1 : 0
+ )
+end
Then(/^there is a software version row for (.+)$/) do |name|
on(SpecialVersion).software_table_row(name).exists?
end
diff --git a/tests/browser/features/step_definitions/search_steps.rb
b/tests/browser/features/step_definitions/search_steps.rb
index ecdf375..cb16aeb 100644
--- a/tests/browser/features/step_definitions/search_steps.rb
+++ b/tests/browser/features/step_definitions/search_steps.rb
@@ -1,5 +1,8 @@
require "cgi"
+Given(/^I am logged in via api$/) do
+ log_in_api
+end
Given(/^I am at the search results page(?: with the search (.+?)(?: and the
prefix (.+))?)?$/) do |search, prefix|
visit(SearchResultsPage, using_params: { search: search, prefix: prefix })
end
diff --git a/tests/browser/features/support/cirrus_search_api_helper.rb
b/tests/browser/features/support/cirrus_search_api_helper.rb
index 8e0061c..a020c2b 100644
--- a/tests/browser/features/support/cirrus_search_api_helper.rb
+++ b/tests/browser/features/support/cirrus_search_api_helper.rb
@@ -4,13 +4,17 @@
# Common code cirrus' test use when dealing with api.
module CirrusSearchApiHelper
+ def log_in_api
+ api.log_in(ENV["MEDIAWIKI_USER"], ENV["MEDIAWIKI_PASSWORD"]) unless
api.logged_in?
+ end
+
def edit_page(title, text, add)
text = File.read("articles/" + text[1..-1]) if text.start_with?("@")
fetched_text = get_page_text(title)
# Note that the space keeps words from smashing together
text = fetched_text + " " + text if add
return if fetched_text.strip == text.strip
- api.log_in(ENV["MEDIAWIKI_USER"], ENV["MEDIAWIKI_PASSWORD"]) unless
api.logged_in?
+ log_in_api
result = api.create_page(title, text)
expect(result.status).to eq 200
expect(result.warnings?).to eq false
@@ -67,7 +71,7 @@
# just uploads the file
def do_upload_file(title, contents, description, sha1, ignorewarnings)
- api.log_in(ENV["MEDIAWIKI_USER"], ENV["MEDIAWIKI_PASSWORD"]) unless
api.logged_in?
+ log_in_api
api.action(
:upload,
filename: title,
diff --git a/tests/browser/features/update_general_api.feature
b/tests/browser/features/update_general_api.feature
index 4a89394..a606080 100644
--- a/tests/browser/features/update_general_api.feature
+++ b/tests/browser/features/update_general_api.feature
@@ -27,3 +27,43 @@
Scenario: Really really long links don't break updates
When a page named ReallyLongLink%{epoch} exists with contents
@really_long_link.txt
Then within 20 seconds api searching for ReallyLongLink%{epoch} yields
ReallyLongLink%{epoch} as the first result
+
+ # This test doesn't rely on our paranoid revision delete handling logic,
rather, it verifies what should work with the
+ # logic with a similar degree of paranoia
+ Scenario: When a revision is deleted the page is updated regardless of if
the revision is current
+ Given I am logged in via api
+ And a page named RevDelTest exists with contents first
+ And a page named RevDelTest exists with contents delete this revision
+ And within 20 seconds api searching for intitle:RevDelTest "delete this
revision" yields RevDelTest as the first result
+ And a page named RevDelTest exists with contents current revision
+ When I delete the second most recent revision via api of RevDelTest
+ Then within 20 seconds api searching for intitle:RevDelTest "delete this
revision" yields none as the first result
+ When I api search for intitle:RevDelTest current revision
+ Then RevDelTest is the first api search result
+
+ @move
+ Scenario: Moved pages that leave a redirect are updated in the index
+ Given I am logged in via api
+ And a page named Move%{epoch} From2 exists with contents move me
+ And within 20 seconds api searching for Move%{epoch} From2 yields
Move%{epoch} From2 as the first result
+ When I move Move%{epoch} From2 to Move%{epoch} To2 and do not leave a
redirect via api
+ Then within 20 seconds api searching for Move%{epoch} From2 yields none as
the first result
+ And within 20 seconds api searching for Move%{epoch} To2 yields
Move%{epoch} To2 as the first result
+
+ @move
+ Scenario: Moved pages that switch indexes are removed from their old index
if they leave a redirect
+ Given I am logged in via api
+ And a page named Move%{epoch} From3 exists with contents move me
+ And within 20 seconds api searching for Move%{epoch} From3 yields
Move%{epoch} From3 as the first result
+ When I move Move%{epoch} From3 to User:Move%{epoch} To3 and leave a
redirect via api
+ Then within 20 seconds api searching for User:Move%{epoch} To3 yields
User:Move%{epoch} To3 as the first result
+ And within 20 seconds api searching for Move%{epoch} From3 yields none
as the first result
+
+ @move
+ Scenario: Moved pages that switch indexes are removed from their old index
if they don't leave a redirect
+ Given I am logged in via api
+ And a page named Move%{epoch} From4 exists with contents move me
+ And within 20 seconds api searching for Move%{epoch} From4 yields
Move%{epoch} From4 as the first result
+ When I move Move%{epoch} From4 to User:Move%{epoch} To4 and do not leave a
redirect via api
+ Then within 20 seconds api searching for User:Move%{epoch} To4 yields
User:Move%{epoch} To4 as the first result
+ And within 20 seconds api searching for Move%{epoch} To4 yields none as
the first result
diff --git a/tests/browser/features/update_general_browser.feature
b/tests/browser/features/update_general_browser.feature
deleted file mode 100644
index 9978df9..0000000
--- a/tests/browser/features/update_general_browser.feature
+++ /dev/null
@@ -1,41 +0,0 @@
-@clean @phantomjs @update
-Feature: Search backend updates
- # This test doesn't rely on our paranoid revision delete handling logic,
rather, it verifies what should work with the
- # logic with a similar degree of paranoia
- Scenario: When a revision is deleted the page is updated regardless of if
the revision is current
- Given I am logged in
- And a page named RevDelTest exists with contents first
- And a page named RevDelTest exists with contents delete this revision
- And within 20 seconds searching for intitle:RevDelTest "delete this
revision" yields RevDelTest as the first result
- And a page named RevDelTest exists with contents current revision
- When I delete the second most recent revision of RevDelTest
- Then within 20 seconds searching for intitle:RevDelTest "delete this
revision" yields none as the first result
- When I search for intitle:RevDelTest current revision
- Then RevDelTest is the first search result
-
- @move
- Scenario: Moved pages that leave a redirect are updated in the index
- Given I am logged in
- And a page named Move%{epoch} From2 exists with contents move me
- And within 20 seconds searching for Move%{epoch} From2 yields
Move%{epoch} From2 as the first result
- When I move Move%{epoch} From2 to Move%{epoch} To2 and do not leave a
redirect
- Then within 20 seconds searching for Move%{epoch} From2 yields none as the
first result
- And within 20 seconds searching for Move%{epoch} To2 yields Move%{epoch}
To2 as the first result
-
- @move
- Scenario: Moved pages that switch indexes are removed from their old index
if they leave a redirect
- Given I am logged in
- And a page named Move%{epoch} From3 exists with contents move me
- And within 20 seconds searching for Move%{epoch} From3 yields
Move%{epoch} From3 as the first result
- When I move Move%{epoch} From3 to User:Move%{epoch} To3 and leave a
redirect
- Then within 20 seconds searching for User:Move%{epoch} To3 yields
User:Move%{epoch} To3 as the first result
- And within 20 seconds searching for Move%{epoch} From3 yields none as
the first result
-
- @move
- Scenario: Moved pages that switch indexes are removed from their old index
if they don't leave a redirect
- Given I am logged in
- And a page named Move%{epoch} From4 exists with contents move me
- And within 20 seconds searching for Move%{epoch} From4 yields
Move%{epoch} From4 as the first result
- When I move Move%{epoch} From4 to User:Move%{epoch} To4 and do not leave a
redirect
- Then within 20 seconds searching for User:Move%{epoch} To4 yields
User:Move%{epoch} To4 as the first result
- And within 20 seconds searching for Move%{epoch} To4 yields none as the
first result
--
To view, visit https://gerrit.wikimedia.org/r/207918
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibc03dcbf075cf5affccdf52f06191aaf4b6c2464
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