Merge pull request #9822 from edx/saleem-latif/SOL-565
saleem-latif/SOL-565
This commit is contained in:
@@ -2,11 +2,16 @@
|
||||
"""
|
||||
End-to-end tests for the main LMS Dashboard (aka, Student Dashboard).
|
||||
"""
|
||||
import datetime
|
||||
|
||||
from ..helpers import UniqueCourseTest
|
||||
from ...fixtures.course import CourseFixture
|
||||
from ...pages.lms.auto_auth import AutoAuthPage
|
||||
from ...pages.lms.dashboard import DashboardPage
|
||||
|
||||
DEFAULT_SHORT_DATE_FORMAT = "%b %d, %Y"
|
||||
DEFAULT_DAY_AND_TIME_FORMAT = "%A at %-I%P"
|
||||
|
||||
|
||||
class BaseLmsDashboardTest(UniqueCourseTest):
|
||||
""" Base test suite for the LMS Student Dashboard """
|
||||
@@ -51,6 +56,12 @@ class BaseLmsDashboardTest(UniqueCourseTest):
|
||||
class LmsDashboardPageTest(BaseLmsDashboardTest):
|
||||
""" Test suite for the LMS Student Dashboard page """
|
||||
|
||||
def setUp(self):
|
||||
super(LmsDashboardPageTest, self).setUp()
|
||||
|
||||
# now datetime for usage in tests
|
||||
self.now = datetime.datetime.now()
|
||||
|
||||
def test_dashboard_course_listings(self):
|
||||
"""
|
||||
Perform a general validation of the course listings section
|
||||
@@ -81,3 +92,128 @@ class LmsDashboardPageTest(BaseLmsDashboardTest):
|
||||
self.assertEqual(facebook_widget.attrs('target')[0], '_blank')
|
||||
self.assertIn(facebook_url, facebook_widget.attrs('href')[0])
|
||||
self.assertIn(facebook_url, facebook_widget.attrs('onclick')[0])
|
||||
|
||||
def test_ended_course_date(self):
|
||||
"""
|
||||
Scenario:
|
||||
Course Date should have the format 'Ended - Sep 23, 2015'
|
||||
if the course on student dashboard has ended.
|
||||
|
||||
As a Student,
|
||||
Given that I have enrolled to a course
|
||||
And the course has ended in the past
|
||||
When I visit dashboard page
|
||||
Then the course date should have the following format "Ended - %b %d, %Y" e.g. "Ended - Sep 23, 2015"
|
||||
"""
|
||||
course_start_date = datetime.datetime(1970, 1, 1)
|
||||
course_end_date = self.now - datetime.timedelta(days=90)
|
||||
|
||||
self.course_fixture.add_course_details({'start_date': course_start_date,
|
||||
'end_date': course_end_date})
|
||||
self.course_fixture.configure_course()
|
||||
|
||||
end_date = course_end_date.strftime(DEFAULT_SHORT_DATE_FORMAT)
|
||||
expected_course_date = "Ended - {end_date}".format(end_date=end_date)
|
||||
|
||||
# reload the page for changes to course date changes to appear in dashboard
|
||||
self.dashboard_page.visit()
|
||||
|
||||
course_date = self.dashboard_page.get_course_date()
|
||||
|
||||
# Test that proper course date with 'ended' message is displayed if a course has already ended
|
||||
self.assertEqual(course_date, expected_course_date)
|
||||
|
||||
def test_running_course_date(self):
|
||||
"""
|
||||
Scenario:
|
||||
Course Date should have the format 'Started - Sep 23, 2015'
|
||||
if the course on student dashboard is running.
|
||||
|
||||
As a Student,
|
||||
Given that I have enrolled to a course
|
||||
And the course has started
|
||||
And the course is in progress
|
||||
When I visit dashboard page
|
||||
Then the course date should have the following format "Started - %b %d, %Y" e.g. "Started - Sep 23, 2015"
|
||||
"""
|
||||
course_start_date = datetime.datetime(1970, 1, 1)
|
||||
course_end_date = self.now + datetime.timedelta(days=90)
|
||||
|
||||
self.course_fixture.add_course_details({'start_date': course_start_date,
|
||||
'end_date': course_end_date})
|
||||
self.course_fixture.configure_course()
|
||||
|
||||
start_date = course_start_date.strftime(DEFAULT_SHORT_DATE_FORMAT)
|
||||
expected_course_date = "Started - {start_date}".format(start_date=start_date)
|
||||
|
||||
# reload the page for changes to course date changes to appear in dashboard
|
||||
self.dashboard_page.visit()
|
||||
|
||||
course_date = self.dashboard_page.get_course_date()
|
||||
|
||||
# Test that proper course date with 'started' message is displayed if a course is in running state
|
||||
self.assertEqual(course_date, expected_course_date)
|
||||
|
||||
def test_future_course_date(self):
|
||||
"""
|
||||
Scenario:
|
||||
Course Date should have the format 'Starts - Sep 23, 2015'
|
||||
if the course on student dashboard starts in future.
|
||||
|
||||
As a Student,
|
||||
Given that I have enrolled to a course
|
||||
And the course starts in future
|
||||
And the course does not start within 5 days
|
||||
When I visit dashboard page
|
||||
Then the course date should have the following format "Starts - %b %d, %Y" e.g. "Starts - Sep 23, 2015"
|
||||
"""
|
||||
course_start_date = self.now + datetime.timedelta(days=30)
|
||||
course_end_date = self.now + datetime.timedelta(days=365)
|
||||
|
||||
self.course_fixture.add_course_details({'start_date': course_start_date,
|
||||
'end_date': course_end_date})
|
||||
self.course_fixture.configure_course()
|
||||
|
||||
start_date = course_start_date.strftime(DEFAULT_SHORT_DATE_FORMAT)
|
||||
expected_course_date = "Starts - {start_date}".format(start_date=start_date)
|
||||
|
||||
# reload the page for changes to course date changes to appear in dashboard
|
||||
self.dashboard_page.visit()
|
||||
|
||||
course_date = self.dashboard_page.get_course_date()
|
||||
|
||||
# Test that proper course date with 'starts' message is displayed if a course is about to start in future,
|
||||
# and course does not start within 5 days
|
||||
self.assertEqual(course_date, expected_course_date)
|
||||
|
||||
def test_near_future_course_date(self):
|
||||
"""
|
||||
Scenario:
|
||||
Course Date should have the format 'Starts - Wednesday at 5am UTC'
|
||||
if the course on student dashboard starts within 5 days.
|
||||
|
||||
As a Student,
|
||||
Given that I have enrolled to a course
|
||||
And the course starts within 5 days
|
||||
When I visit dashboard page
|
||||
Then the course date should have the following format "Starts - %A at %-I%P UTC"
|
||||
e.g. "Starts - Wednesday at 5am UTC"
|
||||
"""
|
||||
course_start_date = self.now + datetime.timedelta(days=2)
|
||||
course_end_date = self.now + datetime.timedelta(days=365)
|
||||
|
||||
self.course_fixture.add_course_details({'start_date': course_start_date,
|
||||
'end_date': course_end_date})
|
||||
self.course_fixture.configure_course()
|
||||
|
||||
start_date = course_start_date.strftime(DEFAULT_DAY_AND_TIME_FORMAT)
|
||||
expected_course_date = "Starts - {start_date} UTC".format(start_date=start_date)
|
||||
|
||||
# reload the page for changes to course date changes to appear in dashboard
|
||||
self.dashboard_page.visit()
|
||||
|
||||
course_date = self.dashboard_page.get_course_date()
|
||||
|
||||
# Test that proper course date with 'starts' message is displayed if a course is about to start in future,
|
||||
# and course starts within 5 days
|
||||
self.assertEqual(course_date, expected_course_date)
|
||||
|
||||
Reference in New Issue
Block a user