QA: porting login test from /qa/browsertests
authorCmcmahon <cmcmahon@wikimedia.org>
Mon, 30 Jun 2014 23:56:46 +0000 (16:56 -0700)
committerCmcmahon <cmcmahon@wikimedia.org>
Mon, 30 Jun 2014 23:57:36 +0000 (16:57 -0700)
Tested in local bare wiki, beta hewiki and enwiki

Change-Id: Icf060de7697cb43d9a8d28c036d4efcbdfd64720

tests/browser/features/login.feature [new file with mode: 0644]
tests/browser/features/step_definitions/login_steps.rb [new file with mode: 0644]
tests/browser/features/support/pages/login_error_page.rb [new file with mode: 0644]

diff --git a/tests/browser/features/login.feature b/tests/browser/features/login.feature
new file mode 100644 (file)
index 0000000..9ff2a2a
--- /dev/null
@@ -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
+#
+@chrome @en.wikipedia.beta.wmflabs.org @firefox @internet_explorer_6 @internet_explorer_7 @internet_explorer_8 @internet_explorer_9 @internet_explorer_10 @phantomjs @test2.wikipedia.org
+Feature: Log in
+
+  Background:
+    Given I am at Log in page
+
+  Scenario: Go to Log in page
+    Then Username element should be there
+      And Password element should be there
+      And Log in element should be there
+
+  Scenario: Log in without entering credentials
+    When I log in without entering credentials
+    Then error box should be visible
+
+  Scenario: Log in without entering password
+    When I log in without entering password
+    Then error box should be visible
+
+  Scenario: Log in with incorrect username
+    When I log in with incorrect username
+    Then error box should be visible
+
+  Scenario: Log in with incorrect password
+    When I log in with incorrect password
+    Then error box should be visible
+
+  @login
+  Scenario: Log in with valid credentials
+    When I am logged in
+    Then error box should not be visible
\ No newline at end of file
diff --git a/tests/browser/features/step_definitions/login_steps.rb b/tests/browser/features/step_definitions/login_steps.rb
new file mode 100644 (file)
index 0000000..b654b2d
--- /dev/null
@@ -0,0 +1,65 @@
+#
+# 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
+#
+Given(/^I am at Log in page$/) do
+  visit LoginPage
+end
+
+When(/^I log in with incorrect password$/) do
+  on(LoginPage).login_with(ENV["MEDIAWIKI_USER"], "incorrect password", false)
+end
+
+When(/^I log in with incorrect username$/) do
+  on(LoginPage).login_with("incorrect username", ENV["MEDIAWIKI_PASSWORD"], false)
+end
+
+When(/^I log in without entering credentials$/) do
+  on(LoginPage).login_with("", "", false)
+end
+
+When(/^I log in without entering password$/) do
+  on(LoginPage).login_with(ENV["MEDIAWIKI_USER"], "", false)
+end
+
+Then(/^error box should be visible$/) do
+  on(LoginErrorPage).error_box_element.should be_visible
+end
+
+Then(/^error box should not be visible$/) do
+  on(LoginErrorPage).error_box_element.should_not be_visible
+end
+
+Then(/^feedback should be (.+)$/) do |feedback|
+  on(LoginPage) do |page|
+    page.feedback_element.when_present.click
+    page.feedback.should match Regexp.escape(feedback)
+  end
+end
+
+Then(/^Log in element should be there$/) do
+  on(LoginPage).login_element.should exist
+end
+
+Then(/^main page should open$/) do
+  @browser.url.should == on(MainPage).class.url
+end
+
+Then(/^Password element should be there$/) do
+  on(LoginPage).password_element.should exist
+end
+
+Then(/^there should be a link to (.+)$/) do |text|
+  on(LoginPage).username_displayed_element.when_present.text.should == text
+end
+
+Then(/^Username element should be there$/) do
+  on(LoginPage).username_element.should exist
+end
diff --git a/tests/browser/features/support/pages/login_error_page.rb b/tests/browser/features/support/pages/login_error_page.rb
new file mode 100644 (file)
index 0000000..4fc9ca7
--- /dev/null
@@ -0,0 +1,5 @@
+class LoginErrorPage
+  include PageObject
+
+  div(:error_box, class: "errorbox")
+end
\ No newline at end of file