|
1 | 1 | import '../../__mocks__/_extendJest.js' |
2 | 2 | import { |
3 | 3 | IBlueprintPiece, |
| 4 | + IngestChangeType, |
4 | 5 | IngestPart, |
5 | 6 | IngestRundown, |
6 | 7 | IngestSegment, |
@@ -51,6 +52,7 @@ import { PlayoutPartInstanceModel } from '../../playout/model/PlayoutPartInstanc |
51 | 52 | import { NrcsIngestCacheType } from '@sofie-automation/corelib/dist/dataModel/NrcsIngestDataCache' |
52 | 53 | import { wrapGenericIngestJob, wrapGenericIngestJobWithPrecheck } from '../jobWrappers.js' |
53 | 54 | import { wrapDefaultObject } from '@sofie-automation/corelib/dist/settings/objectWithOverrides' |
| 55 | +import { ProcessIngestDataContext } from '../../blueprints/context/ProcessIngestDataContext.js' |
54 | 56 |
|
55 | 57 | const handleRemovedRundownWrapped = wrapGenericIngestJob(handleRemovedRundown) |
56 | 58 | const handleUpdatedRundownWrapped = wrapGenericIngestJob(handleUpdatedRundown) |
@@ -1608,6 +1610,77 @@ describe('Test ingest actions for rundowns and segments', () => { |
1608 | 1610 | } |
1609 | 1611 | }) |
1610 | 1612 |
|
| 1613 | + test('processIngestData can force syncIngestUpdateToPartInstance for active rundown', async () => { |
| 1614 | + const rundownData = clone(rundownData1) |
| 1615 | + const syncIngestUpdateToPartInstance = jest.fn() |
| 1616 | + |
| 1617 | + context.updateStudioBlueprint({ |
| 1618 | + processIngestData: async ( |
| 1619 | + blueprintContext, |
| 1620 | + mutableIngestRundown, |
| 1621 | + nrcsIngestRundown, |
| 1622 | + _previous, |
| 1623 | + ingestChanges |
| 1624 | + ) => { |
| 1625 | + if (ingestChanges.source !== IngestChangeType.Ingest) { |
| 1626 | + throw new Error(`Expected ingest changes for this test`) |
| 1627 | + } |
| 1628 | + |
| 1629 | + blueprintContext.defaultApplyIngestChanges(mutableIngestRundown, nrcsIngestRundown, ingestChanges) |
| 1630 | + ;(blueprintContext as ProcessIngestDataContext).requestSyncIngestUpdateToPartInstances() |
| 1631 | + }, |
| 1632 | + }) |
| 1633 | + context.updateShowStyleBlueprint({ |
| 1634 | + syncIngestUpdateToPartInstance, |
| 1635 | + }) |
| 1636 | + |
| 1637 | + try { |
| 1638 | + await handleUpdatedRundownWrapped(context, { |
| 1639 | + rundownExternalId: rundownData.externalId, |
| 1640 | + ingestRundown: rundownData, |
| 1641 | + isCreateAction: true, |
| 1642 | + rundownSource: createRundownSource(device), |
| 1643 | + }) |
| 1644 | + |
| 1645 | + const rundown = (await context.mockCollections.Rundowns.findOne({ externalId: externalId })) as DBRundown |
| 1646 | + expect(rundown).toBeTruthy() |
| 1647 | + |
| 1648 | + await handleActivateRundownPlaylist(context, { |
| 1649 | + playlistId: rundown.playlistId, |
| 1650 | + rehearsal: true, |
| 1651 | + }) |
| 1652 | + await handleTakeNextPart(context, { playlistId: rundown.playlistId, fromPartInstanceId: null }) |
| 1653 | + |
| 1654 | + const selectedInstances = await getSelectedPartInstances( |
| 1655 | + context, |
| 1656 | + (await context.mockCollections.RundownPlaylists.findOne(rundown.playlistId)) as DBRundownPlaylist |
| 1657 | + ) |
| 1658 | + expect(selectedInstances.currentPartInstance?.part.externalId).toBe('part0') |
| 1659 | + expect(selectedInstances.nextPartInstance?.part.externalId).toBe('part1') |
| 1660 | + |
| 1661 | + syncIngestUpdateToPartInstance.mockClear() |
| 1662 | + |
| 1663 | + await handleUpdatedPartWrapped(context, { |
| 1664 | + rundownExternalId: rundownData.externalId, |
| 1665 | + ingestPart: { |
| 1666 | + externalId: 'part2', |
| 1667 | + name: 'Part 2 updated', |
| 1668 | + rank: 0, |
| 1669 | + payload: undefined, |
| 1670 | + }, |
| 1671 | + segmentExternalId: 'segment1', |
| 1672 | + isCreateAction: false, |
| 1673 | + }) |
| 1674 | + |
| 1675 | + expect(syncIngestUpdateToPartInstance).toHaveBeenCalled() |
| 1676 | + const playStatuses = syncIngestUpdateToPartInstance.mock.calls.map((call) => call[3]) |
| 1677 | + expect(playStatuses.some((status) => status === 'current' || status === 'next')).toBe(true) |
| 1678 | + } finally { |
| 1679 | + context.updateStudioBlueprint({ processIngestData: undefined as any }) |
| 1680 | + context.updateShowStyleBlueprint({ syncIngestUpdateToPartInstance: undefined as any }) |
| 1681 | + } |
| 1682 | + }) |
| 1683 | + |
1611 | 1684 | test('previous partinstance getting removed if an adlib part', async () => { |
1612 | 1685 | const rundownData: IngestRundown = { |
1613 | 1686 | externalId: externalId, |
|
0 commit comments