diff --git a/tests/browser/features/reference.feature b/tests/browser/features/reference.feature index 2c0bed9..8e2b85f 100644 --- a/tests/browser/features/reference.feature +++ b/tests/browser/features/reference.feature @@ -1,24 +1,36 @@ # Wikidata UI tests # # Author:: Tobias Gritschacher (tobias.gritschacher@wikimedia.de) # License:: GNU GPL v2+ # # feature definition for references @wikidata.beta.wmflabs.org Feature: Adding references to statements Background: - Given I am on an item page - And The copyright warning has been dismissed - And Anonymous edit warnings are disabled - And I have the following properties with datatype: - | stringprop | string | - And I have statements with the following properties and values: - | stringprop | reference test | + Given I have an item to test + And I have the following properties with datatype: + | stringprop | string | + And I have statements with the following properties and values: + | stringprop | reference test | + And I am on the page of the item to test + And The copyright warning has been dismissed + And Anonymous edit warnings are disabled @ui_only Scenario: Reference UI has all required elements Then Reference add button should be there And Reference cancel button should not be there - And Reference counter should be there \ No newline at end of file + And Reference counter should be there + + @ui_only + Scenario: Click the Add Reference button + When I click the reference add button + Then Reference add button should be disabled + And Reference save button should be disabled + And Reference add snak button should be disabled + And Reference remove snak button should be disabled + And Reference remove button should not be there + And Reference cancel button should be there + And Reference snak property input field should be there diff --git a/tests/browser/features/step_definitions/reference_steps.rb b/tests/browser/features/step_definitions/reference_steps.rb index 529b989..52880d2 100644 --- a/tests/browser/features/step_definitions/reference_steps.rb +++ b/tests/browser/features/step_definitions/reference_steps.rb @@ -1,19 +1,19 @@ # -*- encoding : utf-8 -*- # Wikidata UI tests # # Author:: Tobias Gritschacher (tobias.gritschacher@wikimedia.de) # License:: GNU GPL v2+ # # steps for references Then(/^Reference add button should be there$/) do expect(on(ItemPage).add_reference?).to be true end Then(/^Reference cancel button should not be there$/) do expect(on(ItemPage).cancel_reference?).to be false end Then(/^Reference counter should be there$/) do - expect(on(ItemPage).reference_counter).to be true + expect(on(ItemPage).reference_counter?).to be true end diff --git a/tests/browser/features/support/modules/entity_module.rb b/tests/browser/features/support/modules/entity_module.rb index b6eb823..b2518ba 100644 --- a/tests/browser/features/support/modules/entity_module.rb +++ b/tests/browser/features/support/modules/entity_module.rb @@ -1,140 +1,139 @@ # -*- encoding : utf-8 -*- # Wikidata UI tests # # Author:: Tobias Gritschacher (tobias.gritschacher@wikimedia.de) # License:: GNU GPL v2+ # # page object for entity page #require "ruby_selenium" module EntityPage include PageObject include SitelinkPage include AliasPage include StatementPage - include ReferencePage include ULSPage @@property_url = "" @@property_id = "" @@item_url = "" @@item_id = "" # ***** ACCESSORS ***** # label UI h1(:mw_first_heading, id: "firstHeading") h1(:first_heading, css: "h1.wb-firstHeading") span(:entity_label_span, css: ".wikibase-labelview-text") span(:entity_id_span, css: ".wikibase-labelview-entityid") text_field(:label_input_field, css: ".wikibase-labelview-text input") a(:edit_label_link, css: "h1.wb-firstHeading a.wikibase-toolbareditgroup-editbutton:not(.wikibase-toolbarbutton-disabled)") a(:edit_label_link_disabled, css: "h1.wb-firstHeading a.wikibase-toolbareditgroup-editbutton.wikibase-toolbarbutton-disabled") a(:save_label_link, css: "h1.wb-firstHeading a.wikibase-toolbareditgroup-savebutton:not(.wikibase-toolbarbutton-disabled)") a(:save_label_link_disabled, css: "h1.wb-firstHeading a.wikibase-toolbareditgroup-savebutton.wikibase-toolbarbutton-disabled") a(:cancel_label_link, css: "h1.wb-firstHeading a.wikibase-toolbareditgroup-cancelbutton:not(.wikibase-toolbarbutton-disabled)") a(:cancel_label_link_disabled, css: "h1.wb-firstHeading a.wikibase-toolbareditgroup-cancelbutton.wikibase-toolbarbutton-disabled") # description UI span(:entity_description_span, class: "wikibase-descriptionview-text") text_field(:description_input_field, css: ".wikibase-descriptionview-text input") a(:edit_description_link, css: ".wikibase-descriptionview a.wikibase-toolbareditgroup-editbutton:not(.wikibase-toolbarbutton-disabled)") a(:edit_description_link_disabled, css: ".wikibase-descriptionview a.wikibase-toolbareditgroup-editbutton.wikibase-toolbarbutton-disabled") a(:save_description_link, css: ".wikibase-descriptionview a.wikibase-toolbareditgroup-savebutton:not(.wikibase-toolbarbutton-disabled)") a(:save_description_link_disabled, css: ".wikibase-descriptionview a.wikibase-toolbareditgroup-savebutton.wikibase-toolbarbutton-disabled") a(:cancel_description_link, css: ".wikibase-descriptionview a.wikibase-toolbareditgroup-cancelbutton:not(.wikibase-toolbarbutton-disabled)") a(:cancel_description_link_disabled, css: ".wikibase-descriptionview a.wikibase-toolbareditgroup-cancelbutton.wikibase-toolbarbutton-disabled") span(:api_call_waiting_message, class: "wb-actionmsg") # edit-tab li(:edit_tab, id: "ca-edit") # spinner div(:entity_spinner, xpath: "//div[contains(@class, 'wb-entity-spinner')]") # tooltips & error tooltips div(:wb_tooltip, class: "tipsy-inner") div(:wb_error_div, class: "wikibase-wbtooltip-error-top-message") div(:wb_error_details_div, class: "wikibase-wbtooltip-error-details") a(:wb_error_details_link, class: "wikibase-wbtooltip-error-details-link") # mw notifications div(:mw_notification_content, xpath: "//div[@id='mw-notification-area']/div/div[contains(@class, 'mw-notification-content')]") # ***** METHODS ***** def navigate_to_entity url navigate_to url wait_for_entity_to_load end def wait_for_api_callback ajax_wait api_call_waiting_message_element.when_not_visible end def wait_for_entity_to_load wait_until do entity_spinner? == false end end def wait_for_edit_label_link wait_until do edit_label_link? end end def change_label(label) if edit_label_link? edit_label_link end self.label_input_field= label save_label_link ajax_wait wait_for_api_callback end def change_description(description) if edit_description_link? edit_description_link end self.description_input_field= description save_description_link ajax_wait wait_for_api_callback end def wait_for_mw_notification_shown wait_until do mw_notification_content? == true end end def ajax_wait while (script = @browser.execute_script("return jQuery.active")) != 0 do sleep(1.0/3) end sleep 1 return true end # creates a random string def generate_random_string(length=8) chars = "abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ" string = "" length.times { string << chars[rand(chars.size)] } return string end def set_copyright_ack_cookie cookie = "$.cookie( 'wikibase.acknowledgedcopyrightversion', 'wikibase-1', { 'expires': null, 'path': '/' } );" @browser.execute_script(cookie) end def set_noanonymouseditwarning_cookie cookie = "$.cookie( 'wikibase-no-anonymouseditwarning', '1', { 'expires': null, 'path': '/' } );" @browser.execute_script(cookie) end end diff --git a/tests/browser/features/support/modules/statement_module.rb b/tests/browser/features/support/modules/statement_module.rb index b8167f7..402af27 100644 --- a/tests/browser/features/support/modules/statement_module.rb +++ b/tests/browser/features/support/modules/statement_module.rb @@ -1,141 +1,67 @@ # -*- encoding : utf-8 -*- # Wikidata UI tests # # Author:: Tobias Gritschacher (tobias.gritschacher@wikimedia.de) # License:: GNU GPL v2+ # # module for statement page module StatementPage include PageObject include EntitySelectorPage - #include ReferencePage + include ReferencePage #include QualifierPage # 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 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") 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") textarea(:statement_value_input_field, class: "valueview-input") 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)") - #a(:remove_claim_button, xpath: "//span[contains(@class, 'wb-edittoolbar')]/span/span/span[contains(@class, 'wikibase-toolbareditgroup-ineditmode')]/span/a[not(contains(@class, 'wikibase-toolbarbutton-disabled'))][text()='remove']") - #div(:claim_edit_mode, 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')]") - #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") - #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") - #a(:snaktype_selector_somevalue, xpath: "//ul[contains(@class, 'wb-snaktypeselector-menu')]/li[contains(@class, 'wb-snaktypeselector-menuitem-somevalue')]/a") - #a(:snaktype_selector_novalue, xpath: "//ul[contains(@class, 'wb-snaktypeselector-menu')]/li[contains(@class, 'wb-snaktypeselector-menuitem-novalue')]/a") - #span(:preview_spinner, class: "mw-small-spinner") - + # methods def statement_name_element(group_index) @browser.element(css: ".wb-claimlistview:nth-child(#{group_index}) div.wb-claim-name") end def statement_string_value(group_index, claim_index) @browser.element(xpath: "//div[contains(@class, 'wb-claimlistview')][#{group_index}]//div[contains(@class, 'listview-item')][#{claim_index}]//div[contains(@class, 'valueview-instaticmode')]").text 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 def edit_claim_element(group_index, claim_index) @browser.element(css: ".wb-claimlistview:nth-child(#{group_index}) div.listview-item:nth-child(#{claim_index}) a.wikibase-toolbareditgroup-editbutton:not(.wikibase-toolbarbutton-disabled)") end def wait_for_property_value_box wait_until do self.statement_value_input? || self.statement_value_input_field? end end def wait_for_statement_request_finished wait_until do self.claim_edit_mode? == false end end def wait_for_save_button save_statement_element.when_visible end def get_string_snak_value(value) return '"' + value + '"' end - -=begin - def add_statement(property_label, statement_value) - add_statement - self.entity_selector_input = property_label - ajax_wait - wait_for_entity_selector_list - self.wait_for_property_value_box - if self.statement_value_input? - self.statement_value_input = statement_value - ajax_wait - elsif self.statement_value_input_field? - self.statement_value_input_field = statement_value - ajax_wait - end - save_statement - ajax_wait - self.wait_for_statement_request_finished - end - - def edit_first_statement(statement_value) - edit_first_statement - self.wait_for_property_value_box - self.statement_value_input_element.clear - self.statement_value_input = statement_value - ajax_wait - save_statement - ajax_wait - self.wait_for_statement_request_finished - end - - def add_claim_to_first_statement(statement_value) - add_claim_to_first_statement - self.wait_for_property_value_box - self.statement_value_input = statement_value - save_statement - ajax_wait - self.wait_for_statement_request_finished - end - - def remove_all_claims - while edit_first_statement? - edit_first_statement - remove_claim_button - ajax_wait - self.wait_for_statement_request_finished - end - end - - def change_snaktype(type) - snaktype_selector_icon_element.click - if type == "value" - self.snaktype_selector_value - elsif type == "somevalue" - self.snaktype_selector_somevalue - elsif type == "novalue" - self.snaktype_selector_novalue - end - end -=end end