mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-21 23:05:46 +00:00
fde7ab432f
* feat(playback): add transition-mode helper Centralise the crossfade/AutoDJ/gapless mutual exclusivity in one place instead of the scattered setter combinations across the toolbar, mini player and settings. AutoDJ stays encoded as crossfade + trim-silence, so the persisted flags and the audio engine are unchanged. * feat(queue): split AutoDJ into its own toolbar button + playlist submenu - AutoDJ becomes a standalone toolbar button (Blend icon) next to crossfade, driven by the shared transition-mode helper. The crossfade right-click popover drops the mode switch and keeps only the seconds slider. - Save + load playlist collapse into one Playlist button opening a small submenu, freeing up toolbar space. - queueToolbarStore gains a position-preserving rehydrate migration (legacy save/load -> playlist, autodj inserted after crossfade) with unit tests. - Toolbar customizer and all 9 queue locales updated to match. * feat(mini-player): standalone AutoDJ button, shared transition helper Mirror the queue toolbar: AutoDJ gets its own Blend button, the crossfade popover keeps only the seconds slider. The mini player now drives all three transitions through a single additive `mini:set-transition-mode` event handled by the shared helper, replacing the per-flag mini events. Drop the now-dead crossfade-mode CSS. * feat(settings): segmented track-transition picker, regroup playback Replace the crossfade toggle + inner crossfade/AutoDJ switch with a single Off | Gapless | Crossfade | AutoDJ segmented control (mirroring the Normalization picker above), driven by the shared transition helper — the mutual exclusivity now reads at a glance. Crossfade keeps its seconds slider; AutoDJ shows its content-driven explainer. The block is regrouped under "Track transitions" and "Queue behaviour" headings. Drops the now unused crossfade/gapless description and not-available i18n keys across all 9 locales and adds the new transition strings. * fix(queue): open the playlist submenu inward The playlist submenu inherited the crossfade popover's right:0 anchor and, sitting on the left of the toolbar, opened out under the main container. Anchor it left:0 so it stays inside the queue panel. Update the toolbar test for the new playlist submenu (save/load moved off the toolbar). * feat(settings): box playback sub-sections into panels Wrap Normalization, Track transitions and Queue behaviour each in their own bordered panel with an accent uppercase header (new reusable .settings-group classes), so the sections read as distinct blocks instead of one wall of text. Drops the thin divider that separated them. * docs: changelog, credits and what's new for AutoDJ standalone Fold the standalone-AutoDJ changes into the existing AutoDJ entry in the changelog and the in-app What's New, and add the credit (#1124).
86 lines
3.2 KiB
TypeScript
86 lines
3.2 KiB
TypeScript
import { describe, expect, it, beforeEach } from 'vitest';
|
|
import { useAuthStore } from '../../store/authStore';
|
|
import {
|
|
getTransitionMode,
|
|
transitionFlagsFor,
|
|
setTransitionMode,
|
|
type TransitionMode,
|
|
} from './playbackTransition';
|
|
|
|
const MODES: TransitionMode[] = ['none', 'gapless', 'crossfade', 'autodj'];
|
|
|
|
describe('getTransitionMode', () => {
|
|
it('maps each flag combination to its mode', () => {
|
|
expect(getTransitionMode({ gaplessEnabled: false, crossfadeEnabled: false, crossfadeTrimSilence: false })).toBe('none');
|
|
expect(getTransitionMode({ gaplessEnabled: true, crossfadeEnabled: false, crossfadeTrimSilence: false })).toBe('gapless');
|
|
expect(getTransitionMode({ gaplessEnabled: false, crossfadeEnabled: true, crossfadeTrimSilence: false })).toBe('crossfade');
|
|
expect(getTransitionMode({ gaplessEnabled: false, crossfadeEnabled: true, crossfadeTrimSilence: true })).toBe('autodj');
|
|
});
|
|
|
|
it('treats trim-silence as AutoDJ only while crossfade is on', () => {
|
|
// Stale trim flag with crossfade off is still "none", not AutoDJ.
|
|
expect(getTransitionMode({ gaplessEnabled: false, crossfadeEnabled: false, crossfadeTrimSilence: true })).toBe('none');
|
|
});
|
|
|
|
it('is total — gapless wins if both gapless and crossfade are set', () => {
|
|
expect(getTransitionMode({ gaplessEnabled: true, crossfadeEnabled: true, crossfadeTrimSilence: true })).toBe('gapless');
|
|
});
|
|
});
|
|
|
|
describe('transitionFlagsFor', () => {
|
|
it('round-trips through getTransitionMode for every mode', () => {
|
|
for (const mode of MODES) {
|
|
expect(getTransitionMode(transitionFlagsFor(mode))).toBe(mode);
|
|
}
|
|
});
|
|
|
|
it('never sets more than one independent behaviour at once', () => {
|
|
for (const mode of MODES) {
|
|
const f = transitionFlagsFor(mode);
|
|
// crossfade and gapless are the two independent toggles; trim only rides on crossfade
|
|
expect(f.gaplessEnabled && f.crossfadeEnabled).toBe(false);
|
|
if (f.crossfadeTrimSilence) expect(f.crossfadeEnabled).toBe(true);
|
|
}
|
|
});
|
|
});
|
|
|
|
describe('setTransitionMode', () => {
|
|
beforeEach(() => {
|
|
setTransitionMode('none');
|
|
});
|
|
|
|
it('applies the flags atomically and enforces exclusivity', () => {
|
|
setTransitionMode('crossfade');
|
|
let s = useAuthStore.getState();
|
|
expect(s.crossfadeEnabled).toBe(true);
|
|
expect(s.crossfadeTrimSilence).toBe(false);
|
|
expect(s.gaplessEnabled).toBe(false);
|
|
|
|
setTransitionMode('autodj');
|
|
s = useAuthStore.getState();
|
|
expect(s.crossfadeEnabled).toBe(true);
|
|
expect(s.crossfadeTrimSilence).toBe(true);
|
|
expect(s.gaplessEnabled).toBe(false);
|
|
|
|
setTransitionMode('gapless');
|
|
s = useAuthStore.getState();
|
|
expect(s.gaplessEnabled).toBe(true);
|
|
expect(s.crossfadeEnabled).toBe(false);
|
|
expect(s.crossfadeTrimSilence).toBe(false);
|
|
|
|
setTransitionMode('none');
|
|
s = useAuthStore.getState();
|
|
expect(s.gaplessEnabled).toBe(false);
|
|
expect(s.crossfadeEnabled).toBe(false);
|
|
expect(s.crossfadeTrimSilence).toBe(false);
|
|
});
|
|
|
|
it('preserves crossfadeSecs when switching between crossfade and autodj', () => {
|
|
useAuthStore.getState().setCrossfadeSecs(7);
|
|
setTransitionMode('crossfade');
|
|
setTransitionMode('autodj');
|
|
setTransitionMode('crossfade');
|
|
expect(useAuthStore.getState().crossfadeSecs).toBe(7);
|
|
});
|
|
});
|