fix: update pollSessions JSDoc and remove zombie backoff test
This commit is contained in:
@@ -297,8 +297,9 @@ function setConnectionStatus(level) {
|
||||
|
||||
// ─── Session polling ─────────────────────────────────────────────────────────────────────────────
|
||||
/**
|
||||
* Fetch sessions from all configured _sources in parallel and update the UI.
|
||||
* Falls back to local-only polling when _sources is empty.
|
||||
* Fetch sessions from the appropriate endpoint and update the UI.
|
||||
* Uses /api/federation/sessions when multi_device_enabled is true,
|
||||
* /api/sessions otherwise.
|
||||
* Called by startPolling.
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
|
||||
@@ -2505,56 +2505,6 @@ test('mergeSources returns 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) ---
|
||||
|
||||
Reference in New Issue
Block a user