From 36e9a6d834e4a2e7fa68154f611b5af8d62c891a Mon Sep 17 00:00:00 2001 From: Cmcmahon Date: Thu, 26 Jun 2014 10:57:10 -0700 Subject: [PATCH] Port preferences test from /qa repo Add tests for preferences, make core tests language-independent. Change-Id: I1ba4e2c53a9e1bdb7b832efec4c2c8f6f64d2b86 --- tests/browser/Gemfile.lock | 40 ++++----- tests/browser/features/preferences.feature | 60 +++++++++++++ .../preferences_appearance_steps.rb | 87 +++++++++++++++++++ .../preferences_editing_steps.rb | 54 ++++++++++++ .../preferences_user_profile_steps.rb | 43 +++++++++ .../pages/preferences_appearance_page.rb | 42 +++++++++ .../support/pages/preferences_editing_page.rb | 28 ++++++ .../support/pages/preferences_page.rb | 28 ++++++ .../pages/preferences_user_profile_page.rb | 28 ++++++ 9 files changed, 389 insertions(+), 21 deletions(-) create mode 100644 tests/browser/features/preferences.feature create mode 100644 tests/browser/features/step_definitions/preferences_appearance_steps.rb create mode 100644 tests/browser/features/step_definitions/preferences_editing_steps.rb create mode 100644 tests/browser/features/step_definitions/preferences_user_profile_steps.rb create mode 100644 tests/browser/features/support/pages/preferences_appearance_page.rb create mode 100644 tests/browser/features/support/pages/preferences_editing_page.rb create mode 100644 tests/browser/features/support/pages/preferences_page.rb create mode 100644 tests/browser/features/support/pages/preferences_user_profile_page.rb diff --git a/tests/browser/Gemfile.lock b/tests/browser/Gemfile.lock index d78c9a1177..6ec249361c 100644 --- a/tests/browser/Gemfile.lock +++ b/tests/browser/Gemfile.lock @@ -2,20 +2,20 @@ GEM remote: https://rubygems.org/ specs: builder (3.2.2) - childprocess (0.5.2) + childprocess (0.5.3) ffi (~> 1.0, >= 1.0.11) - chunky_png (1.3.0) - cucumber (1.3.14) + chunky_png (1.3.1) + cucumber (1.3.15) builder (>= 2.1.2) diff-lcs (>= 1.1.3) gherkin (~> 2.12) multi_json (>= 1.7.5, < 2.0) multi_test (>= 0.1.1) - data_magic (0.18) + data_magic (0.19) faker (>= 1.1.2) - yml_reader (>= 0.2) + yml_reader (>= 0.3) diff-lcs (1.2.5) - domain_name (0.5.18) + domain_name (0.5.19) unf (>= 0.0.5, < 1.0.0) faker (1.3.0) i18n (~> 0.5) @@ -27,7 +27,7 @@ GEM ffi (1.9.3) gherkin (2.12.2) multi_json (~> 1.3) - headless (1.0.1) + headless (1.0.2) http-cookie (1.0.2) domain_name (~> 0.5) i18n (0.6.9) @@ -35,32 +35,30 @@ GEM mediawiki_api (0.1.2) faraday (~> 0.9, >= 0.9.0) faraday-cookie_jar (~> 0.0, >= 0.0.6) - mediawiki_selenium (0.2.20) + mediawiki_selenium (0.2.25) cucumber (~> 1.3, >= 1.3.10) headless (~> 1.0, >= 1.0.1) json (~> 1.8, >= 1.8.1) - net-http-persistent (~> 2.9, >= 2.9.1) - page-object (~> 0.9, >= 0.9.5) + page-object (~> 1.0) rest-client (~> 1.6, >= 1.6.7) rspec-expectations (~> 2.14, >= 2.14.4) syntax (~> 1.2, >= 1.2.0) - mime-types (2.2) - multi_json (1.9.2) + mime-types (2.3) + multi_json (1.10.1) multi_test (0.1.1) multipart-post (2.0.0) - net-http-persistent (2.9.4) - page-object (0.9.8) + page-object (1.0) page_navigation (>= 0.9) - selenium-webdriver (>= 2.40.0) - watir-webdriver (>= 0.6.8) + selenium-webdriver (>= 2.42.0) + watir-webdriver (>= 0.6.9) page_navigation (0.9) data_magic (>= 0.14) rest-client (1.6.7) mime-types (>= 1.16) - rspec-expectations (2.14.5) + rspec-expectations (2.99.1) diff-lcs (>= 1.1.3, < 2.0) - rubyzip (1.1.3) - selenium-webdriver (2.41.0) + rubyzip (1.1.4) + selenium-webdriver (2.42.0) childprocess (>= 0.5.0) multi_json (~> 1.0) rubyzip (~> 1.0) @@ -69,10 +67,10 @@ GEM unf (0.1.4) unf_ext unf_ext (0.0.6) - watir-webdriver (0.6.9) + watir-webdriver (0.6.10) selenium-webdriver (>= 2.18.0) websocket (1.0.7) - yml_reader (0.2) + yml_reader (0.3) PLATFORMS ruby diff --git a/tests/browser/features/preferences.feature b/tests/browser/features/preferences.feature new file mode 100644 index 0000000000..2eb5de8195 --- /dev/null +++ b/tests/browser/features/preferences.feature @@ -0,0 +1,60 @@ +# +# This file is subject to the license terms in the LICENSE file found in the +# qa-browsertests top-level directory and at +# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of +# qa-browsertests, including this file, may be copied, modified, propagated, or +# distributed except according to the terms contained in the LICENSE file. +# +# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the +# qa-browsertests top-level directory and at +# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS +# +@chrome @en.wikipedia.beta.wmflabs.org @firefox @internet_explorer_6 @internet_explorer_7 @internet_explorer_8 @internet_explorer_9 @internet_explorer_10 @login @phantomjs @test2.wikipedia.org +Feature: Preferences + + Scenario: Preferences Appearance + Given I am logged in + When I navigate to Preferences + And I click Appearance + Then I can select skins + And I can select image size + And I can select thumbnail size + And I can select Threshold for stub link + And I can select underline preferences + And I have advanced options checkboxes + And I can click Save + And I can restore default settings + And I can select date format + And I can see server time + And I can see local time + And I can select my time zone + + + Scenario: Preferences Editing + Given I am logged in + When I navigate to Preferences + And I click Editing + Then I can select edit area font style + And I can select section editing via edit links + And I can select section editing by right clicking + And I can select section editing by double clicking + And I can select to prompt me when entering a blank edit summary + And I can select to warn me when I leave an edit page with unsaved changes + And I can select show edit toolbar + And I can select show preview on first edit + And I can select show preview before edit box + And I can select live preview + + + Scenario: Preferences User profile + Given I am logged in + When I navigate to Preferences + And I click User profile + Then I can see my Basic informations + And I can change my language + And I can change my gender + And I can see my signature + And I can change my signature + And I can see my email + And I can click Save + And I can restore default settings diff --git a/tests/browser/features/step_definitions/preferences_appearance_steps.rb b/tests/browser/features/step_definitions/preferences_appearance_steps.rb new file mode 100644 index 0000000000..d3e275eaf9 --- /dev/null +++ b/tests/browser/features/step_definitions/preferences_appearance_steps.rb @@ -0,0 +1,87 @@ +# +# This file is subject to the license terms in the LICENSE file found in the +# qa-browsertests top-level directory and at +# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of +# qa-browsertests, including this file, may be copied, modified, propagated, or +# distributed except according to the terms contained in the LICENSE file. +# +# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the +# qa-browsertests top-level directory and at +# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS +# +When(/^I click Appearance$/) do + visit(PreferencesPage).appearance_link_element.when_present.click +end + +When(/^I navigate to Preferences$/) do + visit(PreferencesPage) +end + +Then(/^I can click Save$/) do + on(PreferencesAppearancePage).save_button_element.should exist +end + +Then(/^I can restore default settings$/) do + on(PreferencesAppearancePage).restore_default_link_element.should exist +end + +Then(/^I can see local time$/) do + @browser.text.should match Regexp.escape("Local time") + on(PreferencesAppearancePage).local_time_span_element.should exist +end + +Then(/^I can see server time$/) do + @browser.text.should match Regexp.escape("Server time") +end + +Then(/^I can select date format$/) do + on(PreferencesAppearancePage) do |page| + page.no_preference_radio_element.should exist + page.mo_day_year_radio_element.should exist + page.day_mo_year_radio_element.should exist + page.year_mo_day_radio_element.should exist + page.iso_8601_radio_element.should exist + end +end + +Then(/^I can select image size$/) do + on(PreferencesAppearancePage).size_select_element.should exist +end + +Then(/^I can select my time zone$/) do + @browser.text.should match Regexp.escape("Time zone") + on(PreferencesAppearancePage) do |page| + page.time_offset_select_element.should exist + page.other_offset_element.should exist + end +end + +Then(/^I can select skins$/) do + on(PreferencesAppearancePage) do |page| + page.cologne_blue_element.should exist + page.modern_element.should exist + page.monobook_element.should exist + page.vector_element.should exist + end +end + +Then(/^I can select Threshold for stub link$/) do + on(PreferencesAppearancePage).threshold_select_element.should exist +end + +Then(/^I can select thumbnail size$/) do + on(PreferencesAppearancePage).thumb_select_element.should exist +end + +Then(/^I can select underline preferences$/) do + on(PreferencesAppearancePage).underline_select_element.should exist +end + +Then(/^I have advanced options checkboxes$/) do + on(PreferencesAppearancePage) do |page| + page.hidden_categories_check_element.should exist + page.auto_number_check_element.should exist + end +end + + diff --git a/tests/browser/features/step_definitions/preferences_editing_steps.rb b/tests/browser/features/step_definitions/preferences_editing_steps.rb new file mode 100644 index 0000000000..ad29a74553 --- /dev/null +++ b/tests/browser/features/step_definitions/preferences_editing_steps.rb @@ -0,0 +1,54 @@ +# +# This file is subject to the license terms in the LICENSE file found in the +# qa-browsertests top-level directory and at +# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of +# qa-browsertests, including this file, may be copied, modified, propagated, or +# distributed except according to the terms contained in the LICENSE file. +# +# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the +# qa-browsertests top-level directory and at +# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS +# +When(/^I click Editing$/) do + visit(PreferencesPage).editing_link_element.when_present.click +end + +Then(/^I can select edit area font style$/) do + on(PreferencesEditingPage).edit_area_font_style_select_element.when_present.should exist +end + +Then(/^I can select live preview$/) do + on(PreferencesEditingPage).live_preview_check_element.when_present.should exist +end + +Then(/^I can select section editing by double clicking$/) do + on(PreferencesEditingPage).edit_section_double_click_check_element.when_present.should exist +end + +Then(/^I can select section editing by right clicking$/) do + on(PreferencesEditingPage).edit_section_right_click_check_element.when_present.should exist +end + +Then(/^I can select section editing via edit links$/) do + on(PreferencesEditingPage).edit_section_edit_link_element.when_present.should exist +end + +Then(/^I can select show edit toolbar$/) do + on(PreferencesEditingPage).show_edit_toolbar_check_element.when_present.should exist +end + +Then(/^I can select show preview before edit box$/) do + on(PreferencesEditingPage).preview_on_top_check_element.when_present.should exist +end + +Then(/^I can select show preview on first edit$/) do + on(PreferencesEditingPage).preview_on_first_check_element.when_present.should exist +end + +Then(/^I can select to prompt me when entering a blank edit summary$/) do + on(PreferencesEditingPage).forced_edit_summary_check_element.when_present.should exist +end + +Then(/^I can select to warn me when I leave an edit page with unsaved changes$/) do + on(PreferencesEditingPage).unsaved_changes_check_element.when_present.should exist +end diff --git a/tests/browser/features/step_definitions/preferences_user_profile_steps.rb b/tests/browser/features/step_definitions/preferences_user_profile_steps.rb new file mode 100644 index 0000000000..529af66d8a --- /dev/null +++ b/tests/browser/features/step_definitions/preferences_user_profile_steps.rb @@ -0,0 +1,43 @@ +# +# This file is subject to the license terms in the LICENSE file found in the +# qa-browsertests top-level directory and at +# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of +# qa-browsertests, including this file, may be copied, modified, propagated, or +# distributed except according to the terms contained in the LICENSE file. +# +# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the +# qa-browsertests top-level directory and at +# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS +# +When(/^I click User profile$/) do + visit(PreferencesPage).user_profile_link_element.when_present.click +end + +Then(/^I can change my gender$/) do + on(PreferencesUserProfilePage) do |page| + page.gender_undefined_radio_element.should exist + page.gender_male_radio_element.should exist + page.gender_female_radio_element.should exist + end +end + +Then(/^I can change my language$/) do + on(PreferencesUserProfilePage).lang_select_element.should exist +end + +Then(/^I can change my signature$/) do + on(PreferencesUserProfilePage).signature_field_element.should exist +end + +Then(/^I can see my Basic informations$/) do + on(PreferencesUserProfilePage).basic_info_table_element.should exist +end + +Then(/^I can see my email$/) do + on(PreferencesUserProfilePage).email_table_element.should exist +end + +Then(/^I can see my signature$/) do + on(PreferencesUserProfilePage).signature_table_element.should exist +end + diff --git a/tests/browser/features/support/pages/preferences_appearance_page.rb b/tests/browser/features/support/pages/preferences_appearance_page.rb new file mode 100644 index 0000000000..c01aab4317 --- /dev/null +++ b/tests/browser/features/support/pages/preferences_appearance_page.rb @@ -0,0 +1,42 @@ +# +# This file is subject to the license terms in the LICENSE file found in the +# qa-browsertests top-level directory and at +# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of +# qa-browsertests, including this file, may be copied, modified, propagated, or +# distributed except according to the terms contained in the LICENSE file. +# +# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the +# qa-browsertests top-level directory and at +# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS +# +class PreferencesAppearancePage + include PageObject + + include URL + page_url URL.url("Special:Preferences#mw-prefsection-rendering") + + checkbox(:auto_number_check, id: "mw-input-wpnumberheadings") + checkbox(:collapse_sidebar_vector_check, id: "mw-input-wpvector-collapsiblenav") + radio_button(:cologne_blue, id: "mw-input-wpskin-cologneblue") + radio_button(:day_mo_year_radio, id: "mw-input-wpdate-dmy") + checkbox(:dont_show_aft_check, id: "mw-input-wparticlefeedback-disable") + checkbox(:exclude_from_experiments_check, id: "mw-input-wpvector-noexperiments") + checkbox(:hidden_categories_check, id: "mw-input-wpshowhiddencats") + radio_button(:iso_8601_radio, id: "mw-input-wpdate-ISO_8601") + span(:local_time_span, id: "wpLocalTime") + radio_button(:mo_day_year_radio, id: "mw-input-wpdate-mdy") + radio_button(:modern, id: "mw-input-wpskin-modern") + radio_button(:monobook, id: "mw-input-wpskin-monobook") + radio_button(:no_preference_radio, id: "mw-input-wpdate-default") + text_field(:other_offset, id: "mw-input-wptimecorrection-other") + a(:restore_default_link, text:/Restore all default settings/) + button(:save_button, text: "Save") + select_list(:size_select, id: "mw-input-wpimagesize") + select_list(:threshold_select, id: "mw-input-wpstubthreshold") + select_list(:time_offset_select, id: "mw-input-wptimecorrection") + select_list(:thumb_select, id: "mw-input-wpthumbsize") + select_list(:underline_select, id: "mw-input-wpunderline") + radio_button(:vector, id: "mw-input-wpskin-vector") + radio_button(:year_mo_day_radio, id: "mw-input-wpdate-ymd") +end + diff --git a/tests/browser/features/support/pages/preferences_editing_page.rb b/tests/browser/features/support/pages/preferences_editing_page.rb new file mode 100644 index 0000000000..aed9c41db3 --- /dev/null +++ b/tests/browser/features/support/pages/preferences_editing_page.rb @@ -0,0 +1,28 @@ +# +# This file is subject to the license terms in the LICENSE file found in the +# qa-browsertests top-level directory and at +# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of +# qa-browsertests, including this file, may be copied, modified, propagated, or +# distributed except according to the terms contained in the LICENSE file. +# +# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the +# qa-browsertests top-level directory and at +# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS +# +class PreferencesEditingPage + include PageObject + + include URL + page_url URL.url("Special:Preferences#mw-prefsection-rendering") + + select_list(:edit_area_font_style_select, id: "mw-input-wpeditfont") + checkbox(:edit_section_double_click_check, id: "mw-input-wpeditondblclick") + checkbox(:edit_section_edit_link, id: "mw-input-wpeditsectiononrightclick") + checkbox(:edit_section_right_click_check, id: "mw-input-wpeditsectiononrightclick") + checkbox(:forced_edit_summary_check, id: "mw-input-wpforceeditsummary") + checkbox(:live_preview_check, id: "mw-input-wpuselivepreview") + checkbox(:preview_on_first_check, id: "mw-input-wppreviewonfirst") + checkbox(:preview_on_top_check, id: "mw-input-wppreviewontop") + checkbox(:show_edit_toolbar_check, id: "mw-input-wpshowtoolbar") + checkbox(:unsaved_changes_check, id: "mw-input-wpuseeditwarning") +end diff --git a/tests/browser/features/support/pages/preferences_page.rb b/tests/browser/features/support/pages/preferences_page.rb new file mode 100644 index 0000000000..b581ca44eb --- /dev/null +++ b/tests/browser/features/support/pages/preferences_page.rb @@ -0,0 +1,28 @@ +# +# This file is subject to the license terms in the LICENSE file found in the +# qa-browsertests top-level directory and at +# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of +# qa-browsertests, including this file, may be copied, modified, propagated, or +# distributed except according to the terms contained in the LICENSE file. +# +# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the +# qa-browsertests top-level directory and at +# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS +# +class PreferencesPage + include PageObject + + include URL + page_url URL.url("Special:Preferences") + + a(:appearance_link, text: "Appearance") + a(:date_and_time_link, text: "Date and time") + a(:editing_link, text: "Editing") + a(:gadgets_link, text: "Gadgets") + a(:misc_link, text: "Misc") + a(:pending_changes_link, text: "Pending changes") + a(:recent_changes_link, text: "Recent changes") + a(:search_link, text: "Search") + a(:user_profile_link, text: "User profile") + a(:watchlist_link, text: "Watchlist") +end diff --git a/tests/browser/features/support/pages/preferences_user_profile_page.rb b/tests/browser/features/support/pages/preferences_user_profile_page.rb new file mode 100644 index 0000000000..28e10b97f1 --- /dev/null +++ b/tests/browser/features/support/pages/preferences_user_profile_page.rb @@ -0,0 +1,28 @@ +# +# This file is subject to the license terms in the LICENSE file found in the +# qa-browsertests top-level directory and at +# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of +# qa-browsertests, including this file, may be copied, modified, propagated, or +# distributed except according to the terms contained in the LICENSE file. +# +# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the +# qa-browsertests top-level directory and at +# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS +# +class PreferencesUserProfilePage + include PageObject + + include URL + page_url URL.url("Special:Preferences#mw-prefsection-personal") + + table(:basic_info_table, id: "mw-htmlform-info") + link(:change_password_link, text: "Change password") + table(:email_table, id: "mw-htmlform-email") + radio_button(:gender_female_radio, id: "mw-input-wpgender-male") + radio_button(:gender_male_radio, id: "mw-input-wpgender-female") + radio_button(:gender_undefined_radio, id: "mw-input-wpgender-unknown") + select_list(:lang_select, id: "mw-input-wplanguage") + checkbox(:remember_password_check, id: "mw-input-wprememberpassword") + text_field(:signature_field, id: "mw-input-wpnickname") + table(:signature_table, id: "mw-htmlform-signature") +end -- 2.20.1