Publish Docker Image / build-and-push (./build/Dockerfile, git.lzstealth.com/lzstealth/pulse-signage-web, web) (push) Successful in 1m25s
Publish Docker Image / build-and-push (./build/Dockerfile.player, git.lzstealth.com/lzstealth/pulse-signage-player, player) (push) Successful in 32s
134 lines
4.1 KiB
JavaScript
134 lines
4.1 KiB
JavaScript
const test = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
|
|
require('../src/common');
|
|
|
|
const {
|
|
renderBackgroundTasksPage,
|
|
renderBackgroundTasksScheduledPage
|
|
} = require('../src/web/routes/settings/background-tasks-page');
|
|
|
|
test('background task pages opt into 24-hour timestamps, confirm clearing tasks, and search by dates', () => {
|
|
const baseQueueData = {
|
|
tasks: [
|
|
{
|
|
title: 'Example task',
|
|
key: 'secret-key',
|
|
category: 'Refresh',
|
|
status: 'completed',
|
|
createdAt: '2026-08-04T10:15:00.000Z',
|
|
startedAt: '2026-08-04T10:16:00.000Z',
|
|
finishedAt: '2026-08-04T10:17:00.000Z',
|
|
metadata: {
|
|
playerLabel: 'Player Alpha'
|
|
}
|
|
},
|
|
{
|
|
title: 'Media sync task',
|
|
key: 'media-sync:slide:update:2:lzstealthcom',
|
|
category: 'Refresh',
|
|
status: 'completed',
|
|
createdAt: '2026-08-04T11:15:00.000Z',
|
|
startedAt: '2026-08-04T11:16:00.000Z',
|
|
finishedAt: '2026-08-04T11:17:00.000Z',
|
|
metadata: {
|
|
playerLabel: 'lzstealthcom'
|
|
}
|
|
},
|
|
{
|
|
title: 'Older task',
|
|
key: 'older-key',
|
|
category: 'Refresh',
|
|
status: 'completed',
|
|
createdAt: '2026-08-01T10:15:00.000Z',
|
|
startedAt: '2026-08-01T10:16:00.000Z',
|
|
finishedAt: '2026-08-01T10:17:00.000Z'
|
|
}
|
|
],
|
|
summary: { counts: {}, total: 1, activeCount: 0 }
|
|
};
|
|
|
|
const queueHtml = renderBackgroundTasksPage(baseQueueData, '', {
|
|
permissions: ['background-tasks.allow']
|
|
});
|
|
|
|
const queueKeySearchHtml = renderBackgroundTasksPage(Object.assign({}, baseQueueData, { search: 'secret-key' }), '', {
|
|
permissions: ['background-tasks.allow']
|
|
});
|
|
|
|
const queueDateSearchHtml = renderBackgroundTasksPage(Object.assign({}, baseQueueData, { search: '2026-08-04' }), '', {
|
|
permissions: ['background-tasks.allow']
|
|
});
|
|
|
|
const scheduledHtml = renderBackgroundTasksScheduledPage(
|
|
{
|
|
recurringTasks: [
|
|
{
|
|
title: 'Recurring refresh',
|
|
key: 'refresh',
|
|
intervalMs: 60000,
|
|
nextRunAt: '2026-08-04T10:15:00.000Z',
|
|
lastRunAt: '2026-08-04T09:15:00.000Z',
|
|
metadata: {
|
|
playerIdentifier: 'Player Beta'
|
|
}
|
|
}
|
|
],
|
|
summary: { counts: {}, total: 1, activeCount: 0, scheduledCount: 1 }
|
|
},
|
|
'',
|
|
{
|
|
permissions: ['scheduled-tasks.allow']
|
|
}
|
|
);
|
|
|
|
assert.match(queueHtml, /data-confirm-message="Clear finished background tasks\?"/);
|
|
assert.match(queueHtml, /data-local-datetime-format="24h"/);
|
|
assert.match(queueHtml, /Player Alpha:secret-key/);
|
|
assert.match(queueHtml, /lzstealthcom:media-sync:slide:update:2/);
|
|
assert.doesNotMatch(queueHtml, /lzstealthcom:media-sync:slide:update:2:lzstealthcom/);
|
|
assert.doesNotMatch(queueKeySearchHtml, /Example task/);
|
|
assert.match(queueDateSearchHtml, /Example task/);
|
|
assert.match(scheduledHtml, /data-local-datetime-format="24h"/);
|
|
assert.match(scheduledHtml, /Player:\s+Player Beta/);
|
|
});
|
|
|
|
test('scheduled task interval labels use the largest exact unit while sorting stays numeric', () => {
|
|
const scheduledHtml = renderBackgroundTasksScheduledPage(
|
|
{
|
|
recurringTasks: [
|
|
{
|
|
title: 'Hourly task',
|
|
key: 'hourly',
|
|
intervalMs: 7200000,
|
|
metadata: {}
|
|
},
|
|
{
|
|
title: 'Second task',
|
|
key: 'seconds',
|
|
intervalMs: 3000,
|
|
metadata: {}
|
|
},
|
|
{
|
|
title: 'Minute task',
|
|
key: 'minutes',
|
|
intervalMs: 60000,
|
|
metadata: {}
|
|
}
|
|
],
|
|
sort: 'interval',
|
|
direction: 'asc',
|
|
summary: { counts: {}, total: 3, activeCount: 0, scheduledCount: 3 }
|
|
},
|
|
'',
|
|
{
|
|
permissions: ['scheduled-tasks.allow']
|
|
}
|
|
);
|
|
|
|
assert.match(scheduledHtml, /Every 3 seconds/);
|
|
assert.match(scheduledHtml, /Every minute/);
|
|
assert.match(scheduledHtml, /Every 2 hours/);
|
|
assert.ok(scheduledHtml.indexOf('Every 3 seconds') < scheduledHtml.indexOf('Every minute'));
|
|
assert.ok(scheduledHtml.indexOf('Every minute') < scheduledHtml.indexOf('Every 2 hours'));
|
|
}); |