diff --git a/tests/browser/features/sitelinks.feature b/tests/browser/features/sitelinks.feature index 3bb7d05..ce46934 100644 --- a/tests/browser/features/sitelinks.feature +++ b/tests/browser/features/sitelinks.feature @@ -1,273 +1,224 @@ # Wikidata UI tests # # Author:: Tobias Gritschacher (tobias.gritschacher@wikimedia.de) # License:: GNU GPL v2+ # # feature definition for item sitelinks tests @chrome @firefox @internet_explorer_10 @internet_explorer_11 @local_config @wikidata.beta.wmflabs.org Feature: Edit sitelinks Background: Given I am on an item page And The copyright warning has been dismissed And Anonymous edit warnings are disabled @ui_only Scenario: Sitelink UI has all required elements - Then Sitelink table should be there + Then wikipedia sitelink section should be there And Sitelink heading should be there And Sitelink edit button should be there And Sitelink counter should be there And There should be 0 sitelinks in the list @ui_only Scenario: Click edit button When I click the sitelink edit button Then Sitelink edit button should not be there - And Sitelink remove button should be there + And Sitelink remove button should be disabled And Sitelink save button should be disabled And Sitelink cancel button should be there And Sitelink help field should be there And Sitelink siteid input field should be there And Sitelink pagename input field should be disabled @ui_only Scenario Outline: Type site id When I click the sitelink edit button And I type into the siteid input field Then Sitelink pagename input field should be there And Sitelink save button should be disabled And Sitelink cancel button should be there - And Sitelink remove button should be there + And Sitelink remove button should be disabled And Sitelink siteid dropdown should be there And Sitelink siteid first suggestion should be Examples: | siteid | expected_element | | enwiki | English (enwiki) | | hewiki | עברית (hewiki) | @ui_only Scenario Outline: Type site id and page name When I click the sitelink edit button And I type into the siteid input field And I type into the page input field Then Sitelink save button should be there And Sitelink cancel button should be there And Sitelink remove button should be there And Sitelink pagename dropdown should be there And Sitelink pagename first suggestion should be Examples: | siteid | pagename | expected_element | | enwiki | Main Page | Main Page | | hewiki | עמוד ראשי | עמוד ראשי | @ui_only Scenario: Type site id and page name and change site id to something senseless When I click the sitelink edit button And I type enwiki into the siteid input field And I type Main Page into the page input field And I type nonexistingwiki into the siteid input field Then Sitelink save button should be disabled And Sitelink cancel button should be there - And Sitelink remove button should be there + And Sitelink remove button should be disabled And Sitelink pagename input field should be disabled @ui_only Scenario Outline: Cancel sitelink during siteid selection When I click the sitelink edit button And I Then Sitelink edit button should be there And Sitelink cancel button should not be there And Sitelink remove button should not be there And Sitelink save button should not be there And Sitelink siteid input field should not be there And There should be 0 sitelinks in the list Examples: | cancel | | click the sitelink cancel button | | press the ESC key in the siteid input field | @ui_only Scenario Outline: Cancel sitelink during pagename selection When I click the sitelink edit button And I type enwiki into the siteid input field And I Then Sitelink edit button should be there And Sitelink cancel button should not be there And Sitelink remove button should not be there And Sitelink save button should not be there And Sitelink siteid input field should not be there And There should be 0 sitelinks in the list Examples: | cancel | | click the sitelink cancel button | | press the ESC key in the pagename input field | @modify_entity @save_sitelink @smoke Scenario Outline: Save sitelink Given The following sitelinks do not exist: | enwiki | Asia | When I click the sitelink edit button And I type enwiki into the siteid input field And I type Asia into the page input field And I Then There should be 1 sitelinks in the list Examples: | save | | click the sitelink save button | | press the RETURN key in the pagename input field | @modify_entity @save_sitelink Scenario Outline: Save sitelink and reload Given The following sitelinks do not exist: | enwiki | Asia | When I click the sitelink edit button And I type enwiki into the siteid input field And I type Asia into the page input field And I And I reload the page Then There should be 1 sitelinks in the list Examples: | save | | click the sitelink save button | | press the RETURN key in the pagename input field | @modify_entity @save_sitelink Scenario: Edit sitelink Given The following sitelinks do not exist: | enwiki | Asia | | enwiki | Europe | When I add the following sitelinks: | enwiki | Asia | And I reload the page And I click the sitelink edit button And I type Europe into the page input field And I click the sitelink save button Then There should be 1 sitelinks in the list And Sitelink edit button should be there And Sitelink save button should not be there And Sitelink remove button should not be there @modify_entity @save_sitelink Scenario Outline: Add sitelink Given The following sitelinks do not exist: | | | When I click the sitelink edit button And I type into the siteid input field And I type into the page input field And I click the sitelink save button Then Sitelink edit button should be there And Sitelink save button should not be there And Sitelink cancel button should not be there And Sitelink remove button should not be there And Sitelink siteid input field should not be there And There should be 1 sitelinks in the list - And Sitelink language table cell should contain - And Sitelink code table cell should contain + And Sitelink language code should be And Sitelink link text should be And Sitelink link should lead to article Examples: - | siteid | pagename | expected_language | normalized_pagename | - | enwiki | Asia | English | Asia | - | sqwiki | wikipedia | shqip | Wikipedia | + | siteid | pagename | normalized_pagename | + | enwiki | Asia | Asia | + | sqwiki | wikipedia | Wikipedia | @modify_entity @save_sitelink Scenario: Add multiple sitelinks Given The following sitelinks do not exist: | enwiki | Europe | | dewiki | Test | | sqwiki | Wikipedia | When I add the following sitelinks: | enwiki | Europe | | dewiki | Test | | sqwiki | Wikipedia | Then There should be 3 sitelinks in the list @modify_entity @save_sitelink Scenario: Remove multiple sitelinks Given The following sitelinks do not exist: | enwiki | Europe | | dewiki | Test | | sqwiki | Wikipedia | When I add the following sitelinks: | enwiki | Europe | | dewiki | Test | | sqwiki | Wikipedia | And I remove all sitelinks And I reload the page Then There should be 0 sitelinks in the list And Sitelink edit button should be there - @modify_entity @save_sitelink - Scenario: Initial sorting of sitelinks - Given The following sitelinks do not exist: - | enwiki | Rashidun | - | dewiki | Error | - | sqwiki | Wikipedia | - | simplewiki | Wiktionary | - When I add the following sitelinks: - | enwiki | Rashidun | - | dewiki | Error | - | sqwiki | Wikipedia | - | simplewiki | Wiktionary | - And I reload the page - Then There should be 4 sitelinks in the list - And Order of sitelinks should be: - | dewiki | enwiki | simplewiki | sqwiki | - - @modify_entity @save_sitelink - Scenario: Sorting sitelinks by languagename - Given The following sitelinks do not exist: - | enwiki | Rashidun | - | dewiki | Error | - | sqwiki | Wikipedia | - | simplewiki | Wiktionary | - When I add the following sitelinks: - | enwiki | Rashidun | - | dewiki | Error | - | sqwiki | Wikipedia | - | simplewiki | Wiktionary | - And I reload the page - And I order the sitelinks by languagename - Then There should be 4 sitelinks in the list - And Order of sitelinks should be: - | dewiki | enwiki | sqwiki | simplewiki | - @modify_entity @save_sitelink Scenario: List of sitelinks is complete Given The following sitelinks do not exist: | enwiki | Europe | When I add the following sitelinks: | enwiki | Europe | - And I mock that the list of sitelinks is complete + And I mock that the list of sitelinks is complete And I click the sitelink edit button - Then Sitelink save button should be disabled - And Sitelink remove button should be there - And Sitelink cancel button should be there + Then Sitelink siteid input field should not be there @save_sitelink Scenario: Add sitelink to non existent page When I click the sitelink edit button And I type enwiki into the siteid input field And I type xyz_nonexistentarticle_xyz into the page input field And I click the sitelink save button Then An error message should be displayed - - @modify_entity @save_sitelink - Scenario: Initial sorting of sitelinks - Given The following sitelinks do not exist: - | enwiki | Europe | - When I add the following sitelinks: - | enwiki | Europe | - And I click the sitelink edit button - And I click the sitelink remove button - And I type enwiki into the siteid input field - Then Sitelink pagename input field should be there diff --git a/tests/browser/features/step_definitions/sitelinks_steps.rb b/tests/browser/features/step_definitions/sitelinks_steps.rb index 0f41c47..59f3c96 100644 --- a/tests/browser/features/step_definitions/sitelinks_steps.rb +++ b/tests/browser/features/step_definitions/sitelinks_steps.rb @@ -1,224 +1,216 @@ # -*- encoding : utf-8 -*- # Wikidata UI tests # # Author:: Tobias Gritschacher (tobias.gritschacher@wikimedia.de) # License:: GNU GPL v2+ # # tests for item sitelinks When /^I click the sitelink remove button$/ do on(ItemPage).remove_sitelink_link end When /^I click the sitelink edit button$/ do on(ItemPage).edit_sitelink_link end When /^I click the sitelink cancel button$/ do on(ItemPage).cancel_sitelink_link end When /^I click the sitelink save button$/ do on(ItemPage) do |page| page.save_sitelink_link page.wait_for_api_callback end end When /^I press the ESC key in the siteid input field$/ do on(ItemPage).site_id_input_field_wd.send_keys :escape end When /^I press the ESC key in the pagename input field$/ do on(ItemPage).page_input_field_wd.send_keys :escape end When /^I press the RETURN key in the pagename input field$/ do on(ItemPage) do |page| page.page_input_field_wd.send_keys :return page.wait_for_api_callback end end When /^I type (.+) into the siteid input field$/ do |value| on(ItemPage) do |page| page.site_id_input_field_wd.clear page.site_id_input_field_wd.send_keys value end end When /^I type (.+) into the page input field$/ do |value| on(ItemPage) do |page| page.page_input_field_wd.clear page.page_input_field_wd.send_keys value page.ajax_wait end end When /^I remove all sitelinks$/ do on(ItemPage).remove_all_sitelinks end When /^I add the following sitelinks:$/ do |table| on(ItemPage).add_sitelinks(table.raw) end When /^I order the sitelinks by languagename$/ do on(ItemPage).sitelink_sort_language_element.click end When /^I mock that the list of sitelinks is complete$/ do on(ItemPage).set_sitelink_list_to_full end -Then /^Sitelink table should be there$/ do - expect(on(ItemPage).sitelink_table?).to be true +Then /^(.+) sitelink section should be there$/ do |section| + expect(on(ItemPage).sitelink_section(section)).to be_present end Then /^Sitelink heading should be there$/ do expect(on(ItemPage).sitelink_heading?).to be true end Then /^Sitelink heading should not be there$/ do expect(on(ItemPage).sitelink_heading?).to be false end Then /^Sitelink remove button should be there$/ do expect(on(ItemPage).remove_sitelink_link?).to be true end Then /^Sitelink remove button should not be there$/ do expect(on(ItemPage).remove_sitelink_link?).to be false end Then /^Sitelink remove button should be disabled$/ do on(ItemPage) do |page| expect(page.remove_sitelink_link?).to be false expect(page.remove_sitelink_link_disabled?).to be true end end Then /^Sitelink edit button should be there$/ do expect(on(ItemPage).edit_sitelink_link?).to be true end Then /^Sitelink edit button should not be there$/ do expect(on(ItemPage).edit_sitelink_link?).to be false end Then /^Sitelink edit button should be disabled$/ do on(ItemPage) do |page| expect(page.edit_sitelink_link?).to be false expect(page.edit_sitelink_link_disabled?).to be true end end Then /^Sitelink save button should be there$/ do expect(on(ItemPage).save_sitelink_link?).to be true end Then /^Sitelink save button should not be there$/ do expect(on(ItemPage).save_sitelink_link?).to be false end Then /^Sitelink save button should be disabled$/ do on(ItemPage) do |page| expect(page.save_sitelink_link?).to be false expect(page.save_sitelink_link_disabled?).to be true end end Then /^Sitelink cancel button should be there$/ do expect(on(ItemPage).cancel_sitelink_link?).to be true end Then /^Sitelink cancel button should not be there$/ do expect(on(ItemPage).cancel_sitelink_link?).to be false end Then /^Sitelink counter should be there$/ do expect(on(ItemPage).sitelink_counter?).to be true end Then /^Sitelink counter should show (.+)$/ do |value| expect(on(ItemPage).get_number_of_sitelinks_from_counter).to be == value end Then /^There should be (\d+) sitelinks in the list$/ do |num| expect(on(ItemPage).count_existing_sitelinks).to be == num.to_i end Then /^Sitelink help field should be there$/ do expect(on(ItemPage).sitelink_help_field?).to be true end Then /^Sitelink siteid input field should be there$/ do expect(on(ItemPage).site_id_input_field.present?).to be true end Then /^Sitelink siteid input field should not be there$/ do expect(on(ItemPage).site_id_input_field.present?).to be false end Then /^Sitelink pagename input field should be there$/ do expect(on(ItemPage).page_input_field.present?).to be true end Then /^Sitelink pagename input field should not be there$/ do expect(on(ItemPage).page_input_field.present?).to be false end Then /^Sitelink pagename input field should be disabled$/ do on(ItemPage) do |page| expect(page.page_input_field.present?).to be false expect(page.page_input_field_disabled.present?).to be true end end Then /^Sitelink siteid dropdown should be there$/ do expect(on(ItemPage).site_id_dropdown_element.visible?).to be true end Then /^Sitelink siteid dropdown should not be there$/ do expect(on(ItemPage).site_id_dropdown_element.visible?).to be false end Then /^Sitelink siteid first suggestion should be (.+)$/ do |value| expect(on(ItemPage).site_id_dropdown_first_element).to be == value end Then /^Sitelink pagename dropdown should be there$/ do expect(on(ItemPage).page_name_dropdown_element.visible?).to be true end Then /^Sitelink pagename dropdown should not be there$/ do expect(on(ItemPage).page_name_dropdown_element.visible?).to be false end Then /^Sitelink pagename first suggestion should be (.+)$/ do |value| expect(on(ItemPage).page_name_dropdown_first_element).to be == value end -Then /^Sitelink language table cell should contain (.+)$/ do |value| - expect(on(ItemPage).sitelink_sitename).to be == value -end - -Then /^Sitelink code table cell should contain (.+)$/ do |value| +Then /^Sitelink language code should be (.+)$/ do |value| expect(on(ItemPage).sitelink_siteid).to be == value end Then /^Sitelink link text should be (.+)$/ do |value| expect(on(ItemPage).sitelink_link_element.text).to be == value end Then /^Sitelink link should lead to article (.+)$/ do |value| on(ItemPage) do |page| page.sitelink_link expect(page.article_title).to be == value end end - -Then /^Order of sitelinks should be:$/ do |siteids| - expect(on(ItemPage).get_sitelinks_order).to be == siteids.raw[0] -end diff --git a/tests/browser/features/support/modules/sitelink_module.rb b/tests/browser/features/support/modules/sitelink_module.rb index 4d3728c..ba71c3b 100644 --- a/tests/browser/features/support/modules/sitelink_module.rb +++ b/tests/browser/features/support/modules/sitelink_module.rb @@ -1,122 +1,111 @@ # -*- encoding : utf-8 -*- # Wikidata UI tests # # Author:: Tobias Gritschacher (tobias.gritschacher@wikimedia.de) # License:: GNU GPL v2+ # # module for sitelinks page module SitelinkPage include PageObject # sitelinks UI elements h2(:sitelink_heading, id: 'sitelinks-wikipedia') - table(:sitelink_table, xpath: "//div[contains(@data-wb-sitelinks-group, 'wikipedia')]//table") - element(:sitelink_table_header, :tr, xpath: "//div[contains(@data-wb-sitelinks-group, 'wikipedia')]//table//tr[contains(@class, 'wikibase-sitelinklistview-columnheaders')]") - element(:sitelink_sitename, :td, xpath: "//div[contains(@data-wb-sitelinks-group, 'wikipedia')]//table/tbody/tr/td[1]") - element(:sitelink_siteid, :td, xpath: "//div[contains(@data-wb-sitelinks-group, 'wikipedia')]//table/tbody/tr/td[2]") - a(:sitelink_link, css: "div[data-wb-sitelinks-group='wikipedia'] table > tbody > tr span.wikibase-sitelinkview-page > a") + div(:sitelink_table, css: "div[data-wb-sitelinks-group='wikipedia']") + span(:sitelink_siteid, css: "div[data-wb-sitelinks-group='wikipedia'] ul.wikibase-sitelinklistview-listview span.wikibase-sitelinkview-siteid") + ul(:sitelink_list, css: "div[data-wb-sitelinks-group='wikipedia'] ul.wikibase-sitelinklistview-listview") + a(:sitelink_link, css: "div[data-wb-sitelinks-group='wikipedia'] ul.wikibase-sitelinklistview-listview span.wikibase-sitelinkview-page a") span(:sitelink_counter, class: 'wikibase-sitelinkgroupview-counter') text_field(:page_input_field_disabled, xpath: "//div[contains(@data-wb-sitelinks-group, 'wikipedia')]//table//td[contains(@class, 'wikibase-sitelinkview-link')]//input[@disabled]") ul(:site_id_dropdown, xpath: "//ul[contains(@class, 'wikibase-siteselector-list')]") li(:site_id_dropdown_first_element, xpath: "//ul[contains(@class, 'wikibase-siteselector-list')]/li") ul(:page_name_dropdown, css: 'ul.ui-suggester-list:not(.ui-entityselector-list):not(.wikibase-siteselector-list)') li(:page_name_dropdown_first_element, css: 'ul.ui-suggester-list:not(.ui-entityselector-list):not(.wikibase-siteselector-list) li') - element(:sitelink_sort_language, :th, xpath: "//div[contains(@data-wb-sitelinks-group, 'wikipedia')]//table//th[contains(@class, 'wikibase-sitelinkview-sitename')]") - element(:sitelink_sort_code, :th, xpath: "//div[contains(@data-wb-sitelinks-group, 'wikipedia')]//table//th[contains(@class, 'wikibase-sitelinkview-siteid')]") - element(:sitelink_sort_link, :th, xpath: "//div[contains(@data-wb-sitelinks-group, 'wikipedia')]//table//th[contains(@class, 'wikibase-sitelinkview-link')]") - a(:remove_sitelink_link, css: "div[data-wb-sitelinks-group='wikipedia'] table span.wikibase-toolbar-button-remove:not(.wikibase-toolbarbutton-disabled) > a") - a(:remove_sitelink_link_disabled, css: "div[data-wb-sitelinks-group='wikipedia'] table span.wikibase-toolbar-button-remove.wikibase-toolbarbutton-disabled > a") + a(:remove_sitelink_link, css: "div[data-wb-sitelinks-group='wikipedia'] ul span.wikibase-toolbar-button-remove:not(.wikibase-toolbarbutton-disabled) > a") + a(:remove_sitelink_link_disabled, css: "div[data-wb-sitelinks-group='wikipedia'] ul span.wikibase-toolbar-button-remove.wikibase-toolbarbutton-disabled > a") a(:save_sitelink_link, css: "div[data-wb-sitelinks-group='wikipedia'] .wikibase-toolbar-container span.wikibase-toolbar-button-save:not(.wikibase-toolbarbutton-disabled) > a") a(:save_sitelink_link_disabled, css: "div[data-wb-sitelinks-group='wikipedia'] .wikibase-toolbar-container span.wikibase-toolbar-button-save.wikibase-toolbarbutton-disabled > a") a(:cancel_sitelink_link, css: "div[data-wb-sitelinks-group='wikipedia'] .wikibase-toolbar-container span.wikibase-toolbar-button-cancel:not(.wikibase-toolbarbutton-disabled) > a") a(:edit_sitelink_link, css: "div[data-wb-sitelinks-group='wikipedia'] .wikibase-toolbar-container span.wikibase-toolbar-button-edit:not(.wikibase-toolbarbutton-disabled) > a") a(:edit_sitelink_link_disabled, css: "div[data-wb-sitelinks-group='wikipedia'] .wikibase-toolbar-container wikibase-toolbar-button-edit.wikibase-toolbarbutton-disabled > a") a(:edit_sitelink_link_en, css: "div[data-wb-sitelinks-group='wikipedia'] table tr.wikibase-sitelinkview-enwiki span.wikibase-toolbar-button-edit:not(.wikibase-toolbarbutton-disabled) > a") a(:edit_sitelink_link_en_disabled, css: "div[data-wb-sitelinks-group='wikipedia'] table tr.wikibase-sitelinkview-enwiki span.wikibase-toolbar-button-edit.wikibase-toolbarbutton-disabled > a") span(:article_title, xpath: "//h1[@id='firstHeading']/span") span(:sitelink_help_field, css: "div[data-wb-sitelinks-group='wikipedia'] .wikibase-toolbar-container span.mw-help-field-hint") def site_id_input_field(index = 1) - @browser.element(css: "div[data-wb-sitelinks-group='wikipedia'] table tr:nth-child(#{index}) td.wikibase-sitelinkview-siteid input") + @browser.element(css: "div[data-wb-sitelinks-group='wikipedia'] ul li:nth-child(#{index}) span.wikibase-sitelinkview-siteid input") end def site_id_input_field_wd(index = 1) site_id_input_field(index).wd end def page_input_field(index = 1) - @browser.element(css: "div[data-wb-sitelinks-group='wikipedia'] table tr:nth-child(#{index}) td.wikibase-sitelinkview-link input:not(.wikibase-pagesuggester-disabled)") + @browser.element(css: "div[data-wb-sitelinks-group='wikipedia'] ul li:nth-child(#{index}) span.wikibase-sitelinkview-link input:not(.wikibase-pagesuggester-disabled)") end def page_input_field_wd(index = 1) page_input_field(index).wd end def page_input_field_disabled(index = 1) - @browser.element(css: "div[data-wb-sitelinks-group='wikipedia'] table tr:nth-child(#{index}) td.wikibase-sitelinkview-link input.wikibase-pagesuggester-disabled") + @browser.element(css: "div[data-wb-sitelinks-group='wikipedia'] ul li:nth-child(#{index}) span.wikibase-sitelinkview-link input.wikibase-pagesuggester-disabled") end def page_input_field_disabled_wd(index = 1) page_input_field_disabled(index).wd end + def sitelink_section(section) + @browser.element(css: "div[data-wb-sitelinks-group='#{section}']") + end + # sitelinks methods def count_existing_sitelinks - if sitelink_table_header? == false + if sitelink_list? == false return 0 end count = 0 - sitelink_table_element.each { count = count + 1 } - count - 2 # subtracting the table header row and the footer row + sitelink_list_element.each { count = count + 1 } + count end def get_number_of_sitelinks_from_counter sitelink_counter_element.when_visible scanned = sitelink_counter.scan(/\(([^ ]+)\)/) scanned[0][0] end def remove_all_sitelinks count = 0 number_of_sitelinks = count_existing_sitelinks edit_sitelink_link while count < (number_of_sitelinks) remove_sitelink_link wait_for_api_callback count = count + 1 end save_sitelink_link wait_for_api_callback end def add_sitelinks(sitelinks) edit_sitelink_link index = 1 sitelinks.each do |sitelink| site_id_input_field_wd(index).clear site_id_input_field_wd(index).send_keys sitelink[0] page_input_field_wd(index).clear page_input_field_wd(index).send_keys sitelink[1] index = index + 1 end save_sitelink_link wait_for_api_callback end - def get_sitelinks_order - siteids = [] - sitelink_table_element.each do |row| - siteids.push(row[1].text) - end - siteids.delete_at(0) - siteids.delete_at(siteids.count - 1) - - siteids - end - def set_sitelink_list_to_full @browser.execute_script('$.wikibase.sitelinklistview.prototype.isFull = function() { return true; };') end end