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>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
/// 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');
|
||||
});
|
||||
}
|
||||
@@ -140,6 +140,23 @@ void main() {
|
||||
expect(find.bySemanticsLabel('forest'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('popover hides -hc rows; the High contrast toggle applies the sibling (T-237)', (tester) async {
|
||||
final f2 = await KernelFixture.create(bundledThemes: [_def('midnight'), _def('midnight-hc')]);
|
||||
addTearDown(f2.dispose);
|
||||
await tester.pumpWidget(harness(f2, const ThemeSwitcherStatusItem()));
|
||||
await tester.pump();
|
||||
await tester.tap(find.bySemanticsLabel('Theme: midnight'));
|
||||
await tester.pumpAndSettle();
|
||||
// Base shown, -hc row hidden, toggle present.
|
||||
expect(find.text('midnight'), findsOneWidget);
|
||||
expect(find.text('midnight-hc'), findsNothing);
|
||||
expect(find.text('High contrast'), findsOneWidget);
|
||||
// Toggling high contrast applies the -hc sibling live.
|
||||
await tester.tap(find.bySemanticsLabel('High contrast'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(f2.services.theme.currentName, 'midnight-hc');
|
||||
});
|
||||
|
||||
testWidgets('Esc dismisses the popover without changing the theme (T-234)', (tester) async {
|
||||
await tester.pumpWidget(harness(f, const ThemeSwitcherStatusItem()));
|
||||
await tester.pump();
|
||||
|
||||
Reference in New Issue
Block a user