Commit 9351600c by M. Rehan Committed by GitHub

Merge pull request #14594 from edx/mrehan/duplicate-video-id-in-basic-tab

TNL-6489 – duplicate video id in basic tab
parents 8688edaf f064e991
...@@ -31,10 +31,21 @@ function($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCol ...@@ -31,10 +31,21 @@ function($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCol
type: MetadataModel.GENERIC_TYPE, type: MetadataModel.GENERIC_TYPE,
value: 'display value' value: 'display value'
}, },
models = [DisplayNameEntry, VideoListEntry], VideoIDEntry = {
default_value: 'test default value',
display_name: 'Video ID',
explicitly_set: true,
field_name: 'edx_video_id',
help: 'Specifies the video ID.',
options: [],
type: MetadataModel.GENERIC_TYPE,
value: 'basic tab video id'
},
models = [DisplayNameEntry, VideoListEntry, VideoIDEntry],
testData = { testData = {
'display_name': DisplayNameEntry, display_name: DisplayNameEntry,
'video_url': VideoListEntry video_url: VideoListEntry,
edx_video_id: VideoIDEntry
}, },
metadataDict = { metadataDict = {
object: testData, object: testData,
...@@ -132,6 +143,16 @@ function($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCol ...@@ -132,6 +143,16 @@ function($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCol
type: MetadataModel.GENERIC_TYPE, type: MetadataModel.GENERIC_TYPE,
value: 'OEoXaMPEzfM' value: 'OEoXaMPEzfM'
}, },
videoIDEntry = {
default_value: 'test default value',
display_name: 'Video ID',
explicitly_set: true,
field_name: 'edx_video_id',
help: 'Specifies the video ID.',
options: [],
type: MetadataModel.GENERIC_TYPE,
value: 'advanced tab video id'
},
metadataCollection, metadataCollection,
metadataView; metadataView;
...@@ -148,7 +169,8 @@ function($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCol ...@@ -148,7 +169,8 @@ function($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCol
nameEntry, nameEntry,
subEntry, subEntry,
html5SourcesEntry, html5SourcesEntry,
youtubeEntry youtubeEntry,
videoIDEntry
] ]
); );
...@@ -167,34 +189,55 @@ function($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCol ...@@ -167,34 +189,55 @@ function($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCol
waitsForDisplayName(collection) waitsForDisplayName(collection)
.then(function() { .then(function() {
var displayNameValue = collection[0].getValue(), var displayNameValue, videoUrlValue, videoIDValue;
videoUrlValue = collection[1].getValue();
displayNameValue = transcripts.collection.findWhere({
field_name: 'display_name'
}).getValue();
expect(displayNameValue).toEqual('default'); expect(displayNameValue).toEqual('default');
videoUrlValue = transcripts.collection.findWhere({
field_name: 'video_url'
}).getValue();
expect(videoUrlValue).toEqual([ expect(videoUrlValue).toEqual([
'http://youtu.be/OEoXaMPEzfM', 'http://youtu.be/OEoXaMPEzfM',
'default.mp4', 'default.mp4',
'default.webm' 'default.webm'
]); ]);
videoIDValue = transcripts.collection.findWhere({
field_name: 'edx_video_id'
}).getValue();
expect(videoIDValue).toEqual('advanced tab video id');
}) })
.always(done); .always(done);
}); });
it('If metadataCollection is not defined', function() { it('If metadataCollection is not defined', function() {
var videoUrlValue, videoIDValue;
transcripts.syncBasicTab(null); transcripts.syncBasicTab(null);
var collection = transcripts.collection.models, videoUrlValue = transcripts.collection.findWhere({
videoUrlValue = collection[1].getValue(); field_name: 'video_url'
}).getValue();
expect(videoUrlValue).toEqual([ expect(videoUrlValue).toEqual([
'http://youtu.be/12345678901', 'http://youtu.be/12345678901',
'video.mp4', 'video.mp4',
'video.webm' 'video.webm'
]); ]);
videoIDValue = transcripts.collection.findWhere({
field_name: 'edx_video_id'
}).getValue();
expect(videoIDValue).toEqual('basic tab video id');
}); });
it('Youtube Id has length not eqaul 11', function() { it('Youtube Id has length not eqaul 11', function() {
var model = metadataCollection.findWhere({ var model, videoUrlValue;
model = metadataCollection.findWhere({
field_name: 'youtube_id_1_0' field_name: 'youtube_id_1_0'
}); });
...@@ -206,8 +249,9 @@ function($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCol ...@@ -206,8 +249,9 @@ function($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCol
transcripts.syncBasicTab(metadataCollection, metadataView); transcripts.syncBasicTab(metadataCollection, metadataView);
var collection = transcripts.collection.models, videoUrlValue = transcripts.collection.findWhere({
videoUrlValue = collection[1].getValue(); field_name: 'video_url'
}).getValue();
expect(videoUrlValue).toEqual([ expect(videoUrlValue).toEqual([
'', '',
...@@ -224,42 +268,79 @@ function($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCol ...@@ -224,42 +268,79 @@ function($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCol
var collection = metadataCollection.models; var collection = metadataCollection.models;
waitsForDisplayName(collection) waitsForDisplayName(collection)
.then(function() { .then(function() {
var displayNameValue = collection[0].getValue(); var displayNameValue, subValue, html5SourcesValue, youtubeValue, videoIDValue;
var subValue = collection[1].getValue();
var html5SourcesValue = collection[2].getValue();
var youtubeValue = collection[3].getValue();
displayNameValue = metadataCollection.findWhere({
field_name: 'display_name'
}).getValue();
expect(displayNameValue).toEqual('display value'); expect(displayNameValue).toEqual('display value');
subValue = metadataCollection.findWhere({
field_name: 'sub'
}).getValue();
expect(subValue).toEqual('default'); expect(subValue).toEqual('default');
html5SourcesValue = metadataCollection.findWhere({
field_name: 'html5_sources'
}).getValue();
expect(html5SourcesValue).toEqual([ expect(html5SourcesValue).toEqual([
'video.mp4', 'video.mp4',
'video.webm' 'video.webm'
]); ]);
youtubeValue = metadataCollection.findWhere({
field_name: 'youtube_id_1_0'
}).getValue();
expect(youtubeValue).toEqual('12345678901'); expect(youtubeValue).toEqual('12345678901');
videoIDValue = metadataCollection.findWhere({
field_name: 'edx_video_id'
}).getValue();
expect(videoIDValue).toEqual('basic tab video id');
}) })
.always(done); .always(done);
}); });
it('metadataCollection is not defined', function() { it('metadataCollection is not defined', function() {
transcripts.syncAdvancedTab(null); var displayNameValue, subValue, html5SourcesValue, youtubeValue, videoIDValue;
var collection = metadataCollection.models, transcripts.syncAdvancedTab(null);
displayNameValue = collection[0].getValue(),
subValue = collection[1].getValue(),
html5SourcesValue = collection[2].getValue(),
youtubeValue = collection[3].getValue();
displayNameValue = metadataCollection.findWhere({
field_name: 'display_name'
}).getValue();
expect(displayNameValue).toEqual('default'); expect(displayNameValue).toEqual('default');
subValue = metadataCollection.findWhere({
field_name: 'sub'
}).getValue();
expect(subValue).toEqual('default'); expect(subValue).toEqual('default');
html5SourcesValue = metadataCollection.findWhere({
field_name: 'html5_sources'
}).getValue();
expect(html5SourcesValue).toEqual([ expect(html5SourcesValue).toEqual([
'default.mp4', 'default.mp4',
'default.webm' 'default.webm'
]); ]);
youtubeValue = metadataCollection.findWhere({
field_name: 'youtube_id_1_0'
}).getValue();
expect(youtubeValue).toEqual('OEoXaMPEzfM'); expect(youtubeValue).toEqual('OEoXaMPEzfM');
videoIDValue = metadataCollection.findWhere({
field_name: 'edx_video_id'
}).getValue();
expect(videoIDValue).toEqual('advanced tab video id');
}); });
it('Youtube Id is not adjusted', function() { it('Youtube Id is not adjusted', function() {
var model = transcripts.collection.models[1]; var model, html5SourcesValue, youtubeValue;
model = transcripts.collection.findWhere({
field_name: 'video_url'
});
model.setValue([ model.setValue([
'video.mp4', 'video.mp4',
...@@ -268,14 +349,17 @@ function($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCol ...@@ -268,14 +349,17 @@ function($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCol
transcripts.syncAdvancedTab(metadataCollection); transcripts.syncAdvancedTab(metadataCollection);
var collection = metadataCollection.models, html5SourcesValue = metadataCollection.findWhere({
html5SourcesValue = collection[2].getValue(), field_name: 'html5_sources'
youtubeValue = collection[3].getValue(); }).getValue();
expect(html5SourcesValue).toEqual([ expect(html5SourcesValue).toEqual([
'video.mp4', 'video.mp4',
'video.webm' 'video.webm'
]); ]);
youtubeValue = metadataCollection.findWhere({
field_name: 'youtube_id_1_0'
}).getValue();
expect(youtubeValue).toEqual(''); expect(youtubeValue).toEqual('');
}); });
......
...@@ -667,6 +667,7 @@ class VideoDescriptor(VideoFields, VideoTranscriptsMixin, VideoStudioViewHandler ...@@ -667,6 +667,7 @@ class VideoDescriptor(VideoFields, VideoTranscriptsMixin, VideoStudioViewHandler
display_name = metadata_fields['display_name'] display_name = metadata_fields['display_name']
video_url = metadata_fields['html5_sources'] video_url = metadata_fields['html5_sources']
video_id = metadata_fields['edx_video_id']
youtube_id_1_0 = metadata_fields['youtube_id_1_0'] youtube_id_1_0 = metadata_fields['youtube_id_1_0']
def get_youtube_link(video_id): def get_youtube_link(video_id):
...@@ -698,7 +699,8 @@ class VideoDescriptor(VideoFields, VideoTranscriptsMixin, VideoStudioViewHandler ...@@ -698,7 +699,8 @@ class VideoDescriptor(VideoFields, VideoTranscriptsMixin, VideoStudioViewHandler
metadata = { metadata = {
'display_name': display_name, 'display_name': display_name,
'video_url': video_url 'video_url': video_url,
'edx_video_id': video_id
} }
_context.update({'transcripts_basic_tab_metadata': metadata}) _context.update({'transcripts_basic_tab_metadata': metadata})
......
...@@ -55,6 +55,7 @@ DEFAULT_SETTINGS = [ ...@@ -55,6 +55,7 @@ DEFAULT_SETTINGS = [
# basic # basic
[DISPLAY_NAME, 'Video', False], [DISPLAY_NAME, 'Video', False],
['Default Video URL', 'https://www.youtube.com/watch?v=3_yD_cEKoCk, , ', False], ['Default Video URL', 'https://www.youtube.com/watch?v=3_yD_cEKoCk, , ', False],
['Video ID', '', False],
# advanced # advanced
[DISPLAY_NAME, 'Video', False], [DISPLAY_NAME, 'Video', False],
......
...@@ -1247,6 +1247,12 @@ class VideoDescriptorTest(TestCase, VideoDescriptorTestBase): ...@@ -1247,6 +1247,12 @@ class VideoDescriptorTest(TestCase, VideoDescriptorTestBase):
rendered_context = self.descriptor.get_context() rendered_context = self.descriptor.get_context()
self.assertListEqual(rendered_context['tabs'], correct_tabs) self.assertListEqual(rendered_context['tabs'], correct_tabs)
# Assert that the Video ID field is present in basic tab metadata context.
self.assertEqual(
rendered_context['transcripts_basic_tab_metadata']['edx_video_id'],
self.descriptor.editable_metadata_fields['edx_video_id']
)
def test_export_val_data(self): def test_export_val_data(self):
self.descriptor.edx_video_id = 'test_edx_video_id' self.descriptor.edx_video_id = 'test_edx_video_id'
create_profile('mobile') create_profile('mobile')
......
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