mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 23:35:44 +00:00
92635381ea
a11y-branch hold lifted. Pure share machinery (no @/features runtime imports) → lib/share: shareLink, shareSearch, shareServerOriginLabel, copyEntityShareLink (+tests). The two orchestrators that runtime-import offline/playback/orbit → new features/share: applySharePaste, enqueueShareSearchPayload (+test); doc-only barrel, consumers use deep paths. No low-layer consumes the orchestrators, so no seam is needed — pure move, tests pass unmodified. Drains utils/share. Only import lines changed in the PasteClipboardHandler consumer (logic untouched).
47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { encodeSharePayload } from '@/lib/share/shareLink';
|
|
import { parseShareSearchText } from '@/lib/share/shareSearch';
|
|
import { shareServerOriginLabel } from '@/lib/share/shareServerOriginLabel';
|
|
|
|
const home = {
|
|
id: 'home',
|
|
name: 'Home NAS',
|
|
url: 'https://music.home.example',
|
|
username: 'u1',
|
|
password: 'p1',
|
|
};
|
|
const office = {
|
|
id: 'office',
|
|
name: 'Office',
|
|
url: 'https://music.office.example',
|
|
username: 'u2',
|
|
password: 'p2',
|
|
};
|
|
|
|
describe('shareServerOriginLabel', () => {
|
|
it('returns null when share targets the active server', () => {
|
|
const match = parseShareSearchText(
|
|
encodeSharePayload({ srv: home.url, k: 'track', id: 't-1' }),
|
|
);
|
|
expect(shareServerOriginLabel(match, [home, office], 'home')).toBeNull();
|
|
});
|
|
|
|
it('returns the saved server display name when share is from another saved server', () => {
|
|
const match = parseShareSearchText(
|
|
encodeSharePayload({ srv: office.url, k: 'track', id: 't-1' }),
|
|
);
|
|
expect(shareServerOriginLabel(match, [home, office], 'home')).toBe('Office');
|
|
});
|
|
|
|
it('returns null when the share server is not in saved profiles', () => {
|
|
const match = parseShareSearchText(
|
|
encodeSharePayload({ srv: 'https://unknown.example', k: 'track', id: 't-1' }),
|
|
);
|
|
expect(shareServerOriginLabel(match, [home], 'home')).toBeNull();
|
|
});
|
|
|
|
it('returns null for unsupported share payloads', () => {
|
|
expect(shareServerOriginLabel({ type: 'unsupported' }, [home], 'home')).toBeNull();
|
|
});
|
|
});
|