fix: update pollSessions JSDoc and remove zombie backoff test

This commit is contained in:
Brian Krabach
2026-04-01 13:08:31 -07:00
parent dc7c077b6a
commit 7e28438953
2 changed files with 3 additions and 52 deletions
+3 -2
View File
@@ -297,8 +297,9 @@ function setConnectionStatus(level) {
// ─── Session polling ───────────────────────────────────────────────────────────────────────────── // ─── Session polling ─────────────────────────────────────────────────────────────────────────────
/** /**
* Fetch sessions from all configured _sources in parallel and update the UI. * Fetch sessions from the appropriate endpoint and update the UI.
* Falls back to local-only polling when _sources is empty. * Uses /api/federation/sessions when multi_device_enabled is true,
* /api/sessions otherwise.
* Called by startPolling. * Called by startPolling.
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
-50
View File
@@ -2505,56 +2505,6 @@ test('mergeSources returns empty array for empty input', () => {
assert.deepStrictEqual(result, [], 'mergeSources should return empty array for empty input'); assert.deepStrictEqual(result, [], 'mergeSources should return empty array for empty input');
}); });
// --- pollSessions multi-source (task-5) ---
test('pollSessions skips sources with nextRetryAt in the future', async () => {
const mockStatusEl = { textContent: '', className: '' };
const mockGrid = { innerHTML: '' };
const mockEmptyState = { style: {}, classList: { add: () => {}, remove: () => {} } };
const origGetById = globalThis.document.getElementById;
const origQSA = globalThis.document.querySelectorAll;
globalThis.document.getElementById = (id) => {
if (id === 'connection-status') return mockStatusEl;
if (id === 'session-grid') return mockGrid;
if (id === 'empty-state') return mockEmptyState;
return null;
};
globalThis.document.querySelectorAll = () => [];
const futureRetry = Date.now() + 60000; // 60s in the future
app._setSources([
{ url: '', name: 'Local', type: 'local', status: 'authenticated', backoffMs: 2000 },
{
url: 'https://remote.example.com',
name: 'Remote',
type: 'remote',
status: 'unreachable',
backoffMs: 4000,
nextRetryAt: futureRetry,
},
]);
const fetchCalls = [];
globalThis.fetch = async (url) => {
fetchCalls.push(url);
return { ok: true, json: async () => [{ name: 'local-session' }] };
};
await app.pollSessions();
assert.ok(fetchCalls.some((url) => url === '/api/sessions'), 'should fetch local sessions');
assert.ok(
!fetchCalls.some((url) => url === 'https://remote.example.com/api/sessions'),
'should skip remote source still in backoff',
);
globalThis.document.getElementById = origGetById;
globalThis.document.querySelectorAll = origQSA;
globalThis.fetch = undefined;
app._setSources([]);
});
// --- getVisibleSessions (task-7) --- // --- getVisibleSessions (task-7) ---