@@ -58,78 +58,72 @@ describe('lookahead offset integration', () => {
5858
5959 expect ( res ) . toEqual ( [ ] )
6060 } )
61- test ( 'returns one lookahead object for a single future part ' , async ( ) => {
61+ test ( 'respects lookaheadMaxSearchDistance ' , async ( ) => {
6262 getOrderedPartsAfterPlayheadMock . mockReturnValue ( [
63- {
64- _id : protectString ( 'p1' ) ,
65- classesForNext : [ ] ,
66- } as any ,
63+ { _id : protectString ( 'p1' ) , classesForNext : [ ] } as any ,
64+ { _id : protectString ( 'p2' ) , classesForNext : [ ] } as any ,
65+ { _id : protectString ( 'p3' ) , classesForNext : [ ] } as any ,
66+ { _id : protectString ( 'p4' ) , classesForNext : [ ] } as any ,
6767 ] )
6868
69- const findFetchMock = jest . fn ( ) . mockResolvedValue ( [ makePiece ( { partId : 'p1' , layer : 'layer1' } ) ] )
69+ const findFetchMock = jest
70+ . fn ( )
71+ . mockResolvedValue ( [
72+ makePiece ( { partId : 'p1' , layer : 'layer1' } ) ,
73+ makePiece ( { partId : 'p2' , layer : 'layer1' } ) ,
74+ makePiece ( { partId : 'p3' , layer : 'layer1' } ) ,
75+ makePiece ( { partId : 'p4' , layer : 'layer1' } ) ,
76+ ] )
7077
7178 context = {
7279 ...context ,
80+ studio : {
81+ ...context . studio ,
82+ mappings : {
83+ ...context . studio . mappings ,
84+ layer1 : {
85+ ...context . studio . mappings [ 'layer1' ] ,
86+ lookaheadMaxSearchDistance : 3 ,
87+ } ,
88+ } ,
89+ } ,
7390 directCollections : {
7491 ...context . directCollections ,
7592 Pieces : {
7693 ...context . directCollections . Pieces ,
7794 findFetch : findFetchMock ,
7895 } ,
7996 } ,
80- } as unknown as JobContext
97+ } as JobContext
8198
8299 const res = await getLookeaheadObjects ( context , playoutModel , {
83100 current : undefined ,
84101 next : undefined ,
85102 previous : undefined ,
86103 } as SelectedPartInstancesTimelineInfo )
87104
88- expect ( res ) . toHaveLength ( 1 )
89-
90- const obj = res [ 0 ]
91- expect ( obj . layer ) . toBe ( 'layer1_lookahead' )
92- expect ( obj . objectType ) . toBe ( 'rundown' )
93- expect ( obj . pieceInstanceId ) . toContain ( 'p1' )
94- expect ( obj . partInstanceId ) . toContain ( 'p1' )
95- expect ( obj . content ) . toMatchObject ( {
105+ expect ( res ) . toHaveLength ( 2 )
106+ const obj0 = res [ 0 ]
107+ const obj1 = res [ 1 ]
108+
109+ expect ( obj0 . layer ) . toBe ( 'layer1_lookahead' )
110+ expect ( obj0 . objectType ) . toBe ( 'rundown' )
111+ expect ( obj0 . pieceInstanceId ) . toContain ( 'p1' )
112+ expect ( obj0 . partInstanceId ) . toContain ( 'p1' )
113+ expect ( obj0 . content ) . toMatchObject ( {
114+ deviceType : TSR . DeviceType . CASPARCG ,
115+ type : TSR . TimelineContentTypeCasparCg . MEDIA ,
116+ file : 'AMB' ,
117+ } )
118+ expect ( obj1 . layer ) . toBe ( 'layer1_lookahead' )
119+ expect ( obj1 . objectType ) . toBe ( 'rundown' )
120+ expect ( obj1 . pieceInstanceId ) . toContain ( 'p2' )
121+ expect ( obj1 . partInstanceId ) . toContain ( 'p2' )
122+ expect ( obj1 . content ) . toMatchObject ( {
96123 deviceType : TSR . DeviceType . CASPARCG ,
97124 type : TSR . TimelineContentTypeCasparCg . MEDIA ,
98125 file : 'AMB' ,
99126 } )
100- } )
101- test ( 'respects lookaheadMaxSearchDistance' , async ( ) => {
102- findLargestLookaheadDistanceMock . mockReturnValue ( 10 )
103- getOrderedPartsAfterPlayheadMock . mockReturnValue ( [
104- { _id : protectString ( 'p1' ) , classesForNext : [ ] } as any ,
105- { _id : protectString ( 'p2' ) , classesForNext : [ ] } as any ,
106- ] )
107-
108- context = {
109- ...context ,
110- studio : {
111- ...context . studio ,
112- mappings : {
113- ...context . studio . mappings ,
114- layer1 : {
115- ...context . studio . mappings [ 'layer1' ] ,
116- lookaheadMaxSearchDistance : 1 ,
117- } ,
118- } ,
119- } ,
120- } as JobContext
121-
122- context . directCollections . Pieces . findFetch = jest
123- . fn ( )
124- . mockResolvedValue ( [
125- makePiece ( { partId : 'p1' , layer : 'layer1' } ) ,
126- makePiece ( { partId : 'p2' , layer : 'layer1' } ) ,
127- ] )
128-
129- const res = await getLookeaheadObjects ( context , playoutModel , { } as SelectedPartInstancesTimelineInfo )
130-
131- expect ( res ) . toHaveLength ( 1 )
132- expect ( res [ 0 ] . partInstanceId ) . toContain ( 'p1' )
133127 } )
134128 test ( 'applies nextTimeOffset to lookahead objects in future part' , async ( ) => {
135129 playoutModel = {
@@ -140,11 +134,17 @@ describe('lookahead offset integration', () => {
140134 } ,
141135 } as PlayoutModel
142136 findLargestLookaheadDistanceMock . mockReturnValue ( 1 )
143- getOrderedPartsAfterPlayheadMock . mockReturnValue ( [ { _id : protectString ( 'p1' ) , classesForNext : [ ] } as any ] )
137+ getOrderedPartsAfterPlayheadMock . mockReturnValue ( [
138+ { _id : protectString ( 'p1' ) , classesForNext : [ ] } as any ,
139+ { _id : protectString ( 'p2' ) , classesForNext : [ ] } as any ,
140+ ] )
144141
145142 context . directCollections . Pieces . findFetch = jest
146143 . fn ( )
147- . mockResolvedValue ( [ makePiece ( { partId : 'p1' , layer : 'layer1' , start : 0 } ) ] )
144+ . mockResolvedValue ( [
145+ makePiece ( { partId : 'p1' , layer : 'layer1' } ) ,
146+ makePiece ( { partId : 'p2' , layer : 'layer1' } ) ,
147+ ] )
148148
149149 const res = await getLookeaheadObjects ( context , playoutModel , { } as SelectedPartInstancesTimelineInfo )
150150
0 commit comments