jenkins-bot has submitted this change and it was merged.
Change subject: Add some regression tests for search a file.
......................................................................
Add some regression tests for search a file.
This adds some regression tests for finding a file and the infrastructure
for uploading files and making sure they are up to date.
One search for a file currently doesn't work so it is commented out with
its associated bug number.
Change-Id: I5a5f33df500b2b5e73cb67d61f1d93fc69785aaf
---
M tests/browser/features/full_text.feature
M tests/browser/features/step_definitions/page_steps.rb
M tests/browser/features/step_definitions/search_steps.rb
A tests/browser/features/support/articles/Savepage-greyed.png
M tests/browser/features/support/build_pages.rb
M tests/browser/features/support/pages/article_page.rb
M tests/browser/features/support/pages/search_results_page.rb
A tests/browser/features/support/pages/upload_file_page.rb
8 files changed, 97 insertions(+), 26 deletions(-)
Approvals:
Demon: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/browser/features/full_text.feature
b/tests/browser/features/full_text.feature
index 7dd0410..ebb2eb3 100644
--- a/tests/browser/features/full_text.feature
+++ b/tests/browser/features/full_text.feature
@@ -4,30 +4,37 @@
Given I am at a random page
When I search for <term>
Then I am on a page titled Search results
- And <first_result> the first search result
+ And <first_result> the first search <image?>result
But Two Words is <two_words_is_in> the search results
Examples:
- | term | first_result
| two_words_is_in |
- | catapult | Catapult is in
| in |
- | pickles | Two Words is
| in |
- | catapul* | Catapult is in
| in |
- | rdir | Two Words (redirect is in
| not in |
- | intitle:catapult | Catapult is in
| not in |
- | intitle:catapul* | Catapult is in
| not in |
- | intitle:catapult amazing | Amazing Catapult is
| not in |
- | intitle:catapul* amaz* | Amazing Catapult is
| not in |
- | incategory:weaponry | Catapult is in
| not in |
- | incategory:weaponry amazing | Amazing Catapult is
| not in |
- | incategory:weaponry intitle:catapult | Catapult is in
| not in |
- | incategory:alpha incategory:beta | AlphaBeta is
| not in |
- | incategory:twowords catapult | Two Words is
| in |
- | incategory:twowords intitle:catapult | none is
| not in |
- | incategory:templatetagged two words | Two Words is
| in |
- | talk:catapult | Talk:Two Words is
| not in |
- | talk:intitle:words | Talk:Two Words is
| not in |
- | template:pickles | Template:Template Test is
| not in |
- | pickles/ | Two Words is
| in |
- | catapult/pickles | Two Words is
| in |
+ | term | first_result
| two_words_is_in | image? |
+ | catapult | Catapult is in
| in | |
+ | pickles | Two Words is
| in | |
+ | catapul* | Catapult is in
| in | |
+ | rdir | Two Words (redirect is in
| not in | |
+ | intitle:catapult | Catapult is in
| not in | |
+ | intitle:catapul* | Catapult is in
| not in | |
+ | intitle:catapult amazing | Amazing Catapult is
| not in | |
+ | intitle:catapul* amaz* | Amazing Catapult is
| not in | |
+ | incategory:weaponry | Catapult is in
| not in | |
+ | incategory:weaponry amazing | Amazing Catapult is
| not in | |
+ | incategory:weaponry intitle:catapult | Catapult is in
| not in | |
+ | incategory:alpha incategory:beta | AlphaBeta is
| not in | |
+ | incategory:twowords catapult | Two Words is
| in | |
+ | incategory:twowords intitle:catapult | none is
| not in | |
+ | incategory:templatetagged two words | Two Words is
| in | |
+ | talk:catapult | Talk:Two Words is
| not in | |
+ | talk:intitle:words | Talk:Two Words is
| not in | |
+ | template:pickles | Template:Template Test is
| not in | |
+ | pickles/ | Two Words is
| in | |
+ | catapult/pickles | Two Words is
| in | |
+ # Make sure various ways of searching for a file name work
+ | File:Savepage-greyed.png | File:Savepage-greyed.png is
| not in | image |
+ | File:Savepage | File:Savepage-greyed.png is
| not in | image |
+ | File:greyed.png | File:Savepage-greyed.png is
| not in | image |
+ # Bug 52948
+ #| File:greyed | File:Savepage-greyed.png is
| not in | image |
+ | File:"Screenshot, for test purposes" | File:Savepage-greyed.png is
| not in | image |
@setup_main
Scenario Outline: Searching for empty-string like values
diff --git a/tests/browser/features/step_definitions/page_steps.rb
b/tests/browser/features/step_definitions/page_steps.rb
index 0a58ab4..feae230 100644
--- a/tests/browser/features/step_definitions/page_steps.rb
+++ b/tests/browser/features/step_definitions/page_steps.rb
@@ -2,6 +2,11 @@
edit_page(title, text, false)
end
+Given(/^a file named (.*) exists with contents (.*) and description (.*)$/) do
|title, contents, description|
+ upload_file(title, contents, description) # Make sure the file is correct
+ edit_page(title, description, false) # Make sure the description is
correct
+end
+
When(/^I delete (.+)$/) do |title|
visit(DeletePage, using_params: {page_name: title}) do |page|
page.delete
@@ -42,4 +47,32 @@
page.save
end
end
-end
\ No newline at end of file
+end
+
+def upload_file(title, contents, description)
+ contents = 'features/support/articles/' + contents
+ md5 = Digest::MD5.hexdigest(File.read(contents))
+ md5_string = "md5: #{md5}"
+ visit(ArticlePage, using_params: {page_name: title}) do |page|
+ if page.file_history? && page.file_last_comment? &&
page.file_last_comment.include?(md5_string)
+ return
+ end
+ if !(page.upload_new_version? || page.upload?)
+ step 'I am logged in'
+ visit(ArticlePage, using_params: {page_name: title})
+ end
+ if page.upload?
+ # New file, upload it
+ page.upload
+ else
+ # Existing file, update it
+ page.upload_new_version
+ end
+ end
+ on(UploadFilePage) do |page|
+ page.description = description + "\n" + md5_string
+ page.file = File.absolute_path(contents)
+ page.submit
+ page.error_element.should_not exist
+ end
+end
diff --git a/tests/browser/features/step_definitions/search_steps.rb
b/tests/browser/features/step_definitions/search_steps.rb
index a57f331..935ee0a 100644
--- a/tests/browser/features/step_definitions/search_steps.rb
+++ b/tests/browser/features/step_definitions/search_steps.rb
@@ -90,6 +90,7 @@
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
@@ -100,6 +101,22 @@
end
end
end
+Then(/^(.*) is( in)? the first search imageresult$/) do |title, in_ok|
+ 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_image_result_element.should exist
+ if in_ok then
+ page.first_image_result_element.text.should include title
+ 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 the highlighted title of the first search result$/) do
|highlighted|
on(SearchResultsPage).first_result_highlighted_title.should == highlighted
end
diff --git a/tests/browser/features/support/articles/Savepage-greyed.png
b/tests/browser/features/support/articles/Savepage-greyed.png
new file mode 100644
index 0000000..bbc01c9
--- /dev/null
+++ b/tests/browser/features/support/articles/Savepage-greyed.png
Binary files differ
diff --git a/tests/browser/features/support/build_pages.rb
b/tests/browser/features/support/build_pages.rb
index cc1eaae..6e94532 100644
--- a/tests/browser/features/support/build_pages.rb
+++ b/tests/browser/features/support/build_pages.rb
@@ -12,6 +12,7 @@
And a page named África exists with contents for testing
And a page named Rdir exists with contents #REDIRECT [[Two Words]]
And a page named AlphaBeta exists with contents [[Category:Alpha]]
[[Category:Beta]]
+ And a file named File:Savepage-greyed.png exists with contents
Savepage-greyed.png and description Screenshot, for test purposes, associated
with https://bugzilla.wikimedia.org/show_bug.cgi?id=52908 .
}
$setup_main = true
end
diff --git a/tests/browser/features/support/pages/article_page.rb
b/tests/browser/features/support/pages/article_page.rb
index 1402806..5ee17eb 100644
--- a/tests/browser/features/support/pages/article_page.rb
+++ b/tests/browser/features/support/pages/article_page.rb
@@ -4,4 +4,8 @@
page_url URL.url('<%=params[:page_name]%>')
h1(:title, id: 'firstHeading')
+ table(:file_history, :class => 'filehistory')
+ cell(:file_last_comment){ table_element(:class => 'filehistory')[1][5] }
+ link(:upload, text: 'upload it')
+ link(:upload_new_version, text: 'Upload a new version of this file')
end
diff --git a/tests/browser/features/support/pages/search_results_page.rb
b/tests/browser/features/support/pages/search_results_page.rb
index f400ae4..9e83713 100644
--- a/tests/browser/features/support/pages/search_results_page.rb
+++ b/tests/browser/features/support/pages/search_results_page.rb
@@ -7,15 +7,16 @@
h1(:title, id: 'firstHeading')
div(:first_result, :class => 'mw-search-result-heading')
div(:first_result_text, :class => 'searchresult')
+ link(:first_image_result){ table_element(:class =>
'searchResultImage').cell_element(:index => 1).link_element(:index => 0) }
button(:simple_search_button, value: 'Search')
text_field(:search_input, name: 'search')
div(:suggestion_wrapper, class: 'searchdidyoumean')
- def suggestion
- suggestion_wrapper_element.link_element.text
- end
def suggestion_element
suggestion_wrapper_element.link_element
end
+ def suggestion
+ suggestion_element.text
+ end
def results
@browser.divs(:class => 'mw-search-result-heading')
end
diff --git a/tests/browser/features/support/pages/upload_file_page.rb
b/tests/browser/features/support/pages/upload_file_page.rb
new file mode 100644
index 0000000..60e4864
--- /dev/null
+++ b/tests/browser/features/support/pages/upload_file_page.rb
@@ -0,0 +1,8 @@
+class UploadFilePage
+ include PageObject
+
+ text_area(:description, id: 'wpUploadDescription')
+ file_field(:file, id: 'wpUploadFile')
+ button(:submit, value: 'Upload file')
+ div(:error, class: 'error')
+end
--
To view, visit https://gerrit.wikimedia.org/r/80074
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5a5f33df500b2b5e73cb67d61f1d93fc69785aaf
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: Manybubbles <[email protected]>
Gerrit-Reviewer: Cmcmahon <[email protected]>
Gerrit-Reviewer: Demon <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits