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
c64d9aaa
Commit
c64d9aaa
authored
Jul 27, 2016
by
Muddasser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
automate help links
parent
d145457b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
159 additions
and
7 deletions
+159
-7
common/test/acceptance/pages/studio/index.py
+2
-1
common/test/acceptance/pages/studio/library.py
+2
-2
common/test/acceptance/pages/studio/login.py
+2
-1
common/test/acceptance/pages/studio/signup.py
+2
-2
common/test/acceptance/pages/studio/users.py
+2
-1
common/test/acceptance/pages/studio/utils.py
+56
-0
common/test/acceptance/tests/helpers.py
+93
-0
common/test/acceptance/tests/studio/test_studio_help.py
+0
-0
No files found.
common/test/acceptance/pages/studio/index.py
View file @
c64d9aaa
...
...
@@ -7,6 +7,7 @@ from selenium.webdriver import ActionChains
from
common.test.acceptance.pages.studio
import
BASE_URL
from
common.test.acceptance.pages.studio.login
import
LoginPage
from
common.test.acceptance.pages.studio.signup
import
SignupPage
from
common.test.acceptance.pages.studio.utils
import
HelpMixin
class
HeaderMixin
(
object
):
...
...
@@ -40,7 +41,7 @@ class IndexPage(PageObject, HeaderMixin):
return
self
.
q
(
css
=
'.wrapper-text-welcome'
)
.
visible
class
DashboardPage
(
PageObject
):
class
DashboardPage
(
PageObject
,
HelpMixin
):
"""
Studio Dashboard page with courses.
The user must be logged in to access this page.
...
...
common/test/acceptance/pages/studio/library.py
View file @
c64d9aaa
...
...
@@ -10,13 +10,13 @@ from common.test.acceptance.pages.studio.container import XBlockWrapper
from
common.test.acceptance.pages.studio.users
import
UsersPageMixin
from
common.test.acceptance.pages.studio.pagination
import
PaginatedMixin
from
selenium.webdriver.common.keys
import
Keys
from
common.test.acceptance.pages.studio.utils
import
HelpMixin
from
common.test.acceptance.pages.common.utils
import
confirm_prompt
,
wait_for_notification
from
common.test.acceptance.pages.studio
import
BASE_URL
class
LibraryPage
(
PageObject
):
class
LibraryPage
(
PageObject
,
HelpMixin
):
"""
Base page for Library pages. Defaults URL to the edit page.
"""
...
...
common/test/acceptance/pages/studio/login.py
View file @
c64d9aaa
...
...
@@ -6,6 +6,7 @@ from bok_choy.promise import EmptyPromise
from
common.test.acceptance.pages.studio
import
BASE_URL
from
common.test.acceptance.pages.studio.course_page
import
CoursePage
from
common.test.acceptance.pages.studio.utils
import
HelpMixin
class
LoginMixin
(
object
):
...
...
@@ -34,7 +35,7 @@ class LoginMixin(object):
)
.
fulfill
()
class
LoginPage
(
PageObject
,
LoginMixin
):
class
LoginPage
(
PageObject
,
LoginMixin
,
HelpMixin
):
"""
Login page for Studio.
"""
...
...
common/test/acceptance/pages/studio/signup.py
View file @
c64d9aaa
...
...
@@ -4,11 +4,11 @@ Signup page for studio
from
bok_choy.page_object
import
PageObject
from
common.test.acceptance.pages.studio
import
BASE_URL
from
common.test.acceptance.pages.studio.utils
import
set_input_value
from
common.test.acceptance.pages.studio.utils
import
set_input_value
,
HelpMixin
from
common.test.acceptance.pages.common.utils
import
click_css
class
SignupPage
(
PageObject
):
class
SignupPage
(
PageObject
,
HelpMixin
):
"""
Signup page for Studio.
"""
...
...
common/test/acceptance/pages/studio/users.py
View file @
c64d9aaa
...
...
@@ -6,6 +6,7 @@ from bok_choy.page_object import PageObject
from
common.test.acceptance.tests.helpers
import
disable_animations
from
common.test.acceptance.pages.studio.course_page
import
CoursePage
from
common.test.acceptance.pages.studio
import
BASE_URL
from
common.test.acceptance.pages.studio.utils
import
HelpMixin
def
wait_for_ajax_or_reload
(
browser
):
...
...
@@ -147,7 +148,7 @@ class UsersPageMixin(PageObject):
disable_animations
(
self
)
class
LibraryUsersPage
(
UsersPageMixin
):
class
LibraryUsersPage
(
UsersPageMixin
,
HelpMixin
):
"""
Library Team page in Studio
"""
...
...
common/test/acceptance/pages/studio/utils.py
View file @
c64d9aaa
...
...
@@ -9,6 +9,12 @@ from bok_choy.promise import EmptyPromise
from
common.test.acceptance.pages.common.utils
import
click_css
,
wait_for_notification
NAV_HELP_NOT_SIGNED_IN_CSS
=
'.nav-item.nav-not-signedin-help a'
NAV_HELP_CSS
=
'.nav-item.nav-account-help a'
SIDE_BAR_HELP_AS_LIST_ITEM
=
'.bit li.action-item a'
SIDE_BAR_HELP_CSS
=
'.bit.external-help a'
@js_defined
(
'window.jQuery'
)
def
press_the_notification_button
(
page
,
name
):
# Because the notification uses a CSS transition,
...
...
@@ -148,6 +154,7 @@ def type_in_codemirror(page, index, text, find_prefix="$"):
CodeMirror.signal(cm, "focus", cm);
cm.setValue(arguments[0]);
CodeMirror.signal(cm, "blur", cm);"""
.
format
(
index
=
index
,
find_prefix
=
find_prefix
)
page
.
browser
.
execute_script
(
script
,
str
(
text
))
...
...
@@ -250,3 +257,52 @@ def click_studio_help(page):
def
studio_help_links
(
page
):
"""Return the list of Studio help links in the page footer."""
return
page
.
q
(
css
=
'.support .list-actions a'
)
.
results
class
HelpMixin
(
object
):
"""
Mixin for testing Help links.
"""
def
get_nav_help_element_and_click_help
(
self
,
signed_in
=
True
):
"""
Click on the help, and also get the DOM help element.
It operates on the help elements in the navigation bar.
Arguments:
signed_in (bool): Indicates whether user is signed in or not.
Returns:
WebElement: Help DOM element in the navigation bar.
"""
element_css
=
None
if
signed_in
:
element_css
=
NAV_HELP_CSS
else
:
element_css
=
NAV_HELP_NOT_SIGNED_IN_CSS
self
.
q
(
css
=
element_css
)
.
click
()
return
self
.
q
(
css
=
element_css
)
.
results
[
0
]
def
get_side_bar_help_element_and_click_help
(
self
,
as_list_item
=
False
):
"""
Click on the help, and also get the DOM help element.
It operates on the help elements in the side bar.
Arguments:
as_list_item (bool): Indicates whether help element is
enclosed in a 'li' DOM element.
Returns:
WebElement: Help DOM element in the side bar.
"""
element_css
=
None
if
as_list_item
:
element_css
=
SIDE_BAR_HELP_AS_LIST_ITEM
else
:
element_css
=
SIDE_BAR_HELP_CSS
self
.
q
(
css
=
element_css
)
.
click
()
return
self
.
q
(
css
=
element_css
)
.
results
[
0
]
common/test/acceptance/tests/helpers.py
View file @
c64d9aaa
...
...
@@ -379,6 +379,48 @@ def auto_auth(browser, username, email, staff, course_id):
AutoAuthPage
(
browser
,
username
=
username
,
email
=
email
,
course_id
=
course_id
,
staff
=
staff
)
.
visit
()
def
get_url_with_changed_domain
(
url
):
"""
Replaces .org with .io in the url
Arguments:
url (str): The url to perform replace operation on.
Returns:
str: The updated url
"""
return
url
.
replace
(
'.org/'
,
'.io/'
)
def
assert_link
(
test
,
expected_link
,
actual_link
):
"""
Assert that 'href' and text inside help DOM element are correct.
Arguments:
test: Test on which links are being tested.
expected_link (dict): The expected link attributes.
actual_link (dict): The actual link attribute on page.
"""
test
.
assertEqual
(
expected_link
[
'href'
],
actual_link
.
get_attribute
(
'href'
))
test
.
assertEqual
(
expected_link
[
'text'
],
actual_link
.
text
)
def
assert_opened_help_link_is_correct
(
test
,
url
):
"""
Asserts that url of browser when help link is clicked is correct.
Arguments:
test (WebAppTest): test calling this method.
url (str): url to verify.
"""
test
.
browser
.
switch_to_window
(
test
.
browser
.
window_handles
[
-
1
])
# Assert that url in the browser is the same.
# Please note that .org domain in href attribute of help anchor DOM element
# is changed into .io domain. This is because browser is redirected from .org
# domain to .io domain.
test
.
assertEqual
(
get_url_with_changed_domain
(
url
),
test
.
browser
.
current_url
)
test
.
assertNotIn
(
'Maze Found'
,
test
.
browser
.
title
)
class
EventsTestMixin
(
TestCase
):
"""
Helpers and setup for running tests that evaluate events emitted
...
...
@@ -772,6 +814,57 @@ def create_user_partition_json(partition_id, name, description, groups, scheme="
)
.
to_json
()
def
assert_nav_help_link
(
test
,
page
,
href
,
signed_in
=
True
):
"""
Asserts that help link in navigation bar is correct.
It first checks the url inside anchor DOM element and
then clicks to ensure that help opens correctly.
Arguments:
test (WebAppTest): Test object
page (PageObject): Page object to perform tests on.
href (str): The help link which we expect to see when it is opened.
signed_in (bool): Specifies whether user is logged in or not. (It effects the css)
"""
expected_link
=
{
'href'
:
href
,
'text'
:
'Help'
}
# Get actual anchor help element from the page.
actual_link
=
page
.
get_nav_help_element_and_click_help
(
signed_in
)
# Assert that 'href' and text are the same as expected.
assert_link
(
test
,
expected_link
,
actual_link
)
# Assert that opened link is correct
assert_opened_help_link_is_correct
(
test
,
href
)
def
assert_side_bar_help_link
(
test
,
page
,
href
,
help_text
,
as_list_item
=
False
):
"""
Asserts that help link in side bar is correct.
It first checks the url inside anchor DOM element and
then clicks to ensure that help opens correctly.
Arguments:
test (WebAppTest): Test object
page (PageObject): Page object to perform tests on.
href (str): The help link which we expect to see when it is opened.
as_list_item (bool): Specifies whether help element is in one of the
'li' inside a sidebar list DOM element.
"""
expected_link
=
{
'href'
:
href
,
'text'
:
help_text
}
# Get actual anchor help element from the page.
actual_link
=
page
.
get_side_bar_help_element_and_click_help
(
as_list_item
)
# Assert that 'href' and text are the same as expected.
assert_link
(
test
,
expected_link
,
actual_link
)
# Assert that opened link is correct
assert_opened_help_link_is_correct
(
test
,
href
)
class
TestWithSearchIndexMixin
(
object
):
""" Mixin encapsulating search index creation """
TEST_INDEX_FILENAME
=
"test_root/index_file.dat"
...
...
common/test/acceptance/tests/studio/test_studio_help.py
View file @
c64d9aaa
This diff is collapsed.
Click to expand it.
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