mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-20 14:39:06 +00:00
committed by
Carlos Valente
parent
92fbef3515
commit
94b80d3b0b
@@ -88,8 +88,13 @@ describe('mutation on runtimeState', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('playback operations', async () => {
|
describe('playback operations', async () => {
|
||||||
it('refuses if nothing is loaded', () => {
|
it('refuses if nothing is loaded', async () => {
|
||||||
initRundown(makeRundown({}), {});
|
// force update
|
||||||
|
vi.useFakeTimers();
|
||||||
|
await initRundown(makeRundown({}), {});
|
||||||
|
vi.runAllTimers();
|
||||||
|
vi.useRealTimers();
|
||||||
|
|
||||||
let success = start(mockState);
|
let success = start(mockState);
|
||||||
expect(success).toBe(false);
|
expect(success).toBe(false);
|
||||||
|
|
||||||
@@ -97,9 +102,15 @@ describe('mutation on runtimeState', () => {
|
|||||||
expect(success).toBe(false);
|
expect(success).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('normal playback cycle', () => {
|
test('normal playback cycle', async () => {
|
||||||
// 1. Load event
|
// 1. Load event
|
||||||
const mockRundown = makeRundown({ entries: { [mockEvent.id]: mockEvent }, order: [mockEvent.id] });
|
const mockRundown = makeRundown({ entries: { [mockEvent.id]: mockEvent }, order: [mockEvent.id] });
|
||||||
|
// force update
|
||||||
|
vi.useFakeTimers();
|
||||||
|
await initRundown(mockRundown, {});
|
||||||
|
vi.runAllTimers();
|
||||||
|
vi.useRealTimers();
|
||||||
|
|
||||||
load(mockEvent, mockRundown, mockRundown.order);
|
load(mockEvent, mockRundown, mockRundown.order);
|
||||||
let newState = getState();
|
let newState = getState();
|
||||||
expect(newState.eventNow?.id).toBe(mockEvent.id);
|
expect(newState.eventNow?.id).toBe(mockEvent.id);
|
||||||
@@ -164,20 +175,19 @@ describe('mutation on runtimeState', () => {
|
|||||||
expect(newState.runtime.actualStart).toBeNull();
|
expect(newState.runtime.actualStart).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
// do this before the test so that it is applied
|
|
||||||
const entries = {
|
|
||||||
event1: { ...mockEvent, id: 'event1', timeStart: 0, timeEnd: 1000, duration: 1000, parent: null },
|
|
||||||
event2: { ...mockEvent, id: 'event2', timeStart: 1000, timeEnd: 1500, duration: 500, parent: null },
|
|
||||||
};
|
|
||||||
const rundown = makeRundown({ entries, order: ['event1', 'event2'] });
|
|
||||||
|
|
||||||
// force update
|
|
||||||
vi.useFakeTimers();
|
|
||||||
await initRundown(rundown, {});
|
|
||||||
vi.runAllTimers();
|
|
||||||
vi.useRealTimers();
|
|
||||||
|
|
||||||
test('runtime offset', async () => {
|
test('runtime offset', async () => {
|
||||||
|
const entries = {
|
||||||
|
event1: { ...mockEvent, id: 'event1', timeStart: 0, timeEnd: 1000, duration: 1000, parent: null },
|
||||||
|
event2: { ...mockEvent, id: 'event2', timeStart: 1000, timeEnd: 1500, duration: 500, parent: null },
|
||||||
|
};
|
||||||
|
const rundown = makeRundown({ entries, order: ['event1', 'event2'] });
|
||||||
|
|
||||||
|
// force update
|
||||||
|
vi.useFakeTimers();
|
||||||
|
await initRundown(rundown, {});
|
||||||
|
vi.runAllTimers();
|
||||||
|
vi.useRealTimers();
|
||||||
|
|
||||||
// 1. Load event
|
// 1. Load event
|
||||||
load(entries.event1, rundown, rundown.order);
|
load(entries.event1, rundown, rundown.order);
|
||||||
let newState = getState();
|
let newState = getState();
|
||||||
@@ -284,7 +294,7 @@ describe('roll mode', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('roll takover', () => {
|
describe('roll takeover', async () => {
|
||||||
const rundown = makeRundown({
|
const rundown = makeRundown({
|
||||||
entries: {
|
entries: {
|
||||||
1: { ...mockEvent, id: '1', timeStart: 1000, duration: 1000, timeEnd: 2000 },
|
1: { ...mockEvent, id: '1', timeStart: 1000, duration: 1000, timeEnd: 2000 },
|
||||||
@@ -294,6 +304,12 @@ describe('roll mode', () => {
|
|||||||
order: ['1', '2', '3'],
|
order: ['1', '2', '3'],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// force update
|
||||||
|
vi.useFakeTimers();
|
||||||
|
await initRundown(rundown, {});
|
||||||
|
vi.runAllTimers();
|
||||||
|
vi.useRealTimers();
|
||||||
|
|
||||||
test('from load', () => {
|
test('from load', () => {
|
||||||
load(rundown.entries[3] as PlayableEvent, rundown, rundown.order);
|
load(rundown.entries[3] as PlayableEvent, rundown, rundown.order);
|
||||||
const result = roll(rundown, rundown.order);
|
const result = roll(rundown, rundown.order);
|
||||||
@@ -313,7 +329,7 @@ describe('roll mode', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('roll continue with offset', () => {
|
describe('roll continue with offset', () => {
|
||||||
test('no gaps', () => {
|
test('no gaps', async () => {
|
||||||
const rundown = makeRundown({
|
const rundown = makeRundown({
|
||||||
entries: {
|
entries: {
|
||||||
1: { ...mockEvent, id: '1', timeStart: 1000, duration: 1000, timeEnd: 2000 },
|
1: { ...mockEvent, id: '1', timeStart: 1000, duration: 1000, timeEnd: 2000 },
|
||||||
@@ -323,11 +339,19 @@ describe('roll mode', () => {
|
|||||||
order: ['1', '2', '3'],
|
order: ['1', '2', '3'],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// force update
|
||||||
|
vi.useFakeTimers();
|
||||||
|
await initRundown(rundown, {});
|
||||||
|
vi.runAllTimers();
|
||||||
|
|
||||||
load(rundown.entries[1] as PlayableEvent, rundown, rundown.order);
|
load(rundown.entries[1] as PlayableEvent, rundown, rundown.order);
|
||||||
start();
|
start();
|
||||||
|
// the current offset after manual play
|
||||||
|
const currentOffset = getState().runtime.offset;
|
||||||
let result = roll(rundown, rundown.order, getState().runtime.offset);
|
let result = roll(rundown, rundown.order, getState().runtime.offset);
|
||||||
expect(result).toStrictEqual({ eventId: '1', didStart: false });
|
expect(result).toStrictEqual({ eventId: '1', didStart: false });
|
||||||
expect(getState().runtime.offset).toBe(1000);
|
// the current offset should be maintain by roll mode whn taking over from play
|
||||||
|
expect(getState().runtime.offset).toBe(currentOffset);
|
||||||
|
|
||||||
vi.setSystemTime('jan 1 00:00:01');
|
vi.setSystemTime('jan 1 00:00:01');
|
||||||
result = roll(rundown, rundown.order, getState().runtime.offset);
|
result = roll(rundown, rundown.order, getState().runtime.offset);
|
||||||
@@ -338,6 +362,8 @@ describe('roll mode', () => {
|
|||||||
result = roll(rundown, rundown.order, getState().runtime.offset);
|
result = roll(rundown, rundown.order, getState().runtime.offset);
|
||||||
expect(result).toStrictEqual({ eventId: '3', didStart: true });
|
expect(result).toStrictEqual({ eventId: '3', didStart: true });
|
||||||
expect(getState().runtime.offset).toBe(1000);
|
expect(getState().runtime.offset).toBe(1000);
|
||||||
|
|
||||||
|
vi.useRealTimers();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user