- SOL-465: Initial implementation of certificates web view and signatories (names/titles) - SOL-718 Close button is working properly - SOL-801 Backbone Signatories Modeling - SOL-803 Underscore template: Editor (Add) - SOL-802 Signatories: Underscore template - Details - SOL-804 Signatories: Underscore template: Editor (Edit) - Add signatory delete Django view - SOL-805 Signatory editor (Delete) - Add Coffeescript router - SOL-716 Jasmine Tests - Added missing minified JS library - client side validation of signatory fields - SOL-390 signatories names - Remove obsolete extends Sass files - input maxlength limiting for signatory information - SOL-389: Course title override - SOL-466: Add capability to upload digitized signatures in Studio - ziafazal: fixed css for upload signature image - ziafazal: completed deletion of signature images - UX-1741: Add initial static rendering/styling for Open edX web certs * creating new global static dir * adding static version of edX UX pattern library assets * adding web certificates static assets * adding static (+abstracted) web certificates rendering * creating two tiers of rendering (base + distinguished) * providing sample assets for certificate rendering * supporting RTL layouts * adding certifcates assests to edX static asset pipeline * temporarily hiding the mozilla open badges share action * wiring print button to print view/page * fixup! addressing conflict artifact in valid cert template * fixup! adding missing %hd-subsection sass extend + components comment clean up * fixup! correcting pattern library .hd-4 font-weight value - SOL-468 Linked Student View for Web View Credential - SOL-467: Add capability to upload organization logos for certificates - SOL-391 / SOL-387: Signatory related info (assets) in certificates web view - kelketek: Fixes for static asset collection in certificate HTML view. - SOL-398 Web View: Public Access - mattdrayer: Post-merge branch stabilization - catong: Initial changes to Studio template and Help config file - ziafazal: Branch stabilizations - SOL-387: Display organization logo on LMS web view - talbs/mattdrayer: Branch Stabilizations - talbs: converting backpack action to use a button HTML element - talbs: revising placeholder assets + their rendering in cert view - mattdrayer: Username web view wireup - SOL-386 Certificate Mode Previews - SOL-905: Make organization logo and signatory signature uneditable - SOL-922: Improve test coverage - SOL-765: Add LinkedIn sharing - [marco] temporary styling adjustment to account for smaller linkedin share image / fake button - SOL-921: Address hardcoded template items - SOL-927: Deleting certificate should delete org logo image also * updated invalid template * removed hr * fix invalid certificate error - clrux: Add i18n to certificate templates and partials - mattdrayer: Pylint violations - SOL-920 Certificate Activation/Deactivation - mattdrayer: Added LMS support - SOL-932: Fix preview mode support in certificate view - SOL-934: Fixed bug reported and broken tests - SOL-935 removed the 'valid' word from web view title - talbs: RTL support updates/fixes * revising certificate type icon/name vertical alignment * removing unused older certificate template * revising styling for message/banner actions * abstracting accomplishment type to use course mode + adding in honor/verified-specific placeholders - mattdrayer: JSHint violations
543 lines
16 KiB
Python
543 lines
16 KiB
Python
"""
|
|
Course Certificates page objects.
|
|
The methods in these classes are organized into several conceptual buckets:
|
|
* Helpers: General utility methods used throughout, such as css selection helpers
|
|
* Properties: Specific page/object field getters/setters (mainly for form inputs)
|
|
* Wait Actions: EmptyPromises used to ensure element availabilty prior to performing an action
|
|
* Click Actions: Specific element invocations -- mainly links/buttons but anything clickable
|
|
* Workflows: Complex orchestrations involving any/all of the above
|
|
|
|
"""
|
|
import os
|
|
|
|
from bok_choy.promise import EmptyPromise
|
|
from .course_page import CoursePage
|
|
|
|
|
|
class CertificatesPage(CoursePage):
|
|
"""
|
|
Course Certificates page object wrapper
|
|
Further below you will also find page objects for Certificates and Signatories
|
|
"""
|
|
|
|
url_path = "certificates"
|
|
certficate_css = ".certificates-list"
|
|
|
|
################
|
|
# Helpers
|
|
################
|
|
|
|
def is_browser_on_page(self):
|
|
"""
|
|
Verify that the browser is on the page and it is not still loading.
|
|
"""
|
|
EmptyPromise(
|
|
lambda: self.q(css='body.view-certificates').present,
|
|
'On the certificates page'
|
|
).fulfill()
|
|
|
|
EmptyPromise(
|
|
lambda: not self.q(css='span.spin').visible,
|
|
'Certificates are finished loading'
|
|
).fulfill()
|
|
|
|
return True
|
|
|
|
################
|
|
# Properties
|
|
################
|
|
|
|
@property
|
|
def certificates(self):
|
|
"""
|
|
Return list of the certificates for the course.
|
|
"""
|
|
css = self.certficate_css + ' .wrapper-collection'
|
|
return [Certificate(self, self.certficate_css, index) for index in xrange(len(self.q(css=css)))]
|
|
|
|
@property
|
|
def no_certificates_message_shown(self):
|
|
"""
|
|
Returns whether or not no certificates created message is present.
|
|
"""
|
|
return self.q(css='.wrapper-content ' + self.certficate_css + ' .no-content').present
|
|
|
|
@property
|
|
def no_certificates_message_text(self):
|
|
"""
|
|
Returns text of .no-content container.
|
|
"""
|
|
return self.q(css='.wrapper-content ' + self.certficate_css + ' .no-content').text[0]
|
|
|
|
################
|
|
# Wait Actions
|
|
################
|
|
|
|
def wait_for_confirmation_prompt(self):
|
|
"""
|
|
Show confirmation prompt
|
|
We can't use confirm_prompt because its wait_for_notification is flaky when asynchronous operation
|
|
completed very quickly.
|
|
"""
|
|
self.wait_for_element_visibility('.prompt', 'Prompt is visible')
|
|
self.wait_for_element_visibility('.prompt .action-primary', 'Confirmation button is visible')
|
|
|
|
def wait_for_first_certificate_button(self):
|
|
"""
|
|
Ensure the button is available for use
|
|
"""
|
|
EmptyPromise(
|
|
lambda: self.q(css=self.certficate_css + " .new-button").present,
|
|
'Create first certificate button is displayed'
|
|
).fulfill()
|
|
|
|
def wait_for_add_certificate_button(self):
|
|
"""
|
|
Ensure the button is available for use
|
|
"""
|
|
EmptyPromise(
|
|
lambda: self.q(css=self.certficate_css + " .action-add").present,
|
|
'Add certificate button is displayed'
|
|
).fulfill()
|
|
|
|
################
|
|
# Click Actions
|
|
################
|
|
|
|
def click_first_certificate_button(self):
|
|
"""
|
|
Clicks the 'Create your first certificate' button, which is only displayed at zero state
|
|
"""
|
|
self.q(css=self.certficate_css + " .new-button").first.click()
|
|
|
|
def click_add_certificate_button(self):
|
|
"""
|
|
Clicks the 'Add new certificate' button, which is displayed when certificates already exist
|
|
"""
|
|
self.q(css=self.certficate_css + " .action-add").first.click()
|
|
|
|
################
|
|
# Workflows
|
|
################
|
|
|
|
|
|
class Certificate(object):
|
|
"""
|
|
Certificate page object wrapper
|
|
"""
|
|
|
|
def __init__(self, page, prefix, index):
|
|
self.page = page
|
|
self.selector = prefix + ' .certificates-list-item-{}'.format(index)
|
|
self.index = index
|
|
|
|
################
|
|
# Helpers
|
|
################
|
|
|
|
def get_selector(self, css=''):
|
|
"""
|
|
Return selector fo certificate container
|
|
"""
|
|
return ' '.join([self.selector, css])
|
|
|
|
def find_css(self, css_selector):
|
|
"""
|
|
Find elements as defined by css locator.
|
|
"""
|
|
return self.page.q(css=self.get_selector(css=css_selector))
|
|
|
|
def get_text(self, css):
|
|
"""
|
|
Return text for the defined by css locator.
|
|
"""
|
|
return self.find_css(css).first.text[0]
|
|
|
|
################
|
|
# Properties
|
|
################
|
|
|
|
@property
|
|
def validation_message(self):
|
|
"""
|
|
Return validation message.
|
|
"""
|
|
return self.get_text('.message-status.error')
|
|
|
|
@property
|
|
def mode(self):
|
|
"""
|
|
Return certificate mode.
|
|
"""
|
|
if self.find_css('.collection-edit').present:
|
|
return 'edit'
|
|
elif self.find_css('.collection').present:
|
|
return 'details'
|
|
|
|
@property
|
|
# pylint: disable=invalid-name
|
|
def id(self):
|
|
"""
|
|
Returns certificate id.
|
|
"""
|
|
return self.get_text('.certificate-id .certificate-value')
|
|
|
|
@property
|
|
def name(self):
|
|
"""
|
|
Return certificate name.
|
|
"""
|
|
return self.get_text('.name')
|
|
|
|
@name.setter
|
|
def name(self, value):
|
|
"""
|
|
Set certificate name.
|
|
"""
|
|
self.find_css('.collection-name-input').first.fill(value)
|
|
|
|
@property
|
|
def description(self):
|
|
"""
|
|
Return certificate description.
|
|
"""
|
|
return self.get_text('.certificate-description')
|
|
|
|
@description.setter
|
|
def description(self, value):
|
|
"""
|
|
Set certificate description.
|
|
"""
|
|
self.find_css('.certificate-description-input').first.fill(value)
|
|
|
|
@property
|
|
def course_title(self):
|
|
"""
|
|
Return certificate course title override field.
|
|
"""
|
|
return self.get_text('.course-title-override .certificate-value')
|
|
|
|
@course_title.setter
|
|
def course_title(self, value):
|
|
"""
|
|
Set certificate course title override field.
|
|
"""
|
|
self.find_css('.certificate-course-title-input').first.fill(value)
|
|
|
|
@property
|
|
def signatories(self):
|
|
"""
|
|
Return list of the signatories for the certificate.
|
|
"""
|
|
css = self.selector + ' .signatory-' + self.mode
|
|
return [Signatory(self, self.selector, self.mode, index) for index in xrange(len(self.page.q(css=css)))]
|
|
|
|
################
|
|
# Wait Actions
|
|
################
|
|
|
|
def wait_for_certificate_delete_button(self):
|
|
"""
|
|
Returns whether or not the certificate delete icon is present.
|
|
"""
|
|
return self.find_css('.actions .delete').present
|
|
|
|
def wait_for_hide_details_toggle(self):
|
|
"""
|
|
Certificate details are expanded.
|
|
"""
|
|
return self.find_css('a.detail-toggle.hide-details').present
|
|
|
|
################
|
|
# Click Actions
|
|
################
|
|
|
|
def click_create_certificate_button(self):
|
|
"""
|
|
Create a new certificate.
|
|
"""
|
|
self.find_css('.action-primary').first.click()
|
|
self.page.wait_for_ajax()
|
|
|
|
def click_save_certificate_button(self):
|
|
"""
|
|
Save certificate.
|
|
"""
|
|
self.find_css('.action-primary').first.click()
|
|
self.page.wait_for_ajax()
|
|
|
|
def click_add_signatory_button(self):
|
|
"""
|
|
Add signatory to certificate
|
|
"""
|
|
self.find_css('.action-add-signatory').first.click()
|
|
|
|
def click_edit_certificate_button(self):
|
|
"""
|
|
Open editing view for the certificate.
|
|
"""
|
|
self.find_css('.action-edit .edit').first.click()
|
|
|
|
def click_cancel_edit_certificate(self):
|
|
"""
|
|
Cancel certificate editing.
|
|
"""
|
|
self.find_css('.action-secondary').first.click()
|
|
|
|
def click_certificate_details_toggle(self):
|
|
"""
|
|
Expand/collapse certificate configuration.
|
|
"""
|
|
self.find_css('a.detail-toggle').first.click()
|
|
|
|
################
|
|
# Workflows
|
|
################
|
|
|
|
def delete_certificate(self):
|
|
"""
|
|
Delete the certificate
|
|
"""
|
|
self.wait_for_certificate_delete_button()
|
|
self.find_css('.actions .delete').first.click()
|
|
self.page.wait_for_confirmation_prompt()
|
|
self.find_css('.action-primary').first.click()
|
|
self.page.wait_for_ajax()
|
|
|
|
|
|
class Signatory(object):
|
|
"""
|
|
Signatory page object wrapper
|
|
"""
|
|
def __init__(self, certificate, prefix, mode, index):
|
|
self.certificate = certificate
|
|
self.prefix = prefix
|
|
self.index = index
|
|
self.mode = mode
|
|
|
|
################
|
|
# Helpers
|
|
################
|
|
|
|
@staticmethod
|
|
def file_path(filename):
|
|
"""
|
|
Construct file path to be uploaded from the data upload folder.
|
|
|
|
Arguments:
|
|
filename (str): asset filename
|
|
|
|
"""
|
|
# Should grab common point between this page module and the data folder.
|
|
return os.sep.join(__file__.split(os.sep)[:-4]) + '/data/uploads/' + filename
|
|
|
|
def get_selector(self, css=''):
|
|
"""
|
|
Return selector fo signatory container
|
|
"""
|
|
selector = self.prefix + ' .signatory-{}-view-{}'.format(self.mode, self.index)
|
|
return ' '.join([selector, css])
|
|
|
|
def find_css(self, css_selector):
|
|
"""
|
|
Find elements as defined by css locator.
|
|
"""
|
|
return self.certificate.page.q(css=self.get_selector(css=css_selector))
|
|
|
|
################
|
|
# Properties
|
|
################
|
|
|
|
@property
|
|
def name(self):
|
|
"""
|
|
Return signatory name.
|
|
"""
|
|
return self.find_css('.signatory-panel-body .signatory-name-value').first.text[0]
|
|
|
|
@name.setter
|
|
def name(self, value):
|
|
"""
|
|
Set signatory name.
|
|
"""
|
|
self.find_css('.signatory-name-input').first.fill(value)
|
|
|
|
@property
|
|
def title(self):
|
|
"""
|
|
Return signatory title.
|
|
"""
|
|
return self.find_css('.signatory-panel-body .signatory-title-value').first.text[0]
|
|
|
|
@title.setter
|
|
def title(self, value):
|
|
"""
|
|
Set signatory title.
|
|
"""
|
|
self.find_css('.signatory-title-input').first.fill(value)
|
|
|
|
@property
|
|
def organization(self):
|
|
"""
|
|
Return signatory organization.
|
|
"""
|
|
return self.find_css('.signatory-panel-body .signatory-organization-value').first.text[0]
|
|
|
|
@organization.setter
|
|
def organization(self, value):
|
|
"""
|
|
Set signatory organization.
|
|
"""
|
|
self.find_css('.signatory-organization-input').first.fill(value)
|
|
|
|
################
|
|
# Workflows
|
|
################
|
|
|
|
def edit(self):
|
|
"""
|
|
Open editing view for the signatory.
|
|
"""
|
|
self.find_css('.edit-signatory').first.click()
|
|
self.mode = 'edit'
|
|
self.wait_for_signatory_edit_view()
|
|
|
|
def delete_signatory(self):
|
|
"""
|
|
Delete the signatory
|
|
"""
|
|
# pylint: disable=pointless-statement
|
|
self.wait_for_signatory_delete_icon()
|
|
self.click_signatory_delete_icon()
|
|
self.wait_for_signatory_delete_prompt()
|
|
|
|
self.certificate.page.q(css='#prompt-warning a.button.action-primary').first.click()
|
|
self.certificate.page.wait_for_ajax()
|
|
|
|
def save(self):
|
|
"""
|
|
Save signatory.
|
|
"""
|
|
# Move focus from input to save button and then click it
|
|
self.certificate.page.browser.execute_script(
|
|
"$('{} .signatory-panel-save').focus()".format(self.get_selector())
|
|
)
|
|
self.find_css('.signatory-panel-save').first.click()
|
|
self.mode = 'details'
|
|
self.certificate.page.wait_for_ajax()
|
|
self.wait_for_signatory_detail_view()
|
|
|
|
def close(self):
|
|
"""
|
|
Cancel signatory editing.
|
|
"""
|
|
self.find_css('.signatory-panel-close').first.click()
|
|
self.mode = 'details'
|
|
self.wait_for_signatory_detail_view()
|
|
|
|
def upload_signature_image(self, image_filename):
|
|
"""
|
|
Opens upload image dialog and upload given image file.
|
|
"""
|
|
self.wait_for_signature_image_upload_button()
|
|
self.find_css('.action-upload-signature').first.click()
|
|
self.find_css('.action-upload-signature').first.click()
|
|
self.wait_for_signature_image_upload_prompt()
|
|
|
|
asset_file_path = self.file_path(image_filename)
|
|
self.certificate.page.q(
|
|
css='.assetupload-modal .upload-dialog input[type="file"]'
|
|
)[0].send_keys(asset_file_path)
|
|
|
|
EmptyPromise(
|
|
lambda: not self.certificate.page.q(
|
|
css='.assetupload-modal a.action-upload.disabled'
|
|
).present,
|
|
'Upload button is not disabled anymore'
|
|
).fulfill()
|
|
|
|
self.certificate.page.q(css='.assetupload-modal a.action-upload').first.click()
|
|
EmptyPromise(
|
|
lambda: not self.certificate.page.q(css='.assetupload-modal .upload-dialog').visible,
|
|
'Upload dialog is removed after uploading image'
|
|
).fulfill()
|
|
|
|
################
|
|
# Wait Actions
|
|
################
|
|
|
|
@property
|
|
def wait_for_signatory_delete_icon(self):
|
|
"""
|
|
Returns whether or not the delete icon is present.
|
|
"""
|
|
EmptyPromise(
|
|
lambda: self.certificate.page.q(css='.signatory-panel-delete').present,
|
|
'Delete icon is displayed'
|
|
).fulfill()
|
|
|
|
def wait_for_signatory_delete_prompt(self):
|
|
"""
|
|
Promise to wait until signatory delete prompt is visible
|
|
"""
|
|
EmptyPromise(
|
|
lambda: self.certificate.page.q(css='a.button.action-primary').present,
|
|
'Delete prompt is displayed'
|
|
).fulfill()
|
|
|
|
def wait_for_signatory_edit_view(self):
|
|
"""
|
|
Promise to wait until signatory edit view is loaded
|
|
"""
|
|
EmptyPromise(
|
|
lambda: self.find_css('.signatory-panel-body .signatory-name-input').present,
|
|
'On signatory edit view'
|
|
).fulfill()
|
|
|
|
def wait_for_signatory_detail_view(self):
|
|
"""
|
|
Promise to wait until signatory details view is loaded
|
|
"""
|
|
EmptyPromise(
|
|
lambda: self.find_css('.signatory-panel-body .signatory-name-value').present,
|
|
'On signatory details view'
|
|
).fulfill()
|
|
|
|
def wait_for_signature_image_upload_prompt(self):
|
|
"""
|
|
Promise to wait until signatory image upload prompt is visible
|
|
"""
|
|
EmptyPromise(
|
|
lambda: self.certificate.page.q(css='.assetupload-modal .action-upload').present,
|
|
'Signature image upload dialog opened'
|
|
).fulfill()
|
|
|
|
def wait_for_signature_image_upload_button(self):
|
|
"""
|
|
Promise to wait until signatory image upload button is visible
|
|
"""
|
|
EmptyPromise(
|
|
lambda: self.certificate.page.q(css=".action-upload-signature").first.present,
|
|
'Signature image upload button available'
|
|
).fulfill()
|
|
|
|
@property
|
|
def wait_for_signature_image(self):
|
|
"""
|
|
Promise for the signature image to be displayed
|
|
"""
|
|
EmptyPromise(
|
|
lambda: self.certificate.page.q(css=".current-signature-image .signature-image").present,
|
|
'Signature image available'
|
|
).fulfill()
|
|
|
|
################
|
|
# Click Actions
|
|
################
|
|
|
|
def click_signatory_delete_icon(self):
|
|
"""
|
|
Clicks the signatory deletion icon/action
|
|
"""
|
|
self.find_css('.signatory-panel-delete').first.click()
|