From a4a7948b1d451e926a2b08cd42b629fe75893f22 Mon Sep 17 00:00:00 2001 From: Chris Rodriguez Date: Fri, 1 Jul 2016 08:51:39 -0400 Subject: [PATCH] AC-523 - duplicate-id - instructor_dashboard.py --- common/test/acceptance/pages/lms/dashboard.py | 2 +- .../pages/lms/instructor_dashboard.py | 4 +- .../tests/lms/test_lms_dashboard.py | 118 ++++++++++++++++-- .../coffee/fixtures/autoenrollment.html | 6 +- .../instructor_dashboard/membership.coffee | 12 +- .../certificate-bulk-white-list.underscore | 4 +- .../instructor_dashboard_2/membership.html | 6 +- 7 files changed, 122 insertions(+), 30 deletions(-) diff --git a/common/test/acceptance/pages/lms/dashboard.py b/common/test/acceptance/pages/lms/dashboard.py index 3d8b13e0bf..d859fdfb81 100644 --- a/common/test/acceptance/pages/lms/dashboard.py +++ b/common/test/acceptance/pages/lms/dashboard.py @@ -166,7 +166,7 @@ class DashboardPage(PageObject): """ Get course date of the first course from dashboard """ - return self.q(css='ul.listing-courses .course-item .info-date-block').first.text[0] + return self.q(css='ul.listing-courses .course-item:first-of-type .info-date-block').first.text[0] def click_username_dropdown(self): """ diff --git a/common/test/acceptance/pages/lms/instructor_dashboard.py b/common/test/acceptance/pages/lms/instructor_dashboard.py index 3c9e6ecb8c..e40e3332a3 100644 --- a/common/test/acceptance/pages/lms/instructor_dashboard.py +++ b/common/test/acceptance/pages/lms/instructor_dashboard.py @@ -748,8 +748,8 @@ class MembershipPageAutoEnrollSection(PageObject): """ url = None - auto_enroll_browse_button_selector = '.auto_enroll_csv .file-browse input.file_field#browseBtn' - auto_enroll_upload_button_selector = '.auto_enroll_csv button[name="enrollment_signup_button"]' + auto_enroll_browse_button_selector = '.auto_enroll_csv .file-browse input.file_field#browseBtn-auto_enroll_csv' + auto_enroll_upload_button_selector = '.auto_enroll_csv #submitBtn-auto_enroll_csv' batch_enrollment_selector = '.batch-enrollment' NOTIFICATION_ERROR = 'error' NOTIFICATION_WARNING = 'warning' diff --git a/common/test/acceptance/tests/lms/test_lms_dashboard.py b/common/test/acceptance/tests/lms/test_lms_dashboard.py index 6269f3af71..91ed2c6b1e 100644 --- a/common/test/acceptance/tests/lms/test_lms_dashboard.py +++ b/common/test/acceptance/tests/lms/test_lms_dashboard.py @@ -5,7 +5,7 @@ End-to-end tests for the main LMS Dashboard (aka, Student Dashboard). import datetime from nose.plugins.attrib import attr -from ..helpers import UniqueCourseTest +from ..helpers import UniqueCourseTest, generate_course_key from ...fixtures.course import CourseFixture from ...pages.lms.auto_auth import AutoAuthPage from ...pages.lms.dashboard import DashboardPage @@ -40,9 +40,10 @@ class BaseLmsDashboardTest(UniqueCourseTest): }) self.course_fixture.install() - # Create the test user, register them for the course, and authenticate self.username = "test_{uuid}".format(uuid=self.unique_id[0:6]) self.email = "{user}@example.com".format(user=self.username) + + # Create the test user, register them for the course, and authenticate AutoAuthPage( self.browser, username=self.username, @@ -54,6 +55,83 @@ class BaseLmsDashboardTest(UniqueCourseTest): self.dashboard_page.visit() +class BaseLmsDashboardTestMultiple(UniqueCourseTest): + """ Base test suite for the LMS Student Dashboard with Multiple Courses""" + + def setUp(self): + """ + Initializes the components (page objects, courses, users) for this test suite + """ + # Some parameters are provided by the parent setUp() routine, such as the following: + # self.course_id, self.course_info, self.unique_id + super(BaseLmsDashboardTestMultiple, self).setUp() + + # Load page objects for use by the tests + self.dashboard_page = DashboardPage(self.browser) + + # Configure some aspects of the test course and install the settings into the course + self.courses = { + 'A': { + 'org': 'test_org', + 'number': self.unique_id, + 'run': 'test_run_A', + 'display_name': 'Test Course A' + }, + 'B': { + 'org': 'test_org', + 'number': self.unique_id, + 'run': 'test_run_B', + 'display_name': 'Test Course B' + }, + 'C': { + 'org': 'test_org', + 'number': self.unique_id, + 'run': 'test_run_C', + 'display_name': 'Test Course C' + } + } + + self.username = "test_{uuid}".format(uuid=self.unique_id[0:6]) + self.email = "{user}@example.com".format(user=self.username) + + self.course_keys = {} + self.course_fixtures = {} + + for key, value in self.courses.iteritems(): + course_key = generate_course_key( + value['org'], + value['number'], + value['run'], + ) + + course_fixture = CourseFixture( + value['org'], + value['number'], + value['run'], + value['display_name'], + ) + + course_fixture.add_advanced_settings({ + u"social_sharing_url": {u"value": "http://custom/course/url"} + }) + + course_fixture.install() + + self.course_keys[key] = course_key + self.course_fixtures[key] = course_fixture + + # Create the test user, register them for the course, and authenticate + AutoAuthPage( + self.browser, + username=self.username, + email=self.email, + course_id=course_key + ).visit() + + # Navigate the authenticated, enrolled user to the dashboard page and get testing! + self.dashboard_page.visit() + + class LmsDashboardPageTest(BaseLmsDashboardTest): """ Test suite for the LMS Student Dashboard page """ @@ -109,8 +187,10 @@ class LmsDashboardPageTest(BaseLmsDashboardTest): 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.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) @@ -140,8 +220,10 @@ class LmsDashboardPageTest(BaseLmsDashboardTest): 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.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) @@ -171,8 +253,10 @@ class LmsDashboardPageTest(BaseLmsDashboardTest): 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.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) @@ -203,8 +287,10 @@ class LmsDashboardPageTest(BaseLmsDashboardTest): 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.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) @@ -221,7 +307,7 @@ class LmsDashboardPageTest(BaseLmsDashboardTest): @attr('a11y') -class LmsDashboardA11yTest(BaseLmsDashboardTest): +class LmsDashboardA11yTest(BaseLmsDashboardTestMultiple): """ Class to test lms student dashboard accessibility. """ @@ -230,6 +316,12 @@ class LmsDashboardA11yTest(BaseLmsDashboardTest): """ Test the accessibility of the course listings """ - course_listings = self.dashboard_page.get_course_listings() - self.assertEqual(len(course_listings), 1) + course_listings = self.dashboard_page.get_courses() + self.assertEqual(len(course_listings), 3) + self.dashboard_page.a11y_audit.config.set_rules({ + 'ignore': [ + 'link-href', # AC-530 + 'aria-required-children', # AC-534 + ] + }) self.dashboard_page.a11y_audit.check_for_accessibility_errors() diff --git a/lms/static/coffee/fixtures/autoenrollment.html b/lms/static/coffee/fixtures/autoenrollment.html index 22adbed4b8..abd26226d8 100644 --- a/lms/static/coffee/fixtures/autoenrollment.html +++ b/lms/static/coffee/fixtures/autoenrollment.html @@ -10,11 +10,11 @@
- Browse - + +
- +
diff --git a/lms/static/coffee/src/instructor_dashboard/membership.coffee b/lms/static/coffee/src/instructor_dashboard/membership.coffee index 194f0cd4a3..b5acbf4374 100644 --- a/lms/static/coffee/src/instructor_dashboard/membership.coffee +++ b/lms/static/coffee/src/instructor_dashboard/membership.coffee @@ -117,7 +117,7 @@ class AuthListWidget extends MemberListWidget # create revoke button and insert it into the row label_trans = gettext("Revoke access") - $revoke_btn = $ _.template('
<%= label %>
')({label: label_trans}), + $revoke_btn = $ _.template('
<%- label %>
')({label: label_trans}), class: 'revoke' $revoke_btn.click => @modify_member_access member.email, 'revoke', (error) => @@ -166,10 +166,10 @@ class AuthListWidget extends MemberListWidget @clear_errors() @clear_input() if data.userDoesNotExist - msg = gettext("Could not find a user with username or email address '<%= identifier %>'.") + msg = gettext("Could not find a user with username or email address '<%- identifier %>'.") @show_errors _.template(msg, {identifier: data.unique_student_identifier}) else if data.inactiveUser - msg = gettext("Error: User '<%= username %>' has not yet activated their account. Users must create and activate their accounts before they can be assigned a role.") + msg = gettext("Error: User '<%- username %>' has not yet activated their account. Users must create and activate their accounts before they can be assigned a role.") @show_errors _.template(msg, {username: data.unique_student_identifier}) else if data.removingSelfAsInstructor @show_errors gettext "Error: You cannot remove yourself from the Instructor group!" @@ -181,12 +181,12 @@ class @AutoEnrollmentViaCsv # Wrapper for the AutoEnrollmentViaCsv subsection. # This object handles buttons, success and failure reporting, # and server communication. - @$student_enrollment_form = @$container.find("form#student-auto-enroll-form") - @$enrollment_signup_button = @$container.find("[name='enrollment_signup_button']") + @$student_enrollment_form = @$container.find("#student-auto-enroll-form") + @$enrollment_signup_button = @$container.find("#submitBtn-auto_enroll_csv") @$students_list_file = @$container.find("input[name='students_list']") @$csrf_token = @$container.find("input[name='csrfmiddlewaretoken']") @$results = @$container.find("div.results") - @$browse_button = @$container.find("#browseBtn") + @$browse_button = @$container.find("#browseBtn-auto_enroll_csv") @$browse_file = @$container.find("#browseFile") @processing = false diff --git a/lms/templates/instructor/instructor_dashboard_2/certificate-bulk-white-list.underscore b/lms/templates/instructor/instructor_dashboard_2/certificate-bulk-white-list.underscore index 462f7a0501..5a600897b4 100644 --- a/lms/templates/instructor/instructor_dashboard_2/certificate-bulk-white-list.underscore +++ b/lms/templates/instructor/instructor_dashboard_2/certificate-bulk-white-list.underscore @@ -7,8 +7,8 @@
" />
- <%- gettext("Browse") %> - + +
diff --git a/lms/templates/instructor/instructor_dashboard_2/membership.html b/lms/templates/instructor/instructor_dashboard_2/membership.html index 548abdb0bc..eb7336c963 100644 --- a/lms/templates/instructor/instructor_dashboard_2/membership.html +++ b/lms/templates/instructor/instructor_dashboard_2/membership.html @@ -96,11 +96,11 @@ from openedx.core.djangoapps.course_groups.partition_scheme import get_cohorted_
Browse - - + +
- +