Tobias Gritschacher has uploaded a new change for review. https://gerrit.wikimedia.org/r/52810
Change subject: (testing) adding selenium tests for delted-property/item-handling in UI ...................................................................... (testing) adding selenium tests for delted-property/item-handling in UI Change-Id: Ia84b94cb3ea74ed7f8b2b02686528d6956e4a914 --- A repo/tests/selenium/statements/statements_deleted_prop_spec.rb M selenium/Rakefile M selenium/lib/modules/reference_module.rb A selenium/lib/pages/delete_entity_page.rb 4 files changed, 225 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/10/52810/1 diff --git a/repo/tests/selenium/statements/statements_deleted_prop_spec.rb b/repo/tests/selenium/statements/statements_deleted_prop_spec.rb new file mode 100644 index 0000000..f6eab06 --- /dev/null +++ b/repo/tests/selenium/statements/statements_deleted_prop_spec.rb @@ -0,0 +1,185 @@ +# -*- encoding : utf-8 -*- +# Wikidata UI tests +# +# Author:: Tobias Gritschacher ([email protected]) +# License:: GNU GPL v2+ +# +# tests for statements with deleted properties + +require 'spec_helper' + +num_items = 2#3 +num_props_cm = 1#2 +num_props_item = 1#2 + +cm_string = "Abc.jpg" + +# TODO: this whole entitycreation stuff should be refactored out from here +# items +count = 0 +items = Array.new +while count < num_items do + items.push({"label"=>generate_random_string(10), "description"=>generate_random_string(20)}) + count = count + 1 +end + +# commons media properties +count = 0 +properties_cm = Array.new +while count < num_props_cm do + properties_cm.push({"label"=>generate_random_string(10), "description"=>generate_random_string(20), "datatype"=>"Commons media file"}) + count = count + 1 +end + +# item properties +count = 0 +properties_item = Array.new +while count < num_props_item do + properties_item.push({"label"=>generate_random_string(10), "description"=>generate_random_string(20), "datatype"=>"Item"}) + count = count + 1 +end + +statement_value = generate_random_string(10) +statement_value_changed = generate_random_string(10) + +describe "Check deleted properties in statements UI" do + before :all do + # set up: create items & properties + items.each do |item| + visit_page(CreateItemPage) do |page| + item['id'] = page.create_new_item(item['label'], item['description']) + item['url'] = page.current_url + end + end + properties_cm.each do |property| + visit_page(NewPropertyPage) do |page| + property['id'] = page.create_new_property(property['label'], property['description'], property['datatype']) + property['url'] = page.current_url + end + end + properties_item.each do |property| + visit_page(NewPropertyPage) do |page| + property['id'] = page.create_new_property(property['label'], property['description'], property['datatype']) + property['url'] = page.current_url + end + end + end + + context "Check statements UI with deleted CM type property" do + it "should create statements & add reference" do + on_page(ItemPage) do |page| + page.navigate_to items[0]["url"] + page.wait_for_entity_to_load + page.add_statement(properties_cm[0]["label"], cm_string) + # TODO: refresh needed because of bug 44101 & bug 44547 + #@browser.refresh + page.add_reference_to_first_claim(properties_cm[0]["label"], cm_string) + page.statement1Name.should == properties_cm[0]["label"] + page.statement1ClaimValue1.should == cm_string + page.reference1Property.should == properties_cm[0]["label"] + page.reference1Value.should == cm_string + end + end + it "should delete related property" do + visit_page(RepoLoginPage) do |page| + page.login_with(WIKI_ADMIN_USERNAME, WIKI_ADMIN_PASSWORD) + end + visit_page(DeleteEntityPage) do |page| + page.delete_entity(properties_cm[0]["url"]) + end + end + it "should check correct UI behavior on deleted property" do + on_page(ItemPage) do |page| + page.navigate_to items[0]["url"] + page.wait_for_entity_to_load + page.statement1Name.should_not == properties_cm[0]["label"] + page.statement1Name.include?(properties_cm[0]["id"]).should be_true + page.statement1Name.include?("Deleted property").should be_true + page.editFirstStatement + page.statementValueInput.should == cm_string + page.statementValueInput_element.clear + page.statementValueInput = "changed" + page.saveStatement + ajax_wait + page.wbErrorDiv?.should be_true + page.cancelStatement + page.referenceHeadingToggleLink + page.wait_for_referencesToggle + page.reference1Property.should_not == properties_cm[0]["label"] + page.reference1Property.include?(properties_cm[0]["id"]).should be_true + page.reference1Property.include?("Deleted property").should be_true + page.reference1ValueLink?.should be_false + page.editReference1 + page.referenceValueInput.should == cm_string + # TODO: should it be allowed to edit a reference whose property was deleted? + #page.referenceValueInput_element.clear + #page.referenceValueInput = "changed" + #page.saveReference + #ajax_wait + #page.wbErrorDiv?.should be_true + #page.cancelReference + end + end + end + + context "Check statements UI with deleted ITEM type property" do + it "should create statements & add reference" do + on_page(ItemPage) do |page| + page.navigate_to items[1]["url"] + page.wait_for_entity_to_load + page.add_statement(properties_item[0]["label"], items[0]["label"]) + page.add_reference_to_first_claim(properties_item[0]["label"], items[0]["label"]) + page.statement1Name.should == properties_item[0]["label"] + page.statement1ClaimValue1.should == items[0]["label"] + page.reference1Property.should == properties_item[0]["label"] + page.reference1Value.should == items[0]["label"] + end + end + it "should delete related property" do + visit_page(RepoLoginPage) do |page| + page.login_with(WIKI_ADMIN_USERNAME, WIKI_ADMIN_PASSWORD) + end + visit_page(DeleteEntityPage) do |page| + page.delete_entity(properties_item[0]["url"]) + end + end + it "should check correct UI behavior on deleted property" do + on_page(ItemPage) do |page| + page.navigate_to items[1]["url"] + page.wait_for_entity_to_load + page.statement1Name.should_not == properties_item[0]["label"] + page.statement1Name.include?(properties_item[0]["id"]).should be_true + page.statement1Name.include?("Deleted property").should be_true + # TODO: there's still a bug in the UI showing the referenced item as "deleted": bug 45904 + #page.editFirstStatement + #page.statementValueInput.should == cm_string + #page.statementValueInput_element.clear + #page.statementValueInput = items[0]["label"] + #page.saveStatement + #ajax_wait + #page.wbErrorDiv?.should be_true + #page.cancelStatement + page.referenceHeadingToggleLink + page.wait_for_referencesToggle + page.reference1Property.should_not == properties_item[0]["label"] + page.reference1Property.include?(properties_item[0]["id"]).should be_true + page.reference1Property.include?("Deleted property").should be_true + # TODO: there's still a bug in the UI showing the referenced item as "deleted": bug 45904 + #page.reference1ValueLink?.should be_false + #page.editReference1 + #page.referenceValueInput.should == cm_string + # TODO: should it be allowed to edit a reference whose property was deleted? + #page.referenceValueInput_element.clear + #page.referenceValueInput = "changed" + #page.saveReference + #ajax_wait + #page.wbErrorDiv?.should be_true + #page.cancelReference + end + end + end + + after :all do + # tear down + end +end diff --git a/selenium/Rakefile b/selenium/Rakefile index ffdf1e1..7753f12 100644 --- a/selenium/Rakefile +++ b/selenium/Rakefile @@ -210,7 +210,7 @@ RSpec::Core::RakeTask.new(:statements) do |spec| spec.ruby_opts = "-I lib:spec" - spec.pattern = '../repo/tests/selenium/statements/{statements_spec.rb,statements_cm_spec.rb,statements_item_spec.rb,statements_string_spec.rb,references_spec.rb}' + spec.pattern = '../repo/tests/selenium/statements/{statements_spec.rb,statements_cm_spec.rb,statements_item_spec.rb,statements_string_spec.rb,references_spec.rb,statements_deleted_prop_spec.rb}' end RSpec::Core::RakeTask.new(:statements_basic) do |spec| @@ -238,6 +238,11 @@ spec.pattern = '../repo/tests/selenium/statements/statements_bugs_spec.rb' end +RSpec::Core::RakeTask.new(:statements_deleted_prop) do |spec| + spec.ruby_opts = "-I lib:spec" + spec.pattern = '../repo/tests/selenium/statements/statements_deleted_prop_spec.rb' +end + RSpec::Core::RakeTask.new(:references) do |spec| spec.ruby_opts = "-I lib:spec" spec.pattern = '../repo/tests/selenium/statements/references_spec.rb' diff --git a/selenium/lib/modules/reference_module.rb b/selenium/lib/modules/reference_module.rb index 63ba9b3..f4cea8a 100644 --- a/selenium/lib/modules/reference_module.rb +++ b/selenium/lib/modules/reference_module.rb @@ -21,7 +21,9 @@ div(:reference2Value, :xpath => "//div[contains(@class, 'wb-referenceview')][2]/div[contains(@class, 'wb-reference-snaks')]/div[contains(@class, 'wb-snak-value-container')]/div[contains(@class, 'wb-snak-value')]/div/div") div(:reference3Value, :xpath => "//div[contains(@class, 'wb-referenceview')][3]/div[contains(@class, 'wb-reference-snaks')]/div[contains(@class, 'wb-snak-value-container')]/div[contains(@class, 'wb-snak-value')]/div/div") link(:reference1ValueLink, :xpath => "//div[contains(@class, 'wb-referenceview')][1]/div[contains(@class, 'wb-reference-snaks')]/div[contains(@class, 'wb-snak-value-container')]/div[contains(@class, 'wb-snak-value')]/div/div/a") - text_area(:referenceValueInput, :xpath => "//div[contains(@class, 'valueview-ineditmode')]/div/a/textarea[contains(@class, 'valueview-input')]") + # TODO: could this lead to problems? for CM & item type properties there is an additional "a" element around the textbox; this is not the case for string type properies + #text_area(:referenceValueInput, :xpath => "//div[contains(@class, 'valueview-ineditmode')]/div/a/textarea[contains(@class, 'valueview-input')]") + text_area(:referenceValueInput, :class => "valueview-input") link(:saveReference, :xpath => "//div[contains(@class, 'wb-claim-toolbar')]/span/span/span[contains(@class, 'wb-ui-toolbar-editgroup-ineditmode')]/span/a[text()='save']") link(:cancelReference, :xpath => "//div[contains(@class, 'wb-claim-toolbar')]/span/span/span[contains(@class, 'wb-ui-toolbar-editgroup-ineditmode')]/span/a[text()='cancel']") link(:removeReference, :xpath => "//div[contains(@class, 'wb-claim-toolbar')]/span/span/span[contains(@class, 'wb-ui-toolbar-editgroup-ineditmode')]/span/a[text()='remove']") @@ -40,4 +42,17 @@ end end + def add_reference_to_first_claim(property, value) + addReferenceToFirstClaim + self.entitySelectorInput = property + ajax_wait + wait_for_entity_selector_list + wait_for_reference_value_box + self.referenceValueInput = value + ajax_wait + saveReference + ajax_wait + wait_for_statement_request_finished + end + end diff --git a/selenium/lib/pages/delete_entity_page.rb b/selenium/lib/pages/delete_entity_page.rb new file mode 100644 index 0000000..c4d77a3 --- /dev/null +++ b/selenium/lib/pages/delete_entity_page.rb @@ -0,0 +1,18 @@ +# -*- encoding : utf-8 -*- +# Wikidata UI tests +# +# Author:: Tobias Gritschacher ([email protected]) +# License:: GNU GPL v2+ +# +# page object for delete entity action + +class DeleteEntityPage < ItemPage + include PageObject + + button(:delete, :id => 'wpConfirmB') + + def delete_entity(entity_url) + navigate_to(entity_url + "?action=delete") + delete + end +end -- To view, visit https://gerrit.wikimedia.org/r/52810 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia84b94cb3ea74ed7f8b2b02686528d6956e4a914 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Tobias Gritschacher <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
