Files
openchamber/packages/ui/src/lib/desktopWindowControls.test.ts
T
Pablo Gonzalez 9001e38c54 feat(desktop): gate traffic-lights behind window-controls style setting
Add a Window controls Style setting ('classic' | 'traffic-lights',
default 'classic') next to the existing Position setting. All four
position×style combinations render correctly with side-driven order
(close,min,max left; min,max,close right).

- Restore deleted left-classic branch (h-8 w-8 rounded-md buttons)
- Add right-traffic-lights branch (cluster with ml-1 container)
- Branch on style instead of side in WindowsWindowControls
- Store field + setter with 'classic' default (no migration needed;
  Zustand persist shallow-merges over initial state)
- Settings UI: SettingsTwoColumn with Position chips + Style dropdown
- Sanitize on client (persistence.ts) and server (settings-helpers.js)
- 10 locale dictionaries updated (add-only, no existing keys changed)
- Traffic-light button spacing 8px→10px edge-to-edge
- Delete dead DESKTOP_WINDOW_CONTROLS_WIDTH_PX constant
2026-07-29 19:38:48 +02:00

33 lines
1.2 KiB
TypeScript

import { describe, expect, test } from 'bun:test';
import {
DEFAULT_DESKTOP_WINDOW_CONTROLS_POSITION,
getDesktopWindowControlsOrder,
normalizeDesktopWindowControlsPosition,
resolveDesktopWindowControlsSide,
} from './desktop';
describe('desktop window controls position', () => {
test('defaults to right', () => {
expect(DEFAULT_DESKTOP_WINDOW_CONTROLS_POSITION).toBe('right');
expect(resolveDesktopWindowControlsSide(undefined)).toBe('right');
expect(resolveDesktopWindowControlsSide('right')).toBe('right');
expect(resolveDesktopWindowControlsSide('left')).toBe('left');
});
test('maps legacy auto to right', () => {
expect(normalizeDesktopWindowControlsPosition('auto')).toBe('right');
expect(normalizeDesktopWindowControlsPosition('left')).toBe('left');
expect(normalizeDesktopWindowControlsPosition('right')).toBe('right');
expect(normalizeDesktopWindowControlsPosition('invalid')).toEqual(undefined);
});
test('left uses macOS traffic-light order', () => {
expect(getDesktopWindowControlsOrder('left')).toEqual(['close', 'minimize', 'maximize']);
});
test('right uses Windows order', () => {
expect(getDesktopWindowControlsOrder('right')).toEqual(['minimize', 'maximize', 'close']);
});
});