Commit 871b7fe7 by Mushtaq Ali

Add feature disabled JS tests

Fix quality
parent 554c90d1
......@@ -21,7 +21,7 @@ from edxval.api import (
get_video_info,
get_course_video_image_url,
create_or_update_video_transcript
)
)
from mock import Mock, patch
from contentstore.models import VideoUploadConfig
......@@ -287,8 +287,8 @@ class VideosHandlerTestCase(VideoUploadTestMixin, CourseTestCase):
}
],
{
'en': 'English',
'es': 'Spanish'
'en': 'English',
'es': 'Spanish'
}
)
)
......@@ -653,12 +653,6 @@ class VideosHandlerTestCase(VideoUploadTestMixin, CourseTestCase):
is_video_transcript_enabled
)
# Verify that transcripts column is present in the response if videos transcript feature is enabled.
self.assertEqual(
'<div class="video-head-col video-col transcripts-col">Transcripts</div>' in response.content,
is_video_transcript_enabled
)
@ddt.ddt
@patch.dict('django.conf.settings.FEATURES', {'ENABLE_VIDEO_UPLOAD_PIPELINE': True})
......
......@@ -580,6 +580,7 @@ def _get_index_videos(course):
_get_values(video) for video in _get_videos(course)
]
def get_all_transcript_languages(is_video_transcript_enabled=False):
"""
Returns all possible languages for transcript.
......@@ -592,7 +593,7 @@ def get_all_transcript_languages(is_video_transcript_enabled=False):
# Get third party transcription languages.
third_party_transcription_languages = transcription_plans[TranscriptProvider.THREE_PLAY_MEDIA]['languages']
third_party_transcription_languages = dict(third_party_transcription_languages, **cielo_fidelity['MECHANICAL']['languages'])
third_party_transcription_languages = dict(third_party_transcription_languages , **cielo_fidelity['PREMIUM']['languages'])
third_party_transcription_languages = dict(third_party_transcription_languages, **cielo_fidelity['PREMIUM']['languages'])
third_party_transcription_languages = dict(third_party_transcription_languages, **cielo_fidelity['PROFESSIONAL']['languages'])
# Get all settings languages dict.
......@@ -603,6 +604,7 @@ def get_all_transcript_languages(is_video_transcript_enabled=False):
# Return combined settings and 3rd party transcript languages.
return dict(all_languages, **third_party_transcription_languages)
def videos_index_html(course):
"""
Returns an HTML page to display previous video uploads and allow new ones
......
define(
['jquery', 'underscore', 'backbone', 'js/views/video_transcripts', 'common/js/spec_helpers/template_helpers'],
function($, _, Backbone, VideoTranscriptsView, TemplateHelpers) {
['jquery', 'underscore', 'backbone', 'js/views/video_transcripts', 'js/views/previous_video_upload_list',
'common/js/spec_helpers/template_helpers'],
function($, _, Backbone, VideoTranscriptsView, PreviousVideoUploadListView, TemplateHelpers) {
'use strict';
describe('VideoTranscriptsView', function() {
var $videoTranscriptsViewEl,
videoTranscriptsView,
var videoTranscriptsView,
renderView,
transcripts = {
en: 'English',
......@@ -21,37 +21,68 @@ define(
ur: 'Urdu'
},
videoSupportedFileFormats = ['.mov', '.mp4'],
TRANSCRIPT_DOWNLOAD_FILE_FORMAT = 'srt';
renderView = function(availableTranscripts) {
videoTranscriptsView = new VideoTranscriptsView({
transcripts: availableTranscripts,
edxVideoID: edxVideoID,
clientVideoID: clientVideoID,
TRANSCRIPT_DOWNLOAD_FILE_FORMAT = 'srt',
videoListView;
renderView = function(availableTranscripts, isVideoTranscriptEnabled) {
var videoViewIndex = 0,
isVideoTranscriptEnabled = isVideoTranscriptEnabled || _.isUndefined(isVideoTranscriptEnabled), // eslint-disable-line max-len, no-redeclare
videoData = {
client_video_id: clientVideoID,
edx_video_id: edxVideoID,
created: '2014-11-25T23:13:05',
transcripts: availableTranscripts
},
videoCollection = new Backbone.Collection([new Backbone.Model(videoData)]);
videoListView = new PreviousVideoUploadListView({
collection: videoCollection,
videoImageSettings: {},
transcriptAvailableLanguages: transcriptAvailableLanguages,
videoSupportedFileFormats: videoSupportedFileFormats
videoSupportedFileFormats: videoSupportedFileFormats,
isVideoTranscriptEnabled: isVideoTranscriptEnabled
});
videoTranscriptsView.setElement($('.transcripts-col'));
$videoTranscriptsViewEl = videoTranscriptsView.render().$el;
videoListView.setElement($('.wrapper-assets'));
videoListView.render();
videoTranscriptsView = videoListView.itemViews[videoViewIndex].videoTranscriptsView;
};
beforeEach(function() {
setFixtures(
'<div class="video-col transcripts-col"></div>'
);
TemplateHelpers.installTemplate('video-transcripts');
setFixtures('<section class="wrapper-assets"></section>');
TemplateHelpers.installTemplate('previous-video-upload-list');
renderView(transcripts);
});
it('renders as expected', function() {
expect($videoTranscriptsViewEl.find('.show-video-transcripts-container')).toExist();
expect(videoListView.$el.find('.show-video-transcripts-container')).toExist();
// Verify transcript container is present.
expect(videoListView.$el.find('.show-video-transcripts-container')).toExist();
// Veirfy transcript column header is present.
expect(videoListView.$el.find('.js-table-head .video-head-col.transcripts-col')).toExist();
// Verify transcript data column is present.
expect(videoListView.$el.find('.js-table-body .transcripts-col')).toExist();
// Verify view has initiallized.
expect(_.isUndefined(videoTranscriptsView)).toEqual(false);
});
it('does not render transcripts view if feature is disabled', function() {
renderView({}, false);
// Verify transcript container is not present.
expect(videoListView.$el.find('.show-video-transcripts-container')).not.toExist();
// Veirfy transcript column header is not present.
expect(videoListView.$el.find('.js-table-head .video-head-col.transcripts-col')).not.toExist();
// Verify transcript data column is not present.
expect(videoListView.$el.find('.js-table-body .transcripts-col')).not.toExist();
// Verify view has not initiallized.
expect(_.isUndefined(videoTranscriptsView)).toEqual(true);
});
it('does not shows transcripts', function() {
expect(
$videoTranscriptsViewEl.find('.show-video-transcripts-wrapper').hasClass('hidden')
videoTranscriptsView.$el.find('.show-video-transcripts-wrapper').hasClass('hidden')
).toEqual(true);
expect($videoTranscriptsViewEl.find('.toggle-show-transcripts-button-text').html().trim()).toEqual(
expect(videoTranscriptsView.$el.find('.toggle-show-transcripts-button-text').html().trim()).toEqual(
'Show transcripts (' + _.size(transcripts) + ')'
);
});
......@@ -59,50 +90,50 @@ define(
it('shows transcripts container on show transcript button click', function() {
// Verify transcript container is hidden
expect(
$videoTranscriptsViewEl.find('.show-video-transcripts-wrapper').hasClass('hidden')
videoTranscriptsView.$el.find('.show-video-transcripts-wrapper').hasClass('hidden')
).toEqual(true);
// Verify initial button text
expect($videoTranscriptsViewEl.find('.toggle-show-transcripts-button-text').html().trim()).toEqual(
expect(videoTranscriptsView.$el.find('.toggle-show-transcripts-button-text').html().trim()).toEqual(
'Show transcripts (' + _.size(transcripts) + ')'
);
$videoTranscriptsViewEl.find('.toggle-show-transcripts-button').click();
videoTranscriptsView.$el.find('.toggle-show-transcripts-button').click();
// Verify transcript container is not hidden
expect(
$videoTranscriptsViewEl.find('.show-video-transcripts-wrapper').hasClass('hidden')
videoTranscriptsView.$el.find('.show-video-transcripts-wrapper').hasClass('hidden')
).toEqual(false);
// Verify button text is changed.
expect($videoTranscriptsViewEl.find('.toggle-show-transcripts-button-text').html().trim()).toEqual(
expect(videoTranscriptsView.$el.find('.toggle-show-transcripts-button-text').html().trim()).toEqual(
'Hide transcripts (' + _.size(transcripts) + ')'
);
});
it('hides transcripts when clicked on hide transcripts button', function() {
// Click to show transcripts first.
$videoTranscriptsViewEl.find('.toggle-show-transcripts-button').click();
videoTranscriptsView.$el.find('.toggle-show-transcripts-button').click();
// Verify button text.
expect($videoTranscriptsViewEl.find('.toggle-show-transcripts-button-text').html().trim()).toEqual(
expect(videoTranscriptsView.$el.find('.toggle-show-transcripts-button-text').html().trim()).toEqual(
'Hide transcripts (' + _.size(transcripts) + ')'
);
// Verify transcript container is not hidden
expect(
$videoTranscriptsViewEl.find('.show-video-transcripts-wrapper').hasClass('hidden')
videoTranscriptsView.$el.find('.show-video-transcripts-wrapper').hasClass('hidden')
).toEqual(false);
$videoTranscriptsViewEl.find('.toggle-show-transcripts-button').click();
videoTranscriptsView.$el.find('.toggle-show-transcripts-button').click();
// Verify button text is changed.
expect($videoTranscriptsViewEl.find('.toggle-show-transcripts-button-text').html().trim()).toEqual(
expect(videoTranscriptsView.$el.find('.toggle-show-transcripts-button-text').html().trim()).toEqual(
'Show transcripts (' + _.size(transcripts) + ')'
);
// Verify transcript container is hidden
expect(
$videoTranscriptsViewEl.find('.show-video-transcripts-wrapper').hasClass('hidden')
videoTranscriptsView.$el.find('.show-video-transcripts-wrapper').hasClass('hidden')
).toEqual(true);
});
......@@ -112,20 +143,20 @@ define(
// Verify appropriate text is shown
expect(
$videoTranscriptsViewEl.find('.transcripts-empty-text').html()
videoTranscriptsView.$el.find('.transcripts-empty-text').html()
).toEqual('No transcript available yet.');
});
it('renders correct transcript attributes', function() {
var $transcriptEl;
// Show transcripts
$videoTranscriptsViewEl.find('.toggle-show-transcripts-button').click();
expect($videoTranscriptsViewEl.find('.show-video-transcript-content').length).toEqual(
videoTranscriptsView.$el.find('.toggle-show-transcripts-button').click();
expect(videoTranscriptsView.$el.find('.show-video-transcript-content').length).toEqual(
_.size(transcripts)
);
_.each(transcripts, function(langaugeText, languageCode) {
$transcriptEl = $($videoTranscriptsViewEl.find('#show-video-transcript-content-' + languageCode));
$transcriptEl = $(videoTranscriptsView.$el.find('#show-video-transcript-content-' + languageCode));
// Verify correct transcript title is set.
expect($transcriptEl.find('.transcript-title').html()).toEqual(
'Video client title n_' + languageCode + '.' + TRANSCRIPT_DOWNLOAD_FILE_FORMAT
......
......@@ -62,7 +62,7 @@ define(
StringUtils.interpolate(
gettext('{toggleShowTranscriptText} transcripts ({totalTranscripts})'),
{
toggleShowTranscriptText: $transcriptsWrapperEl.hasClass('hidden') ? gettext('Show') : gettext('Hide'),
toggleShowTranscriptText: $transcriptsWrapperEl.hasClass('hidden') ? gettext('Show') : gettext('Hide'), // eslint-disable-line max-len
totalTranscripts: _.size(this.transcripts)
}
)
......
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