diff --git a/common/test/acceptance/pages/lms/ccx_dashboard_page.py b/common/test/acceptance/pages/lms/ccx_dashboard_page.py new file mode 100644 index 0000000000..6a5a0f27a7 --- /dev/null +++ b/common/test/acceptance/pages/lms/ccx_dashboard_page.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +""" +CCX coach dashboard page +""" +from bok_choy.promise import EmptyPromise +from common.test.acceptance.pages.lms.course_page import CoursePage + + +class CoachDashboardPage(CoursePage): + """ + CCX coach dashboard, where ccx coach can manage a course. + """ + url_path = "ccx_coach" + + def is_browser_on_page(self): + """ + check if ccx dashboard is open. + """ + return self.q(css='div.instructor-dashboard-wrapper-2').present + + def is_browser_on_enrollment_page(self): + """ + check if enrollment page in ccx dashboard is open. + """ + return self.q(css='div.batch-enrollment').present + + def fill_ccx_name_text_box(self, ccx_name): + """ + Fill in the form with the provided ccx name and submit it. + """ + ccx_name_selector = "#ccx_name" + create_ccx_button = "#create-ccx" + + # Fill the ccx_name. + self.wait_for_element_visibility(ccx_name_selector, 'CCX name field is visible') + self.q(css=ccx_name_selector).fill(ccx_name) + + # Verify create ccx button is present before clicking. + EmptyPromise( + lambda: self.q(css=create_ccx_button).present, "Create a new Custom Course for edX" + ).fulfill() + self.q(css=create_ccx_button).click() diff --git a/common/test/acceptance/tests/lms/test_ccx.py b/common/test/acceptance/tests/lms/test_ccx.py new file mode 100644 index 0000000000..9d8f0a4312 --- /dev/null +++ b/common/test/acceptance/tests/lms/test_ccx.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +""" +End-to-end tests for the CCX dashboard. +""" +from nose.plugins.attrib import attr + +from common.test.acceptance.fixtures.course import CourseFixture +from common.test.acceptance.tests.helpers import UniqueCourseTest, EventsTestMixin +from common.test.acceptance.pages.lms.auto_auth import AutoAuthPage +from common.test.acceptance.pages.lms.ccx_dashboard_page import CoachDashboardPage + + +@attr('shard_7') +class CreateCCXCoachTest(EventsTestMixin, UniqueCourseTest): + """ + Test ccx end to end process. + """ + USERNAME = "coach_tester" + EMAIL = "coach_tester@example.com" + + def setUp(self): + super(CreateCCXCoachTest, self).setUp() + self.course_info.update({"settings": {"enable_ccx": "true"}}) + self.course_fixture = CourseFixture(**self.course_info).install() + self.coach_dashboard_page = CoachDashboardPage(self.browser, self.course_id) + + def _auto_auth(self, username, email): + """ + Logout and login with given credentials. + """ + AutoAuthPage(self.browser, username=username, email=email, + course_id=self.course_id, staff=True).visit() + + def test_create_ccx(self): + """ + Assert that ccx created. + """ + ccx_name = "Test ccx" + self._auto_auth(self.USERNAME, self.EMAIL) + self.coach_dashboard_page.visit() + + self.coach_dashboard_page.fill_ccx_name_text_box(ccx_name) + self.coach_dashboard_page.wait_for_page() + + # Assert that new ccx is created and we are on ccx dashboard/enrollment tab. + self.assertTrue(self.coach_dashboard_page.is_browser_on_enrollment_page()) diff --git a/lms/envs/bok_choy.env.json b/lms/envs/bok_choy.env.json index 04b5076ead..78f455fcac 100644 --- a/lms/envs/bok_choy.env.json +++ b/lms/envs/bok_choy.env.json @@ -87,7 +87,8 @@ "AUTOMATIC_VERIFY_STUDENT_IDENTITY_FOR_TESTING": true, "ENABLE_COURSE_DISCOVERY": true, "ENABLE_SPECIAL_EXAMS": true, - "SHOW_LANGUAGE_SELECTOR": true + "SHOW_LANGUAGE_SELECTOR": true, + "CUSTOM_COURSES_EDX": true }, "FEEDBACK_SUBMISSION_EMAIL": "", "GITHUB_REPO_ROOT": "** OVERRIDDEN **", diff --git a/lms/templates/ccx/coach_dashboard.html b/lms/templates/ccx/coach_dashboard.html index b94ca71a35..5affcd489a 100644 --- a/lms/templates/ccx/coach_dashboard.html +++ b/lms/templates/ccx/coach_dashboard.html @@ -167,7 +167,7 @@ from openedx.core.djangolib.js_utils import ( function validateForm(form) { var newCCXName = $(form).find('#ccx_name').val(); var $errorMessage = $('#ccx-create-message'); - var hasCcxConnector = ${has_ccx_connector | n, dump_js_escaped_json}; + var hasCcxConnector = ${has_ccx_connector | n, dump_js_escaped_json} === 'true'; if (!newCCXName && !hasCcxConnector) { $errorMessage.text("${_('Please enter a valid CCX name.') | n, js_escaped_string}");