Commit 871b7fe7 by Mushtaq Ali

Add feature disabled JS tests

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