diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/edit/ActivityDuration.vue b/contentcuration/contentcuration/frontend/channelEdit/components/edit/ActivityDuration.vue index d27fdc50e1..2313f898a7 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/edit/ActivityDuration.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/components/edit/ActivityDuration.vue @@ -6,7 +6,7 @@ v-if="audioVideoUpload && selectedDuration === 'exactTime'" class="defaultUpload md2 sm3" > - {{ convertToHHMMSS(defaultUploadTime) }} + {{ convertToHHMMSS(duration || `00:00`) }} file.file_format === 'mp4' || file.file_format === 'mp3' - )[0].duration; + if ( + this.firstNode.kind === ContentKindsNames.AUDIO || + this.firstNode.kind === ContentKindsNames.VIDEO + ) { + // filter for the correct file types, + // to exclude files such as subtitle or cc + let audioVideoFiles; + audioVideoFiles = this.nodeFiles.filter(file => this.allowedFileType(file)); + // return the last item in the array + const file = audioVideoFiles[audioVideoFiles.length - 1]; + return file.duration; } else { return null; } @@ -734,6 +741,17 @@ isUnique(value) { return value !== nonUniqueValue; }, + allowedFileType(file) { + let allowedFileTypes = []; + // add the relevant format presets for audio and video + // high res and low res are currently the same, so only one is included + allowedFileTypes.push( + FormatPresetsMap.get(FormatPresetsNames.HIGH_RES_VIDEO).allowed_formats + ); + allowedFileTypes.push(FormatPresetsMap.get(FormatPresetsNames.AUDIO).allowed_formats); + allowedFileTypes = allowedFileTypes.flat(); + return allowedFileTypes.includes(file.file_format); + }, getValueFromNodes(key) { const results = uniq( this.nodes.map(node => { diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/edit/__tests__/activityDuration.spec.js b/contentcuration/contentcuration/frontend/channelEdit/components/edit/__tests__/activityDuration.spec.js index 31dcb2414b..ae2d880026 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/edit/__tests__/activityDuration.spec.js +++ b/contentcuration/contentcuration/frontend/channelEdit/components/edit/__tests__/activityDuration.spec.js @@ -16,33 +16,6 @@ describe('ActivityDuration', () => { const shortActivityMax = 30; const longActivityMin = 31; const longActivityMax = 120; - describe(`default state for audio/video resources`, () => { - it(`should display a static upload time when 'Exact time to complete' for audio/video resources as initial state`, () => { - const defaultValue = '17:12'; - const wrapper = shallowMount(ActivityDuration); - expect(wrapper.vm.defaultUploadTime).toEqual(defaultValue); - }); - it(`should display the file's time at upload when 'Exact time to complete' is chosen in Completion dropdown`, () => { - // TODO: defaultValue will need to be changed when file-upload-duration is implemented - const defaultValue = '17:12'; - const wrapper = shallowMount(ActivityDuration, { - propsData: { duration: 123 }, - }); - expect(wrapper.props('duration')).toEqual(123); - expect(wrapper.vm.defaultUploadTime).not.toEqual(defaultValue); - expect(wrapper.vm.defaultUploadTime).toEqual(123); - }); - it(`should display a "stand-in" at upload if file's time at upload is not available when 'Exact time to complete' is chosen in Completion dropdown`, () => { - // TODO: defaultValue will need to be changed when file-upload-duration is implemented - const defaultValue = '17:12'; - const wrapper = shallowMount(ActivityDuration, { - propsData: { duration: null }, - }); - expect(wrapper.props('duration')).toEqual(null); - expect(wrapper.vm.defaultUploadTime).toEqual(defaultValue); - expect(wrapper.vm.defaultUploadTime).not.toEqual(null); - }); - }); describe(`convert seconds to minutes for display`, () => { it(`should display the seconds passed down from parent as minutes`, () => {