@@ -81,6 +81,95 @@ describe('ActivePlaylistTopic', () => {
8181 const testShowStyleBase = makeTestShowStyleBase ( )
8282 await topic . update ( ShowStyleBaseHandler . name , testShowStyleBase as ShowStyleBaseExt )
8383
84+ const segment1id = protectString ( 'SEGMENT_1' )
85+ const part1 : Partial < DBPart > = {
86+ _id : protectString ( 'PART_1' ) ,
87+ title : 'Test Part' ,
88+ segmentId : segment1id ,
89+ expectedDurationWithTransition : 10000 ,
90+ expectedDuration : 10000 ,
91+ publicData : { b : 'c' } ,
92+ }
93+ const testPartInstances : PartialDeep < SelectedPartInstances > = {
94+ current : {
95+ _id : currentPartInstanceId ,
96+ part : part1 ,
97+ timings : { plannedStartedPlayback : 1600000060000 } ,
98+ segmentId : segment1id ,
99+ } ,
100+ firstInSegmentPlayout : { } ,
101+ inCurrentSegment : [
102+ literal < PartialDeep < DBPartInstance > > ( {
103+ _id : protectString ( currentPartInstanceId ) ,
104+ part : part1 ,
105+ timings : { plannedStartedPlayback : 1600000060000 } ,
106+ } ) ,
107+ ] as DBPartInstance [ ] ,
108+ }
109+ await topic . update ( PartInstancesHandler . name , testPartInstances as SelectedPartInstances )
110+
111+ await topic . update ( PartsHandler . name , [ part1 ] as DBPart [ ] )
112+
113+ await topic . update ( SegmentHandler . name , {
114+ _id : segment1id ,
115+ } as DBSegment )
116+
117+ topic . addSubscriber ( mockSubscriber )
118+
119+ const expectedStatus : ActivePlaylistStatus = {
120+ event : 'activePlaylist' ,
121+ name : playlist . name ,
122+ id : unprotectString ( playlist . _id ) ,
123+ currentPart : {
124+ id : 'PART_1' ,
125+ name : 'Test Part' ,
126+ segmentId : 'SEGMENT_1' ,
127+ timing : { startTime : 1600000060000 , expectedDurationMs : 10000 , projectedEndTime : 1600000070000 } ,
128+ pieces : [ ] ,
129+ autoNext : undefined ,
130+ publicData : { b : 'c' } ,
131+ } ,
132+ nextPart : null ,
133+ currentSegment : {
134+ id : 'SEGMENT_1' ,
135+ timing : {
136+ expectedDurationMs : 10000 ,
137+ projectedEndTime : 1600000070000 ,
138+ } ,
139+ } ,
140+ rundownIds : unprotectStringArray ( playlist . rundownIdsInOrder ) ,
141+ publicData : { a : 'b' } ,
142+ timing : {
143+ timingMode : PlaylistTimingType . None ,
144+ } ,
145+ }
146+
147+ // eslint-disable-next-line @typescript-eslint/unbound-method
148+ expect ( mockSubscriber . send ) . toHaveBeenCalledTimes ( 1 )
149+ expect ( JSON . parse ( mockSubscriber . send . mock . calls [ 0 ] [ 0 ] as string ) ) . toMatchObject (
150+ JSON . parse ( JSON . stringify ( expectedStatus ) )
151+ )
152+ } )
153+
154+ it ( 'provides segment and part with segment timing' , async ( ) => {
155+ const topic = new ActivePlaylistTopic ( makeMockLogger ( ) )
156+ const mockSubscriber = makeMockSubscriber ( )
157+
158+ const currentPartInstanceId = 'CURRENT_PART_INSTANCE_ID'
159+
160+ const playlist = makeTestPlaylist ( )
161+ playlist . activationId = protectString ( 'somethingRandom' )
162+ playlist . currentPartInfo = {
163+ consumesQueuedSegmentId : false ,
164+ manuallySelected : false ,
165+ partInstanceId : protectString ( currentPartInstanceId ) ,
166+ rundownId : playlist . rundownIdsInOrder [ 0 ] ,
167+ }
168+ await topic . update ( PlaylistHandler . name , playlist )
169+
170+ const testShowStyleBase = makeTestShowStyleBase ( )
171+ await topic . update ( ShowStyleBaseHandler . name , testShowStyleBase as ShowStyleBaseExt )
172+
84173 const segment1id = protectString ( 'SEGMENT_1' )
85174 const part1 : Partial < DBPart > = {
86175 _id : protectString ( 'PART_1' ) ,
0 commit comments