mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 15:25:46 +00:00
7c9a300022
* feat(share): library deep links (psysonic2) with paste and toolbar actions Add base64url-encoded payloads for track, album, artist, and ordered queue. Handle paste outside inputs to switch server, validate entities, navigate or play. Reuse clipboard helper for context menu, queue panel, album and artist headers. Tests distinguish server invite strings from library shares. * fix(share): play partial queue when some shared tracks are missing Skip unavailable song IDs when pasting a queue share while preserving order. Toast when some tracks are missing; error only if none resolve. Add openedQueuePartial and queueAllUnavailable i18n; remove queueTracksMissing. * feat(settings): paste server invites globally and scroll to add form Handle psysonic1- magic strings outside inputs: navigate to settings or login with prefilled add-server fields. Decode invites embedded in surrounding text. Scroll the add-server block into view when opening from a paste so long server lists stay oriented. --------- Co-authored-by: Maxim Isaev <im@friclub.ru>
56 lines
1.7 KiB
TypeScript
56 lines
1.7 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import {
|
|
SERVER_MAGIC_STRING_PREFIX,
|
|
DECODED_PASSWORD_VISUAL_MASK,
|
|
decodeServerMagicString,
|
|
decodeServerMagicStringFromText,
|
|
encodeServerMagicString,
|
|
} from './serverMagicString';
|
|
|
|
describe('DECODED_PASSWORD_VISUAL_MASK', () => {
|
|
it('has fixed length independent of real passwords', () => {
|
|
expect(DECODED_PASSWORD_VISUAL_MASK.length).toBe(10);
|
|
});
|
|
});
|
|
|
|
describe('serverMagicString', () => {
|
|
it('round-trips url, username, password', () => {
|
|
const original = {
|
|
url: 'https://music.example.com',
|
|
username: 'alice',
|
|
password: 's3cret!',
|
|
};
|
|
const encoded = encodeServerMagicString(original);
|
|
expect(encoded.startsWith(SERVER_MAGIC_STRING_PREFIX)).toBe(true);
|
|
expect(decodeServerMagicString(encoded)).toEqual(original);
|
|
});
|
|
|
|
it('round-trips optional name', () => {
|
|
const original = {
|
|
url: 'http://127.0.0.1:4533',
|
|
username: 'bob',
|
|
password: 'x',
|
|
name: 'Home',
|
|
};
|
|
const encoded = encodeServerMagicString(original);
|
|
expect(decodeServerMagicString(encoded)).toEqual(original);
|
|
});
|
|
|
|
it('rejects invalid input', () => {
|
|
expect(decodeServerMagicString('')).toBeNull();
|
|
expect(decodeServerMagicString('nope')).toBeNull();
|
|
expect(decodeServerMagicString(`${SERVER_MAGIC_STRING_PREFIX}%%%`)).toBeNull();
|
|
});
|
|
|
|
it('decodes invite embedded in surrounding text', () => {
|
|
const original = {
|
|
url: 'https://music.example.com',
|
|
username: 'alice',
|
|
password: 'pw',
|
|
};
|
|
const line = encodeServerMagicString(original);
|
|
expect(decodeServerMagicStringFromText(`Copy:\n${line}\nThanks`)).toEqual(original);
|
|
expect(decodeServerMagicStringFromText('no token')).toBeNull();
|
|
});
|
|
});
|