Tobias Gritschacher has submitted this change and it was merged. Change subject: Selenium tests for autocomments/autosummaries ......................................................................
Selenium tests for autocomments/autosummaries Change-Id: I457f42dd4e8a65dd369b3c8cadbc8950d423924d --- A repo/tests/selenium/item/autocomments_spec.rb M repo/tests/selenium/statements/qualifiers_spec.rb M selenium/Rakefile M selenium/lib/modules/qualifiers_module.rb M selenium/lib/modules/statement_module.rb M selenium/lib/pages/history_page.rb 6 files changed, 244 insertions(+), 4 deletions(-) Approvals: Tobias Gritschacher: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/repo/tests/selenium/item/autocomments_spec.rb b/repo/tests/selenium/item/autocomments_spec.rb new file mode 100644 index 0000000..6be315a --- /dev/null +++ b/repo/tests/selenium/item/autocomments_spec.rb @@ -0,0 +1,220 @@ +# -*- encoding : utf-8 -*- +# Wikidata UI tests +# +# Author:: Tobias Gritschacher (tobias.gritschac...@wikimedia.de) +# License:: GNU GPL v2+ +# +# tests for autocomments + +require 'spec_helper' + +num_items = 2 +num_props_string = 3 +#num_props_item = 1 + +# 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_string = Array.new +string_values = Array.new +while count < num_props_string do + properties_string.push({"label"=>generate_random_string(10), "description"=>generate_random_string(20), "datatype"=>"String"}) + string_values.push({"value"=>generate_random_string(10), "changed_value"=>generate_random_string(10)}) + 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 + +describe "Check AC/AS" 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_string.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 "autocomments/autosummaries setClaim" do + it "should check add claim AC/AS" do + on_page(ItemPage) do |page| + page.navigate_to items[0]["url"] + page.wait_for_entity_to_load + page.add_statement(properties_string[0]["label"], string_values[0]["value"]) + end + on_page(HistoryPage) do |page| + page.navigate_to_item_history + page.autocomment1.include?("Created claim:").should == true + page.autosummary1.include?("Property:" + PROPERTY_ID_PREFIX + properties_string[0]["id"] + ": " + string_values[0]["value"]).should == true + end + end + it "should check add one qualifier AC/AS" do + on_page(ItemPage) do |page| + page.navigate_to items[0]["url"] + page.wait_for_entity_to_load + page.add_qualifier_to_first_claim(properties_string[1]["label"], string_values[1]["value"]) + end + on_page(HistoryPage) do |page| + page.navigate_to_item_history + page.autocomment1.include?("Changed one qualifier of claim:").should == true + page.autosummary1.include?("Property:" + PROPERTY_ID_PREFIX + properties_string[0]["id"] + ": " + string_values[0]["value"]).should == true + end + end + it "should check edit one qualifier AC/AS" do + on_page(ItemPage) do |page| + page.navigate_to items[0]["url"] + page.wait_for_entity_to_load + page.editFirstStatement + page.qualifierValueInput1_element.clear + page.qualifierValueInput1 = string_values[1]["changed_value"] + ajax_wait + page.saveStatement + ajax_wait + page.wait_for_statement_request_finished + end + on_page(HistoryPage) do |page| + page.navigate_to_item_history + page.autocomment1.include?("Changed 2 qualifiers of claim:").should == true + page.autosummary1.include?("Property:" + PROPERTY_ID_PREFIX + properties_string[0]["id"] + ": " + string_values[0]["value"]).should == true + end + end + it "should check remove one qualifier AC/AS" do + on_page(ItemPage) do |page| + page.navigate_to items[0]["url"] + page.wait_for_entity_to_load + page.editFirstStatement + page.removeQualifierLine1 + page.saveStatement + ajax_wait + page.wait_for_statement_request_finished + end + on_page(HistoryPage) do |page| + page.navigate_to_item_history + page.autocomment1.include?("Changed one qualifier of claim:").should == true + page.autosummary1.include?("Property:" + PROPERTY_ID_PREFIX + properties_string[0]["id"] + ": " + string_values[0]["value"]).should == true + end + end + it "should check add two qualifiers AC/AS" do + on_page(ItemPage) do |page| + page.navigate_to items[0]["url"] + page.wait_for_entity_to_load + page.editFirstStatement + page.addQualifier + page.entitySelectorInput = properties_string[1]["label"] + ajax_wait + page.wait_for_qualifier_value_box + page.qualifierValueInput1 = string_values[1]["value"] + ajax_wait + page.addQualifier + page.entitySelectorInput2 = properties_string[2]["label"] + ajax_wait + page.wait_for_qualifier_value_box + page.qualifierValueInput2 = string_values[2]["value"] + ajax_wait + page.saveStatement + ajax_wait + page.wait_for_statement_request_finished + end + on_page(HistoryPage) do |page| + page.navigate_to_item_history + page.autocomment1.include?("Changed 2 qualifiers of claim:").should == true + page.autosummary1.include?("Property:" + PROPERTY_ID_PREFIX + properties_string[0]["id"] + ": " + string_values[0]["value"]).should == true + end + end + it "should check edit claim AC/AS" do + on_page(ItemPage) do |page| + page.navigate_to items[0]["url"] + page.wait_for_entity_to_load + page.edit_first_statement(string_values[0]["changed_value"]) + end + on_page(HistoryPage) do |page| + page.navigate_to_item_history + page.autocomment1.include?("Changed claim:").should == true + page.autosummary1.include?("Property:" + PROPERTY_ID_PREFIX + properties_string[0]["id"] + ": " + string_values[0]["changed_value"]).should == true + end + end + it "should check edit claim & two qualifiers AC/AS" do + on_page(ItemPage) do |page| + page.navigate_to items[0]["url"] + page.wait_for_entity_to_load + page.editFirstStatement + page.statementValueInput_element.clear + page.statementValueInput = string_values[0]["value"] + ajax_wait + page.qualifierValueInput1_element.clear + page.qualifierValueInput1 = string_values[1]["changed_value"] + ajax_wait + page.qualifierValueInput2_element.clear + page.qualifierValueInput2 = string_values[2]["changed_value"] + ajax_wait + page.saveStatement + ajax_wait + page.wait_for_statement_request_finished + end + on_page(HistoryPage) do |page| + page.navigate_to_item_history + page.autocomment1.include?("Changed claim:").should == true + page.autosummary1.include?("Property:" + PROPERTY_ID_PREFIX + properties_string[0]["id"] + ": " + string_values[0]["value"]).should == true + end + end + it "should check remove two qualifiers AC/AS" do + on_page(ItemPage) do |page| + page.navigate_to items[0]["url"] + page.wait_for_entity_to_load + page.editFirstStatement + page.removeQualifierLine2 + page.removeQualifierLine1 + page.saveStatement + ajax_wait + page.wait_for_statement_request_finished + end + on_page(HistoryPage) do |page| + page.navigate_to_item_history + page.autocomment1.include?("Changed 2 qualifiers of claim:").should == true + page.autosummary1.include?("Property:" + PROPERTY_ID_PREFIX + properties_string[0]["id"] + ": " + string_values[0]["value"]).should == true + end + end + end + context "autocomments/autosummaries removeClaim" do + it "should check remove claim AC/AS" do + on_page(ItemPage) do |page| + page.navigate_to items[1]["url"] + page.wait_for_entity_to_load + page.add_statement(properties_string[0]["label"], string_values[0]["value"]) + page.editFirstStatement + page.removeClaimButton + ajax_wait + page.wait_for_statement_request_finished + end + on_page(HistoryPage) do |page| + page.navigate_to_item_history + page.autocomment1.include?("Removed claim:").should == true + page.autosummary1.include?("Property:" + PROPERTY_ID_PREFIX + properties_string[0]["id"] + ": " + string_values[0]["value"]).should == true + end + end + end + + after :all do + # tear down + end +end diff --git a/repo/tests/selenium/statements/qualifiers_spec.rb b/repo/tests/selenium/statements/qualifiers_spec.rb index 08ec183..fcd99f2 100644 --- a/repo/tests/selenium/statements/qualifiers_spec.rb +++ b/repo/tests/selenium/statements/qualifiers_spec.rb @@ -240,7 +240,7 @@ end end - it "should check editing a reference" do + it "should check editing a qualifier" do on_page(ItemPage) do |page| page.navigate_to items[0]["url"] page.wait_for_entity_to_load diff --git a/selenium/Rakefile b/selenium/Rakefile index 38a309d..3d2ea5f 100644 --- a/selenium/Rakefile +++ b/selenium/Rakefile @@ -268,6 +268,11 @@ spec.pattern = '../repo/tests/selenium/item/ip_notification_spec.rb' end +RSpec::Core::RakeTask.new(:autocomments) do |spec| + spec.ruby_opts = "-I lib:spec" + spec.pattern = '../repo/tests/selenium/item/autocomments_spec.rb' +end + task :run_tests, :taskname, :browser, :remote, :os do |t, args| task = args[:taskname] || :all setup_env(args[:browser], args[:remote], args[:os]) diff --git a/selenium/lib/modules/qualifiers_module.rb b/selenium/lib/modules/qualifiers_module.rb index d9106f6..7d3e3b3 100644 --- a/selenium/lib/modules/qualifiers_module.rb +++ b/selenium/lib/modules/qualifiers_module.rb @@ -8,7 +8,7 @@ module ReferencePage include PageObject - # references UI elements + # qualifiers UI elements div(:qualifiersContainer, :class => "wb-claim-qualifiers") link(:addQualifier, :xpath => "//div[contains(@class, 'wb-claim-qualifiers')]/div[contains(@class, 'wb-snaklistview')]/span[contains(@class, 'wb-addtoolbar')]/div/span/span/a[text()='add qualifier']") link(:removeQualifierLine1, :xpath => "//div[contains(@class, 'wb-claim-qualifiers')]/div[contains(@class, 'wb-snaklistview')]/div[contains(@class, 'wb-snaklistview-listview')]/div[contains(@class, 'wb-snakview')][1]/span[contains(@class, 'wb-removetoolbar')]/div/span/span/a[text()='remove']") @@ -33,13 +33,14 @@ def add_qualifier_to_first_claim(property, value) editFirstStatement + addQualifier self.entitySelectorInput = property ajax_wait wait_for_entity_selector_list wait_for_qualifier_value_box self.qualifierValueInput1 = value ajax_wait - saveReference + saveStatement ajax_wait wait_for_statement_request_finished end diff --git a/selenium/lib/modules/statement_module.rb b/selenium/lib/modules/statement_module.rb index 39f0109..a7a9c0d 100644 --- a/selenium/lib/modules/statement_module.rb +++ b/selenium/lib/modules/statement_module.rb @@ -38,7 +38,7 @@ def wait_for_property_value_box wait_until do - self.statementValueInput + self.statementValueInput? end end @@ -64,6 +64,17 @@ self.wait_for_statement_request_finished end + def edit_first_statement(statement_value) + editFirstStatement + self.wait_for_property_value_box + self.statementValueInput_element.clear + self.statementValueInput = statement_value + ajax_wait + saveStatement + ajax_wait + self.wait_for_statement_request_finished + end + def add_claim_to_first_statement(statement_value) addClaimToFirstStatement self.wait_for_property_value_box diff --git a/selenium/lib/pages/history_page.rb b/selenium/lib/pages/history_page.rb index 4db3859..1f59126 100644 --- a/selenium/lib/pages/history_page.rb +++ b/selenium/lib/pages/history_page.rb @@ -23,6 +23,9 @@ link(:undo8, :css => "ul#pagehistory > li:nth-child(8) > span.mw-history-undo > a") link(:undo9, :css => "ul#pagehistory > li:nth-child(9) > span.mw-history-undo > a") + span(:autocomment1, :xpath => "//ul[@id='pagehistory']/li[1]/span[contains(@class, 'comment')]/span/span[contains(@class, 'autocomment')]") + span(:autosummary1, :xpath => "//ul[@id='pagehistory']/li[1]/span[contains(@class, 'comment')]/span") + link(:curLink4, :css => "ul#pagehistory > li:nth-child(4) > span.mw-history-histlinks > a") link(:oldRevision5, :css => "ul#pagehistory > li:nth-child(5) > a") link(:restoreLink, :css => "div#mw-diff-otitle1 > strong > a:nth-child(2)") -- To view, visit https://gerrit.wikimedia.org/r/60252 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I457f42dd4e8a65dd369b3c8cadbc8950d423924d Gerrit-PatchSet: 5 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: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits