mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 07:15:47 +00:00
fix(eq): show the active AutoEQ profile name in the preset picker (#1147)
* fix(eq): surface the active AutoEQ profile name in the preset picker * i18n(settings): add AutoEQ preset group label (10 locales) * docs(changelog): AutoEQ active-profile picker fix (#1147)
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
||||
import { cleanup, screen } from '@testing-library/react';
|
||||
import { renderWithProviders } from '../test/helpers/renderWithProviders';
|
||||
import Equalizer from './Equalizer';
|
||||
import { useEqStore } from '../store/eqStore';
|
||||
|
||||
const FLAT = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||
|
||||
function resetEq(over: Record<string, unknown> = {}): void {
|
||||
useEqStore.setState({
|
||||
gains: [...FLAT],
|
||||
enabled: true,
|
||||
preGain: 0,
|
||||
activePreset: 'Flat',
|
||||
customPresets: [],
|
||||
...over,
|
||||
});
|
||||
}
|
||||
|
||||
describe('Equalizer preset picker', () => {
|
||||
beforeEach(() => resetEq());
|
||||
afterEach(() => cleanup());
|
||||
|
||||
it('shows the active AutoEQ profile name in the picker', () => {
|
||||
// AutoEQ sets activePreset to the headphone name — neither a built-in nor a
|
||||
// saved custom preset. It must still be visible in the picker.
|
||||
resetEq({ activePreset: 'Sennheiser HD 600', customPresets: [] });
|
||||
const { container } = renderWithProviders(<Equalizer />);
|
||||
|
||||
expect(screen.getByText('Sennheiser HD 600')).toBeInTheDocument();
|
||||
// AutoEQ profiles are not deletable custom presets → no delete button.
|
||||
expect(container.querySelector('[data-tooltip="Delete preset"]')).toBeNull();
|
||||
});
|
||||
|
||||
it('shows the delete button only for a saved custom preset', () => {
|
||||
resetEq({
|
||||
activePreset: 'My Mix',
|
||||
customPresets: [{ name: 'My Mix', gains: [...FLAT], builtin: false }],
|
||||
});
|
||||
const { container } = renderWithProviders(<Equalizer />);
|
||||
|
||||
expect(screen.getByText('My Mix')).toBeInTheDocument();
|
||||
expect(container.querySelector('[data-tooltip="Delete preset"]')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('shows no delete button for a built-in preset', () => {
|
||||
resetEq({ activePreset: 'Rock' });
|
||||
const { container } = renderWithProviders(<Equalizer />);
|
||||
|
||||
expect(container.querySelector('[data-tooltip="Delete preset"]')).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -55,7 +55,12 @@ export default function Equalizer() {
|
||||
return () => details.removeEventListener('toggle', onToggle);
|
||||
}, [redraw]);
|
||||
|
||||
const isCustomSaved = activePreset && !BUILTIN_PRESETS.some(p => p.name === activePreset);
|
||||
const isCustomSaved = activePreset !== null && customPresets.some(p => p.name === activePreset);
|
||||
const isBuiltin = activePreset !== null && BUILTIN_PRESETS.some(p => p.name === activePreset);
|
||||
// AutoEQ profiles store the headphone name in activePreset, which is neither a
|
||||
// built-in nor a saved custom preset — surface it in the picker so the active
|
||||
// profile name stays visible after the lookup clears.
|
||||
const isAutoEq = activePreset !== null && !isBuiltin && !isCustomSaved;
|
||||
const selectValue = activePreset ?? '__custom__';
|
||||
|
||||
const handleSave = () => {
|
||||
@@ -85,6 +90,7 @@ export default function Equalizer() {
|
||||
onChange={v => applyPreset(v)}
|
||||
options={[
|
||||
...(activePreset === null ? [{ value: '__custom__', label: t('settings.eqPresetCustom'), disabled: true }] : []),
|
||||
...(isAutoEq ? [{ value: activePreset!, label: activePreset!, group: t('settings.eqPresetAutoEqGroup') }] : []),
|
||||
...BUILTIN_PRESETS.map(p => ({ value: p.name, label: p.name, group: t('settings.eqPresetBuiltin') })),
|
||||
...customPresets.map(p => ({ value: p.name, label: p.name, group: t('settings.eqPresetCustomGroup') })),
|
||||
]}
|
||||
|
||||
Reference in New Issue
Block a user