jenkins-bot has submitted this change and it was merged.

Change subject: Add tests for Russian folding
......................................................................


Add tests for Russian folding

For now, you'd have to manually set up Russian language wiki,
under ru.wiki.local.wmftest.net, and ensure it uses "ru" as the language.
These tests rely on that being present.

Bug: T102298
Bug: T124592
Change-Id: Ide7fc6dcb3602df07c916a74f469d6346a48be62
---
M tests/browser/environments.yml
A tests/browser/features/russian_folding.feature
M tests/browser/features/step_definitions/page_steps.rb
M tests/browser/features/step_definitions/search_steps.rb
M tests/browser/features/support/hooks.rb
5 files changed, 64 insertions(+), 0 deletions(-)

Approvals:
  Cindy-the-browser-test-bot: Looks good to me, but someone else must approve
  DCausse: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/browser/environments.yml b/tests/browser/environments.yml
index b07b6cc..cd0d6fe 100644
--- a/tests/browser/environments.yml
+++ b/tests/browser/environments.yml
@@ -20,6 +20,7 @@
   mediawiki_commons_api_url: 
http://commons.wiki.local.wmftest.net:8080/w/api.php
   mediawiki_url: http://cirrustest.wiki.local.wmftest.net:8080/wiki/
   mediawiki_url_commons: http://commons.wiki.local.wmftest.net:8080/wiki/
+  mediawiki_url_ru: http://ru.wiki.local.wmftest.net:8080/wiki/
   mediawiki_user: admin
   mediawiki_password: vagrant
   reuse_browser: true
@@ -49,6 +50,7 @@
   mediawiki_commons_api_url: 
http://commons-cirrus-browser-bot.wmflabs.org/w/api.php
   mediawiki_url: http://cirrustest-cirrus-browser-bot.wmflabs.org/wiki/
   mediawiki_url_commons: http://commons-cirrus-browser-bot.wmflabs.org/wiki/
+  mediawiki_url_ru: http://ru-cirrus-browser-bot.wmflabs.org/wiki/
   mediawiki_user: admin
   mediawiki_password: vagrant
   reuse_browser: true
diff --git a/tests/browser/features/russian_folding.feature 
b/tests/browser/features/russian_folding.feature
new file mode 100644
index 0000000..e8185b4
--- /dev/null
+++ b/tests/browser/features/russian_folding.feature
@@ -0,0 +1,23 @@
+@clean @api @ru
+Feature: Searches with Russian accents
+  Scenario: Searching for ё when text has е
+    When I api search on ru for чёрная дыра
+    Then Черная дыра is the first api search result
+
+  Scenario: Searching for е when text has ё
+    When I api search on ru for черный
+    Then Саша Чёрный is the first api search result
+
+  Scenario: Searching for no accent and lowercase
+    When I api search on ru for гликберг
+    Then Саша Чёрный is the first api search result
+
+  Scenario: Searching with insource allows to find exact matches
+    When I api search on ru for insource:гликберг
+    Then there are no api search results
+    And I api search on ru for insource:гли́кберг
+    Then Саша Чёрный is the first api search result
+
+  Scenario: Searching for with accent
+    When I api search on ru for Бра́зер
+    Then Бразер is the first api search result
diff --git a/tests/browser/features/step_definitions/page_steps.rb 
b/tests/browser/features/step_definitions/page_steps.rb
index d742ff5..5088c63 100644
--- a/tests/browser/features/step_definitions/page_steps.rb
+++ b/tests/browser/features/step_definitions/page_steps.rb
@@ -3,6 +3,13 @@
   edit_page(title, text, false)
 end
 
+Given(/^a page on (\w+) named (.*) exists(?: with contents (.*))?$/) do |wiki, 
title, text|
+  text = title unless text
+  on_wiki(wiki) do
+    edit_page(title, text, false)
+  end
+end
+
 Given(/^a file named (.*) exists(?: on (commons))? with contents (.*) and 
description (.*)$/) do |title, wiki, contents, description|
   on_wiki(wiki) do
     upload_file(title, contents, description)   # Make sure the file is correct
diff --git a/tests/browser/features/step_definitions/search_steps.rb 
b/tests/browser/features/step_definitions/search_steps.rb
index 6a450aa..adecca3 100644
--- a/tests/browser/features/step_definitions/search_steps.rb
+++ b/tests/browser/features/step_definitions/search_steps.rb
@@ -46,6 +46,23 @@
     @api_error = e
   end
 end
+When(/^I api search on (\w+) for (.*)$/) do |wiki, search|
+  begin
+    on_wiki(wiki) do
+      @api_result = search_for(
+        search.gsub(/%[^ {]+%/, @search_vars)
+          .gsub(/%\{\\u([\dA-Fa-f]{4,6})\}%/) do  # replace %{\uXXXX}% with 
the unicode code point
+            [Regexp.last_match[1].hex].pack("U")
+          end,
+        {}
+      )
+    end
+  rescue MediawikiApi::ApiError => e
+    @api_error = e
+  rescue MediawikiApi::HttpError => e
+    @api_error = e
+  end
+end
 When(/^I get api suggestions for (.*?)(?: using the (.*) profile)?$/) do 
|search, profile|
   begin
     profile = profile ? profile : "fuzzy"
diff --git a/tests/browser/features/support/hooks.rb 
b/tests/browser/features/support/hooks.rb
index e8b082d..20e04d3 100644
--- a/tests/browser/features/support/hooks.rb
+++ b/tests/browser/features/support/hooks.rb
@@ -680,6 +680,18 @@
   end
 end
 
+ruwiki = false
+setup_ruwiki = lambda do |world|
+  unless ruwiki
+    world.steps %(
+    Given a page on ru named Черная дыра exists with contents Черная дыра́ — 
область пространства-времени
+      And a page on ru named Саша Чёрный exists with contents настоящее имя 
Алекса́ндр Миха́йлович Гли́кберг
+      And a page on ru named Бразер exists with contents белорусский советский 
скульптор
+    )
+    ruwiki = true
+  end
+end
+
 # Optimization for parallel runners so only one does the setup, Makes the bold
 # assumption parallel runner is going to run everything.
 lock_file_path = "/tmp/parallel_cucumber.lock"
@@ -919,3 +931,6 @@
 Before("@filesearch") do
   setup_files_for_search.call(self)
 end
+Before("@ru") do
+  setup_ruwiki.call(self)
+end

-- 
To view, visit https://gerrit.wikimedia.org/r/313609
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ide7fc6dcb3602df07c916a74f469d6346a48be62
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: Smalyshev <[email protected]>
Gerrit-Reviewer: Cindy-the-browser-test-bot <[email protected]>
Gerrit-Reviewer: DCausse <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: Gehel <[email protected]>
Gerrit-Reviewer: Manybubbles <[email protected]>
Gerrit-Reviewer: Smalyshev <[email protected]>
Gerrit-Reviewer: Tjones <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to