Commit 35d04bff by asadiqbal

SOL-1385

parent a8cca47c
......@@ -15,6 +15,13 @@ class CertificateConfigFixtureError(Exception):
pass
class CertificateConfigUpdateFixtureError(Exception):
"""
Error occurred while updating certificate config fixture.
"""
pass
class CertificateConfigFixture(StudioApiFixture):
"""
Fixture to create certificates configuration for a course
......@@ -44,3 +51,22 @@ class CertificateConfigFixture(StudioApiFixture):
)
return self
def update_certificate(self, certificate_id):
"""
Update the certificates config data to certificate endpoint.
"""
response = self.session.put(
'{}/certificates/{}/{}'.format(STUDIO_BASE_URL, self.course_id, certificate_id),
data=json.dumps(self.certificates),
headers=self.headers
)
if not response.ok:
raise CertificateConfigUpdateFixtureError(
"Could not update certificate {0}. Status was {1}".format(
json.dumps(self.certificates), response.status_code
)
)
return self
......@@ -1057,6 +1057,13 @@ class CertificatesPage(PageObject):
return self.get_selector('#btn-start-generating-certificates')
@property
def generate_certificates_disabled_button(self): # pylint: disable=invalid-name
"""
Returns the disabled state of button
"""
return self.get_selector('#disabled-btn-start-generating-certificates')
@property
def certificate_generation_status(self):
"""
Returns certificate generation status message container.
......
......@@ -22,6 +22,7 @@ from ...pages.lms.problem import ProblemPage
from ...pages.lms.track_selection import TrackSelectionPage
from ...pages.lms.pay_and_verify import PaymentAndVerificationFlow, FakePaymentPage
from common.test.acceptance.tests.helpers import disable_animations
from ...fixtures.certificates import CertificateConfigFixture
class BaseInstructorDashboardTest(EventsTestMixin, UniqueCourseTest):
......@@ -589,12 +590,37 @@ class CertificatesTest(BaseInstructorDashboardTest):
def setUp(self):
super(CertificatesTest, self).setUp()
self.course_fixture = CourseFixture(**self.course_info).install()
self.test_certificate_config = {
'id': 1,
'name': 'Certificate name',
'description': 'Certificate description',
'course_title': 'Course title override',
'signatories': [],
'version': 1,
'is_active': True
}
CourseFixture(**self.course_info).install()
self.cert_fixture = CertificateConfigFixture(self.course_id, self.test_certificate_config)
self.cert_fixture.install()
self.user_name, self.user_id = self.log_in_as_instructor()
self.instructor_dashboard_page = self.visit_instructor_dashboard()
self.certificates_section = self.instructor_dashboard_page.select_certificates()
disable_animations(self.certificates_section)
def test_generate_certificates_buttons_is_disable(self):
"""
Scenario: On the Certificates tab of the Instructor Dashboard, Generate Certificates button is disable.
Given that I am on the Certificates tab on the Instructor Dashboard
The instructor-generation and cert_html_view_enabled feature flags have been enabled
But the certificate is not active in settings.
Then I see a 'Generate Certificates' button disabled
"""
self.test_certificate_config['is_active'] = False
self.cert_fixture.update_certificate(1)
self.browser.refresh()
self.assertFalse(self.certificates_section.generate_certificates_button.visible)
self.assertTrue(self.certificates_section.generate_certificates_disabled_button.visible)
def test_generate_certificates_buttons_is_visible(self):
"""
Scenario: On the Certificates tab of the Instructor Dashboard, Generate Certificates button is visible.
......
......@@ -299,6 +299,7 @@ def _section_certificates(course):
'enabled_for_course': certs_api.cert_generation_enabled(course.id),
'instructor_generation_enabled': instructor_generation_enabled,
'html_cert_enabled': html_cert_enabled,
'active_certificate': certs_api.get_active_web_certificate(course),
'certificate_statuses': GeneratedCertificate.get_unique_statuses(course_key=course.id),
'urls': {
'generate_example_certificates': reverse(
......
......@@ -73,7 +73,12 @@ import json
<div class="start-certificate-generation">
<h2>${_("Generate Certificates")}</h2>
<form id="certificates-generating-form" method="post" action="${section_data['urls']['start_certificate_generation']}">
<input type="button" id="btn-start-generating-certificates" value="${_('Generate Certificates')}" data-endpoint="${section_data['urls']['start_certificate_generation']}"/>
% if section_data['html_cert_enabled'] and section_data['active_certificate'] is None:
<p>${_("Course certificate generation requires an activated web certificate configuration.")}</p>
<input type="button" id="disabled-btn-start-generating-certificates" class="is-disabled" aria-disabled="true" value="${_('Generate Certificates')}"/>
% else:
<input type="button" id="btn-start-generating-certificates" value="${_('Generate Certificates')}" data-endpoint="${section_data['urls']['start_certificate_generation']}"/>
%endif
</form>
<div class="certificate-generation-status"></div>
</div>
......
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