Files
pipelines/app/test/features/terminal/terminal_tab_events_test.dart
T
alan b59ab5fad7 Terminal round 3: readable palettes, panel and card sizing, rail, tabs
- 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>
2026-11-26 02:25:16 +00:00

91 lines
3.0 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/terminal/terminal_hub.dart';
import 'package:pipelines_app/features/terminal/terminal_layout.dart';
import 'terminal_app.dart';
import 'terminal_fixtures.dart';
const _dot = ValueKey('terminal-tab-bell');
void main() {
late TerminalGateway mac;
late TerminalHub hub;
late TerminalLayout layout;
setUp(() {
mac = TerminalGateway()
..add('term_a', cwd: '/Users/op/src', text: r'$ ')
..add('term_b', cwd: '/Users/op/docs', text: r'$ ');
layout = TerminalLayout(store: MemoryLayoutStore())..visible = true;
hub = TerminalHub(
TestMachines([machine('mac', mac, name: 'Mac')]),
layout: layout,
);
});
tearDown(() async {
hub.dispose();
await mac.close();
});
/// Lets a pushed frame arrive and draw.
Future<void> drain(WidgetTester tester) async {
for (var i = 0; i < 3; i++) {
await tester.pump(const Duration(milliseconds: 1));
}
}
Future<void> open(WidgetTester tester) async {
await pumpTerminalApp(tester, hub: hub, layout: layout);
await tester.pumpAndSettle();
expect(hub.tabs, hasLength(2));
expect(hub.selected!.info.id, 'term_a');
}
testWidgets('a bell in a tab that is not shown dots it until it is '
'selected; the shown tab only flashes', (tester) async {
final semantics = tester.ensureSemantics();
await open(tester);
mac.write('term_b', '\x07');
await drain(tester);
expect(find.byKey(_dot), findsOneWidget);
expect(find.bySemanticsLabel(RegExp(r'\bBell\b')), findsOneWidget);
semantics.dispose();
// The shown terminal flashes instead.
mac.write('term_a', '\x07');
await drain(tester);
expect(find.byKey(const ValueKey('terminal-bell-flash')), findsOneWidget);
expect(find.byKey(_dot), findsOneWidget);
await tester.tap(find.text('docs'));
await tester.pumpAndSettle();
expect(find.byKey(_dot), findsNothing);
// Hidden, every tab dots; turned off, none does.
layout.hide();
await tester.pumpAndSettle();
mac.write('term_b', '\x07');
await drain(tester);
expect(hub.tabs.last.bellUnseen, isTrue);
layout.show();
await tester.pumpAndSettle();
expect(hub.tabs.last.bellUnseen, isFalse);
layout.setBell(false);
mac.write('term_a', '\x07');
await tester.pumpAndSettle();
expect(hub.tabs.first.bellUnseen, isFalse);
});
testWidgets('a folder reported with OSC 7 names an untitled tab and its '
'tooltip; a shell title still wins', (tester) async {
await open(tester);
mac.write('term_a', '\x1b]7;file://mac/Users/op/src/app\x07');
await drain(tester);
expect(find.text('app'), findsOneWidget);
expect(hub.tabs.first.cwd, '/Users/op/src/app');
expect(find.byTooltip('app\nMac: /Users/op/src/app'), findsOneWidget);
mac.write('term_a', '\x1b]0;vim notes\x07');
await drain(tester);
expect(find.text('vim notes'), findsOneWidget);
expect(find.text('app'), findsNothing);
});
}