Tobias Gritschacher has uploaded a new change for review. https://gerrit.wikimedia.org/r/110966
Change subject: Browsertests for statements with item values ...................................................................... Browsertests for statements with item values Change-Id: I8c31e1a68b3bd3c96b42e47d74ccf13324f7e55e --- A tests/browser/features/statements_item.feature M tests/browser/features/statements_string.feature M tests/browser/features/step_definitions/statement_steps.rb M tests/browser/features/support/modules/statement_module.rb M tests/browser/features/support/modules/wikibase_api_module.rb 5 files changed, 61 insertions(+), 12 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/66/110966/1 diff --git a/tests/browser/features/statements_item.feature b/tests/browser/features/statements_item.feature new file mode 100644 index 0000000..cc82c32 --- /dev/null +++ b/tests/browser/features/statements_item.feature @@ -0,0 +1,38 @@ +# Wikidata UI tests +# +# Author:: Tobias Gritschacher (tobias.gritschac...@wikimedia.de) +# License:: GNU GPL v2+ +# +# feature definition for item type statements tests + +@wikidata.beta.wmflabs.org +Feature: Creating statements of type item + + 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 item + Given There are properties with the following handles and datatypes: + | itemprop | wikibase-item | + Given There are items with the following handles: + | item1 | + When I click the statement add button + And I select the property itemprop + And I enter the label of the item with handle <itemhandle> as 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 for claim 1 in group 1 should be there + And Statement name of group 1 should be the label of itemprop + And Statement value of claim 1 in group 1 should be the label of the item with handle <itemhandle> + + Examples: + | itemhandle | save | + #| item1 | click the statement save button | + | item1 | press the RETURN key in the statement value input field | diff --git a/tests/browser/features/statements_string.feature b/tests/browser/features/statements_string.feature index 8b8274e..7414629 100644 --- a/tests/browser/features/statements_string.feature +++ b/tests/browser/features/statements_string.feature @@ -3,10 +3,10 @@ # Author:: Tobias Gritschacher (tobias.gritschac...@wikimedia.de) # License:: GNU GPL v2+ # -# feature definition for statements tests +# feature definition for string type statements tests @wikidata.beta.wmflabs.org -Feature: Creating statements +Feature: Creating statements of type string Background: Given I am on an item page @@ -19,7 +19,7 @@ | 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 enter the string <value> as statement value And I <save> Then Statement add button should be there And Statement cancel button should not be there @@ -41,7 +41,7 @@ | 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 enter the string it's a string as statement value And I click the statement save button And I reload the page Then Statement add button should be there diff --git a/tests/browser/features/step_definitions/statement_steps.rb b/tests/browser/features/step_definitions/statement_steps.rb index cc67233..44967c9 100644 --- a/tests/browser/features/step_definitions/statement_steps.rb +++ b/tests/browser/features/step_definitions/statement_steps.rb @@ -37,8 +37,16 @@ end end -When /^I enter (.+) as string statement value$/ do |value| +When /^I enter the string (.+) as statement value$/ do |value| on(ItemPage).statement_value_input_field = value +end + +When /^I enter the label of the item with handle (.+) as statement value$/ do |handle| + on(ItemPage) do |page| + page.statement_value_input_field_element.clear + page.statement_value_input_field = @items[handle]["label"] + page.ajax_wait + end end When /^I enter a too long string as statement value$/ do @@ -114,3 +122,7 @@ 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 value of claim (.+) in group (.+) should be the label of the item with handle (.+)$/ do |claim_index, group_index, handle| + on(ItemPage).statement_value_element(group_index, claim_index).text.should == @items[handle]["label"] +end diff --git a/tests/browser/features/support/modules/statement_module.rb b/tests/browser/features/support/modules/statement_module.rb index e999949..ca89bb3 100644 --- a/tests/browser/features/support/modules/statement_module.rb +++ b/tests/browser/features/support/modules/statement_module.rb @@ -20,7 +20,7 @@ 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") textarea(:statement_value_input, xpath: "//div[contains(@class, 'wb-claimlistview')]//input[contains(@class, 'valueview-input')]") - textarea(:statement_value, xpath: "//div[contains(@class, 'wb-claimlistview')]//textarea[contains(@class, 'valueview-input')]") + #textarea(:statement_value, xpath: "//div[contains(@class, 'wb-claimlistview')]//textarea[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(:claim_edit_mode, :css => ".wb-claim-section div.wb-edit") @@ -33,12 +33,6 @@ #div(:statement2Name, xpath: "//div[contains(@class, 'wb-claimlistview')][2]//div[contains(@class, 'wb-claim-name')]") #a(:statement1Link, xpath: "//div[contains(@class, 'wb-claimlistview')][1]//div[contains(@class, 'wb-claim-name')]/a") #a(:statement2Link, xpath: "//div[contains(@class, 'wb-claimlistview')][2]//div[contains(@class, 'wb-claim-name')]/a") - #element(:statement1Claim_value1, :a, xpath: "//div[contains(@class, 'wb-claimlistview')][1]//div[contains(@class, 'wb-claimview')][1]//div[contains(@class, 'wb-claim-mainsnak')]/div[contains(@class, 'wb-snak-value-container')]/div[contains(@class, 'wb-snak-value')]/div/div/a") - #element(:statement1Claim_value2, :a, xpath: "//div[contains(@class, 'wb-claimlistview')][1]//div[contains(@class, 'wb-claimview')][2]//div[contains(@class, 'wb-claim-mainsnak')]/div[contains(@class, 'wb-snak-value-container')]/div[contains(@class, 'wb-snak-value')]/div/div/a") - #element(:statement1Claim_value3, :a, xpath: "//div[contains(@class, 'wb-claimlistview')][1]//div[contains(@class, 'wb-claimview')][3]//div[contains(@class, 'wb-claim-mainsnak')]/div[contains(@class, 'wb-snak-value-container')]/div[contains(@class, 'wb-snak-value')]/div/div/a") - #element(:statement2Claim_value1, :a, xpath: "//div[contains(@class, 'wb-claimlistview')][2]//div[contains(@class, 'wb-claimview')][1]//div[contains(@class, 'wb-claim-mainsnak')]/div[contains(@class, 'wb-snak-value-container')]/div[contains(@class, 'wb-snak-value')]/div/div/a") - #element(:statement2Claim_value2, :a, xpath: "//div[contains(@class, 'wb-claimlistview')][2]//div[contains(@class, 'wb-claimview')][2]//div[contains(@class, 'wb-claim-mainsnak')]/div[contains(@class, 'wb-snak-value-container')]/div[contains(@class, 'wb-snak-value')]/div/div/a") - #element(:statement2Claim_value3, :a, xpath: "//div[contains(@class, 'wb-claimlistview')][2]//div[contains(@class, 'wb-claimview')][3]//div[contains(@class, 'wb-claim-mainsnak')]/div[contains(@class, 'wb-snak-value-container')]/div[contains(@class, 'wb-snak-value')]/div/div/a") #span(:statement1Claim_value1Nolink, xpath: "//div[contains(@class, 'wb-claimlistview')][1]//div[contains(@class, 'wb-claimview')][1]//div[contains(@class, 'wb-claim-mainsnak')]/div[contains(@class, 'wb-snak-value-container')]/div[contains(@class, 'wb-snak-value')]/div/div/span") #span(:snaktype_selector_icon, xpath: "//div[contains(@class, 'wb-snak-typeselector')]/span[contains(@class, 'wb-snaktypeselector')]") #a(:snaktype_selector_value, xpath: "//ul[contains(@class, 'wb-snaktypeselector-menu')]/li[contains(@class, 'wb-snaktypeselector-menuitem-value')]/a") @@ -54,6 +48,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_value_element(group_index, claim_index) + @browser.element(css: ".wb-claimlistview:nth-child(#{group_index}) div.listview-item:nth-child(#{claim_index}) div.wb-snak-value a") + end + def edit_claim(group_index, claim_index) edit_claim_element(group_index, claim_index).click end diff --git a/tests/browser/features/support/modules/wikibase_api_module.rb b/tests/browser/features/support/modules/wikibase_api_module.rb index 84a5357..13c9469 100644 --- a/tests/browser/features/support/modules/wikibase_api_module.rb +++ b/tests/browser/features/support/modules/wikibase_api_module.rb @@ -69,6 +69,7 @@ items = Hash.new handles.each do |handle| + handle = handle[0] data = '{"labels":{"en":{"language":"en","value":"' + generate_random_string(8) + '"}},"descriptions":{"en":{"language":"en","value":"' + generate_random_string(20) + '"}}}' item = wb_create_entity(data, "item") -- To view, visit https://gerrit.wikimedia.org/r/110966 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8c31e1a68b3bd3c96b42e47d74ccf13324f7e55e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Tobias Gritschacher <tobias.gritschac...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits