Release v2.19.0: indexed content references
Publish Docker Image / build-and-push-existing-registry (./build/Dockerfile, web, pulse-signage-web) (push) Successful in 1m11s
Publish Docker Image / build-and-push-existing-registry (./build/Dockerfile.player, player, pulse-signage-player) (push) Successful in 33s

This commit is contained in:
lzstealth committed 2026-10-24 19:50:12 +01:00
1 parent 24f1603b43
commit b59fe08298
31 files changed
+663 -237

No files matched your search

+44 -8
View File
@@ -7,6 +7,7 @@ const sharp = require('sharp');
require('../src/common');
const library = require('../src/web/lib/media/weather-icon-library');
const weatherIcons = require('../src/web/public/js/shared/weather-icons');
const { isWeatherIconSetUsed } = require('../src/web/routes/settings/weather-icons');
const vm = require('node:vm');
const placeholderContext = { window: {} };
vm.runInNewContext(fs.readFileSync(path.join(__dirname, '../src/web/public/js/shared/placeholder-utils.js'), 'utf8'), placeholderContext);
@@ -206,15 +207,50 @@ test('weather sets require every condition image and support replacement', async
}
});
test('weather icon usage recognizes one set reference', function () {
const content = { weather: { weather_icon_set_id: 'set' } };
const isUsed = function (setId) {
return Object.values(content).some(function (region) {
return region && region.weather_icon_set_id === setId;
});
test('weather icon usage guard checks the indexed reference value', async function () {
const pool = { async query(_sql, params) { return [[{ owner_count: params[1] === 'set' ? 1 : 0 }]]; } };
assert.equal(await isWeatherIconSetUsed(pool, 'set'), true);
assert.equal(await isWeatherIconSetUsed(pool, 'other'), false);
});
test('weather icon sync refreshes slides using direct and template-default references once', async function () {
const originalSetWeatherIconSetEnabled = library.setWeatherIconSetEnabled;
const originalCollectWeatherIconSyncOperations = library.collectWeatherIconSyncOperations;
const handlers = {};
const tasks = [];
const app = {
get(route, ...callbacks) { handlers['GET ' + route] = callbacks; },
post(route, ...callbacks) { handlers['POST ' + route] = callbacks; }
};
assert.equal(isUsed('set'), true);
assert.equal(isUsed('other'), false);
library.setWeatherIconSetEnabled = function (_root, id, enabled) { return { id: id, name: 'Set', enabled: enabled }; };
library.collectWeatherIconSyncOperations = function () { return []; };
try {
require('../src/web/routes/settings/weather-icons')(app, {
mediaDir: 'unused',
pool: {
async query(sql) {
if (sql.includes('FROM d_players')) return [[{ id: 1, identifier: 'player-1' }]];
if (sql.includes('SELECT DISTINCT owner_type, owner_id')) return [[
{ owner_type: 'slide', owner_id: 22 },
{ owner_type: 'template', owner_id: 7 }
]];
if (sql.includes('FROM c_slides WHERE template_id IN')) return [[{ id: 23 }, { id: 22 }]];
return [[]];
}
},
backgroundTaskQueue: { async enqueueTask(task) { tasks.push(task); } },
requirePermission() { return function (_req, _res, next) { next(); }; }
});
const response = { redirect() { return this; } };
await handlers['POST /settings/weather-icons/:id/toggle'].at(-1)(
{ body: { enabled: '0' }, params: { id: 'set' } }, response, function (error) { if (error) throw error; }
);
assert.deepEqual(tasks.filter(function (task) { return task.taskType === 'slide-thumbnail-refresh'; }).map(function (task) { return task.payload.slideId; }).sort(), [22, 23]);
} finally {
library.setWeatherIconSetEnabled = originalSetWeatherIconSetEnabled;
library.collectWeatherIconSyncOperations = originalCollectWeatherIconSyncOperations;
}
});
test('weather icon set create, update, toggle, and delete are audited', async function () {