Tobias Gritschacher has submitted this change and it was merged. Change subject: Extended browser tests for statements UI ......................................................................
Extended browser tests for statements UI Change-Id: Icee2c9042ea44922d88742ea2ee9eb97fbfd2816 --- M selenium_cuc/features/statement.feature M selenium_cuc/features/step_definitions/description_steps.rb M selenium_cuc/features/step_definitions/entity_steps.rb M selenium_cuc/features/step_definitions/label_steps.rb M selenium_cuc/features/step_definitions/statement_steps.rb M selenium_cuc/features/support/modules/entity_selector_module.rb M selenium_cuc/features/support/modules/statement_module.rb M selenium_cuc/features/support/utils/utils.rb 8 files changed, 136 insertions(+), 16 deletions(-) Approvals: Tobias Gritschacher: Verified; Looks good to me, approved diff --git a/selenium_cuc/features/statement.feature b/selenium_cuc/features/statement.feature index 41a835b..c1fae52 100644 --- a/selenium_cuc/features/statement.feature +++ b/selenium_cuc/features/statement.feature @@ -45,3 +45,62 @@ | cancel | | click the statement cancel button | | press the ESC key in the entity selector input field | + + @ui_only + Scenario: Select a property + 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 + Then Statement add button should be disabled + And Statement cancel button should be there + And Statement save button should be disabled + And Entity selector input element should be there + And Statement value input element should be there + + @ui_only + Scenario: Select a property and enter a statement value + 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 something as string statement value + Then Statement add button should be disabled + And Statement cancel button should be there + And Statement save button should be there + And Entity selector input element should be there + And Statement value input element should be there + + @ui_only + Scenario Outline: Cancel statement after selecting a property + 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 something as string statement value + And I <cancel> + 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 + + Examples: + | cancel | + | click the statement cancel button | + | press the ESC key in the entity selector input field | + | press the ESC key in the statement value input field | + + @ui_only + Scenario: Select a property, enter a statement value and clear the property + 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 something as string statement value + And I enter invalid in the property input field + Then Statement add button should be disabled + And Statement cancel button should be there + And Statement save button should be disabled + And Entity selector input element should be there + And Statement value input element should not be there diff --git a/selenium_cuc/features/step_definitions/description_steps.rb b/selenium_cuc/features/step_definitions/description_steps.rb index aaf375b..cc40f96 100644 --- a/selenium_cuc/features/step_definitions/description_steps.rb +++ b/selenium_cuc/features/step_definitions/description_steps.rb @@ -60,7 +60,7 @@ end Then /^Description input element should contain original description$/ do - on(ItemPage).descriptionInputField.should == @entity["description"] + on(ItemPage).descriptionInputField.should == @item_under_test["description"] end Then /^Description input element should be empty$/ do @@ -87,7 +87,7 @@ on(ItemPage) do |page| page.firstHeading.should be_true page.entityDescriptionSpan.should be_true - page.entityDescriptionSpan.should == @entity["description"] + page.entityDescriptionSpan.should == @item_under_test["description"] end end diff --git a/selenium_cuc/features/step_definitions/entity_steps.rb b/selenium_cuc/features/step_definitions/entity_steps.rb index 0c91606..42a8607 100644 --- a/selenium_cuc/features/step_definitions/entity_steps.rb +++ b/selenium_cuc/features/step_definitions/entity_steps.rb @@ -9,8 +9,16 @@ Given /^I am on an item page$/ do item_data = '{"labels":{"en":{"language":"en","value":"' + generate_random_string(8) + '"}},"descriptions":{"en":{"language":"en","value":"' + generate_random_string(20) + '"}}}' item = create_new_entity(item_data, 'item') - @entity = item + @item_under_test = item on(ItemPage).navigate_to_entity item["url"] +end + +Given /^There are properties with the following handles and datatypes:$/ do |props| + @properties = create_new_properties(props.raw) +end + +Given /^There are items with the following handles:$/ do |handles| + @items = create_new_items(handles.raw) end Given /^The copyright warning has been dismissed$/ do @@ -22,9 +30,9 @@ end Given /^I am on an item page with empty label and description$/ do - item_data = '{"labels":{"en":{"language":"en","value":"' + "" + '"}},"descriptions":{"en":{"language":"en","value":"' + "" + '"}}}' + item_data = '{"labels":{"en":{"language":"en","value":"' + '' + '"}},"descriptions":{"en":{"language":"en","value":"' + '' + '"}}}' item = create_new_entity(item_data, 'item') - @entity = item + @item_under_test = item on(ItemPage).navigate_to_entity item["url"] end diff --git a/selenium_cuc/features/step_definitions/label_steps.rb b/selenium_cuc/features/step_definitions/label_steps.rb index ff31e1e..fe12a28 100644 --- a/selenium_cuc/features/step_definitions/label_steps.rb +++ b/selenium_cuc/features/step_definitions/label_steps.rb @@ -60,7 +60,7 @@ end Then /^Label input element should contain original label$/ do - on(ItemPage).labelInputField.should == @entity["label"] + on(ItemPage).labelInputField.should == @item_under_test["label"] end Then /^Label input element should be empty$/ do @@ -87,8 +87,8 @@ on(ItemPage) do |page| page.firstHeading.should be_true page.entityLabelSpan.should be_true - @browser.title.include?(@entity["label"]).should be_true - page.entityLabelSpan.should == @entity["label"] + @browser.title.include?(@item_under_test["label"]).should be_true + page.entityLabelSpan.should == @item_under_test["label"] end end @@ -104,7 +104,7 @@ Then /^Entity id should be displayed next to the label$/ do on(ItemPage) do |page| page.entityIdSpan_element.visible?.should be_true - page.entityIdSpan.sub(/[()]/, '') == @entity["label"] + page.entityIdSpan.sub(/[()]/, '') == @item_under_test["label"] end end diff --git a/selenium_cuc/features/step_definitions/statement_steps.rb b/selenium_cuc/features/step_definitions/statement_steps.rb index 51b7429..6bf9963 100644 --- a/selenium_cuc/features/step_definitions/statement_steps.rb +++ b/selenium_cuc/features/step_definitions/statement_steps.rb @@ -14,6 +14,29 @@ on(ItemPage).cancelStatement end +When /^I select the property (.+)$/ do |handle| + on(ItemPage) do |page| + page.select_entity(@properties[handle]["label"]) + page.wait_for_property_value_box + end +end + +When /^I enter (.+) in the property input field$/ do |value| + on(ItemPage) do |page| + page.entitySelectorInput_element.clear + page.entitySelectorInput = value + page.ajax_wait + end +end + +When /^I enter (.+) as string statement value$/ do |value| + on(ItemPage).statementValueInputField = value +end + +When /^I press the ESC key in the statement value input field$/ do + on(ItemPage).statementValueInputField_element.send_keys :escape +end + Then /^Statement help field should be there$/ do on(ItemPage).statementHelpField?.should be_true end @@ -53,7 +76,7 @@ end Then /^Statement value input element should be there$/ do - on(ItemPage).statementValueInput?.should be_true + on(ItemPage).statementValueInputField?.should be_true end Then /^Statement value input element should not be there$/ do diff --git a/selenium_cuc/features/support/modules/entity_selector_module.rb b/selenium_cuc/features/support/modules/entity_selector_module.rb index 6e19727..1bed0b9 100644 --- a/selenium_cuc/features/support/modules/entity_selector_module.rb +++ b/selenium_cuc/features/support/modules/entity_selector_module.rb @@ -16,15 +16,14 @@ text_field(:entitySelectorInput, xpath: "//div[contains(@class, 'wb-claimlistview')]//input[contains(@class, 'ui-entityselector-input')]", index: 0) text_field(:entitySelectorInput2, xpath: "//div[contains(@class, 'wb-claimlistview')]//input[contains(@class, 'ui-entityselector-input')]", index: 1) - #ul(:entitySelectorList, class: "ui-entityselector-list") - #a(:firstEntitySelectorLink, xpath: "//ul[contains(@class, 'ui-entityselector-list')]/li/a") + ul(:entitySelectorList, class: "ui-entityselector-list") + a(:firstEntitySelectorLink, xpath: "//ul[contains(@class, 'ui-entityselector-list')]/li/a") #span(:firstEntitySelectorLabel, xpath: "//ul[contains(@class, 'ui-entityselector-list')]/li/a/span/span[contains(@class, 'ui-entityselector-label')]") #span(:firstEntitySelectorDescription, xpath: "//ul[contains(@class, 'ui-entityselector-list')]/li/a/span/span[contains(@class, 'ui-entityselector-description')]") #text_field(:entitySelectorInput2, xpath: "//div[contains(@class, 'wb-claimlistview')]//input[contains(@class, 'ui-entityselector-input')]", index: 1) #text_field(:entitySelectorSearchInput, id: "searchInput") #ul(:entitySelectorSearch, xpath: "//body/ul[contains(@class, 'ui-entityselector-list')]") -=begin def wait_for_entity_selector_list wait_until do entitySelectorList? @@ -45,6 +44,7 @@ ajax_wait end +=begin def count_search_results entitySelectorSearch_element.items end diff --git a/selenium_cuc/features/support/modules/statement_module.rb b/selenium_cuc/features/support/modules/statement_module.rb index 7f73d9c..71d4025 100644 --- a/selenium_cuc/features/support/modules/statement_module.rb +++ b/selenium_cuc/features/support/modules/statement_module.rb @@ -21,11 +21,12 @@ a(:cancelStatementDisabled, css: ".wb-claimlistview div.listview-item.wb-new a.wikibase-toolbareditgroup-cancelbutton.wikibase-toolbarbutton-disabled") textarea(:statementValueInput, xpath: "//div[contains(@class, 'wb-claimlistview')]//input[contains(@class, 'valueview-input')]") span(:statementHelpField, :css => "div.wb-claimlistview span.mw-help-field-hint") + text_field(:statementValueInputField, class: "valueview-input") #a(:addClaimToFirstStatement, css: "div.wb-claimlistview:nth-child(1) > span.wb-addtoolbar a:not(.wikibase-toolbarbutton-disabled)") #a(:editFirstStatement, css: "span.wb-edittoolbar > span > span > span.wikibase-toolbareditgroup-innoneditmode > span > a:not(.wikibase-toolbarbutton-disabled):nth-child(1)") #a(:removeClaimButton, xpath: "//span[contains(@class, 'wb-edittoolbar')]/span/span/span[contains(@class, 'wikibase-toolbareditgroup-ineditmode')]/span/a[not(contains(@class, 'wikibase-toolbarbutton-disabled'))][text()='remove']") - #text_field(:statementValueInputField, class: "valueview-input") + #div(:claimEditMode, xpath: "//div[contains(@class, 'wb-claim-section')]/div[contains(@class, 'wb-edit')]") #div(:statement1Name, xpath: "//div[contains(@class, 'wb-claimlistview')][1]//div[contains(@class, 'wb-claim-name')]") #div(:statement2Name, xpath: "//div[contains(@class, 'wb-claimlistview')][2]//div[contains(@class, 'wb-claim-name')]") @@ -44,13 +45,13 @@ #a(:snaktypeSelectorNovalue, xpath: "//ul[contains(@class, 'wb-snaktypeselector-menu')]/li[contains(@class, 'wb-snaktypeselector-menuitem-novalue')]/a") #span(:previewSpinner, class: "mw-small-spinner") -=begin def wait_for_property_value_box wait_until do self.statementValueInput? || self.statementValueInputField? end end +=begin def wait_for_statement_request_finished wait_until do self.claimEditMode? == false diff --git a/selenium_cuc/features/support/utils/utils.rb b/selenium_cuc/features/support/utils/utils.rb index 39d99cd..6a5344f 100644 --- a/selenium_cuc/features/support/utils/utils.rb +++ b/selenium_cuc/features/support/utils/utils.rb @@ -16,6 +16,35 @@ return string end +def create_new_properties(props) + properties = Hash.new + + props.each do |prop| + handle = prop[0] + type = prop[1] + data = '{"labels":{"en":{"language":"en","value":"' + generate_random_string(8) + + '"}},"descriptions":{"en":{"language":"en","value":"' + generate_random_string(20) + + '"}},"datatype":"' + type + '"}' + property = create_new_entity(data, 'property') + properties[handle] = property + end + + properties +end + +def create_new_items(handles) + items = Hash.new + + handles.each do |handle| + data = '{"labels":{"en":{"language":"en","value":"' + generate_random_string(8) + + '"}},"descriptions":{"en":{"language":"en","value":"' + generate_random_string(20) + '"}}}' + item = create_new_entity(data, 'item') + items[handle] = item + end + + items +end + # creates a new entity via the API def create_new_entity(data, type = 'item') uri = URI(URL.repo_api) @@ -36,7 +65,7 @@ resp = ActiveSupport::JSON.decode(response.body) if resp["success"] != 1 - abort("Failed to create new entity: API error") + abort("Failed to create new entity: API error: " + resp["error"]["info"]) end id = resp["entity"]["id"] -- To view, visit https://gerrit.wikimedia.org/r/96671 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Icee2c9042ea44922d88742ea2ee9eb97fbfd2816 Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Tobias Gritschacher <tobias.gritschac...@wikimedia.de> Gerrit-Reviewer: Tobias Gritschacher <tobias.gritschac...@wikimedia.de> 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