Release v2.10.4
This commit is contained in:
@@ -195,3 +195,56 @@ test('client command route forwards a single screen command', async () => {
|
||||
assert.equal(calls[0].connectionId, undefined);
|
||||
assert.equal(response.body.ok, true);
|
||||
});
|
||||
|
||||
test('client command route uses the bridge device route without a public player URL', async () => {
|
||||
const { app, handlers } = createAppHarness();
|
||||
const calls = [];
|
||||
registerScreenCommandRoutes(app, {
|
||||
pool: {
|
||||
async query(sql) {
|
||||
if (String(sql).includes('SELECT id, name, slug FROM d_screens WHERE slug = ?')) {
|
||||
return [[{ id: 1, name: 'Lobby', slug: 'lobby' }]];
|
||||
}
|
||||
return [[]];
|
||||
}
|
||||
},
|
||||
common: { async fetchPlayerRegistrations() { return []; } },
|
||||
forwardPlayerCommand() {
|
||||
throw new Error('direct player fallback should not be used');
|
||||
},
|
||||
forwardPlayerCommandToBaseUrl() {
|
||||
throw new Error('public URL fallback should not be used');
|
||||
},
|
||||
forwardPlayerCommandToDevice(deviceId, payload) {
|
||||
calls.push({ deviceId, payload });
|
||||
return { ok: true };
|
||||
},
|
||||
getScreenConnections: async () => ({
|
||||
connections: [{ id: 'connection-1', deviceId: 'browser-tab-1', playerDeviceId: 'remote-player-1', playerPublicBaseUrl: null }]
|
||||
}),
|
||||
isClientNameAvailable() { return true; },
|
||||
withClientNameReservation() {},
|
||||
broadcastDashboardState() {},
|
||||
requirePermission() {
|
||||
return function (_req, _res, next) { next(); };
|
||||
}
|
||||
});
|
||||
|
||||
const response = {
|
||||
statusCode: 200,
|
||||
body: null,
|
||||
status(code) { this.statusCode = code; return this; },
|
||||
json(payload) { this.body = payload; return this; }
|
||||
};
|
||||
await handlers['/clients/:slug/commands'][1]({
|
||||
params: { slug: 'lobby' },
|
||||
body: { command: 'pause', connectionId: 'connection-1' },
|
||||
query: {}
|
||||
}, response, () => {});
|
||||
|
||||
assert.equal(response.statusCode, 200);
|
||||
assert.deepEqual(calls, [{
|
||||
deviceId: 'remote-player-1',
|
||||
payload: { screenSlug: 'lobby', command: 'pause', connectionId: 'connection-1' }
|
||||
}]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user