Skip to content

Commit

Permalink
fix: issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Oct 10, 2023
1 parent 171e4f3 commit a67648f
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ describe('Test blueprint api context', () => {
partInstanceId: info.PartInstance._id,
rundownId: info.PartInstance.rundownId,
manuallySelected: false,
consumesNextSegmentId: false,
consumesQueuedSegmentId: false,
}
} else {
return {
Expand Down Expand Up @@ -1242,7 +1242,7 @@ describe('Test blueprint api context', () => {

// Ensure there are no pending updates already
for (const partInstance of cache.LoadedPartInstances) {
expect((partInstance as PlayoutPartInstanceModelImpl).HasChanges).toBeFalsy()
expect((partInstance as PlayoutPartInstanceModelImpl).HasAnyChanges()).toBeFalsy()
}

// Update it and expect it to match
Expand Down Expand Up @@ -1289,15 +1289,10 @@ describe('Test blueprint api context', () => {
},
}
expect(pieceInstance1).toEqual(pieceInstance0After)
expect((partInstance1 as PlayoutPartInstanceModelImpl).HasChanges).toBeTruthy()
// expect(
// Array.from(cache.PieceInstances.documents.values()).filter((doc) => !doc || !!doc.updated)
// ).toMatchObject([
// {
// updated: true,
// document: { _id: pieceInstance1._id },
// },
// ])
expect((partInstance1 as PlayoutPartInstanceModelImpl).PartInstanceHasChanges).toBeFalsy()
expect((partInstance1 as PlayoutPartInstanceModelImpl).ChangedPieceInstanceIds()).toEqual([
pieceInstance1._id,
])

expect(context.nextPartState).toEqual(ActionPartChange.NONE)
expect(context.currentPartState).toEqual(ActionPartChange.SAFE_CHANGE)
Expand Down Expand Up @@ -1720,7 +1715,7 @@ describe('Test blueprint api context', () => {
const { context } = await getActionExecutionContext(jobContext, cache)

// Ensure there are no pending updates already
expect((cache.NextPartInstance! as PlayoutPartInstanceModelImpl).HasChanges).toBeFalsy()
expect((cache.NextPartInstance! as PlayoutPartInstanceModelImpl).HasAnyChanges()).toBeFalsy()

// Update it and expect it to match
const partInstance0Before = clone(partInstance0)
Expand All @@ -1731,11 +1726,11 @@ describe('Test blueprint api context', () => {
classes: ['123'],
badProperty: 9, // This will be dropped
}
const resultPiece = await context.updatePartInstance('next', partInstance0Delta)
const partInstance1 = cache.NextPartInstance!
const resultPart = await context.updatePartInstance('next', partInstance0Delta)
const partInstance1 = cache.NextPartInstance! as PlayoutPartInstanceModelImpl
expect(partInstance1).toBeTruthy()

expect(resultPiece).toEqual(convertPartInstanceToBlueprints(partInstance1.PartInstance))
expect(resultPart).toEqual(convertPartInstanceToBlueprints(partInstance1.PartInstance))

const pieceInstance0After = {
...partInstance0Before,
Expand All @@ -1745,15 +1740,8 @@ describe('Test blueprint api context', () => {
},
}
expect(partInstance1.PartInstance).toEqual(pieceInstance0After)
expect((partInstance1 as PlayoutPartInstanceModelImpl).HasChanges).toBeTruthy()
// expect(
// Array.from(cache.PartInstances.documents.values()).filter((doc) => !doc || !!doc.updated)
// ).toMatchObject([
// {
// updated: true,
// document: { _id: partInstance1._id },
// },
// ])
expect(partInstance1.PartInstanceHasChanges).toBeTruthy()
expect(partInstance1.ChangedPieceInstanceIds()).toHaveLength(0)

expect(context.nextPartState).toEqual(ActionPartChange.SAFE_CHANGE)
expect(context.currentPartState).toEqual(ActionPartChange.NONE)
Expand Down
24 changes: 12 additions & 12 deletions packages/job-worker/src/cache/__tests__/DatabaseCaches.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,18 +292,18 @@ describe('DatabaseCaches', () => {
}).toThrow(/failed .+ assertion,.+ was modified/gi)
}

{
const cache = await loadStudioPlayoutModel(context)

// Insert a document:
cache.deferBeforeSave(() => {
//
})

expect(() => {
cache.assertNoChanges()
}).toThrow(/failed .+ assertion,.+ deferred/gi)
}
// {
// const cache = await loadStudioPlayoutModel(context)

// // Insert a document:
// cache.deferBeforeSave(() => {
// //
// })

// expect(() => {
// cache.assertNoChanges()
// }).toThrow(/failed .+ assertion,.+ deferred/gi)
// }

{
const cache = await loadStudioPlayoutModel(context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ exports[`Playout API Basic rundown control 1`] = `
"core": "0.0.0-test",
"studio": "asdf",
},
"timelineBlob": "[{"id":"playlist_randomId9000_status","objectType":"rundown","enable":{"while":1},"layer":"rundown_status","content":{"deviceType":"ABSTRACT"},"classes":["rundown_active"],"priority":0},{"id":"part_group_randomId9000_part0_0_randomId9002","objectType":"rundown","enable":{"start":"now"},"priority":5,"layer":"","content":{"deviceType":"ABSTRACT","type":"group"},"children":[],"isGroup":true,"metaData":{"isPieceTimeline":true}},{"id":"part_group_firstobject_randomId9000_part0_0_randomId9002","objectType":"rundown","enable":{"start":0},"layer":"group_first_object","content":{"deviceType":"ABSTRACT","type":"callback","callBack":"partPlaybackStarted","callBackData":{"rundownPlaylistId":"playlist_randomId9000","partInstanceId":"randomId9000_part0_0_randomId9002"},"callBackStopped":"partPlaybackStopped"},"inGroup":"part_group_randomId9000_part0_0_randomId9002","classes":[],"priority":0},{"id":"piece_group_control_randomId9000_part0_0_randomId9002_randomId9000_piece001","objectType":"rundown","enable":{"start":0},"layer":"vt0","priority":5,"content":{"deviceType":"ABSTRACT","type":"callback","callBack":"piecePlaybackStarted","callBackData":{"rundownPlaylistId":"playlist_randomId9000","partInstanceId":"randomId9000_part0_0_randomId9002","pieceInstanceId":"randomId9000_part0_0_randomId9002_randomId9000_piece001","dynamicallyInserted":false},"callBackStopped":"piecePlaybackStopped"},"classes":["current_part"],"inGroup":"part_group_randomId9000_part0_0_randomId9002","metaData":{"isPieceTimeline":true,"triggerPieceInstanceId":"randomId9000_part0_0_randomId9002_randomId9000_piece001"}},{"id":"piece_group_randomId9000_part0_0_randomId9002_randomId9000_piece001","content":{"deviceType":"ABSTRACT","type":"group"},"children":[],"inGroup":"part_group_randomId9000_part0_0_randomId9002","isGroup":true,"objectType":"rundown","enable":{"start":"#piece_group_control_randomId9000_part0_0_randomId9002_randomId9000_piece001.start - 0","end":"#piece_group_control_randomId9000_part0_0_randomId9002_randomId9000_piece001.end + 0"},"layer":"","metaData":{"isPieceTimeline":true,"pieceInstanceGroupId":"randomId9000_part0_0_randomId9002_randomId9000_piece001"},"priority":0}]",
"timelineHash": "randomId9006",
"timelineBlob": "[{"id":"playlist_randomId9000_status","objectType":"rundown","enable":{"while":1},"layer":"rundown_status","content":{"deviceType":"ABSTRACT"},"classes":["rundown_active"],"priority":0},{"id":"part_group_randomId9000_part0_0_randomId9003","objectType":"rundown","enable":{"start":"now"},"priority":5,"layer":"","content":{"deviceType":"ABSTRACT","type":"group"},"children":[],"isGroup":true,"metaData":{"isPieceTimeline":true}},{"id":"part_group_firstobject_randomId9000_part0_0_randomId9003","objectType":"rundown","enable":{"start":0},"layer":"group_first_object","content":{"deviceType":"ABSTRACT","type":"callback","callBack":"partPlaybackStarted","callBackData":{"rundownPlaylistId":"playlist_randomId9000","partInstanceId":"randomId9000_part0_0_randomId9003"},"callBackStopped":"partPlaybackStopped"},"inGroup":"part_group_randomId9000_part0_0_randomId9003","classes":[],"priority":0},{"id":"piece_group_control_randomId9000_part0_0_randomId9003_randomId9000_piece001","objectType":"rundown","enable":{"start":0},"layer":"vt0","priority":5,"content":{"deviceType":"ABSTRACT","type":"callback","callBack":"piecePlaybackStarted","callBackData":{"rundownPlaylistId":"playlist_randomId9000","partInstanceId":"randomId9000_part0_0_randomId9003","pieceInstanceId":"randomId9000_part0_0_randomId9003_randomId9000_piece001","dynamicallyInserted":false},"callBackStopped":"piecePlaybackStopped"},"classes":["current_part"],"inGroup":"part_group_randomId9000_part0_0_randomId9003","metaData":{"isPieceTimeline":true,"triggerPieceInstanceId":"randomId9000_part0_0_randomId9003_randomId9000_piece001"}},{"id":"piece_group_randomId9000_part0_0_randomId9003_randomId9000_piece001","content":{"deviceType":"ABSTRACT","type":"group"},"children":[],"inGroup":"part_group_randomId9000_part0_0_randomId9003","isGroup":true,"objectType":"rundown","enable":{"start":"#piece_group_control_randomId9000_part0_0_randomId9003_randomId9000_piece001.start - 0","end":"#piece_group_control_randomId9000_part0_0_randomId9003_randomId9000_piece001.end + 0"},"layer":"","metaData":{"isPieceTimeline":true,"pieceInstanceGroupId":"randomId9000_part0_0_randomId9003_randomId9000_piece001"},"priority":0}]",
"timelineHash": "randomId9008",
},
]
`;
Expand Down Expand Up @@ -55,7 +55,7 @@ exports[`Playout API Basic rundown control 3`] = `
"studio": "asdf",
},
"timelineBlob": "[]",
"timelineHash": "randomId9007",
"timelineHash": "randomId9010",
},
]
`;
Expand All @@ -67,7 +67,6 @@ exports[`Playout API Basic rundown control 4`] = `
"currentPartInfo": null,
"externalId": "MOCK_RUNDOWNPLAYLIST",
"holdState": 0,
"lastTakeTime": 0,
"modified": 0,
"name": "Default RundownPlaylist",
"nextPartInfo": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exports[`Timeline Adlib pieces Current part with preroll 1`] = `
"studio": "asdf",
},
"timelineBlob": "[]",
"timelineHash": "randomId9013",
"timelineHash": "randomId9022",
},
]
`;
Expand All @@ -29,7 +29,7 @@ exports[`Timeline Adlib pieces Current part with preroll and adlib preroll 1`] =
"studio": "asdf",
},
"timelineBlob": "[]",
"timelineHash": "randomId9013",
"timelineHash": "randomId9022",
},
]
`;
Expand All @@ -45,8 +45,8 @@ exports[`Timeline Basic rundown 1`] = `
"core": "0.0.0-test",
"studio": "asdf",
},
"timelineBlob": "[{"id":"playlist_randomId9000_status","objectType":"rundown","enable":{"while":1},"layer":"rundown_status","content":{"deviceType":"ABSTRACT"},"classes":["rundown_active"],"priority":0},{"id":"part_group_randomId9000_part0_0_randomId9004","objectType":"rundown","enable":{"start":"now"},"priority":5,"layer":"","content":{"deviceType":"ABSTRACT","type":"group"},"children":[],"isGroup":true,"metaData":{"isPieceTimeline":true}},{"id":"part_group_firstobject_randomId9000_part0_0_randomId9004","objectType":"rundown","enable":{"start":0},"layer":"group_first_object","content":{"deviceType":"ABSTRACT","type":"callback","callBack":"partPlaybackStarted","callBackData":{"rundownPlaylistId":"playlist_randomId9000","partInstanceId":"randomId9000_part0_0_randomId9004"},"callBackStopped":"partPlaybackStopped"},"inGroup":"part_group_randomId9000_part0_0_randomId9004","classes":[],"priority":0},{"id":"piece_group_control_randomId9002_randomId9000_piece001","objectType":"rundown","enable":{"start":0},"layer":"vt0","priority":5,"content":{"deviceType":"ABSTRACT","type":"callback","callBack":"piecePlaybackStarted","callBackData":{"rundownPlaylistId":"playlist_randomId9000","partInstanceId":"randomId9000_part0_0_randomId9004","pieceInstanceId":"randomId9002_randomId9000_piece001","dynamicallyInserted":false},"callBackStopped":"piecePlaybackStopped"},"classes":["current_part"],"inGroup":"part_group_randomId9000_part0_0_randomId9004","metaData":{"isPieceTimeline":true,"triggerPieceInstanceId":"randomId9002_randomId9000_piece001"}},{"id":"piece_group_randomId9002_randomId9000_piece001","content":{"deviceType":"ABSTRACT","type":"group"},"children":[],"inGroup":"part_group_randomId9000_part0_0_randomId9004","isGroup":true,"objectType":"rundown","enable":{"start":"#piece_group_control_randomId9002_randomId9000_piece001.start - 0","end":"#piece_group_control_randomId9002_randomId9000_piece001.end + 0"},"layer":"","metaData":{"isPieceTimeline":true,"pieceInstanceGroupId":"randomId9002_randomId9000_piece001"},"priority":0}]",
"timelineHash": "randomId9012",
"timelineBlob": "[{"id":"playlist_randomId9000_status","objectType":"rundown","enable":{"while":1},"layer":"rundown_status","content":{"deviceType":"ABSTRACT"},"classes":["rundown_active"],"priority":0},{"id":"part_group_randomId9000_part0_0_randomId9003","objectType":"rundown","enable":{"start":"now"},"priority":5,"layer":"","content":{"deviceType":"ABSTRACT","type":"group"},"children":[],"isGroup":true,"metaData":{"isPieceTimeline":true}},{"id":"part_group_firstobject_randomId9000_part0_0_randomId9003","objectType":"rundown","enable":{"start":0},"layer":"group_first_object","content":{"deviceType":"ABSTRACT","type":"callback","callBack":"partPlaybackStarted","callBackData":{"rundownPlaylistId":"playlist_randomId9000","partInstanceId":"randomId9000_part0_0_randomId9003"},"callBackStopped":"partPlaybackStopped"},"inGroup":"part_group_randomId9000_part0_0_randomId9003","classes":[],"priority":0},{"id":"piece_group_control_randomId9000_part0_0_randomId9003_randomId9000_piece001","objectType":"rundown","enable":{"start":0},"layer":"vt0","priority":5,"content":{"deviceType":"ABSTRACT","type":"callback","callBack":"piecePlaybackStarted","callBackData":{"rundownPlaylistId":"playlist_randomId9000","partInstanceId":"randomId9000_part0_0_randomId9003","pieceInstanceId":"randomId9000_part0_0_randomId9003_randomId9000_piece001","dynamicallyInserted":false},"callBackStopped":"piecePlaybackStopped"},"classes":["current_part"],"inGroup":"part_group_randomId9000_part0_0_randomId9003","metaData":{"isPieceTimeline":true,"triggerPieceInstanceId":"randomId9000_part0_0_randomId9003_randomId9000_piece001"}},{"id":"piece_group_randomId9000_part0_0_randomId9003_randomId9000_piece001","content":{"deviceType":"ABSTRACT","type":"group"},"children":[],"inGroup":"part_group_randomId9000_part0_0_randomId9003","isGroup":true,"objectType":"rundown","enable":{"start":"#piece_group_control_randomId9000_part0_0_randomId9003_randomId9000_piece001.start - 0","end":"#piece_group_control_randomId9000_part0_0_randomId9003_randomId9000_piece001.end + 0"},"layer":"","metaData":{"isPieceTimeline":true,"pieceInstanceGroupId":"randomId9000_part0_0_randomId9003_randomId9000_piece001"},"priority":0}]",
"timelineHash": "randomId9010",
},
]
`;
Expand All @@ -63,7 +63,7 @@ exports[`Timeline Basic rundown 2`] = `
"studio": "asdf",
},
"timelineBlob": "[]",
"timelineHash": "randomId9014",
"timelineHash": "randomId9012",
},
]
`;
Expand All @@ -80,7 +80,7 @@ exports[`Timeline In transitions Basic inTransition 1`] = `
"studio": "asdf",
},
"timelineBlob": "[]",
"timelineHash": "randomId9016",
"timelineHash": "randomId9014",
},
]
`;
Expand All @@ -97,7 +97,7 @@ exports[`Timeline In transitions Basic inTransition with contentDelay + preroll
"studio": "asdf",
},
"timelineBlob": "[]",
"timelineHash": "randomId9016",
"timelineHash": "randomId9014",
},
]
`;
Expand All @@ -114,7 +114,7 @@ exports[`Timeline In transitions Basic inTransition with contentDelay 1`] = `
"studio": "asdf",
},
"timelineBlob": "[]",
"timelineHash": "randomId9016",
"timelineHash": "randomId9014",
},
]
`;
Expand All @@ -131,7 +131,7 @@ exports[`Timeline In transitions Basic inTransition with planned pieces 1`] = `
"studio": "asdf",
},
"timelineBlob": "[]",
"timelineHash": "randomId9016",
"timelineHash": "randomId9014",
},
]
`;
Expand All @@ -148,7 +148,7 @@ exports[`Timeline In transitions Preroll 1`] = `
"studio": "asdf",
},
"timelineBlob": "[]",
"timelineHash": "randomId9016",
"timelineHash": "randomId9014",
},
]
`;
Expand All @@ -165,7 +165,7 @@ exports[`Timeline In transitions inTransition disabled 1`] = `
"studio": "asdf",
},
"timelineBlob": "[]",
"timelineHash": "randomId9016",
"timelineHash": "randomId9014",
},
]
`;
Expand All @@ -182,7 +182,7 @@ exports[`Timeline In transitions inTransition is disabled during hold 1`] = `
"studio": "asdf",
},
"timelineBlob": "[]",
"timelineHash": "randomId9018",
"timelineHash": "randomId9016",
},
]
`;
Expand All @@ -199,7 +199,7 @@ exports[`Timeline In transitions inTransition with existing infinites 1`] = `
"studio": "asdf",
},
"timelineBlob": "[]",
"timelineHash": "randomId9017",
"timelineHash": "randomId9015",
},
]
`;
Expand All @@ -216,7 +216,7 @@ exports[`Timeline In transitions inTransition with new infinite 1`] = `
"studio": "asdf",
},
"timelineBlob": "[]",
"timelineHash": "randomId9017",
"timelineHash": "randomId9015",
},
]
`;
Expand All @@ -233,7 +233,7 @@ exports[`Timeline Infinite Pieces Infinite Piece has stable timing across timeli
"studio": "asdf",
},
"timelineBlob": "[]",
"timelineHash": "randomId9017",
"timelineHash": "randomId9016",
},
]
`;
Expand All @@ -250,7 +250,7 @@ exports[`Timeline Out transitions Basic outTransition 1`] = `
"studio": "asdf",
},
"timelineBlob": "[]",
"timelineHash": "randomId9016",
"timelineHash": "randomId9014",
},
]
`;
Expand All @@ -267,7 +267,7 @@ exports[`Timeline Out transitions outTransition + inTransition 1`] = `
"studio": "asdf",
},
"timelineBlob": "[]",
"timelineHash": "randomId9016",
"timelineHash": "randomId9014",
},
]
`;
Expand All @@ -284,7 +284,7 @@ exports[`Timeline Out transitions outTransition + preroll (2) 1`] = `
"studio": "asdf",
},
"timelineBlob": "[]",
"timelineHash": "randomId9016",
"timelineHash": "randomId9014",
},
]
`;
Expand All @@ -301,7 +301,7 @@ exports[`Timeline Out transitions outTransition + preroll 1`] = `
"studio": "asdf",
},
"timelineBlob": "[]",
"timelineHash": "randomId9016",
"timelineHash": "randomId9014",
},
]
`;
Expand All @@ -318,7 +318,7 @@ exports[`Timeline Out transitions outTransition is disabled during hold 1`] = `
"studio": "asdf",
},
"timelineBlob": "[]",
"timelineHash": "randomId9018",
"timelineHash": "randomId9016",
},
]
`;
17 changes: 8 additions & 9 deletions packages/job-worker/src/playout/__tests__/timeline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1129,12 +1129,11 @@ describe('Timeline', () => {
})

describe('Adlib pieces', () => {
async function doStartAdlibPiece(
playlistId: RundownPlaylistId,
currentPartInstance: PlayoutPartInstanceModel,
adlibSource: AdLibPiece
) {
async function doStartAdlibPiece(playlistId: RundownPlaylistId, adlibSource: AdLibPiece) {
await runJobWithPlayoutCache(context, { playlistId }, null, async (cache) => {
const currentPartInstance = cache.CurrentPartInstance as PlayoutPartInstanceModel
expect(currentPartInstance).toBeTruthy()

const rundown = cache.getRundown(currentPartInstance.PartInstance.rundownId) as PlayoutRundownModel
expect(rundown).toBeTruthy()

Expand Down Expand Up @@ -1214,10 +1213,11 @@ describe('Timeline', () => {
const { currentPartInstance } = await getPartInstances()
expect(currentPartInstance).toBeTruthy()

console.log('inst', currentPartInstance?.PartInstance._id)

// Insert an adlib piece
await doStartAdlibPiece(
playlistId,
currentPartInstance!,
literal<AdLibPiece>({
_id: protectString('adlib1'),
rundownId: currentPartInstance!.PartInstance.rundownId,
Expand All @@ -1232,7 +1232,7 @@ describe('Timeline', () => {
})
)

const adlibbedPieceId = 'randomId9007'
const adlibbedPieceId = 'randomId9010'

// The adlib should be starting at 'now'
await checkTimings({
Expand Down Expand Up @@ -1383,7 +1383,6 @@ describe('Timeline', () => {
// Insert an adlib piece
await doStartAdlibPiece(
playlistId,
currentPartInstance!,
literal<AdLibPiece>({
_id: protectString('adlib1'),
rundownId: currentPartInstance!.PartInstance.rundownId,
Expand All @@ -1399,7 +1398,7 @@ describe('Timeline', () => {
})
)

const adlibbedPieceId = 'randomId9007'
const adlibbedPieceId = 'randomId9010'

// The adlib should be starting at 'now'
await checkTimings({
Expand Down
Loading

0 comments on commit a67648f

Please sign in to comment.