The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
// Settings ▸ Terminal, after it was rebuilt on the app's own `SettingRow`.
//
// Like `settings_screen_test.dart`, this NEVER calls a mutating method on
// `terminalFontStore`: that singleton persists through the real
// `HarnessFileStore`, i.e. the user's actual `~/.harness/desktop-app/state.json`.
// Everything here reads the store's untouched default, so the size stepper is
// exercised at 13pt (both buttons live) rather than driven to a bound.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/settings/sections/terminal_section.dart';
import 'package:harness/shared/theme/app_theme.dart';
import 'package:harness/shared/widgets/app_select_field.dart';
import 'package:harness/terminal/installed_fonts.dart';
import 'package:harness/terminal/terminal_font_store.dart';
import 'package:harness/terminal/terminal_theme_store.dart';
/// The terminal sample remains independent of the app's text scale.
final _sample = find.byWidgetPredicate(
(w) =>
w is Text &&
(w.textSpan?.toPlainText().startsWith('agent@harness') ?? false),
);
Widget _host({double textScale = 1.0}) => MaterialApp(
theme: buildAppTheme(brightness: Brightness.light),
home: Builder(
builder: (context) {
AppTheme.brightness.value = Brightness.light;
return BrightnessScope(
child: MediaQuery(
data: MediaQueryData(textScaler: TextScaler.linear(textScale)),
// The pane the settings rail leaves for a section at the window's
// own minimum width.
child: const Scaffold(
body: SizedBox(width: 820, height: 700, child: TerminalSection()),
),
),
);
},
),
);
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
testWidgets('terminal selectors announce purpose independently of value', (
tester,
) async {
final semantics = tester.ensureSemantics();
try {
await tester.pumpWidget(_host());
await tester.pumpAndSettle();
final colors = tester
.getSemantics(find.bySemanticsLabel('Terminal colors'))
.getSemanticsData();
final font = tester
.getSemantics(find.bySemanticsLabel('Terminal font'))
.getSemanticsData();
expect(colors.label, 'Terminal colors');
expect(colors.value, terminalThemeStore.value.label);
expect(font.label, 'Terminal font');
expect(font.value, terminalFontStore.selection.label);
} finally {
semantics.dispose();
}
});
testWidgets('the pane lays out with no overflow at the window minimum', (
tester,
) async {
tester.view.physicalSize = const Size(820 * 2, 700 * 2);
tester.view.devicePixelRatio = 2;
addTearDown(tester.view.reset);
await tester.pumpWidget(_host());
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
expect(find.text('Colors'), findsOneWidget);
expect(find.text('Font'), findsOneWidget);
expect(find.text('Size'), findsOneWidget);
expect(find.text('Preview'), findsOneWidget);
expect(_sample, findsOneWidget);
});
testWidgets('every colour scheme is offered, and the default is on', (
tester,
) async {
tester.view.physicalSize = const Size(820 * 2, 700 * 2);
tester.view.devicePixelRatio = 2;
addTearDown(tester.view.reset);
await tester.pumpWidget(_host());
await tester.pumpAndSettle();
// Unlike the font list, this one has no per-platform filter to get wrong:
// colours resolve the same everywhere, so every value must be reachable.
final field = tester.widget<AppSelectField<TerminalThemeChoice>>(
find.byKey(const Key('terminal-colour-scheme-dropdown')),
);
expect(
field.options.map((option) => option.value),
TerminalThemeChoice.values,
);
expect(field.value, terminalThemeStore.value);
// The store is the real singleton — see this file's header. Read only.
expect(terminalThemeStore.value, TerminalThemeChoice.fallback);
expect(find.text('Match app appearance'), findsWidgets);
});
testWidgets(
'the font list is the presets, then installed monospaced faces, then the rest',
(tester) async {
debugResetInstalledFonts();
debugFontLister = () async => [
const InstalledFont('Helvetica', monospace: false),
const InstalledFont('PT Mono', monospace: true),
// Duplicate a preset available on this host. Menlo is not a Linux preset.
InstalledFont(
TerminalFontChoice.available.first.label,
monospace: true,
),
const InstalledFont('Andale Mono', monospace: true),
];
addTearDown(() {
debugFontLister = null;
debugResetInstalledFonts();
});
tester.view.physicalSize = const Size(820 * 2, 700 * 2);
tester.view.devicePixelRatio = 2;
addTearDown(tester.view.reset);
await tester.pumpWidget(_host());
await tester.pumpAndSettle();
final field = tester.widget<AppSelectField<TerminalFontSelection>>(
find.byKey(const Key('terminal-font-family-dropdown')),
);
expect(field.filterable, isTrue);
expect(field.options.map((option) => option.label), [
for (final choice in TerminalFontChoice.available) choice.label,
'Andale Mono',
'PT Mono',
'Helvetica',
]);
// Read only — the store is the real singleton, see this file's header.
expect(field.value, terminalFontStore.selection);
},
);
testWidgets('the preview refuses the app-wide text scale', (tester) async {
// The fifth seam named in `appearance_section.dart`, and the one nothing
// guarded: the preview exists to show the size the TERMINAL will render
// at, so a sample that grew with the app's UI scale would advertise a size
// the terminal never draws.
tester.view.physicalSize = const Size(820 * 2, 700 * 2);
tester.view.devicePixelRatio = 2;
addTearDown(tester.view.reset);
await tester.pumpWidget(_host());
await tester.pumpAndSettle();
final resting = tester.getSize(_sample);
await tester.pumpWidget(_host(textScale: 2.0));
await tester.pumpAndSettle();
final scaled = tester.getSize(_sample);
expect(
scaled,
resting,
reason:
'the preview is drawn at the terminal font size, not the app text '
'scale — see TextScaler.noScaling in _Screen',
);
});
testWidgets('Reset is dead while the pick already IS the default', (
tester,
) async {
tester.view.physicalSize = const Size(820 * 2, 700 * 2);
tester.view.devicePixelRatio = 2;
addTearDown(tester.view.reset);
await tester.pumpWidget(_host());
await tester.pumpAndSettle();
expect(terminalFontStore.isDefault, isTrue);
final reset = tester.widget<OutlinedButton>(
find.byKey(const Key('terminal-settings-reset-button')),
);
expect(
reset.onPressed,
isNull,
reason: 'a Reset that would change nothing should not look pressable',
);
});
}