Adrian Lang has uploaded a new change for review.

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

Change subject: Add ugly test for bug 62868.
......................................................................

Add ugly test for bug 62868.

Change-Id: I840f38bdee4ab0f86bde8af986f782dcb66c9dc9
---
M tests/browser/features/statement.feature
M tests/browser/features/step_definitions/entity_selector_steps.rb
M tests/browser/features/step_definitions/statement_steps.rb
M tests/browser/features/support/modules/entity_selector_module.rb
M tests/browser/features/support/modules/statement_module.rb
5 files changed, 46 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/89/119989/1

diff --git a/tests/browser/features/statement.feature 
b/tests/browser/features/statement.feature
index 02d66c3..cc48396 100644
--- a/tests/browser/features/statement.feature
+++ b/tests/browser/features/statement.feature
@@ -104,3 +104,17 @@
       And Statement save button should be disabled
       And Entity selector input element should be there
       And Statement value input element should not be there
+
+  @ui_only @repo_login
+  Scenario: Select a property, use entity selector
+    Given There are properties with the following handles and datatypes:
+      | itemprop | wikibase-item |
+    When I click the statement add button
+      And I select the property itemprop
+                       And I press the q key in the second entity selector 
input field
+                       And I press the ARROWDOWN key in the second entity 
selector input field
+                       And I press the ARROWDOWN key in the second entity 
selector input field
+                       And I press the ENTER key in the second entity selector 
input field
+                       And I memorize the value of the second entity selector 
input field
+                       And I press the ENTER key in the second entity selector 
input field
+    Then Statement item value of claim 1 in group 1 should be what I memorized
diff --git a/tests/browser/features/step_definitions/entity_selector_steps.rb 
b/tests/browser/features/step_definitions/entity_selector_steps.rb
index d187524..3c2a42d 100644
--- a/tests/browser/features/step_definitions/entity_selector_steps.rb
+++ b/tests/browser/features/step_definitions/entity_selector_steps.rb
@@ -6,8 +6,27 @@
 #
 # tests for entity selector
 
-When /^I press the ESC key in the entity selector input field$/ do
-  on(ItemPage).entity_selector_input_element.send_keys :escape
+When(/^I press the (.+) key in the (.*)entity selector input field$/) do |key, 
second|
+       mapping = {
+               'ENTER' => :return,
+               'ARROWDOWN' => :arrow_down,
+               'ESC' => :escape
+       }
+       if mapping[key] then key = mapping[key] end
+       if second == 'second ' then
+               on(ItemPage).entity_selector_input2_element.send_keys key
+       else
+               on(ItemPage).entity_selector_input_element.send_keys key
+       end
+       sleep 1
+end
+
+When(/^I memorize the value of the (.*)entity selector input field$/) do 
|second|
+       if second == 'second ' then
+               @memorized = 
on(ItemPage).entity_selector_input2_element.attribute_value("value")
+       else
+               @memorized = 
on(ItemPage).entity_selector_input_element.attribute_value("value")
+       end
 end
 
 Then /^Entity selector input element should be there$/ do
diff --git a/tests/browser/features/step_definitions/statement_steps.rb 
b/tests/browser/features/step_definitions/statement_steps.rb
index aaf397a..47b4c15 100644
--- a/tests/browser/features/step_definitions/statement_steps.rb
+++ b/tests/browser/features/step_definitions/statement_steps.rb
@@ -117,3 +117,8 @@
 Then /^Statement string value of claim (.+) in group (.+) should be (.+)$/ do 
|claim_index, group_index, value|
   on(ItemPage).statement_string_value_element(group_index, 
claim_index).attribute_value("value").should == value
 end
+
+Then(/^Statement item value of claim (\d+) in group (\d+) should be what I 
memorized$/) do |claim_index, group_index|
+       print @memorized
+       on(ItemPage).statement_item_value_link(group_index, 
claim_index).text.should == @memorized
+end
diff --git a/tests/browser/features/support/modules/entity_selector_module.rb 
b/tests/browser/features/support/modules/entity_selector_module.rb
index 770308d..e348012 100644
--- a/tests/browser/features/support/modules/entity_selector_module.rb
+++ b/tests/browser/features/support/modules/entity_selector_module.rb
@@ -13,8 +13,8 @@
   a(:first_entity_selector_link, xpath: "//ul[contains(@class, 
'ui-entityselector-list')]/li/a")
   span(:first_entity_selector_label, xpath: "//ul[contains(@class, 
'ui-entityselector-list')]/li/a/span/span[contains(@class, 
'ui-entityselector-label')]")
   span(:first_entity_selector_description, xpath: "//ul[contains(@class, 
'ui-entityselector-list')]/li/a/span/span[contains(@class, 
'ui-entityselector-description')]")
-  text_field(:entity_selector_input, xpath: "//div[contains(@class, 
'wb-claimlistview')]//input[contains(@class, 'ui-entityselector-input')]", 
index: 0)
-  text_field(:entity_selector_input2, xpath: "//div[contains(@class, 
'wb-claimlistview')]//input[contains(@class, 'ui-entityselector-input')]", 
index: 1)
+  text_field(:entity_selector_input, xpath: "//div[contains(@class, 
'wb-claimlistview')]//*[contains(@class, 'ui-entityselector-input')]", index: 0)
+  text_field(:entity_selector_input2, xpath: "//div[contains(@class, 
'wb-claimlistview')]//*[contains(@class, 'ui-entityselector-input')]", index: 1)
 
   ul(:entity_selector_list, class: "ui-entityselector-list")
   a(:first_entity_selector_link, xpath: "//ul[contains(@class, 
'ui-entityselector-list')]/li/a")
diff --git a/tests/browser/features/support/modules/statement_module.rb 
b/tests/browser/features/support/modules/statement_module.rb
index 42bc4f9..e00bd6f 100644
--- a/tests/browser/features/support/modules/statement_module.rb
+++ b/tests/browser/features/support/modules/statement_module.rb
@@ -54,6 +54,10 @@
     @browser.element(xpath: "//div[contains(@class, 
'wb-claimlistview')][#{group_index}]//div[contains(@class, 
'listview-item')][#{claim_index}]//textarea[contains(@class, 
'valueview-input')]")
   end
 
+  def statement_item_value_link(group_index, claim_index)
+    @browser.element(xpath: "//div[contains(@class, 
'wb-claimlistview')][#{group_index}]//div[contains(@class, 
'listview-item')][#{claim_index}]//*[contains(@class, 'valueview-value')]//a")
+  end
+
   def edit_claim(group_index, claim_index)
     edit_claim_element(group_index, claim_index).click
   end

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I840f38bdee4ab0f86bde8af986f782dcb66c9dc9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Adrian Lang <adrian.l...@wikimedia.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to