Smalyshev has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/313609

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

Add tests for Russian folding

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, 58 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch 
refs/changes/09/313609/1

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..ddfdefc
--- /dev/null
+++ b/tests/browser/features/russian_folding.feature
@@ -0,0 +1,17 @@
+@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 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: newchange
Gerrit-Change-Id: Ide7fc6dcb3602df07c916a74f469d6346a48be62
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: Smalyshev <[email protected]>

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

Reply via email to