Release 2.6.8
This commit is contained in:
@@ -342,3 +342,181 @@ test('dashboard move client button opens the move modal for the selected row', (
|
||||
assert.equal(clientNameInput.value, 'Lobby Client');
|
||||
assert.equal(playerBaseUrlInput.value, 'http://player.local');
|
||||
});
|
||||
|
||||
test('dashboard screen group controls stay disabled until a group is selected', () => {
|
||||
const script = fs.readFileSync(require.resolve('../src/web/public/js/dashboard/dashboard-page.js'), 'utf8');
|
||||
const pauseInput = { value: 'true' };
|
||||
const blackoutInput = { value: 'true' };
|
||||
const reloadButton = {
|
||||
disabled: false,
|
||||
innerHTML: '',
|
||||
setAttribute() {},
|
||||
classList: { add() {}, remove() {} }
|
||||
};
|
||||
const pauseButton = {
|
||||
disabled: false,
|
||||
innerHTML: '',
|
||||
setAttribute() {},
|
||||
classList: { add() {}, remove() {} }
|
||||
};
|
||||
const blackoutButton = {
|
||||
disabled: false,
|
||||
innerHTML: '',
|
||||
setAttribute() {},
|
||||
classList: { add() {}, remove() {} }
|
||||
};
|
||||
const forms = [
|
||||
{
|
||||
getAttribute(name) {
|
||||
if (name === 'data-screen-command-action') {
|
||||
return 'reload';
|
||||
}
|
||||
return '';
|
||||
},
|
||||
setAttribute() {},
|
||||
querySelector(selector) {
|
||||
if (selector === 'button[type="submit"]') {
|
||||
return reloadButton;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
},
|
||||
{
|
||||
getAttribute(name) {
|
||||
if (name === 'data-screen-command-action') {
|
||||
return 'pause';
|
||||
}
|
||||
return '';
|
||||
},
|
||||
setAttribute() {},
|
||||
querySelector(selector) {
|
||||
if (selector === 'button[type="submit"]') {
|
||||
return pauseButton;
|
||||
}
|
||||
if (selector === 'input[name="paused"]') {
|
||||
return pauseInput;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
},
|
||||
{
|
||||
getAttribute(name) {
|
||||
if (name === 'data-screen-command-action') {
|
||||
return 'blackout';
|
||||
}
|
||||
return '';
|
||||
},
|
||||
setAttribute() {},
|
||||
querySelector(selector) {
|
||||
if (selector === 'button[type="submit"]') {
|
||||
return blackoutButton;
|
||||
}
|
||||
if (selector === 'input[name="blackout"]') {
|
||||
return blackoutInput;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
];
|
||||
const select = {
|
||||
value: '',
|
||||
options: [
|
||||
{ textContent: 'Select Screen Group', getAttribute() { return ''; } },
|
||||
{ textContent: 'Lobby', getAttribute(name) { return name === 'data-screen-name' ? 'Lobby' : ''; } },
|
||||
{ textContent: 'All Screens', getAttribute(name) { return name === 'data-screen-name' ? 'All screens' : ''; } }
|
||||
],
|
||||
selectedIndex: 0,
|
||||
dataset: {},
|
||||
addEventListener(type, handler) {
|
||||
if (type === 'change') {
|
||||
this.changeHandler = handler;
|
||||
}
|
||||
}
|
||||
};
|
||||
const context = {
|
||||
document: {
|
||||
body: {
|
||||
classList: {
|
||||
toggle() {},
|
||||
add() {},
|
||||
remove() {}
|
||||
}
|
||||
},
|
||||
getElementById(id) {
|
||||
if (id === 'screen-command-select') {
|
||||
return select;
|
||||
}
|
||||
if (id === 'dashboard-clients-table') {
|
||||
return { getAttribute() { return 'false'; } };
|
||||
}
|
||||
if (id === 'dashboard-clients-table-body') {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
querySelector(selector) {
|
||||
if (selector === '[data-screen-command-select]') {
|
||||
return select;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
querySelectorAll(selector) {
|
||||
if (selector === '[data-screen-command-form]') {
|
||||
return forms;
|
||||
}
|
||||
return [];
|
||||
},
|
||||
addEventListener() {}
|
||||
},
|
||||
window: {
|
||||
location: {
|
||||
search: '',
|
||||
protocol: 'http:',
|
||||
host: 'example.test'
|
||||
},
|
||||
webUiHelpers: {
|
||||
escapeHtml(value) { return String(value); },
|
||||
formatDashboardDate(value) { return String(value); },
|
||||
getClientRowKey(client) { return String(client && client.id || ''); },
|
||||
getClientDisplayName(client) { return String(client && (client.client_name || client.name || client.clientId) || ''); },
|
||||
setButtonVariant() {},
|
||||
normalizeDisplayIp(value) { return String(value); }
|
||||
},
|
||||
WebSocket: null,
|
||||
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() {}
|
||||
};
|
||||
context.window.document = context.document;
|
||||
context.window.WebSocket = context.WebSocket;
|
||||
|
||||
vm.runInNewContext(script, context);
|
||||
|
||||
assert.equal(reloadButton.disabled, true);
|
||||
assert.equal(pauseButton.disabled, true);
|
||||
assert.equal(blackoutButton.disabled, true);
|
||||
|
||||
select.value = 'lobby';
|
||||
select.selectedIndex = 1;
|
||||
select.changeHandler();
|
||||
|
||||
assert.equal(reloadButton.disabled, false);
|
||||
assert.equal(pauseButton.disabled, false);
|
||||
assert.equal(blackoutButton.disabled, false);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user