File tree Expand file tree Collapse file tree 3 files changed +59
-5
lines changed
Expand file tree Collapse file tree 3 files changed +59
-5
lines changed Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ export type FEFrontCardStyle =
107107 | 'DefaultCardstyle' ;
108108
109109/** @see https://github.com/guardian/frontend/blob/0bf69f55a/common/app/model/content/Atom.scala#L191-L196 */
110- interface FEMediaAsset {
110+ export interface FEMediaAsset {
111111 id : string ;
112112 version : number ;
113113 platform : string ;
Original file line number Diff line number Diff line change 1+ import type { FEMediaAsset , FEMediaAtom } from '../frontend/feFront' ;
2+ import { getActiveMediaAtom } from './enhanceCards' ;
3+
4+ describe ( 'Enhance Cards' , ( ) => {
5+ it ( 'filters out m3u8 assets until supported by DCR' , ( ) => {
6+ const isLoopingVideoTest = true ;
7+ const videoReplace = true ;
8+ const assets : FEMediaAsset [ ] = [
9+ {
10+ id : 'https://guim-example.co.uk/atomID-1.m3u8' ,
11+ version : 1 ,
12+ platform : 'Url' ,
13+ mimeType : 'application/vnd.apple.mpegurl' ,
14+ } ,
15+ {
16+ id : 'https://guim-example.co.uk/atomID-1.mp4' ,
17+ version : 1 ,
18+ platform : 'Url' ,
19+ mimeType : 'video/mp4' ,
20+ } ,
21+ ] ;
22+ const mediaAtom : FEMediaAtom = {
23+ id : 'atomID' ,
24+ assets,
25+ title : 'Example video' ,
26+ duration : 15 ,
27+ source : '' ,
28+ posterImage : { allImages : [ ] } ,
29+ trailImage : { allImages : [ ] } ,
30+ expired : false ,
31+ activeVersion : 1 ,
32+ } ;
33+ const cardTrailImage = '' ;
34+
35+ expect (
36+ getActiveMediaAtom (
37+ isLoopingVideoTest ,
38+ videoReplace ,
39+ mediaAtom ,
40+ cardTrailImage ,
41+ ) ,
42+ ) . toEqual ( {
43+ atomId : 'atomID' ,
44+ duration : 15 ,
45+ height : 400 ,
46+ image : '' ,
47+ type : 'LoopVideo' ,
48+ videoId : 'https://guim-example.co.uk/atomID-1.mp4' ,
49+ width : 500 ,
50+ } ) ;
51+ } ) ;
52+ } ) ;
Original file line number Diff line number Diff line change @@ -192,16 +192,18 @@ const decideMediaAtomImage = (
192192 * @see https://github.com/guardian/frontend/pull/26247 for inspiration
193193 */
194194
195- const getActiveMediaAtom = (
195+ export const getActiveMediaAtom = (
196196 isLoopingVideoTest : boolean ,
197197 videoReplace : boolean ,
198198 mediaAtom ?: FEMediaAtom ,
199199 cardTrailImage ?: string ,
200200) : MainMedia | undefined => {
201201 if ( mediaAtom ) {
202- const asset = mediaAtom . assets . find (
203- ( { version } ) => version === mediaAtom . activeVersion ,
204- ) ;
202+ const m3u8MimeType = 'application/vnd.apple.mpegurl' ;
203+ const asset = mediaAtom . assets
204+ // filter out m3u8 assets, as these are not yet supported by DCR
205+ . filter ( ( _ ) => _ . mimeType !== m3u8MimeType )
206+ . find ( ( { version } ) => version === mediaAtom . activeVersion ) ;
205207
206208 const image = decideMediaAtomImage (
207209 videoReplace ,
You can’t perform that action at this time.
0 commit comments