Merge pull request #15390 from edx/christina/first-react
Convert Studio course and library dashboard lists to React.
This commit is contained in:
@@ -205,12 +205,13 @@ class DashboardPage(PageObject, HelpMixin):
|
||||
)
|
||||
self.q(css='.ui-autocomplete .ui-menu-item a').filter(lambda el: el.text == item_text)[0].click()
|
||||
|
||||
def list_courses(self):
|
||||
def list_courses(self, archived=False):
|
||||
"""
|
||||
List all the courses found on the page's list of libraries.
|
||||
List all the courses found on the page's list of courses.
|
||||
"""
|
||||
# Workaround Selenium/Firefox bug: `.text` property is broken on invisible elements
|
||||
course_tab_link = self.q(css='#course-index-tabs .courses-tab a')
|
||||
tab_selector = '#course-index-tabs .{} a'.format('archived-courses-tab' if archived else 'courses-tab')
|
||||
course_tab_link = self.q(css=tab_selector)
|
||||
if course_tab_link:
|
||||
course_tab_link.click()
|
||||
div2info = lambda element: {
|
||||
@@ -220,13 +221,14 @@ class DashboardPage(PageObject, HelpMixin):
|
||||
'run': element.find_element_by_css_selector('.course-run .value').text,
|
||||
'url': element.find_element_by_css_selector('a.course-link').get_attribute('href'),
|
||||
}
|
||||
return self.q(css='.courses li.course-item').map(div2info).results
|
||||
course_list_selector = '.{} li.course-item'.format('archived-courses' if archived else 'courses')
|
||||
return self.q(css=course_list_selector).map(div2info).results
|
||||
|
||||
def has_course(self, org, number, run):
|
||||
def has_course(self, org, number, run, archived=False):
|
||||
"""
|
||||
Returns `True` if course for given org, number and run exists on the page otherwise `False`
|
||||
"""
|
||||
for course in self.list_courses():
|
||||
for course in self.list_courses(archived):
|
||||
if course['org'] == org and course['number'] == number and course['run'] == run:
|
||||
return True
|
||||
return False
|
||||
@@ -245,6 +247,7 @@ class DashboardPage(PageObject, HelpMixin):
|
||||
'name': element.find_element_by_css_selector('.course-title').text,
|
||||
'org': element.find_element_by_css_selector('.course-org .value').text,
|
||||
'number': element.find_element_by_css_selector('.course-num .value').text,
|
||||
'link_element': element.find_element_by_css_selector('a.library-link'),
|
||||
'url': element.find_element_by_css_selector('a.library-link').get_attribute('href'),
|
||||
}
|
||||
self.wait_for_element_visibility('.libraries li.course-item', "Switch to library tab")
|
||||
@@ -259,6 +262,14 @@ class DashboardPage(PageObject, HelpMixin):
|
||||
return True
|
||||
return False
|
||||
|
||||
def click_library(self, name):
|
||||
"""
|
||||
Click on the library with the given name.
|
||||
"""
|
||||
for lib in self.list_libraries():
|
||||
if lib['name'] == name:
|
||||
lib['link_element'].click()
|
||||
|
||||
@property
|
||||
def language_selector(self):
|
||||
"""
|
||||
|
||||
@@ -97,6 +97,9 @@ class CreateCourseTest(AcceptanceTest):
|
||||
self.assertTrue(self.dashboard_page.has_course(
|
||||
org=self.course_org, number=self.course_number, run=self.course_run
|
||||
))
|
||||
# Click on the course listing and verify that the Studio course outline page opens.
|
||||
self.dashboard_page.click_course_run(self.course_run)
|
||||
course_outline_page.wait_for_page()
|
||||
|
||||
def test_create_course_with_existing_org_via_autocomplete(self):
|
||||
"""
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
"""
|
||||
Acceptance tests for Home Page (My Courses / My Libraries).
|
||||
"""
|
||||
import datetime
|
||||
from uuid import uuid4
|
||||
|
||||
from flaky import flaky
|
||||
from opaque_keys.edx.locator import LibraryLocator
|
||||
|
||||
from base_studio_test import StudioCourseTest
|
||||
from common.test.acceptance.pages.common.auto_auth import AutoAuthPage
|
||||
from common.test.acceptance.pages.lms.account_settings import AccountSettingsPage
|
||||
from common.test.acceptance.pages.studio.index import DashboardPage
|
||||
from common.test.acceptance.pages.studio.library import LibraryEditPage
|
||||
from common.test.acceptance.pages.studio.overview import CourseOutlinePage
|
||||
from common.test.acceptance.tests.helpers import AcceptanceTest, get_selected_option_text, select_option_by_text
|
||||
|
||||
|
||||
@@ -60,6 +63,9 @@ class CreateLibraryTest(AcceptanceTest):
|
||||
# Then go back to the home page and make sure the new library is listed there:
|
||||
self.dashboard_page.visit()
|
||||
self.assertTrue(self.dashboard_page.has_library(name=name, org=org, number=number))
|
||||
# Click on the library listing and verify that the library edit view loads.
|
||||
self.dashboard_page.click_library(name)
|
||||
lib_page.wait_for_page()
|
||||
|
||||
|
||||
class StudioLanguageTest(AcceptanceTest):
|
||||
@@ -95,3 +101,44 @@ class StudioLanguageTest(AcceptanceTest):
|
||||
get_selected_option_text(language_selector),
|
||||
u'Dummy Language (Esperanto)'
|
||||
)
|
||||
|
||||
|
||||
class ArchivedCourseTest(StudioCourseTest):
|
||||
""" Tests that archived courses appear in their own list. """
|
||||
|
||||
def setUp(self, is_staff=True, test_xss=False):
|
||||
"""
|
||||
Load the helper for the home page (dashboard page)
|
||||
"""
|
||||
super(ArchivedCourseTest, self).setUp(is_staff=is_staff, test_xss=test_xss)
|
||||
self.dashboard_page = DashboardPage(self.browser)
|
||||
|
||||
def populate_course_fixture(self, course_fixture):
|
||||
current_time = datetime.datetime.now()
|
||||
course_start_date = current_time - datetime.timedelta(days=60)
|
||||
course_end_date = current_time - datetime.timedelta(days=90)
|
||||
|
||||
course_fixture.add_course_details({
|
||||
'start_date': course_start_date,
|
||||
'end_date': course_end_date
|
||||
})
|
||||
|
||||
def test_archived_course(self):
|
||||
"""
|
||||
Scenario: Ensure that an archived course displays in its own list and can be clicked on.
|
||||
"""
|
||||
self.dashboard_page.visit()
|
||||
self.assertTrue(self.dashboard_page.has_course(
|
||||
org=self.course_info['org'], number=self.course_info['number'], run=self.course_info['run'],
|
||||
archived=True
|
||||
))
|
||||
|
||||
# Click on the archived course and make sure that the Studio course outline appears.
|
||||
self.dashboard_page.click_course_run(self.course_info['run'])
|
||||
course_outline_page = CourseOutlinePage(
|
||||
self.browser,
|
||||
self.course_info['org'],
|
||||
self.course_info['number'],
|
||||
self.course_info['run']
|
||||
)
|
||||
course_outline_page.wait_for_page()
|
||||
|
||||
Reference in New Issue
Block a user