1- import { JSONBlobStringify , PieceLifespan , StatusCode } from '@sofie-automation/blueprints-integration'
1+ import {
2+ ForceQuickLoopAutoNext ,
3+ JSONBlobStringify ,
4+ PieceLifespan ,
5+ StatusCode ,
6+ } from '@sofie-automation/blueprints-integration'
27import { AdLibPiece } from '@sofie-automation/corelib/dist/dataModel/AdLibPiece'
38import {
49 PartInstanceId ,
@@ -14,6 +19,7 @@ import {
1419} from '@sofie-automation/corelib/dist/dataModel/PeripheralDevice'
1520import { EmptyPieceTimelineObjectsBlob , Piece } from '@sofie-automation/corelib/dist/dataModel/Piece'
1621import { PieceInstance } from '@sofie-automation/corelib/dist/dataModel/PieceInstance'
22+ import { QuickLoopMarkerType } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist'
1723import { DBRundown } from '@sofie-automation/corelib/dist/dataModel/Rundown'
1824import { RundownBaselineAdLibItem } from '@sofie-automation/corelib/dist/dataModel/RundownBaselineAdLibPiece'
1925import { DBSegment } from '@sofie-automation/corelib/dist/dataModel/Segment'
@@ -178,6 +184,76 @@ describe('PlayoutModelImpl', () => {
178184 } )
179185 } )
180186 } )
187+
188+ describe ( 'quickLoop for locked playlist loops' , ( ) => {
189+ it ( 'keeps the quickLoop locked state on activation/reset/deactivation' , async ( ) => {
190+ const rundownId = protectString ( 'rundown01' )
191+ const playlistId = await context . mockCollections . RundownPlaylists . insertOne ( {
192+ ...defaultRundownPlaylist ( protectString ( `playlist_${ rundownId } ` ) , context . studioId ) ,
193+ quickLoop : {
194+ start : { type : QuickLoopMarkerType . PLAYLIST } ,
195+ end : { type : QuickLoopMarkerType . PLAYLIST } ,
196+ locked : true ,
197+ running : false ,
198+ forceAutoNext : ForceQuickLoopAutoNext . DISABLED ,
199+ } ,
200+ } )
201+
202+ const playlist = await context . mockCollections . RundownPlaylists . findOne ( playlistId )
203+
204+ const rundown : DBRundown = defaultRundown (
205+ unprotectString ( rundownId ) ,
206+ context . studioId ,
207+ null ,
208+ playlistId ,
209+ showStyleCompound . _id ,
210+ showStyleCompound . showStyleVariantId
211+ )
212+ rundown . _id = rundownId
213+ await context . mockCollections . Rundowns . insertOne ( rundown )
214+
215+ const peripheralDevices = [ setupMockPlayoutGateway ( protectString ( 'playoutGateway0' ) ) ]
216+
217+ const { partInstances, groupedPieceInstances, rundowns } = await getPlayoutModelImplArugments (
218+ context ,
219+ playlistId ,
220+ rundownId
221+ )
222+
223+ if ( ! playlist ) throw new Error ( 'Playlist not found!' )
224+
225+ await runWithPlaylistLock ( context , playlistId , async ( lock ) => {
226+ const model = new PlayoutModelImpl (
227+ context ,
228+ lock ,
229+ playlistId ,
230+ peripheralDevices ,
231+ playlist ,
232+ partInstances ,
233+ groupedPieceInstances ,
234+ rundowns ,
235+ undefined
236+ )
237+
238+ const activationId = model . activatePlaylist ( false )
239+ expect ( model . playlist . quickLoop ?. locked ) . toBe ( true )
240+ expect ( model . playlist . quickLoop ?. start ?. type ) . toBe ( QuickLoopMarkerType . PLAYLIST )
241+ expect ( model . playlist . quickLoop ?. end ?. type ) . toBe ( QuickLoopMarkerType . PLAYLIST )
242+
243+ model . resetPlaylist ( true )
244+ expect ( model . playlist . quickLoop ?. locked ) . toBe ( true )
245+ expect ( model . playlist . quickLoop ?. start ?. type ) . toBe ( QuickLoopMarkerType . PLAYLIST )
246+ expect ( model . playlist . quickLoop ?. end ?. type ) . toBe ( QuickLoopMarkerType . PLAYLIST )
247+
248+ model . deactivatePlaylist ( )
249+ expect ( model . playlist . quickLoop ?. locked ) . toBe ( true )
250+ expect ( model . playlist . quickLoop ?. start ?. type ) . toBe ( QuickLoopMarkerType . PLAYLIST )
251+ expect ( model . playlist . quickLoop ?. end ?. type ) . toBe ( QuickLoopMarkerType . PLAYLIST )
252+ expect ( model . playlist . activationId ) . not . toBe ( activationId )
253+ expect ( model . playlist . currentPartInfo ) . toBeNull ( )
254+ } )
255+ } )
256+ } )
181257} )
182258
183259async function getPlayoutModelImplArugments (
0 commit comments