const test = require('node:test'); const assert = require('node:assert/strict'); const { createNotifyPlayerScreens } = require('../src/web/lib/notify-player-screens'); test('playlist notifications use the player URL reported by the screen connection', async () => { const calls = []; const notify = createNotifyPlayerScreens( async function () { calls.push({ type: 'fallback' }); return { ok: true }; }, async function () { return { connections: [{ playerPublicBaseUrl: 'http://192.168.0.80:8082' }] }; }, async function (baseUrl, slug, command) { calls.push({ baseUrl, slug, command }); return { ok: true }; }, async function () { return 'http://player:8081'; } ); const count = await notify(['test'], 'refresh'); assert.equal(count, 1); assert.deepEqual(calls, [{ baseUrl: 'http://player:8081', slug: 'test', command: 'refresh' }]); }); test('playlist notifications use the bridge device route for remote player connections', async () => { const calls = []; const notify = createNotifyPlayerScreens( async function () { calls.push({ type: 'fallback' }); return { ok: true }; }, async function () { return { connections: [{ playerDeviceId: 'remote-player-1', playerPublicBaseUrl: 'https://remote.example' }] }; }, async function () { calls.push({ type: 'base-url' }); return { ok: true }; }, async function () { return 'http://player:8081'; }, async function (deviceId, payload) { calls.push({ deviceId, payload }); return { ok: true }; } ); const count = await notify(['remote-screen'], 'refresh'); assert.equal(count, 1); assert.deepEqual(calls, [{ deviceId: 'remote-player-1', payload: { command: 'refresh', screenSlug: 'remote-screen' } }]); });