Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
554c90d1
Commit
554c90d1
authored
Dec 20, 2017
by
Mushtaq Ali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add JS tests
parent
111e9362
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
148 additions
and
7 deletions
+148
-7
cms/static/cms/js/spec/main.js
+1
-0
cms/static/js/spec/views/video_transcripts_spec.js
+139
-0
cms/static/js/views/video_transcripts.js
+2
-3
cms/templates/js/previous-video-upload.underscore
+1
-1
cms/templates/js/video-transcripts.underscore
+5
-3
No files found.
cms/static/cms/js/spec/main.js
View file @
554c90d1
...
@@ -259,6 +259,7 @@
...
@@ -259,6 +259,7 @@
'js/spec/views/previous_video_upload_spec'
,
'js/spec/views/previous_video_upload_spec'
,
'js/spec/views/video_thumbnail_spec'
,
'js/spec/views/video_thumbnail_spec'
,
'js/spec/views/course_video_settings_spec'
,
'js/spec/views/course_video_settings_spec'
,
'js/spec/views/video_transcripts_spec'
,
'js/spec/views/previous_video_upload_list_spec'
,
'js/spec/views/previous_video_upload_list_spec'
,
'js/spec/views/assets_spec'
,
'js/spec/views/assets_spec'
,
'js/spec/views/baseview_spec'
,
'js/spec/views/baseview_spec'
,
...
...
cms/static/js/spec/views/video_transcripts_spec.js
0 → 100644
View file @
554c90d1
define
(
[
'jquery'
,
'underscore'
,
'backbone'
,
'js/views/video_transcripts'
,
'common/js/spec_helpers/template_helpers'
],
function
(
$
,
_
,
Backbone
,
VideoTranscriptsView
,
TemplateHelpers
)
{
'use strict'
;
describe
(
'VideoTranscriptsView'
,
function
()
{
var
$videoTranscriptsViewEl
,
videoTranscriptsView
,
renderView
,
transcripts
=
{
en
:
'English'
,
es
:
'Spanish'
,
ur
:
'Urdu'
},
edxVideoID
=
'test-edx-video-id'
,
clientVideoID
=
'Video client title name.mp4'
,
transcriptAvailableLanguages
=
{
en
:
'English'
,
es
:
'Spanish'
,
cn
:
'Chinese'
,
ar
:
'Arabic'
,
ur
:
'Urdu'
},
videoSupportedFileFormats
=
[
'.mov'
,
'.mp4'
],
TRANSCRIPT_DOWNLOAD_FILE_FORMAT
=
'srt'
;
renderView
=
function
(
availableTranscripts
)
{
videoTranscriptsView
=
new
VideoTranscriptsView
({
transcripts
:
availableTranscripts
,
edxVideoID
:
edxVideoID
,
clientVideoID
:
clientVideoID
,
transcriptAvailableLanguages
:
transcriptAvailableLanguages
,
videoSupportedFileFormats
:
videoSupportedFileFormats
});
videoTranscriptsView
.
setElement
(
$
(
'.transcripts-col'
));
$videoTranscriptsViewEl
=
videoTranscriptsView
.
render
().
$el
;
};
beforeEach
(
function
()
{
setFixtures
(
'<div class="video-col transcripts-col"></div>'
);
TemplateHelpers
.
installTemplate
(
'video-transcripts'
);
renderView
(
transcripts
);
});
it
(
'renders as expected'
,
function
()
{
expect
(
$videoTranscriptsViewEl
.
find
(
'.show-video-transcripts-container'
)).
toExist
();
});
it
(
'does not shows transcripts'
,
function
()
{
expect
(
$videoTranscriptsViewEl
.
find
(
'.show-video-transcripts-wrapper'
).
hasClass
(
'hidden'
)
).
toEqual
(
true
);
expect
(
$videoTranscriptsViewEl
.
find
(
'.toggle-show-transcripts-button-text'
).
html
().
trim
()).
toEqual
(
'Show transcripts ('
+
_
.
size
(
transcripts
)
+
')'
);
});
it
(
'shows transcripts container on show transcript button click'
,
function
()
{
// Verify transcript container is hidden
expect
(
$videoTranscriptsViewEl
.
find
(
'.show-video-transcripts-wrapper'
).
hasClass
(
'hidden'
)
).
toEqual
(
true
);
// Verify initial button text
expect
(
$videoTranscriptsViewEl
.
find
(
'.toggle-show-transcripts-button-text'
).
html
().
trim
()).
toEqual
(
'Show transcripts ('
+
_
.
size
(
transcripts
)
+
')'
);
$videoTranscriptsViewEl
.
find
(
'.toggle-show-transcripts-button'
).
click
();
// Verify transcript container is not hidden
expect
(
$videoTranscriptsViewEl
.
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
(
'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
();
// Verify button text.
expect
(
$videoTranscriptsViewEl
.
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'
)
).
toEqual
(
false
);
$videoTranscriptsViewEl
.
find
(
'.toggle-show-transcripts-button'
).
click
();
// Verify button text is changed.
expect
(
$videoTranscriptsViewEl
.
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'
)
).
toEqual
(
true
);
});
it
(
'renders appropriate text when no transcript is available'
,
function
()
{
// Render view with no transcripts
renderView
({});
// Verify appropriate text is shown
expect
(
$videoTranscriptsViewEl
.
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
(
_
.
size
(
transcripts
)
);
_
.
each
(
transcripts
,
function
(
langaugeText
,
languageCode
)
{
$transcriptEl
=
$
(
$videoTranscriptsViewEl
.
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
);
// Verify transcript language dropdown has correct value set.
expect
(
$transcriptEl
.
find
(
'.transcript-language-menu'
).
val
(),
languageCode
);
});
});
});
}
);
cms/static/js/views/video_transcripts.js
View file @
554c90d1
...
@@ -39,13 +39,12 @@ define(
...
@@ -39,13 +39,12 @@ define(
Returns transcript title.
Returns transcript title.
*/
*/
getTranscriptClientTitle
:
function
()
{
getTranscriptClientTitle
:
function
()
{
// Use a fixed length tranascript name.
var
clientTitle
=
this
.
clientVideoID
;
var
clientTitle
=
this
.
clientVideoID
.
substring
(
0
,
20
);
// Remove video file extension for transcript title.
// Remove video file extension for transcript title.
_
.
each
(
this
.
videoSupportedFileFormats
,
function
(
videoFormat
)
{
_
.
each
(
this
.
videoSupportedFileFormats
,
function
(
videoFormat
)
{
clientTitle
.
replace
(
videoFormat
,
''
);
clientTitle
.
replace
(
videoFormat
,
''
);
});
});
return
clientTitle
;
return
clientTitle
.
substring
(
0
,
20
)
;
},
},
/*
/*
...
...
cms/templates/js/previous-video-upload.underscore
View file @
554c90d1
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
<% if (isVideoTranscriptEnabled) { %>
<% if (isVideoTranscriptEnabled) { %>
<div class="video-col transcripts-col"></div>
<div class="video-col transcripts-col"></div>
<% } %>
<% } %>
<div class="video-col status-col"><%- status %>
</div>
<div class="video-col status-col"><%- status %></div>
<div class="video-col actions-col">
<div class="video-col actions-col">
<ul class="actions-list">
<ul class="actions-list">
<li class="action-item action-remove">
<li class="action-item action-remove">
...
...
cms/templates/js/video-transcripts.underscore
View file @
554c90d1
<div class='show-video-transcripts-container'>
<% if (_.size(transcripts)) { %>
<% if (_.size(transcripts)) { %>
<button class="button-link toggle-show-transcripts-button">
<button class="button-link toggle-show-transcripts-button">
<strong>
<strong>
...
@@ -8,12 +9,12 @@
...
@@ -8,12 +9,12 @@
</strong>
</strong>
</button>
</button>
<% } else { %>
<% } else { %>
<span><%- gettext('No transcript available yet.') %></span>
<span
class='transcripts-empty-text'
><%- gettext('No transcript available yet.') %></span>
<% }%>
<% }%>
<div class='show-video-transcripts-wrapper hidden'>
<div class='show-video-transcripts-wrapper hidden'>
<% _.each(transcripts, function(transcriptLanguageText, transcriptLanguageCode){ %>
<% _.each(transcripts, function(transcriptLanguageText, transcriptLanguageCode){ %>
<div class='show-video-transcript-content'>
<div
id='show-video-transcript-content-<%- transcriptLanguageCode %>'
class='show-video-transcript-content'>
<strong><%- StringUtils.interpolate(gettext('{transcriptClientTitle}_{transcriptLanguageCode}.{fileExtension}'), {transcriptClientTitle: transcriptClientTitle, transcriptLanguageCode: transcriptLanguageCode, fileExtension: transcriptDownloadFileFormat}) %></strong>
<strong
class='transcript-title'
><%- StringUtils.interpolate(gettext('{transcriptClientTitle}_{transcriptLanguageCode}.{fileExtension}'), {transcriptClientTitle: transcriptClientTitle, transcriptLanguageCode: transcriptLanguageCode, fileExtension: transcriptDownloadFileFormat}) %></strong>
<select id='transcript-language-<%- transcriptLanguageCode %>' class='transcript-language-menu'>
<select id='transcript-language-<%- transcriptLanguageCode %>' class='transcript-language-menu'>
<option value=''>Select Language</option>
<option value=''>Select Language</option>
<% _.each(transcriptAvailableLanguages, function(availableLanguage){ %>
<% _.each(transcriptAvailableLanguages, function(availableLanguage){ %>
...
@@ -36,3 +37,4 @@
...
@@ -36,3 +37,4 @@
</div>
</div>
<% }) %>
<% }) %>
</div>
</div>
</div>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment