Merge pull request #19453 from edx/arch/cleanup-login

Studio login/registration redirects to LMS
This commit is contained in:
Nimisha Asthagiri
2018-12-19 11:52:45 -05:00
committed by GitHub
27 changed files with 128 additions and 145 deletions

View File

@@ -3,4 +3,6 @@ import os
# Get the URL of the instance under test
HOSTNAME = os.environ.get('BOK_CHOY_HOSTNAME', 'localhost')
CMS_PORT = os.environ.get('BOK_CHOY_CMS_PORT', 8031)
LMS_PORT = os.environ.get('BOK_CHOY_LMS_PORT', 8003)
BASE_URL = os.environ.get('test_url', 'http://{}:{}'.format(HOSTNAME, CMS_PORT))
LMS_URL = os.environ.get('test_url', 'http://{}:{}'.format(HOSTNAME, LMS_PORT))

View File

@@ -4,7 +4,7 @@ Login page for Studio.
from bok_choy.page_object import PageObject
from bok_choy.promise import EmptyPromise
from common.test.acceptance.pages.studio import BASE_URL
from common.test.acceptance.pages.studio import LMS_URL
from common.test.acceptance.pages.studio.course_page import CoursePage
from common.test.acceptance.pages.studio.utils import HelpMixin
@@ -13,24 +13,25 @@ class LoginMixin(object):
"""
Mixin class used for logging into the system.
"""
def fill_field(self, css, value):
def fill_password(self, password):
"""
Fill the login form field with the value.
Fill the password field with the value.
"""
self.q(css=css).fill(value)
self.q(css="#login-password").fill(password)
def login(self, email, password, expect_success=True):
"""
Attempt to log in using 'email' and 'password'.
"""
self.fill_field('input#email', email)
self.fill_field('input#password', password)
self.q(css='button#submit').first.click()
self.wait_for_element_visibility('#login-email', 'Email field is shown')
self.q(css="#login-email").fill(email)
self.fill_password(password)
self.q(css=".login-button").click()
# Ensure that we make it to another page
if expect_success:
EmptyPromise(
lambda: "signin" not in self.browser.current_url,
lambda: "login" not in self.browser.current_url,
"redirected from the login page"
).fulfill()
@@ -39,17 +40,20 @@ class LoginPage(PageObject, LoginMixin, HelpMixin):
"""
Login page for Studio.
"""
url = BASE_URL + "/signin"
url = LMS_URL + "/login"
def is_browser_on_page(self):
return self.q(css='body.view-signin').visible
return (
self.q(css="#login-anchor").is_present() and
self.q(css=".login-button").visible
)
class CourseOutlineSignInRedirectPage(CoursePage, LoginMixin):
"""
Page shown when the user tries to accesses the course while not signed in.
Page shown when the user tries to access the course while not signed in.
"""
url_path = "course"
def is_browser_on_page(self):
return self.q(css='body.view-signin').visible
return self.q(css=".login-button").visible

View File

