Skip to content

Commit f0201af

Browse files
committed
test: add tests for quickLoop on entire playlist
1 parent 2d22144 commit f0201af

1 file changed

Lines changed: 77 additions & 1 deletion

File tree

packages/job-worker/src/playout/model/implementation/__tests__/PlayoutModelImpl.spec.ts

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
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'
27
import { AdLibPiece } from '@sofie-automation/corelib/dist/dataModel/AdLibPiece'
38
import {
49
PartInstanceId,
@@ -14,6 +19,7 @@ import {
1419
} from '@sofie-automation/corelib/dist/dataModel/PeripheralDevice'
1520
import { EmptyPieceTimelineObjectsBlob, Piece } from '@sofie-automation/corelib/dist/dataModel/Piece'
1621
import { PieceInstance } from '@sofie-automation/corelib/dist/dataModel/PieceInstance'
22+
import { QuickLoopMarkerType } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist'
1723
import { DBRundown } from '@sofie-automation/corelib/dist/dataModel/Rundown'
1824
import { RundownBaselineAdLibItem } from '@sofie-automation/corelib/dist/dataModel/RundownBaselineAdLibPiece'
1925
import { 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

183259
async function getPlayoutModelImplArugments(

0 commit comments

Comments
 (0)