mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-05 15:33:59 +00:00
Feat/navigate (#81)
* feat/navigate upgrade react router * feat/navigate migrate to react router 6 * feat/navigate style modal * feat/navigate create endpoints for app settings * feat/navigate protect editor with pin * feat/navigate apply dynamic routing draft * feat/navigate upgrade relevant packages * feat/navigate restructure directory and add tests * feat/navigate test aliases validation * feat/navigate validate aliases before sending * feat/navigate create data endpoint * feat/navigate config: prettier * feat/navigate invalidate empty strings * feat/navigate create endpoints * feat/navigate parse on import * feat/navigate navigate to alias * feat/navigate user help and sample data * feat/navigate refact aliases modal * feat/navigate refact settings style * feat/navigate update sample db * feat/navigate link is relative to hostname * feat/navigate navigate to first match * feat/navigate update readme and version bump * feat/navigate config: create shared module * feat/navigate config: cheat module install * feat/navigate fix tests * feat/navigate run tests in pull request * Update ontime_cy.yml
This commit is contained in:
@@ -10,8 +10,8 @@ import { OSCIntegration } from './integrations/Osc.js';
|
||||
import { HTTPIntegration } from './integrations/Http.js';
|
||||
import { cleanURL } from '../utils/url.js';
|
||||
import getRandomName from '../utils/getRandomName.js';
|
||||
import { stringFromMillis } from '../utils/time.js';
|
||||
import { generateId } from '../utils/generate_id.js';
|
||||
import { stringFromMillis } from 'ontime-utils/time.js';
|
||||
import { generateId } from 'ontime-utils/generate_id.js';
|
||||
|
||||
/*
|
||||
* Class EventTimer adds functions specific to APP
|
||||
@@ -111,13 +111,20 @@ export class EventTimer extends Timer {
|
||||
* @description Shutdown process
|
||||
*/
|
||||
shutdown() {
|
||||
clearInterval(this._interval);
|
||||
this.info('SERVER', 'Shutting down ontime');
|
||||
this.info('TX', '... Closing socket server');
|
||||
this.io.close();
|
||||
this.info('TX', '... Closing OSC Client');
|
||||
this.osc.shutdown();
|
||||
this.info('TX', '... Closing HTTP Client');
|
||||
this.http.shutdown();
|
||||
if (this.io != null) {
|
||||
this.info('TX', '... Closing socket server');
|
||||
this.io.close();
|
||||
}
|
||||
if (this.osc != null) {
|
||||
this.info('TX', '... Closing OSC Client');
|
||||
this.osc.shutdown();
|
||||
}
|
||||
if (this.http != null) {
|
||||
this.info('TX', '... Closing HTTP Client');
|
||||
this.http.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import { stringFromMillis } from '../utils/time.js';
|
||||
import { stringFromMillis } from 'ontime-utils/time.js';
|
||||
|
||||
export class Timer {
|
||||
constructor() {
|
||||
|
||||
@@ -1,24 +1,18 @@
|
||||
import {EventTimer} from "../EventTimer";
|
||||
import { EventTimer } from '../EventTimer';
|
||||
import http from 'http';
|
||||
import express from "express";
|
||||
import express from 'express';
|
||||
|
||||
// Create server
|
||||
const app = express();
|
||||
const server = http.createServer(app);
|
||||
|
||||
|
||||
// necessary config
|
||||
const timerConfig = {refresh: 1000};
|
||||
const timerConfig = { refresh: 1000 };
|
||||
|
||||
beforeEach(async () => {
|
||||
server.listen(0, '0.0.0.0');
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
afterAll(async () => {
|
||||
await server.close();
|
||||
});
|
||||
|
||||
|
||||
test('object instantiates correctly', async () => {
|
||||
const t = new EventTimer(server, timerConfig);
|
||||
|
||||
@@ -41,16 +35,15 @@ test('object instantiates correctly', async () => {
|
||||
// and its own properties
|
||||
expect(t.ontimeCycle).toBe('idle');
|
||||
expect(t.prevCycle).toBeNull();
|
||||
expect(t.lastUpdate).toBeNull();
|
||||
expect(t.io).not.toBeNull();
|
||||
expect(t.osc).toBeNull();
|
||||
expect(t.http).toBeNull();
|
||||
expect(t._numClients).toBe(0);
|
||||
expect(t._interval).not.toBeNull();
|
||||
expect(t.presenter).toStrictEqual({text: '', visible: false});
|
||||
expect(t.public).toStrictEqual({text: '', visible: false});
|
||||
expect(t.lower).toStrictEqual({text: '', visible: false});
|
||||
expect(t.lower).toStrictEqual({text: '', visible: false});
|
||||
expect(t.presenter).toStrictEqual({ text: '', visible: false });
|
||||
expect(t.public).toStrictEqual({ text: '', visible: false });
|
||||
expect(t.lower).toStrictEqual({ text: '', visible: false });
|
||||
expect(t.lower).toStrictEqual({ text: '', visible: false });
|
||||
|
||||
const expectTitlesPublic = {
|
||||
titleNow: null,
|
||||
@@ -78,19 +71,20 @@ test('object instantiates correctly', async () => {
|
||||
expect(t.numEvents).toBe(0);
|
||||
expect(t._eventlist).toBeNull();
|
||||
expect(t.onAir).toBeFalsy();
|
||||
});
|
||||
|
||||
t.shutdown();
|
||||
});
|
||||
|
||||
describe('test triggers behaviour', () => {
|
||||
const t = new EventTimer(server, timerConfig);
|
||||
|
||||
it('ignores bad commands', () => {
|
||||
test('ignores bad commands', async(done) => {
|
||||
const success = t.trigger('test');
|
||||
expect(success).toBeFalsy();
|
||||
})
|
||||
|
||||
it('does not allow triggering events with an empty list', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
test('does not allow triggering events with an empty list', async(done) => {
|
||||
expect(t.numEvents).toBe(0);
|
||||
|
||||
expect(t.trigger('start')).toBeFalsy();
|
||||
@@ -106,10 +100,10 @@ describe('test triggers behaviour', () => {
|
||||
expect(t.onAir).toBeTruthy();
|
||||
expect(t.trigger('offAir')).toBeTruthy();
|
||||
expect(t.onAir).toBeFalsy();
|
||||
done();
|
||||
});
|
||||
|
||||
it('...and is consistent by calling the class methods', () => {
|
||||
|
||||
test('...and is consistent by calling the class methods', async (done) => {
|
||||
expect(t.numEvents).toBe(0);
|
||||
expect(t.state).toBe('stop');
|
||||
|
||||
@@ -133,5 +127,8 @@ describe('test triggers behaviour', () => {
|
||||
|
||||
t.reload();
|
||||
expect(t.state).toBe('stop');
|
||||
done();
|
||||
});
|
||||
})
|
||||
|
||||
t.shutdown();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user