[codex] Fix Jellyfin setup and discovery toggle (#59)

This commit is contained in:
2026-05-02 19:56:10 -07:00
committed by GitHub
parent 27f5b2bb58
commit db30c61327
38 changed files with 1372 additions and 107 deletions
+51 -1
View File
@@ -1,6 +1,6 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { createHandleJellyfinAuthCommands } from './jellyfin-cli-auth';
import { createHandleJellyfinAuthCommands, persistJellyfinAuthSession } from './jellyfin-cli-auth';
test('jellyfin auth handler processes logout', async () => {
const calls: string[] = [];
@@ -70,6 +70,7 @@ test('jellyfin auth handler processes login', async () => {
jellyfinConfig: {
serverUrl: '',
username: '',
recentServers: ['http://localhost'],
},
serverUrl: 'http://localhost',
clientInfo: {
@@ -91,11 +92,60 @@ test('jellyfin auth handler processes login', async () => {
deviceId: 'd1',
clientName: 'SubMiner',
clientVersion: '1.0',
recentServers: ['http://localhost'],
},
});
assert.ok(calls.some((entry) => entry.includes('Jellyfin login succeeded')));
});
test('persistJellyfinAuthSession stores client metadata and recent servers', () => {
let patchPayload: unknown = null;
let storedSession: unknown = null;
persistJellyfinAuthSession({
session: {
serverUrl: 'http://localhost:8096',
username: 'alice',
accessToken: 'token',
userId: 'uid',
},
clientInfo: {
deviceId: 'device-1',
clientName: 'SubMiner',
clientVersion: '1.0',
},
existingRecentServers: [
' http://old.example:8096/ ',
'http://localhost:8096',
'',
'http://another.example:8096',
],
saveStoredSession: (session) => {
storedSession = session;
},
patchRawConfig: (patch) => {
patchPayload = patch;
},
});
assert.deepEqual(storedSession, { accessToken: 'token', userId: 'uid' });
assert.deepEqual(patchPayload, {
jellyfin: {
enabled: true,
serverUrl: 'http://localhost:8096',
username: 'alice',
deviceId: 'device-1',
clientName: 'SubMiner',
clientVersion: '1.0',
recentServers: [
'http://localhost:8096',
'http://old.example:8096',
'http://another.example:8096',
],
},
});
});
test('jellyfin auth handler no-ops when no auth command', async () => {
const handleAuth = createHandleJellyfinAuthCommands({
patchRawConfig: () => {},