Adding login specs for Android apps

twilson, panda, 2

  - added shared examples for Candroid and SpeedGrader for
    login view and credentials

  - minor simplification of iOS specs

  - to test: comment/uncomment appium init and skip statements in
    mobile_common, spin up Appium server, create and edit yml file,
    and run specs

Change-Id: Ia984a79bac51104dba232cf348a77fdc6a656c8b
Reviewed-on: https://gerrit.instructure.com/61280
Tested-by: Jenkins
Reviewed-by: Derek Hansen <dhansen@instructure.com>
Product-Review: Derek Hansen <dhansen@instructure.com>
QA-Review: Derek Hansen <dhansen@instructure.com>
This commit is contained in:
Taylor Wilson 2015-08-19 12:36:14 -06:00 committed by Derek Hansen
parent ee92311187
commit 2fce15aaa9
7 changed files with 124 additions and 14 deletions

View File

@ -0,0 +1,11 @@
require_relative '../../../helpers/login_common'
describe 'candroid login credentials' do
include_examples 'in-process server selenium tests'
include_context 'appium mobile specs', 'candroid'
let(:app_login_message){ /(Canvas for Android)/ }
let(:app_access_message){ /Canvas for Android is requesting access.*/ }
# examples located in: spec/selenium/appium/android/helpers/login_common.rb
it_behaves_like 'login credentials for candroid and speedgrader', 'candroid'
end

View File

