Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
59e2a9d01This file is pinned to the selected release. Download the original to open it in your design tool.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness_mobile/core/models.dart';
import 'package:harness_mobile/phone/phone_status.dart';
import 'package:harness_mobile/phone/status_pill.dart';
import 'package:harness_mobile/phone/terminal_header.dart';
/// The terminal's top bar: *agent* over *folder ⑂ branch*, with the
/// connection state as a dot on the engine mark.
void main() {
group('the folder is named by its own name alone', () {
for (final (cwd, label) in [
(
'/Users/dudu/Bitcoin_builder/Grid/autonomous-harness',
'autonomous-harness',
),
('/home/tony/work/harness', 'harness'),
('/Users/dudu/notes', 'notes'),
('/Users/dudu', '~'),
('/root', '~'),
('~', '~'),
('/root/app', 'app'),
('/srv', 'srv'),
('/opt/tools/grid', 'grid'),
(r'C:\Users\tony\code\harness', 'harness'),
('/', '/'),
]) {
test('$cwd → $label', () => expect(projectPathLabel(cwd), label));
}
});
group('the sheet names the folder with its parent, the rest folded', () {
for (final (cwd, label) in [
(
'/Users/dudu/Bitcoin_builder/Grid/autonomous-harness/mobile',
'~/…/autonomous-harness/mobile',
),
('/home/tony/work/harness', '~/work/harness'),
('/Users/dudu/notes', '~/notes'),
('/Users/dudu', '~'),
('/root/a/b/c', '~/…/b/c'),
('/srv/app', '/srv/app'),
('/opt/tools/grid', '/…/tools/grid'),
(r'C:\Users\tony\code\harness', 'C:/…/code/harness'),
('/', '/'),
]) {
test('$cwd → $label', () => expect(projectPathTrail(cwd), label));
}
});
testWidgets('two lines, and the state on the mark', (tester) async {
final agent = Agent.fromJson({
'id': 'a',
'name': 'agent-3',
'engine': 'claude',
'project': {
'name': 'autonomous-harness',
'cwd': '/Users/dudu/Bitcoin_builder/Grid/autonomous-harness',
'branch': 'feat/mobile-ios-android',
},
});
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: TerminalHeader(
agent: agent,
status: (label: 'Live', tone: PhoneTone.good),
),
),
),
);
expect(find.text('agent-3'), findsOneWidget);
expect(find.text('autonomous-harness'), findsOneWidget);
expect(find.text('feat/mobile-ios-android'), findsOneWidget);
// No word for the state — the dot says it, and its tooltip.
expect(find.text('Live'), findsNothing);
expect(find.byType(StatusDot), findsOneWidget);
expect(find.byTooltip('Live'), findsOneWidget);
});
}