mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-20 14:39:06 +00:00
Ux/54 help (#88)
* ux/54-help tooltips * ux/54-help refetch after mutation * ux/54-help broadcast event index * ux/54-help prevent multiple keypresses when key held * ux/54-help fat clock * ux/54-help progress bar user defined * ux/54-help onAir is button * ux/54-help OSC: add missing presenter message * ux/54-help OSC: enable / disable OSC * ux/54-help handle timezone in excel date import * ux/54-help tray left click to show app * ux/54-help create queriable endpoint * ux/54-help fix memoisation in lower thirds * ux/54-help revise icons * ux/54-help clarify text * ux/54-help forgiving text parsing * ux/54-help add smart keywords * ux/54-help version bump
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { server, shutdown, startServer } from '../../app.js';
|
||||
import supertest from 'supertest';
|
||||
|
||||
beforeAll(() => startServer());
|
||||
afterAll(() => shutdown());
|
||||
|
||||
describe('When a GET request request is sent', () => {
|
||||
test('GET /event returns a valid object', async () => {
|
||||
await supertest(server)
|
||||
.get('/event')
|
||||
.expect(200)
|
||||
.then((response) => {
|
||||
expect(response.text.includes('<!doctype html>')).toBe(false);
|
||||
expect(response.body).toBeDefined();
|
||||
expect(typeof response.body.title).toBe('string');
|
||||
expect(typeof response.body.url).toBe('string');
|
||||
expect(typeof response.body.publicInfo).toBe('string');
|
||||
expect(typeof response.body.backstageInfo).toBe('string');
|
||||
expect(typeof response.body.endMessage).toBe('string');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,57 @@
|
||||
import { server, shutdown, startServer } from '../../app.js';
|
||||
import supertest from 'supertest';
|
||||
|
||||
beforeAll(() => startServer());
|
||||
afterAll(() => shutdown());
|
||||
|
||||
const testEvent = {
|
||||
title: 'API test event',
|
||||
subtitle: 'test title',
|
||||
presenter: 'test presenter',
|
||||
note: 'test note',
|
||||
timeStart: 0,
|
||||
timeEnd: 42,
|
||||
isPublic: false,
|
||||
type: 'event',
|
||||
id: 'superSpecial12',
|
||||
};
|
||||
|
||||
describe('When a POST request is sent', () => {
|
||||
test('POST /event should return a 201', async () => {
|
||||
await supertest(server)
|
||||
.post('/events')
|
||||
.send(testEvent)
|
||||
.expect(201)
|
||||
});
|
||||
});
|
||||
|
||||
describe('When a GET request request is sent', () => {
|
||||
test('GET /events returns a valid object', async () => {
|
||||
await supertest(server)
|
||||
.get('/events')
|
||||
.expect(200)
|
||||
.then((response) => {
|
||||
expect(response.text.includes('<!doctype html>')).toBe(false);
|
||||
expect(response.body).toBeDefined();
|
||||
expect(typeof response.body).toBe('object');
|
||||
});
|
||||
});
|
||||
test('GET /events/:eventId returns a valid object', async () => {
|
||||
await supertest(server)
|
||||
.get(`/events/${testEvent.id}`)
|
||||
.expect(200)
|
||||
.then((response) => {
|
||||
expect(response.text.includes('<!doctype html>')).toBe(false);
|
||||
expect(response.body).toBeDefined();
|
||||
expect(response.body.title).toBe(testEvent.title);
|
||||
expect(response.body.subtitle).toBe(testEvent.subtitle);
|
||||
expect(response.body.presenter).toBe(testEvent.presenter);
|
||||
expect(response.body.note).toBe(testEvent.note);
|
||||
expect(response.body.timeStart).toBe(testEvent.timeStart);
|
||||
expect(response.body.timeEnd).toBe(testEvent.timeEnd);
|
||||
expect(response.body.isPublic).toBe(testEvent.isPublic);
|
||||
expect(response.body.type).toBe(testEvent.type);
|
||||
expect(response.body.id).toBe(testEvent.id);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,98 @@
|
||||
import { server, shutdown, startServer } from '../../app.js';
|
||||
import supertest from 'supertest';
|
||||
|
||||
beforeAll(() => startServer());
|
||||
afterAll(() => shutdown());
|
||||
|
||||
describe('When a GET request request is sent', () => {
|
||||
test('GET /ontime/poll returns a valid object', async () => {
|
||||
await supertest(server)
|
||||
.get('/ontime/poll')
|
||||
.expect(200)
|
||||
.then((response) => {
|
||||
expect(response.text.includes('<!doctype html>')).toBe(false);
|
||||
expect(response.body).toBeDefined();
|
||||
expect(typeof response.body.clock).toBe('number');
|
||||
expect(typeof response.body.running).toBe('number');
|
||||
expect(typeof response.body.timer).toBe('string');
|
||||
expect(typeof response.body.playback).toBe('string');
|
||||
expect(typeof response.body.title).toBe('string');
|
||||
expect(typeof response.body.presenter).toBe('string');
|
||||
});
|
||||
});
|
||||
|
||||
test('GET /ontime/db returns a JSON object', async () => {
|
||||
await supertest(server)
|
||||
.get('/ontime/db')
|
||||
.expect(200)
|
||||
.then((response) => {
|
||||
expect(response.text.includes('<!doctype html>')).toBe(false);
|
||||
expect(response.body).toBeDefined();
|
||||
expect(response.headers['content-type']).toContain('json');
|
||||
});
|
||||
});
|
||||
|
||||
test('GET /ontime/info returns a valid object', async () => {
|
||||
await supertest(server)
|
||||
.get('/ontime/info')
|
||||
.expect(200)
|
||||
.then((response) => {
|
||||
expect(response.text.includes('<!doctype html>')).toBe(false);
|
||||
expect(response.body).toBeDefined();
|
||||
expect(typeof response.body.networkInterfaces).toBe('object');
|
||||
expect(typeof response.body.version).toBe('number');
|
||||
expect(typeof response.body.serverPort).toBe('number');
|
||||
expect(typeof response.body.osc).toBe('object');
|
||||
});
|
||||
});
|
||||
|
||||
test('GET /ontime/aliases returns a valid object', async () => {
|
||||
await supertest(server)
|
||||
.get('/ontime/aliases')
|
||||
.expect(200)
|
||||
.then((response) => {
|
||||
expect(response.text.includes('<!doctype html>')).toBe(false);
|
||||
expect(response.body).toBeDefined();
|
||||
expect(typeof response.body).toBe('object');
|
||||
});
|
||||
});
|
||||
|
||||
test('GET /ontime/settings returns a valid object', async () => {
|
||||
await supertest(server)
|
||||
.get('/ontime/settings')
|
||||
.expect(200)
|
||||
.then((response) => {
|
||||
expect(response.text.includes('<!doctype html>')).toBe(false);
|
||||
expect(response.body).toBeDefined();
|
||||
expect(typeof response.body.version).toBe('number');
|
||||
expect(typeof response.body.serverPort).toBe('number');
|
||||
expect(typeof response.body.pinCode).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
test('GET /ontime/osc returns a valid object', async () => {
|
||||
await supertest(server)
|
||||
.get('/ontime/osc')
|
||||
.expect(200)
|
||||
.then((response) => {
|
||||
expect(response.text.includes('<!doctype html>')).toBe(false);
|
||||
expect(response.body).toBeDefined();
|
||||
expect(typeof response.body.port).toBe('number');
|
||||
expect(typeof response.body.portOut).toBe('number');
|
||||
expect(typeof response.body.targetIP).toBe('string');
|
||||
expect(typeof response.body.enabled).toBe('boolean');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Any other returns the app', () => {
|
||||
test('GET / returns ontime app', async () => {
|
||||
await supertest(server)
|
||||
.get('/')
|
||||
.expect(200)
|
||||
.then((response) => {
|
||||
expect(response.body).toBeDefined();
|
||||
expect(response.text.includes('<!doctype html>')).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,129 @@
|
||||
import { server, shutdown, startServer } from '../../app.js';
|
||||
import supertest from 'supertest';
|
||||
|
||||
beforeAll(() => startServer());
|
||||
afterAll(() => shutdown());
|
||||
|
||||
describe('When a GET request request is sent', () => {
|
||||
test('GET /playback returns a valid object', async () => {
|
||||
await supertest(server)
|
||||
.get('/playback')
|
||||
.expect(200)
|
||||
.then((response) => {
|
||||
expect(response.text.includes('<!doctype html>')).toBe(false);
|
||||
expect(response.body).toBeDefined();
|
||||
expect(typeof response.body.playback).toBe('string');
|
||||
expect(response.body.playback).toBe('stop' || 'start' || 'pause' || 'roll');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('When a GET state change is sent', () => {
|
||||
test('GET /playback/onAir returns 200', async () => {
|
||||
await supertest(server)
|
||||
.get('/playback/onAir')
|
||||
.expect(200)
|
||||
.then((response) => {
|
||||
expect(response.text.includes('<!doctype html>')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
test('GET /playback/offAir returns 200', async () => {
|
||||
await supertest(server)
|
||||
.get('/playback/offAir')
|
||||
.expect(200)
|
||||
.then((response) => {
|
||||
expect(response.text.includes('<!doctype html>')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
test('GET /playback/start returns 200', async () => {
|
||||
await supertest(server)
|
||||
.get('/playback/start')
|
||||
.expect(200)
|
||||
.then((response) => {
|
||||
expect(response.text.includes('<!doctype html>')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
test('GET /playback/play returns 200', async () => {
|
||||
await supertest(server)
|
||||
.get('/playback/play')
|
||||
.expect(200)
|
||||
.then((response) => {
|
||||
expect(response.text.includes('<!doctype html>')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
test('GET /playback/pause returns 200', async () => {
|
||||
await supertest(server)
|
||||
.get('/playback/pause')
|
||||
.expect(200)
|
||||
.then((response) => {
|
||||
expect(response.text.includes('<!doctype html>')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
test('GET /playback/stop returns 200', async () => {
|
||||
await supertest(server)
|
||||
.get('/playback/stop')
|
||||
.expect(200)
|
||||
.then((response) => {
|
||||
expect(response.text.includes('<!doctype html>')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
test('GET /playback/roll returns 200', async () => {
|
||||
await supertest(server)
|
||||
.get('/playback/roll')
|
||||
.expect(200)
|
||||
.then((response) => {
|
||||
expect(response.text.includes('<!doctype html>')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
test('GET /playback/previous returns 200', async () => {
|
||||
await supertest(server)
|
||||
.get('/playback/previous')
|
||||
.expect(200)
|
||||
.then((response) => {
|
||||
expect(response.text.includes('<!doctype html>')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
test('GET /playback/next returns 200', async () => {
|
||||
await supertest(server)
|
||||
.get('/playback/next')
|
||||
.expect(200)
|
||||
.then((response) => {
|
||||
expect(response.text.includes('<!doctype html>')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
test('GET /playback/unload returns 200', async () => {
|
||||
await supertest(server)
|
||||
.get('/playback/unload')
|
||||
.expect(200)
|
||||
.then((response) => {
|
||||
expect(response.text.includes('<!doctype html>')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
test('GET /playback/reload returns 200', async () => {
|
||||
await supertest(server)
|
||||
.get('/playback/reload')
|
||||
.expect(200)
|
||||
.then((response) => {
|
||||
expect(response.text.includes('<!doctype html>')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
test('GET of unknown request returns app', async () => {
|
||||
await supertest(server)
|
||||
.get('/playback/madeup')
|
||||
.expect(200)
|
||||
.then((response) => {
|
||||
expect(response.text.includes('<!doctype html>')).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -15,8 +15,12 @@ import {
|
||||
postSettings,
|
||||
getAliases,
|
||||
postAliases,
|
||||
poll,
|
||||
} from '../controllers/ontimeController.js';
|
||||
|
||||
// create route between controller and '/ontime/sync' endpoint
|
||||
router.get('/poll', poll);
|
||||
|
||||
// create route between controller and '/ontime/db' endpoint
|
||||
router.get('/db', dbDownload);
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
pbPrevious,
|
||||
pbNext,
|
||||
pbUnload,
|
||||
pbReload
|
||||
pbReload,
|
||||
} from '../controllers/playbackController.js';
|
||||
|
||||
// create route between controller and '/playback/' endpoint
|
||||
|
||||
Reference in New Issue
Block a user