@ -0,0 +1,90 @@
require_relative 'android_common'
# ======================================================================================================================
# Shared Examples for Candroid and Speedgrader Mobile Apps
# ======================================================================================================================
shared_examples 'login credentials for candroid and speedgrader' do |app_name|
before(:all) do
user_with_pseudonym(username: 'teacher1', password: 'teacher')
end
after(:all) do
logout(false)
end
context 'user provides bad credentials' do
before(:each) do
enter_school
end
# TODO: write test cases for bad credentials
end
context 'user forgot their password' do
before(:each) do
enter_school
end
after(:each) do
back
end
it 'routes to password reset view', priority: "1", test_id: pick_test_id_for_app(app_name, 221322, 295519) do
find_ele_by_attr('tags', 'android.view.View', 'name', /(I don't know my password)/).click
wait_true(timeout: 10, interval: 0.100){ button_exact('Request Password') }
expect(find_ele_by_attr('tags', 'android.view.View', 'name', /(change your password)/).name)
.to eq('Enter your Email and we\'ll send you a link to change your password.')
expect(first_textfield).to be_displayed # TODO: ask dev team for content descriptor
back_to_login_view = find_ele_by_attr('tags', 'android.view.View', 'name', /Back to Login/)
expect(back_to_login_view.name).to eq('Back to Login')
back_to_login_view.click
end
end
context 'user provides good credentials' do
before(:each) do
enter_school
provide_credentials(@user.primary_pseudonym.unique_id, user_password(@user))
end
after(:each) do
logout(false)
end
it 'passes login and routes to home page', priority: "1", test_id: pick_test_id_for_app(app_name, 221323, 295521) do
wait_true(timeout: 10, interval: 0.250){ find_ele_by_attr('tags', 'android.view.View', 'name', app_login_message) }
expect(find_ele_by_attr('tags', 'android.view.View', 'name', app_access_message))
.to be_an_instance_of(Selenium::WebDriver::Element)
expect(find_ele_by_attr('tags', 'android.view.View', 'name', /(You are logging into this app as)/))
.to be_an_instance_of(Selenium::WebDriver::Element)
expect(find_ele_by_attr('tags', 'android.view.View', 'name', /#{(@user.primary_pseudonym.unique_id)}/))
.to be_an_instance_of(Selenium::WebDriver::Element)
expect(find_ele_by_attr('tags', 'android.view.View', 'name', /Cancel/).name).to eq('Cancel')
remember_auth = find_ele_by_attr('tags', 'android.widget.CheckBox', 'name', /Remember my authorization for this service/)
expect(remember_auth.attribute('checked')).to eq('false')
remember_auth.click
expect(remember_auth.attribute('checked')).to eq('true')
button('Log in').click
skip_tutorial
# User avatar displays on Home Page but takes time to load
wait_true(timeout:10, interval: 0.250){ candroid_app ? find_element(:id, 'userProfilePic') : find_element(:id, 'courseSwitcher') }
end
end
end
# ======================================================================================================================
# Helper Methods
# ======================================================================================================================
def provide_credentials(username, password)
first_textfield.send_keys(username)
last_textfield.send_keys(password)
button('Log in').click
end

View File

@ -0,0 +1,11 @@
require_relative '../../../helpers/login_common'
describe 'speedgrader login credentials' do
include_examples 'in-process server selenium tests'
include_context 'appium mobile specs', 'speedgrader_android'
let(:app_login_message){ /(Canvas for Android)/ } # TODO: ask dev team to modify this for Speedgrader
let(:app_access_message){ /Canvas for Android is requesting access.*/ } # TODO: ask dev team to modify this for Speedgrader
# examples located in: spec/selenium/appium/android/helpers/login_common.rb
it_behaves_like 'login credentials for candroid and speedgrader', 'speedgrader_android'
end

View File

@ -122,7 +122,7 @@ end
def dismiss_user_polling
begin
find_element(:id, 'How do you like Canvas?')
find_element(:id, 'Ask me later').click
find_element(:id, 'Don\'t ask me again').click
rescue => ex
raise ex unless ex.is_a?(Selenium::WebDriver::Error::NoSuchElementError)
end

View File

@ -106,13 +106,8 @@ shared_context 'icanvas and speedgrader login credentials' do |app_name|
it 'passes login and routes to home page', priority: "1", test_id: pick_test_id_for_app(app_name, 14041, 303730) do
# App requests access to Canvas account; need to wait for next WebView to load
if app_name =~ /(speedgrader)/
wait_true(timeout: 10, interval: 0.250){ text_exact('SpeedGrader') }
expect(text_exact('SpeedGrader is requesting access to your account.')).to be_displayed
else
wait_true(timeout: 10, interval: 0.250){ text_exact('Canvas for iOS') }
expect(text_exact('Canvas for iOS is requesting access to your account.')).to be_displayed
end
wait_true(timeout: 10, interval: 0.250){ text_exact(app_login_message) }
expect(text_exact(app_access_message)).to be_displayed
# Verify paragraph text includes username
links = tags('UIALink')
@ -133,12 +128,7 @@ shared_context 'icanvas and speedgrader login credentials' do |app_name|
# User is occasionally polled here
dismiss_user_polling
if app_name =~ /(speedgrader)/
wait_true(timeout: 10, interval: 0.250){ find_element(:id, 'CSGSlideMenuView') }
else
wait_true(timeout: 10, interval: 0.250){ find_element(:id, 'Profile') }
end
wait_true(timeout: 10, interval: 0.250){ find_element(:id, app_login_success) }
end
end
end

View File

@ -3,6 +3,10 @@ require_relative '../../../helpers/login_common'
describe 'user logging into icanvas app' do
include_examples 'in-process server selenium tests'
include_examples 'appium mobile specs', 'icanvas'
let(:app_login_message){ 'Canvas for iOS' }
let(:app_access_message){ 'Canvas for iOS is requesting access to your account.' }
let(:app_login_success){ 'Profile' }
# examples located in: spec/selenium/appium/ios/helpers/login_common.rb
it_behaves_like 'icanvas and speedgrader login credentials', 'icanvas'
end

View File

@ -3,6 +3,10 @@ require_relative '../../../helpers/login_common'
describe 'user logging into speedgrader app' do
include_examples 'in-process server selenium tests'
include_examples 'appium mobile specs', 'speedgrader_ios'
let(:app_login_message){ 'SpeedGrader' }
let(:app_access_message){ 'SpeedGrader is requesting access to your account.' }
let(:app_login_success){ 'CSGSlideMenuView' }
# examples located in: spec/selenium/appium/ios/helpers/login_common.rb
it_behaves_like 'icanvas and speedgrader login credentials', 'speedgrader_ios'
end