Files
clide/test/builtin/theme_picker/theme_families_test.dart
T
jpmschweitzerandClaude Opus 4.8 5fcc42bd8c tidy the theme switcher popover (T-237)
Per demo feedback on the T-234 status-bar popover: collapse the -hc
theme rows into a single 'High contrast' toggle at the top (applies the
chosen base theme's -hc sibling live, falling back to the base when none
exists); list base themes only, sorted by display name; widen 240->280
and ellipsize rows so 'Catppuccin Mocha' no longer wraps; swap the swatch
dot for the Phosphor palette icon; lowercase the bar label to match the
all-lowercase status bar (proper case kept in the a11y label).

New pure theme_families helpers (base/sibling/resolve), unit-tested.
Modal picker_view consistency + the status-bar right-alignment remain on
T-237.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-03 22:46:17 +02:00

44 lines
1.7 KiB
Dart

/// Tests for the theme-family helpers (T-237).
library;
import 'package:clide/builtin/theme_picker/src/theme_families.dart';
import 'package:clide/kernel/kernel.dart';
import 'package:test/test.dart';
ThemeDefinition _def(String name, String display) => ThemeDefinition(name: name, displayName: display, dark: true, palette: Palette(const {}));
void main() {
final all = [
_def('clide', 'Clide'),
_def('clide-hc', 'Clide (high contrast)'),
_def('midnight', 'Midnight'),
_def('midnight-hc', 'Midnight (high contrast)'),
_def('catppuccin-mocha', 'Catppuccin Mocha'),
_def('catppuccin-mocha-hc', 'Catppuccin Mocha (high contrast)'),
_def('paper', 'Paper'), // no -hc sibling in this fixture
];
test('isHcName / baseThemeName', () {
expect(isHcName('midnight-hc'), isTrue);
expect(isHcName('midnight'), isFalse);
expect(baseThemeName('midnight-hc'), 'midnight');
expect(baseThemeName('catppuccin-mocha-hc'), 'catppuccin-mocha');
expect(baseThemeName('clide'), 'clide');
});
test('baseThemes drops -hc/-cb and sorts by display name', () {
final bases = baseThemes(all).map((t) => t.name).toList();
expect(bases, ['catppuccin-mocha', 'clide', 'midnight', 'paper']); // alphabetical by display
expect(bases.any(isHcName), isFalse);
});
test('hasHcSibling + resolveThemeName', () {
expect(hasHcSibling(all, 'midnight'), isTrue);
expect(hasHcSibling(all, 'paper'), isFalse);
expect(resolveThemeName(all, 'midnight', highContrast: true), 'midnight-hc');
expect(resolveThemeName(all, 'midnight', highContrast: false), 'midnight');
// No sibling → falls back to the base even when high contrast is on.
expect(resolveThemeName(all, 'paper', highContrast: true), 'paper');
});
}