diff --git a/muxplex/frontend/app.js b/muxplex/frontend/app.js index bbfc9ae..be09494 100644 --- a/muxplex/frontend/app.js +++ b/muxplex/frontend/app.js @@ -134,6 +134,8 @@ var _previewSessionName = null; // track by NAME, not DOM element let _sources = []; let _settingsOpen = false; let _serverSettings = null; +let _gridViewMode = 'flat'; +let _activeFilterDevice = 'all'; const DISPLAY_SETTINGS_KEY = 'muxplex.display'; const DISPLAY_DEFAULTS = { fontSize: 14, @@ -1671,6 +1673,18 @@ function _setViewMode(mode) { _viewMode = mode; } +/** Test-only: set _sources directly. */ +function _setSources(sources) { _sources = sources; } + +/** Test-only: set _serverSettings directly. */ +function _setServerSettings(settings) { _serverSettings = settings; } + +/** Test-only: get _gridViewMode. */ +function _getGridViewMode() { return _gridViewMode; } + +/** Test-only: get _sources. */ +function _getSources() { return _sources; } + document.addEventListener('DOMContentLoaded', () => { initDeviceId(); applyDisplaySettings(loadDisplaySettings()); @@ -1759,5 +1773,9 @@ if (typeof module !== 'undefined' && module.exports) { // Test-only helpers _setCurrentSessions, _setViewMode, + _setSources, + _setServerSettings, + _getGridViewMode, + _getSources, }; } diff --git a/muxplex/frontend/tests/test_app.mjs b/muxplex/frontend/tests/test_app.mjs index aaf70d8..5ef0479 100644 --- a/muxplex/frontend/tests/test_app.mjs +++ b/muxplex/frontend/tests/test_app.mjs @@ -2004,6 +2004,28 @@ test('createNewSession polls for session before auto-opening (not immediate setT ); }); +// --- federation state helpers (task-3) --- + +test('_setSources sets internal _sources array', () => { + assert.doesNotThrow(() => app._setSources([{ url: '', name: 'test' }])); +}); + +test('_setServerSettings sets internal _serverSettings', () => { + assert.doesNotThrow(() => app._setServerSettings({ sort_order: 'recent' })); +}); + +test('_getGridViewMode returns current _gridViewMode value', () => { + assert.strictEqual(typeof app._getGridViewMode(), 'string', '_getGridViewMode should return a string'); + assert.strictEqual(app._getGridViewMode(), 'flat', '_gridViewMode should default to flat'); +}); + +test('_getSources returns current _sources array', () => { + app._setSources([{ url: 'http://test', name: 'Test' }]); + const sources = app._getSources(); + assert.ok(Array.isArray(sources), '_getSources should return an array'); + assert.strictEqual(sources[0].url, 'http://test', '_getSources should return value set by _setSources'); +}); + // --- buildSources --- test('buildSources returns only local source when no remote_instances', () => {