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
f1f4f2e2
Commit
f1f4f2e2
authored
Sep 26, 2016
by
Muddasser
Committed by
GitHub
Sep 26, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13145 from edx/muddasser/edx/automate_help
automate help links
parents
b228f9e4
87747282
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
189 additions
and
13 deletions
+189
-13
common/test/acceptance/pages/studio/container.py
+2
-1
common/test/acceptance/pages/studio/course_page.py
+12
-2
common/test/acceptance/pages/studio/index.py
+11
-2
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
+20
-3
common/test/acceptance/pages/studio/utils.py
+59
-0
common/test/acceptance/tests/helpers.py
+79
-0
common/test/acceptance/tests/studio/test_studio_help.py
+0
-0
No files found.
common/test/acceptance/pages/studio/container.py
View file @
f1f4f2e2
...
...
@@ -5,13 +5,14 @@ Container page in Studio
from
bok_choy.page_object
import
PageObject
from
bok_choy.promise
import
Promise
,
EmptyPromise
from
common.test.acceptance.pages.studio
import
BASE_URL
from
common.test.acceptance.pages.studio.utils
import
HelpMixin
from
common.test.acceptance.pages.common.utils
import
click_css
,
confirm_prompt
from
common.test.acceptance.pages.studio.utils
import
type_in_codemirror
class
ContainerPage
(
PageObject
):
class
ContainerPage
(
PageObject
,
HelpMixin
):
"""
Container page in Studio
"""
...
...
common/test/acceptance/pages/studio/course_page.py
View file @
f1f4f2e2
"""
Base class for pages specific to a course in Studio.
"""
from
abc
import
abstractmethod
import
os
from
opaque_keys.edx.locator
import
CourseLocator
from
bok_choy.page_object
import
PageObject
from
common.test.acceptance.pages.studio
import
BASE_URL
from
common.test.acceptance.pages.studio.utils
import
HelpMixin
class
CoursePage
(
PageObject
):
class
CoursePage
(
PageObject
,
HelpMixin
):
"""
Abstract base class for page objects specific to a course in Studio.
"""
...
...
@@ -17,6 +18,15 @@ class CoursePage(PageObject):
# Does not need to include the leading forward or trailing slash
url_path
=
""
@abstractmethod
def
is_browser_on_page
(
self
):
"""
Verifies browser is on the correct page.
Should be implemented in child classes.
"""
pass
def
__init__
(
self
,
browser
,
course_org
,
course_num
,
course_run
):
"""
Initialize the page object for the course located at
...
...
common/test/acceptance/pages/studio/index.py
View file @
f1f4f2e2
...
...
@@ -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
):
...
...
@@ -30,7 +31,7 @@ class HeaderMixin(object):
return
next_page
.
wait_for_page
()
class
IndexPage
(
PageObject
,
HeaderMixin
):
class
IndexPage
(
PageObject
,
HeaderMixin
,
HelpMixin
):
"""
Home page for Studio when not logged in.
"""
...
...
@@ -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.
...
...
@@ -321,3 +322,11 @@ class DashboardPageWithPrograms(DashboardPage):
element
.
find_element_by_css_selector
(
'.course-org .value'
)
.
text
,
# org key
)
return
self
.
q
(
css
=
'div.programs-tab li.course-item'
)
.
map
(
div2info
)
.
results
def
click_new_program_button
(
self
):
"""
Click on the new program button.
"""
self
.
q
(
css
=
'.button.new-button.new-program-button'
)
.
click
()
self
.
wait_for_ajax
()
self
.
wait_for_element_visibility
(
".account-username"
,
"New program page is open"
)
common/test/acceptance/pages/studio/library.py
View file @
f1f4f2e2
...
...
@@ -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 @
f1f4f2e2
...
...
@@ -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 @
f1f4f2e2
...
...
@@ -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 @
f1f4f2e2
"""
Page classes to test either the Course Team page or the Library Team page.
"""
import
os
from
opaque_keys.edx.locator
import
CourseLocator
from
bok_choy.promise
import
EmptyPromise
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 +150,7 @@ class UsersPageMixin(PageObject):
disable_animations
(
self
)
class
LibraryUsersPage
(
UsersPageMixin
):
class
LibraryUsersPage
(
UsersPageMixin
,
HelpMixin
):
"""
Library Team page in Studio
"""
...
...
@@ -163,13 +166,27 @@ class LibraryUsersPage(UsersPageMixin):
return
"{}/library/{}/team/"
.
format
(
BASE_URL
,
unicode
(
self
.
locator
))
class
CourseTeamPage
(
CoursePage
,
UsersPageMixin
):
class
CourseTeamPage
(
UsersPageMixin
,
CoursePage
):
"""
Course Team page in Studio.
"""
url_path
=
"course_team"
@property
def
url
(
self
):
"""
Construct a URL to the page within the course.
"""
# TODO - is there a better way to make this agnostic to the underlying default module store?
default_store
=
os
.
environ
.
get
(
'DEFAULT_STORE'
,
'draft'
)
course_key
=
CourseLocator
(
self
.
course_info
[
'course_org'
],
self
.
course_info
[
'course_num'
],
self
.
course_info
[
'course_run'
],
deprecated
=
(
default_store
==
'draft'
)
)
return
"/"
.
join
([
BASE_URL
,
self
.
url_path
,
unicode
(
course_key
)])
class
UserWrapper
(
PageObject
):
"""
...
...
common/test/acceptance/pages/studio/utils.py
View file @
f1f4f2e2
...
...
@@ -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
=
'.external-help a, .external-help-button'
@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,55 @@ 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
)
.
first
.
click
()
return
self
.
q
(
css
=
element_css
)
.
results
[
0
]
def
get_side_bar_help_element_and_click_help
(
self
,
as_list_item
=
False
,
index
=-
1
):
"""
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.
index (int): The index of element in case there are more than
one matching elements.
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
help_element
=
self
.
q
(
css
=
element_css
)
.
results
[
index
]
help_element
.
click
()
return
help_element
common/test/acceptance/tests/helpers.py
View file @
f1f4f2e2
...
...
@@ -379,6 +379,32 @@ def auto_auth(browser, username, email, staff, course_id):
AutoAuthPage
(
browser
,
username
=
username
,
email
=
email
,
course_id
=
course_id
,
staff
=
staff
)
.
visit
()
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.
test
.
assertEqual
(
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 +798,59 @@ 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
,
index
=-
1
):
"""
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.
index (int): The index of element in case there are more than
one matching elements.
"""
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
=
as_list_item
,
index
=
index
)
# 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 @
f1f4f2e2
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