mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-27 17:46:46 +00:00
d49424e95b
* feat(ui): prototype compact hero and toolbar buttons (Large/Small appearance setting) * feat(settings): rename action-button size toggle to "Compact buttons" Promote the hero-button prototype to a real, app-wide setting. - rename heroButtonSize → buttonSize, data-hero-buttons → data-button-size, hero-action-bar/hero-btn-label → compact-action-bar/compact-btn-label - relabel "Hero buttons" → "Compact buttons" and broaden the description (action + toolbar buttons across detail pages and browse views) in all 11 locales - move the feature CSS out of cover-lightbox.css into its own compact-buttons.css - add tests: themeStore buttonSize toggle, SelectionToggleButton * docs(changelog): compact buttons appearance toggle (#1189) * docs(credits): compact buttons appearance toggle (#1189)
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest';
|
|
import { render, screen } from '@testing-library/react';
|
|
import userEvent from '@testing-library/user-event';
|
|
import SelectionToggleButton from './SelectionToggleButton';
|
|
|
|
describe('SelectionToggleButton', () => {
|
|
it('shows the select label and calls onToggle on click', async () => {
|
|
const onToggle = vi.fn();
|
|
const user = userEvent.setup();
|
|
render(
|
|
<SelectionToggleButton
|
|
active={false}
|
|
onToggle={onToggle}
|
|
selectLabel="Multi-select"
|
|
cancelLabel="Cancel selection"
|
|
/>,
|
|
);
|
|
const btn = screen.getByRole('button', { name: 'Multi-select' });
|
|
await user.click(btn);
|
|
expect(onToggle).toHaveBeenCalledOnce();
|
|
});
|
|
|
|
it('shows the cancel label and active styling when active', () => {
|
|
render(
|
|
<SelectionToggleButton
|
|
active
|
|
onToggle={() => {}}
|
|
selectLabel="Multi-select"
|
|
cancelLabel="Cancel selection"
|
|
/>,
|
|
);
|
|
const btn = screen.getByRole('button', { name: 'Cancel selection' });
|
|
expect(btn).toHaveClass('btn-sort-active');
|
|
});
|
|
|
|
it('keeps the label in a toolbar-btn-label span for compact-mode hiding', () => {
|
|
render(
|
|
<SelectionToggleButton
|
|
active={false}
|
|
onToggle={() => {}}
|
|
selectLabel="Multi-select"
|
|
cancelLabel="Cancel"
|
|
/>,
|
|
);
|
|
expect(document.querySelector('.toolbar-btn-label')?.textContent).toBe('Multi-select');
|
|
});
|
|
});
|