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 @@ -106,7 +106,7 @@ export type FEFrontCardStyle =
106
106
| 'DefaultCardstyle' ;
107
107
108
108
/** @see https://github.com/guardian/frontend/blob/0bf69f55a/common/app/model/content/Atom.scala#L191-L196 */
109
- interface FEMediaAsset {
109
+ export interface FEMediaAsset {
110
110
id : string ;
111
111
version : number ;
112
112
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 = (
192
192
* @see https://github.com/guardian/frontend/pull/26247 for inspiration
193
193
*/
194
194
195
- const getActiveMediaAtom = (
195
+ export const getActiveMediaAtom = (
196
196
isLoopingVideoTest : boolean ,
197
197
videoReplace : boolean ,
198
198
mediaAtom ?: FEMediaAtom ,
199
199
cardTrailImage ?: string ,
200
200
) : MainMedia | undefined => {
201
201
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 ) ;
205
207
206
208
const image = decideMediaAtomImage (
207
209
videoReplace ,
You can’t perform that action at this time.
0 commit comments