jenkins-bot has submitted this change and it was merged. Change subject: Migrating statement string value browsertests to cucumber ......................................................................
Migrating statement string value browsertests to cucumber Change-Id: I524360719656adfaa0a4f9e84749c6f8a72dc783 --- A tests/browser/features/statements_string.feature M tests/browser/features/step_definitions/statement_steps.rb M tests/browser/features/support/modules/statement_module.rb 3 files changed, 112 insertions(+), 5 deletions(-) Approvals: WikidataJenkins: Verified Adrian Lang: Looks good to me, approved jenkins-bot: Verified diff --git a/tests/browser/features/statements_string.feature b/tests/browser/features/statements_string.feature new file mode 100644 index 0000000..55ed1d5 --- /dev/null +++ b/tests/browser/features/statements_string.feature @@ -0,0 +1,64 @@ +# Wikidata UI tests +# +# Author:: Tobias Gritschacher (tobias.gritschac...@wikimedia.de) +# License:: GNU GPL v2+ +# +# feature definition for statements tests + +@wikidata.beta.wmflabs.org +Feature: Creating statements + + Background: + Given I am on an item page + And The copyright warning has been dismissed + And Anonymous edit warnings are disabled + + @repo_login @modify_entity + Scenario Outline: Adding a statement of type string + Given There are properties with the following handles and datatypes: + | stringprop | string | + When I click the statement add button + And I select the property stringprop + And I enter <value> as string statement value + And I <save> + Then Statement add button should be there + And Statement cancel button should not be there + And Statement save button should not be there + And Entity selector input element should not be there + And Statement value input element should not be there + And Statement edit button should be there + And Statement name should be the label of stringprop + And Statement string value should be <value> + + Examples: + | value | save | + | it's a string | press the RETURN key in the statement value input field | + | <script>$('body').empty();</script> | click the statement save button | + + @repo_login @modify_entity + Scenario: Adding a statement of type string and reload page + Given There are properties with the following handles and datatypes: + | stringprop | string | + When I click the statement add button + And I select the property stringprop + And I enter it's a string as string statement value + And I click the statement save button + And I reload the page + Then Statement add button should be there + And Statement cancel button should not be there + And Statement save button should not be there + And Entity selector input element should not be there + And Statement value input element should not be there + And Statement edit button should be there + And Statement name should be the label of stringprop + And Statement string value should be it's a string + + @repo_login @modify_entity + Scenario: Adding a statement of type string with a too long string + Given There are properties with the following handles and datatypes: + | stringprop | string | + When I click the statement add button + And I select the property stringprop + And I enter a too long string as statement value + And I click the statement save button + Then An error message should be displayed diff --git a/tests/browser/features/step_definitions/statement_steps.rb b/tests/browser/features/step_definitions/statement_steps.rb index 3621b8c..10539d7 100644 --- a/tests/browser/features/step_definitions/statement_steps.rb +++ b/tests/browser/features/step_definitions/statement_steps.rb @@ -14,6 +14,14 @@ on(ItemPage).cancel_statement end +When /^I click the statement save button$/ do + on(ItemPage) do |page| + page.save_statement + page.ajax_wait + page.wait_for_statement_request_finished + end +end + When /^I select the property (.+)$/ do |handle| on(ItemPage) do |page| page.select_entity(@properties[handle]["label"]) @@ -33,8 +41,20 @@ on(ItemPage).statement_value_input_field = value end +When /^I enter a too long string as statement value$/ do + step 'I enter looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong as string statement value' +end + When /^I press the ESC key in the statement value input field$/ do on(ItemPage).statement_value_input_field_element.send_keys :escape +end + +When /^I press the RETURN key in the statement value input field$/ do + on(ItemPage) do |page| + page.statement_value_input_field_element.send_keys :return + page.ajax_wait + page.wait_for_statement_request_finished + end end Then /^Statement help field should be there$/ do @@ -50,6 +70,10 @@ page.add_statement?.should be_false page.add_statement_disabled?.should be_true end +end + +Then /^Statement edit button should be there$/ do + on(ItemPage).edit_statement1_claim1?.should be_true end Then /^Statement save button should be there$/ do @@ -82,3 +106,11 @@ Then /^Statement value input element should not be there$/ do on(ItemPage).statement_value_input?.should be_false end + +Then /^Statement name should be the label of (.+)$/ do |handle| + on(ItemPage).statement1_name.should == @properties[handle]["label"] +end + +Then /^Statement string value should be (.+)$/ do |value| + on(ItemPage).get_statement_string_value.should == value +end \ No newline at end of file diff --git a/tests/browser/features/support/modules/statement_module.rb b/tests/browser/features/support/modules/statement_module.rb index fbb4b8b..6c411e3 100644 --- a/tests/browser/features/support/modules/statement_module.rb +++ b/tests/browser/features/support/modules/statement_module.rb @@ -15,13 +15,17 @@ # statements UI elements a(:add_statement, css: "div.wb-claimlistview a.wb-addtoolbar-addbutton:not(.wikibase-toolbarbutton-disabled)") a(:add_statement_disabled, css: "div.wb-claimlistview a.wb-addtoolbar-addbutton.wikibase-toolbarbutton-disabled") - a(:save_statement, css: ".wb-claimlistview div.listview-item.wb-new a.wikibase-toolbareditgroup-savebutton:not(.wikibase-toolbarbutton-disabled)") - a(:save_statement_disabled, css: ".wb-claimlistview div.listview-item.wb-new a.wikibase-toolbareditgroup-savebutton.wikibase-toolbarbutton-disabled") - a(:cancel_statement, css: ".wb-claimlistview div.listview-item.wb-new a.wikibase-toolbareditgroup-cancelbutton:not(.wikibase-toolbarbutton-disabled)") - a(:cancel_statement_disabled, css: ".wb-claimlistview div.listview-item.wb-new a.wikibase-toolbareditgroup-cancelbutton.wikibase-toolbarbutton-disabled") + a(:save_statement, css: ".wb-claimlistview div.listview-item a.wikibase-toolbareditgroup-savebutton:not(.wikibase-toolbarbutton-disabled)") + a(:save_statement_disabled, css: ".wb-claimlistview div.listview-item a.wikibase-toolbareditgroup-savebutton.wikibase-toolbarbutton-disabled") + a(:cancel_statement, css: ".wb-claimlistview div.listview-item a.wikibase-toolbareditgroup-cancelbutton:not(.wikibase-toolbarbutton-disabled)") + a(:cancel_statement_disabled, css: ".wb-claimlistview div.listview-item a.wikibase-toolbareditgroup-cancelbutton.wikibase-toolbarbutton-disabled") + a(:edit_statement1_claim1, css: ".wb-claimlistview:nth-child(1) div.listview-item:nth-child(1) a.wikibase-toolbareditgroup-editbutton:not(.wikibase-toolbarbutton-disabled)") textarea(:statement_value_input, xpath: "//div[contains(@class, 'wb-claimlistview')]//input[contains(@class, 'valueview-input')]") span(:statement_help_field, :css => "div.wb-claimlistview span.mw-help-field-hint") text_field(:statement_value_input_field, class: "valueview-input") + div(:statement1_name, :css => ".wb-claimlistview:nth-child(1) div.wb-claim-name") + div(:statement1_claim1_value, :css => ".wb-claimlistview:nth-child(1) div.wb-claimview:nth-child(1) div.wb-claim-mainsnak div.wb-snak-value-container div.wb-snak-value") + div(:claim_edit_mode, :css => ".wb-claim-section div.wb-edit") #a(:add_claim_to_first_statement, css: "div.wb-claimlistview:nth-child(1) > span.wb-addtoolbar a:not(.wikibase-toolbarbutton-disabled)") #a(:edit_first_statement, css: "span.wb-edittoolbar > span > span > span.wikibase-toolbareditgroup-innoneditmode > span > a:not(.wikibase-toolbarbutton-disabled):nth-child(1)") @@ -51,13 +55,20 @@ end end -=begin + def get_statement_string_value + edit_statement1_claim1 + value = statement_value_input_field + cancel_statement + return value + end + def wait_for_statement_request_finished wait_until do self.claim_edit_mode? == false end end +=begin def add_statement(property_label, statement_value) add_statement self.entity_selector_input = property_label -- To view, visit https://gerrit.wikimedia.org/r/109089 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I524360719656adfaa0a4f9e84749c6f8a72dc783 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Tobias Gritschacher <tobias.gritschac...@wikimedia.de> Gerrit-Reviewer: Adrian Lang <adrian.l...@wikimedia.de> Gerrit-Reviewer: Henning Snater <henning.sna...@wikimedia.de> Gerrit-Reviewer: WikidataJenkins <wikidata-servi...@wikimedia.org> Gerrit-Reviewer: Zfilipin <zfili...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits