feat(remote): add remote control defaults to config store

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Administrator 2026-03-12 06:54:46 +01:00
parent 92e94b1e8a
commit c2932a1577
2 changed files with 59 additions and 0 deletions

View File

@ -75,6 +75,12 @@ const DEFAULTS = {
delaySec: 3, delaySec: 3,
autoStart: true, autoStart: true,
hosters: [] // pre-selected hosters, empty = ask via modal hosters: [] // pre-selected hosters, empty = ask via modal
},
remote: {
enabled: false,
port: 9100,
token: '',
allowInput: true
} }
}, },
history: [] history: []

View File

@ -0,0 +1,53 @@
const { describe, it } = require('node:test');
const assert = require('node:assert');
const path = require('path');
const fs = require('fs');
const os = require('os');
// Minimal app mock for ConfigStore
function createTestConfigStore() {
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'mhu-test-'));
const mockApp = {
isPackaged: false,
getPath: (name) => tmpDir,
getPath: () => tmpDir
};
const ConfigStore = require('../lib/config-store');
const store = new ConfigStore(mockApp);
store.filePath = path.join(tmpDir, 'test-config.json');
return { store, tmpDir };
}
describe('remote config defaults', () => {
it('should include remote settings in defaults', () => {
const { store } = createTestConfigStore();
const config = store.load();
const remote = config.globalSettings.remote;
assert.strictEqual(remote.enabled, false);
assert.strictEqual(remote.port, 9100);
assert.strictEqual(typeof remote.token, 'string');
assert.strictEqual(remote.token, '');
assert.strictEqual(remote.allowInput, true);
});
it('should deep-merge remote settings with existing config', async () => {
const { store } = createTestConfigStore();
// Save config with partial remote settings
await store.save({
globalSettings: {
remote: { enabled: true, port: 9200 }
}
});
const config = store.load();
const remote = config.globalSettings.remote;
// Saved values preserved
assert.strictEqual(remote.enabled, true);
assert.strictEqual(remote.port, 9200);
// Defaults merged in
assert.strictEqual(remote.allowInput, true);
assert.strictEqual(remote.token, '');
});
});