b59ab5fad7
- Colours: terminal background is the theme's lowest surface; the 16 ANSI colours come from a chosen palette (Theme colours, Classic, Calm, Vivid; Settings > Terminal > Colours, saved as `palette`) adjusted in lightness to the background: colours 4.5:1, bright ones lighter than normal, white light and black dark in both themes so white-on-red/blue/magenta and black-on-green/yellow/cyan (ls setuid, setgid, sticky) keep 3:1. Selection, find matches and the current match keep text at 4.5:1. - Bottom panel opens at 40% of the window, at least 16 rows, until dragged; the dragged height is remembered (old saved 300 px default reads as never resized). - Navigation rail scrolls its tabs (and below 240 px Settings too), so items never overlap under a tall panel. - Chat command cards: Expand / Collapse grows a live terminal to 60% of the window (finished output only to its rows); collapsed stays 12 rows. - Terminal tabs: ellipsised titles (220 px) with the whole title in the tooltip, selected tab filled, outlined and bold, close buttons are IconButtons (48 px touch, 40 px desktop). - Capture fixture: ?terminalColors=1 and ?terminalPalette=. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
125 lines
4.0 KiB
Dart
125 lines
4.0 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/features/settings/settings_terminal_section.dart';
|
|
import 'package:pipelines_app/features/terminal/terminal_layout.dart';
|
|
|
|
class _Store implements TerminalLayoutStore {
|
|
String? saved;
|
|
@override
|
|
Future<String?> load() async => saved;
|
|
@override
|
|
Future<bool> save(String value) async {
|
|
saved = value;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
void main() {
|
|
late _Store store;
|
|
late TerminalLayout layout;
|
|
|
|
setUp(() {
|
|
store = _Store();
|
|
layout = TerminalLayout(store: store);
|
|
});
|
|
|
|
Future<void> pump(WidgetTester tester) async {
|
|
tester.view.physicalSize = const Size(900, 1400);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: Scaffold(
|
|
body: SingleChildScrollView(
|
|
child: SettingsTerminalSection(layout: layout),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> saved() =>
|
|
jsonDecode(store.saved!) as Map<String, dynamic>;
|
|
|
|
testWidgets('text size, scrollback and the visual bell are chosen in '
|
|
'Settings and saved with the layout', (tester) async {
|
|
await pump(tester);
|
|
expect(find.text('Text size'), findsOneWidget);
|
|
expect(find.text('Scrollback'), findsOneWidget);
|
|
await tester.tap(find.byType(DropdownMenu<double>));
|
|
await tester.pumpAndSettle();
|
|
await tester.tap(find.text('16 pt').last);
|
|
await tester.pumpAndSettle();
|
|
expect(layout.fontSize, 16);
|
|
expect(saved()['font_size'], 16);
|
|
await tester.tap(find.byType(DropdownMenu<int>));
|
|
await tester.pumpAndSettle();
|
|
await tester.tap(find.text('50k lines').last);
|
|
await tester.pumpAndSettle();
|
|
expect(layout.scrollback, 50000);
|
|
expect(saved()['scrollback'], 50000);
|
|
await tester.tap(find.byKey(const ValueKey('settings-terminal-bell')));
|
|
await tester.pumpAndSettle();
|
|
expect(layout.bell, isFalse);
|
|
final restored = TerminalLayout(store: store);
|
|
await restored.restore();
|
|
expect(restored.fontSize, 16);
|
|
expect(restored.scrollback, 50000);
|
|
expect(restored.bell, isFalse);
|
|
// Default text size clears it.
|
|
await tester.tap(find.byType(DropdownMenu<double>));
|
|
await tester.pumpAndSettle();
|
|
await tester.tap(find.text('Default').last);
|
|
await tester.pumpAndSettle();
|
|
expect(layout.fontSize, isNull);
|
|
expect(saved().containsKey('font_size'), isFalse);
|
|
});
|
|
|
|
testWidgets('the colour palette is chosen in Settings, saved and '
|
|
'restored', (tester) async {
|
|
await pump(tester);
|
|
expect(find.text('Colours'), findsOneWidget);
|
|
await tester.tap(find.byType(DropdownMenu<TerminalPalette>));
|
|
await tester.pumpAndSettle();
|
|
for (final palette in TerminalPalette.values) {
|
|
expect(find.text(palette.label), findsWidgets);
|
|
}
|
|
await tester.tap(find.text('Calm').last);
|
|
await tester.pumpAndSettle();
|
|
expect(layout.palette, TerminalPalette.calm);
|
|
expect(saved()['palette'], 'calm');
|
|
final restored = TerminalLayout(store: store);
|
|
await restored.restore();
|
|
expect(restored.palette, TerminalPalette.calm);
|
|
});
|
|
|
|
test('an unknown saved palette restores the theme colours', () async {
|
|
store.saved = jsonEncode({'palette': 'nonesuch'});
|
|
await layout.restore();
|
|
expect(layout.palette, TerminalPalette.theme);
|
|
});
|
|
|
|
testWidgets('a zoom from the keyboard shows in the menu at once', (
|
|
tester,
|
|
) async {
|
|
await pump(tester);
|
|
layout.setFontSize(17);
|
|
await tester.pump();
|
|
final menu = tester.widget<DropdownMenu<double>>(
|
|
find.byType(DropdownMenu<double>),
|
|
);
|
|
expect(menu.initialSelection, 17);
|
|
});
|
|
|
|
test('a saved scrollback outside the choices and sizes out of range are '
|
|
'not restored as they were', () async {
|
|
store.saved = jsonEncode({'scrollback': 7, 'font_size': 400});
|
|
await layout.restore();
|
|
expect(layout.scrollback, terminalScrollbackDefault);
|
|
expect(layout.fontSize, terminalFontSizeMax);
|
|
expect(layout.bell, isTrue);
|
|
});
|
|
}
|