Refine player control-plane flow
This commit is contained in:
@@ -218,3 +218,140 @@ test('dashboard kiosk launcher requires both confirmation and a player selection
|
||||
assert.equal(downloadLink.classList.contains('disabled'), false);
|
||||
assert.equal(downloadLink.attributes.href, '/downloads/kiosk/pulse-signage-kiosk.bat?playerUrl=http%3A%2F%2Fplayer-a.example');
|
||||
});
|
||||
|
||||
test('screen controls include an all screens option and update the target summary', () => {
|
||||
const script = fs.readFileSync(require.resolve('../src/web/public/js/dashboard/dashboard-page.js'), 'utf8');
|
||||
const select = {
|
||||
value: '__all__',
|
||||
selectedIndex: 2,
|
||||
options: [
|
||||
{ value: 'alpha', textContent: 'Alpha', getAttribute() { return null; } },
|
||||
{ value: 'beta', textContent: 'Beta', getAttribute() { return null; } },
|
||||
{ value: '__all__', textContent: 'All screens', getAttribute(name) { return name === 'data-screen-target-all' ? 'true' : null; } }
|
||||
],
|
||||
listeners: {},
|
||||
addEventListener(type, handler) {
|
||||
this.listeners[type] = handler;
|
||||
}
|
||||
};
|
||||
const commandInput = { value: '' };
|
||||
const pausedInput = { value: 'true' };
|
||||
const button = {
|
||||
innerHTML: '',
|
||||
disabled: false
|
||||
};
|
||||
const form = {
|
||||
dataset: {},
|
||||
getAttribute(name) {
|
||||
if (name === 'data-screen-command-action') {
|
||||
return 'pause';
|
||||
}
|
||||
return this[name] || '';
|
||||
},
|
||||
querySelector(selector) {
|
||||
if (selector === 'input[name="command"]') {
|
||||
return commandInput;
|
||||
}
|
||||
if (selector === 'input[name="paused"]') {
|
||||
return pausedInput;
|
||||
}
|
||||
if (selector === 'button[type="submit"]') {
|
||||
return button;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
querySelectorAll() {
|
||||
return [button, commandInput, pausedInput];
|
||||
},
|
||||
setAttribute(name, value) {
|
||||
this[name] = value;
|
||||
},
|
||||
action: ''
|
||||
};
|
||||
const pill = { classList: { toggle() {}, add() {}, remove() {} }, textContent: '' };
|
||||
const nameNode = { textContent: '' };
|
||||
const metaNode = { textContent: '' };
|
||||
const context = {
|
||||
document: {
|
||||
getElementById(id) {
|
||||
if (id === 'screen-command-select') {
|
||||
return select;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
querySelector(selector) {
|
||||
if (selector === '[data-screen-command-pill]') {
|
||||
return pill;
|
||||
}
|
||||
if (selector === '[data-screen-command-name]') {
|
||||
return nameNode;
|
||||
}
|
||||
if (selector === '[data-screen-command-meta]') {
|
||||
return metaNode;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
querySelectorAll(selector) {
|
||||
return selector === '[data-screen-command-form]' ? [form] : [];
|
||||
}
|
||||
},
|
||||
window: {
|
||||
webUiHelpers: {
|
||||
escapeHtml(value) { return String(value); },
|
||||
formatDashboardDate(value) { return String(value); },
|
||||
getClientRowKey() { return ''; },
|
||||
getClientDisplayName() { return ''; },
|
||||
setButtonVariant() {},
|
||||
normalizeDisplayIp(value) { return String(value); }
|
||||
},
|
||||
WebSocket: null,
|
||||
location: {
|
||||
protocol: 'http:',
|
||||
host: 'example.test'
|
||||
},
|
||||
setTimeout() { return 1; },
|
||||
clearTimeout() {},
|
||||
alert() {},
|
||||
prompt() {
|
||||
return null;
|
||||
},
|
||||
webHandleDashboardState() {}
|
||||
},
|
||||
WebSocket: function MockWebSocket() {},
|
||||
JSON: JSON,
|
||||
Number: Number,
|
||||
String: String,
|
||||
Boolean: Boolean,
|
||||
Array: Array,
|
||||
Object: Object,
|
||||
Math: Math,
|
||||
Set: Set,
|
||||
URLSearchParams: URLSearchParams,
|
||||
FormData: function FormData() {},
|
||||
setTimeout() {},
|
||||
clearTimeout() {},
|
||||
console: console
|
||||
};
|
||||
context.window.document = context.document;
|
||||
context.window.WebSocket = context.WebSocket;
|
||||
|
||||
vm.runInNewContext(script, context);
|
||||
|
||||
context.window.webHandleDashboardState({
|
||||
screens: [
|
||||
{ slug: 'alpha', name: 'Alpha' },
|
||||
{ slug: 'beta', name: 'Beta' }
|
||||
],
|
||||
clients: [
|
||||
{ screen_slug: 'alpha', paused: true },
|
||||
{ screen_slug: 'beta', paused: true }
|
||||
]
|
||||
});
|
||||
|
||||
assert.equal(form.action, '/clients/__all__/commands');
|
||||
assert.equal(nameNode.textContent, 'All screens');
|
||||
assert.equal(metaNode.textContent, 'Commands sent here target every client across every screen group.');
|
||||
assert.match(button.innerHTML, /Resume all screens/);
|
||||
assert.equal(commandInput.value, 'pause');
|
||||
assert.equal(pausedInput.value, 'false');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user