Publish Docker Image / build-and-push (./build/Dockerfile, git.lzstealth.com/lzstealth/pulse-signage-web, web) (push) Successful in 1m12s
Publish Docker Image / build-and-push (./build/Dockerfile.player, git.lzstealth.com/lzstealth/pulse-signage-player, player) (push) Successful in 30s
47 lines
1.7 KiB
JavaScript
47 lines
1.7 KiB
JavaScript
const test = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
|
|
const { buildApiSourcePayload } = require('../src/data/api-sources');
|
|
const { buildRssFeedPayload } = require('../src/data/rss-feeds');
|
|
const { normalizeIntervalMs } = require('../src/web/lib/background-tasks/queue');
|
|
|
|
test('data source payloads accept hours as an update interval unit', () => {
|
|
const apiPayload = buildApiSourcePayload({
|
|
body: {
|
|
name: 'API source',
|
|
api_url: 'https://example.com/api',
|
|
update_interval_value: '2',
|
|
update_interval_unit: 'hours'
|
|
}
|
|
}, null);
|
|
|
|
const rssPayload = buildRssFeedPayload({
|
|
body: {
|
|
name: 'RSS feed',
|
|
feed_url: 'https://example.com/feed.xml',
|
|
update_interval_value: '3',
|
|
update_interval_unit: 'hours',
|
|
item_limit: '5'
|
|
}
|
|
}, null);
|
|
|
|
assert.equal(apiPayload.updateIntervalUnit, 'hours');
|
|
assert.equal(apiPayload.updateIntervalValue, 2);
|
|
assert.equal(rssPayload.updateIntervalUnit, 'hours');
|
|
assert.equal(rssPayload.updateIntervalValue, 3);
|
|
});
|
|
|
|
test('background task interval conversion supports hours', () => {
|
|
assert.equal(normalizeIntervalMs(2, 'hours'), 7_200_000);
|
|
});
|
|
|
|
test('data source forms expose hours as an interval option', () => {
|
|
const apiTemplate = fs.readFileSync(path.join(__dirname, '..', 'src', 'web', 'views', 'data-sources', 'api-sources', 'form.hbs'), 'utf8');
|
|
const rssTemplate = fs.readFileSync(path.join(__dirname, '..', 'src', 'web', 'views', 'data-sources', 'rss-feeds', 'form.hbs'), 'utf8');
|
|
|
|
assert.match(apiTemplate, /value="hours"[\s\S]*>Hours<\/option>/);
|
|
assert.match(rssTemplate, /value="hours"[\s\S]*>Hours<\/option>/);
|
|
});
|