@@ -4,7 +4,7 @@ Signup page for studio
from bok_choy.page_object import PageObject
from common.test.acceptance.pages.common.utils import click_css
from common.test.acceptance.pages.studio import BASE_URL
from common.test.acceptance.pages.studio import LMS_URL
from common.test.acceptance.pages.studio.utils import HelpMixin, set_input_value
@@ -13,22 +13,29 @@ class SignupPage(PageObject, HelpMixin):
Signup page for Studio.
"""
url = BASE_URL + "/signup"
url = LMS_URL + "/register"
def is_browser_on_page(self):
return self.q(css='body.view-signup').visible
return (
self.q(css="#register-anchor").is_present() and
self.q(css=".register-button").visible
)
def input_password(self, password):
"""Inputs a password and then returns the password input"""
return set_input_value(self, '#password', password)
return set_input_value(self, "#register-password", password)
def sign_up_user(self, registration_dictionary):
def sign_up_user(self, email, name, username, password, country="US", favorite_movie="Alf"):
"""
Register the user.
"""
for css, value in registration_dictionary.iteritems():
set_input_value(self, css, value)
self.q(css="#register-email").fill(email)
self.q(css="#register-name").fill(name)
self.q(css="#register-username").fill(username)
self.q(css="#register-password").fill(password)
self.q(css="#register-country").results[0].send_keys(country)
self.q(css="#register-favorite_movie").fill(favorite_movie)
click_css(page=self, css='#tos', require_notification=False)
click_css(page=self, css='#submit', require_notification=False)
self.wait_for_element_absence('#submit', 'Submit button is gone.')
# Submit it
self.q(css=".register-button").click()
self.wait_for_element_absence('.register-button', 'Register button is gone.')

View File

@@ -8,6 +8,7 @@ from selenium.webdriver.common.keys import Keys
from base_studio_test import StudioCourseTest
from common.test.acceptance.fixtures.course import CourseFixture, XBlockFixtureDesc
from common.test.acceptance.pages.common.auto_auth import AutoAuthPage
from common.test.acceptance.pages.studio import LMS_URL
from common.test.acceptance.pages.studio.asset_index import AssetIndexPageStudioFrontend
from common.test.acceptance.pages.studio.course_info import CourseUpdatesPage
from common.test.acceptance.pages.studio.edit_tabs import PagesPage
@@ -118,15 +119,14 @@ class SignUpAndSignInTest(UniqueCourseTest):
index_page.visit()
index_page.click_sign_up()
unique_number = uuid.uuid4().hex[:4]
registration_dic = {
'#email': '{}-email@host.com'.format(unique_number),
'#name': '{}-name'.format(unique_number),
'#username': '{}-username'.format(unique_number),
'#password': '{}-password'.format(unique_number),
}
# Register the user.
self.sign_up_page.sign_up_user(registration_dic)
unique_number = uuid.uuid4().hex[:4]
self.sign_up_page.sign_up_user(
'{}-email@host.com'.format(unique_number),
'{}-name'.format(unique_number),
'{}-username'.format(unique_number),
'{}-password'.format(unique_number),
)
home = HomePage(self.browser)
home.wait_for_page()
@@ -145,8 +145,8 @@ class SignUpAndSignInTest(UniqueCourseTest):
password_input = self.sign_up_page.input_password('a') # Arbitrary short password that will fail
password_input.send_keys(Keys.TAB) # Focus out of the element
index_page.wait_for_element_visibility('#password_error', 'Password Error Message')
self.assertIsNotNone(index_page.q(css='#password_error').text) # Make sure there is an error message
index_page.wait_for_element_visibility('#register-password-validation-error', 'Password Error Message')
self.assertIsNotNone(index_page.q(css='#register-password-validation-error-msg')) # Error message should exist
def test_login_with_valid_redirect(self):
"""
@@ -184,9 +184,8 @@ class SignUpAndSignInTest(UniqueCourseTest):
self.browser.get(self.browser.current_url.split('=')[0] + '=http://www.google.com')
# Login
self.course_outline_sign_in_redirect_page.login(self.user['email'], self.user['password'])
home = HomePage(self.browser)
home.wait_for_page()
self.assertEqual(self.browser.current_url, home.url)
# Verify that we land in LMS instead of the invalid redirect url
self.assertEqual(self.browser.current_url, LMS_URL + "/dashboard")
def test_login_with_mistyped_credentials(self):
"""
@@ -219,16 +218,9 @@ class SignUpAndSignInTest(UniqueCourseTest):
)
# Verify that login error is shown
self.course_outline_sign_in_redirect_page.wait_for_element_visibility(
'#login_error',
".js-form-errors.status.submission-error",
'Login error is visible'
)
# Change the password
self.course_outline_sign_in_redirect_page.fill_field('input#password', 'changed_password')
# Login error should not be visible
self.course_outline_sign_in_redirect_page.wait_for_element_invisibility(
'#login_error',
'Login error is not visible'
)
# Login with correct credentials
self.course_outline_sign_in_redirect_page.login(self.user['email'], self.user['password'])
self.course_outline_page.wait_for_page()

View File

@@ -84,68 +84,6 @@ class StudioHelpTest(StudioCourseTest):
)
@attr(shard=20)
class SignInHelpTest(AcceptanceTest):
"""
Tests help links on 'Sign In' page
"""
def setUp(self):
super(SignInHelpTest, self).setUp()
self.index_page = IndexPage(self.browser)
self.index_page.visit()
def test_sign_in_nav_help(self):
"""
Scenario: Help link in navigation bar is working on 'Sign In' page.
Given that I am on the 'Sign In" page.
And I want help about the sign in
And I click the 'Help' in the navigation bar
Then Help link should open.
And help url should be correct
"""
sign_in_page = self.index_page.click_sign_in()
expected_url = _get_expected_documentation_url('/getting_started/index.html')
# Assert that help link is correct.
assert_nav_help_link(
test=self,
page=sign_in_page,
href=expected_url,
signed_in=False
)
@attr(shard=20)
class SignUpHelpTest(AcceptanceTest):
"""
Tests help links on 'Sign Up' page.
"""
def setUp(self):
super(SignUpHelpTest, self).setUp()
self.index_page = IndexPage(self.browser)
self.index_page.visit()
def test_sign_up_nav_help(self):
"""
Scenario: Help link in navigation bar is working on 'Sign Up' page.
Given that I am on the 'Sign Up" page.
And I want help about the sign up
And I click the 'Help' in the navigation bar
Then Help link should open.
And help url should be correct
"""
sign_up_page = self.index_page.click_sign_up()
expected_url = _get_expected_documentation_url('/getting_started/index.html')
# Assert that help link is correct.
assert_nav_help_link(
test=self,
page=sign_up_page,
href=expected_url,
signed_in=False
)
@attr(shard=20)
class HomeHelpTest(StudioCourseTest):
"""