Commit 3683ee7f by Muddasser

Help Links second pass

parent c64d9aaa
...@@ -5,13 +5,14 @@ Container page in Studio ...@@ -5,13 +5,14 @@ Container page in Studio
from bok_choy.page_object import PageObject from bok_choy.page_object import PageObject
from bok_choy.promise import Promise, EmptyPromise from bok_choy.promise import Promise, EmptyPromise
from common.test.acceptance.pages.studio import BASE_URL 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.common.utils import click_css, confirm_prompt
from common.test.acceptance.pages.studio.utils import type_in_codemirror from common.test.acceptance.pages.studio.utils import type_in_codemirror
class ContainerPage(PageObject): class ContainerPage(PageObject, HelpMixin):
""" """
Container page in Studio Container page in Studio
""" """
......
""" """
Base class for pages specific to a course in Studio. Base class for pages specific to a course in Studio.
""" """
from abc import abstractmethod
import os import os
from opaque_keys.edx.locator import CourseLocator from opaque_keys.edx.locator import CourseLocator
from bok_choy.page_object import PageObject from bok_choy.page_object import PageObject
from common.test.acceptance.pages.studio import BASE_URL 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. Abstract base class for page objects specific to a course in Studio.
""" """
...@@ -17,6 +18,15 @@ class CoursePage(PageObject): ...@@ -17,6 +18,15 @@ class CoursePage(PageObject):
# Does not need to include the leading forward or trailing slash # Does not need to include the leading forward or trailing slash
url_path = "" 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): def __init__(self, browser, course_org, course_num, course_run):
""" """
Initialize the page object for the course located at Initialize the page object for the course located at
......
...@@ -31,7 +31,7 @@ class HeaderMixin(object): ...@@ -31,7 +31,7 @@ class HeaderMixin(object):
return next_page.wait_for_page() return next_page.wait_for_page()
class IndexPage(PageObject, HeaderMixin): class IndexPage(PageObject, HeaderMixin, HelpMixin):
""" """
Home page for Studio when not logged in. Home page for Studio when not logged in.
""" """
...@@ -322,3 +322,11 @@ class DashboardPageWithPrograms(DashboardPage): ...@@ -322,3 +322,11 @@ class DashboardPageWithPrograms(DashboardPage):
element.find_element_by_css_selector('.course-org .value').text, # org key 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 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")
""" """
Page classes to test either the Course Team page or the Library Team page. 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.promise import EmptyPromise
from bok_choy.page_object import PageObject from bok_choy.page_object import PageObject
from common.test.acceptance.tests.helpers import disable_animations from common.test.acceptance.tests.helpers import disable_animations
...@@ -164,13 +166,27 @@ class LibraryUsersPage(UsersPageMixin, HelpMixin): ...@@ -164,13 +166,27 @@ class LibraryUsersPage(UsersPageMixin, HelpMixin):
return "{}/library/{}/team/".format(BASE_URL, unicode(self.locator)) return "{}/library/{}/team/".format(BASE_URL, unicode(self.locator))
class CourseTeamPage(CoursePage, UsersPageMixin): class CourseTeamPage(UsersPageMixin, CoursePage):
""" """
Course Team page in Studio. Course Team page in Studio.
""" """
url_path = "course_team" 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): class UserWrapper(PageObject):
""" """
......
...@@ -12,7 +12,7 @@ from common.test.acceptance.pages.common.utils import click_css, wait_for_notifi ...@@ -12,7 +12,7 @@ from common.test.acceptance.pages.common.utils import click_css, wait_for_notifi
NAV_HELP_NOT_SIGNED_IN_CSS = '.nav-item.nav-not-signedin-help a' NAV_HELP_NOT_SIGNED_IN_CSS = '.nav-item.nav-not-signedin-help a'
NAV_HELP_CSS = '.nav-item.nav-account-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_AS_LIST_ITEM = '.bit li.action-item a'
SIDE_BAR_HELP_CSS = '.bit.external-help a' SIDE_BAR_HELP_CSS = '.external-help a, .external-help-button'
@js_defined('window.jQuery') @js_defined('window.jQuery')
...@@ -282,10 +282,10 @@ class HelpMixin(object): ...@@ -282,10 +282,10 @@ class HelpMixin(object):
else: else:
element_css = NAV_HELP_NOT_SIGNED_IN_CSS element_css = NAV_HELP_NOT_SIGNED_IN_CSS
self.q(css=element_css).click() self.q(css=element_css).first.click()
return self.q(css=element_css).results[0] return self.q(css=element_css).results[0]
def get_side_bar_help_element_and_click_help(self, as_list_item=False): 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. Click on the help, and also get the DOM help element.
...@@ -294,6 +294,8 @@ class HelpMixin(object): ...@@ -294,6 +294,8 @@ class HelpMixin(object):
Arguments: Arguments:
as_list_item (bool): Indicates whether help element is as_list_item (bool): Indicates whether help element is
enclosed in a 'li' DOM element. enclosed in a 'li' DOM element.
index (int): The index of element in case there are more than
one matching elements.
Returns: Returns:
WebElement: Help DOM element in the side bar. WebElement: Help DOM element in the side bar.
...@@ -304,5 +306,5 @@ class HelpMixin(object): ...@@ -304,5 +306,5 @@ class HelpMixin(object):
else: else:
element_css = SIDE_BAR_HELP_CSS element_css = SIDE_BAR_HELP_CSS
self.q(css=element_css).click() self.q(css=element_css).results[index].click()
return self.q(css=element_css).results[0] return self.q(css=element_css).results[index]
...@@ -839,7 +839,7 @@ def assert_nav_help_link(test, page, href, signed_in=True): ...@@ -839,7 +839,7 @@ def assert_nav_help_link(test, page, href, signed_in=True):
assert_opened_help_link_is_correct(test, href) assert_opened_help_link_is_correct(test, href)
def assert_side_bar_help_link(test, page, href, help_text, as_list_item=False): 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. Asserts that help link in side bar is correct.
...@@ -852,13 +852,15 @@ def assert_side_bar_help_link(test, page, href, help_text, as_list_item=False): ...@@ -852,13 +852,15 @@ def assert_side_bar_help_link(test, page, href, help_text, as_list_item=False):
href (str): The help link which we expect to see when it is opened. 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 as_list_item (bool): Specifies whether help element is in one of the
'li' inside a sidebar list DOM element. 'li' inside a sidebar list DOM element.
index (int): The index of element in case there are more than
one matching elements.
""" """
expected_link = { expected_link = {
'href': href, 'href': href,
'text': help_text 'text': help_text
} }
# Get actual anchor help element from the page. # Get actual anchor help element from the page.
actual_link = page.get_side_bar_help_element_and_click_help(as_list_item) 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 that 'href' and text are the same as expected.
assert_link(test, expected_link, actual_link) assert_link(test, expected_link, actual_link)
# Assert that opened link is correct # Assert that opened link is correct
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment