Release v2.10.3
Publish Docker Image / build-and-push-existing-registry (./build/Dockerfile, web, pulse-signage-web) (push) Successful in 1m13s
Publish Docker Image / build-and-push-existing-registry (./build/Dockerfile.player, player, pulse-signage-player) (push) Successful in 31s

This commit is contained in:
2026-08-29 01:56:45 +01:00
parent 30814f3f46
commit 3f4f57020a
60 changed files with 1075 additions and 523 deletions
+84 -1
View File
@@ -1,7 +1,7 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const { refreshApiSource, refreshRssFeed } = require('../src/web/lib/data-source-refresh');
const { refreshApiSource, refreshRssFeed, refreshWeatherLocation } = require('../src/web/lib/data-source-refresh');
function createConnection(options) {
const state = Object.assign({
@@ -178,3 +178,86 @@ test('refreshRssFeed skips notifications when the RSS items are unchanged', asyn
assert.deepEqual(notifyCalls, []);
});
test('refreshWeatherLocation notifies players when the forecast changes', async () => {
const connection = createConnection({
slideRows: [{ id: 12, content_json: JSON.stringify({ weather_location_id: 4 }) }],
screenRows: [{ slug: 'screen-c' }]
});
const notifyCalls = [];
const pool = { async getConnection() { return connection; } };
const common = {
async fetchWeatherLocationForecast() {
return { responseJson: JSON.stringify({ temperature: 21 }) };
},
parseJsonSafe(value) {
return JSON.parse(value);
}
};
await refreshWeatherLocation(pool, common, {
id: 4,
last_pulled_at: new Date(),
last_response_json: JSON.stringify({ temperature: 20 })
}, 42, async function (slugs, payload) {
notifyCalls.push({ slugs, payload });
});
assert.deepEqual(notifyCalls, [{ slugs: ['screen-c'], payload: 'refresh' }]);
});
test('refreshWeatherLocation skips notifications when the forecast is unchanged within the hour', async () => {
const connection = createConnection({
slideRows: [{ id: 12, content_json: JSON.stringify({ weather_location_id: 4 }) }],
screenRows: [{ slug: 'screen-c' }]
});
const notifyCalls = [];
const pool = { async getConnection() { return connection; } };
const snapshot = JSON.stringify({ temperature: 20 });
const common = {
async fetchWeatherLocationForecast() {
return { responseJson: snapshot };
},
parseJsonSafe(value) {
return JSON.parse(value);
}
};
await refreshWeatherLocation(pool, common, {
id: 4,
last_pulled_at: new Date(),
last_response_json: snapshot
}, 42, async function (slugs, payload) {
notifyCalls.push({ slugs, payload });
});
assert.deepEqual(notifyCalls, []);
});
test('refreshWeatherLocation notifies when an unchanged forecast crosses into a new hour', async () => {
const connection = createConnection({
slideRows: [{ id: 12, content_json: JSON.stringify({ weather_location_id: 4 }) }],
screenRows: [{ slug: 'screen-c' }]
});
const notifyCalls = [];
const pool = { async getConnection() { return connection; } };
const snapshot = JSON.stringify({ temperature: 20 });
const common = {
async fetchWeatherLocationForecast() {
return { responseJson: snapshot };
},
parseJsonSafe(value) {
return JSON.parse(value);
}
};
await refreshWeatherLocation(pool, common, {
id: 4,
last_pulled_at: new Date('2000-01-01T00:00:00.000Z'),
last_response_json: snapshot
}, 42, async function (slugs, payload) {
notifyCalls.push({ slugs, payload });
});
assert.deepEqual(notifyCalls, [{ slugs: ['screen-c'], payload: 'refresh' }]);
});