Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
96dcdb43
Commit
96dcdb43
authored
Nov 14, 2014
by
Renzo Lucioni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Selenium tests of logistration password reset
parent
83f8de6c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
2 deletions
+69
-2
common/test/acceptance/pages/lms/login_and_register.py
+40
-1
common/test/acceptance/tests/lms/test_lms.py
+29
-1
No files found.
common/test/acceptance/pages/lms/login_and_register.py
View file @
96dcdb43
...
...
@@ -191,6 +191,32 @@ class CombinedLoginAndRegisterPage(PageObject):
# Submit it
self
.
q
(
css
=
".login-button"
)
.
click
()
def
password_reset
(
self
,
email
):
"""Navigates to, fills in, and submits the password reset form.
Requires that the "login" form is visible.
Keyword Arguments:
email (unicode): The user's email address.
"""
login_form
=
self
.
current_form
# Click the password reset link on the login page
self
.
q
(
css
=
"a.forgot-password"
)
.
click
()
# Wait for the password reset form to load
EmptyPromise
(
lambda
:
self
.
current_form
!=
login_form
,
"Finish toggling to the password reset form"
)
.
fulfill
()
# Fill in the form
self
.
q
(
css
=
"#password-reset-email"
)
.
fill
(
email
)
# Submit it
self
.
q
(
css
=
"button.js-reset"
)
.
click
()
@property
@unguarded
def
current_form
(
self
):
...
...
@@ -207,7 +233,7 @@ class CombinedLoginAndRegisterPage(PageObject):
return
"register"
elif
self
.
q
(
css
=
".login-button"
)
.
visible
:
return
"login"
elif
self
.
q
(
css
=
".js-reset"
)
.
visible
:
elif
self
.
q
(
css
=
".js-reset"
)
.
visible
or
self
.
q
(
css
=
".js-reset-success"
)
.
visible
:
return
"password-reset"
@property
...
...
@@ -221,3 +247,16 @@ class CombinedLoginAndRegisterPage(PageObject):
errors
=
self
.
errors
return
(
bool
(
errors
),
errors
)
return
Promise
(
_check_func
,
"Errors are visible"
)
.
fulfill
()
@property
def
success
(
self
):
"""Return a success message displayed to the user."""
if
self
.
q
(
css
=
".submission-success"
)
.
visible
:
return
self
.
q
(
css
=
".submission-success h4"
)
.
text
def
wait_for_success
(
self
):
"""Wait for a success message to be visible, then return it."""
def
_check_func
():
success
=
self
.
success
return
(
bool
(
success
),
success
)
return
Promise
(
_check_func
,
"Success message is visible"
)
.
fulfill
()
common/test/acceptance/tests/lms/test_lms.py
View file @
96dcdb43
...
...
@@ -69,7 +69,12 @@ class RegistrationTest(UniqueCourseTest):
@attr
(
'shard_1'
)
class
LoginFromCombinedPageTest
(
UniqueCourseTest
):
"""Test that we can log in using the combined login/registration page. """
"""Test that we can log in using the combined login/registration page.
Also test that we can request a password reset from the combined
login/registration page.
"""
def
setUp
(
self
):
"""Initialize the page objects and create a test course. """
...
...
@@ -112,6 +117,29 @@ class LoginFromCombinedPageTest(UniqueCourseTest):
self
.
login_page
.
visit
()
.
toggle_form
()
self
.
assertEqual
(
self
.
login_page
.
current_form
,
"register"
)
def
test_password_reset_success
(
self
):
# Create a user account
email
,
password
=
self
.
_create_unique_user
()
# Navigate to the password reset form and try to submit it
self
.
login_page
.
visit
()
.
password_reset
(
email
=
email
)
# Expect that we're shown a success message
self
.
assertIn
(
"PASSWORD RESET EMAIL SENT"
,
self
.
login_page
.
wait_for_success
())
def
test_password_reset_failure
(
self
):
# Navigate to the password reset form
self
.
login_page
.
visit
()
# User account does not exist
self
.
login_page
.
password_reset
(
email
=
"nobody@nowhere.com"
)
# Expect that we're shown a failure message
self
.
assertIn
(
"No active user with the provided email address exists."
,
self
.
login_page
.
wait_for_errors
()
)
def
_create_unique_user
(
self
):
username
=
"test_{uuid}"
.
format
(
uuid
=
self
.
unique_id
[
0
:
6
])
email
=
"{user}@example.com"
.
format
(
user
=
username
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment