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
test(mobile): bring 24 failing tests up to date with the UI they test
Dev jacob1c6a1b2f6e24
diff --git a/mobile/test/agent_pager_attach_test.dart b/mobile/test/agent_pager_attach_test.dartindex 3535da1b2..a83ed2e85 100644--- a/mobile/test/agent_pager_attach_test.dart+++ b/mobile/test/agent_pager_attach_test.dart@@ -2,25 +2,47 @@ import 'dart:async';import 'package:flutter/material.dart';import 'package:flutter_test/flutter_test.dart';+import 'package:harness_mobile/core/models.dart';import 'package:harness_mobile/phone/agent_pane_prune.dart';import 'package:harness_mobile/phone/agent_swipe.dart';import 'package:harness_mobile/state/app_state.dart';import 'agent_pager_fixture.dart';-/// The pager holds exactly the agent being READ: no other is opened, and the one swiped away from-/// is closed.+/// The pager holds a HANDFUL of agents open — the one being read, the ones a swipe or two away, and+/// the two just left — and hands the rest back a beat after each swipe. See `AgentSwipeHost._keepSet`.////// ⚠️ **Why this has a test of its own.** The daemon keeps a single controller per agent, so an open-/// stream is a claim on that agent's terminal. The pager used to open the agent one swipe either-/// side to have its output ready before the swipe landed, and to keep every agent it had visited —-/// so reading one agent on the phone took two more away from the desktop, and a lap of the list took-/// them all.+/// stream is a claim on that agent's terminal. The pager once kept every agent it had visited, so a+/// lap of the list took them all away from the desktop.+///+/// The fixture's machine predates `terminalNoTakeoverAvailable`, so nothing here is attached AHEAD of+/// a swipe (`AppNotifier.warmAgentPane`): every open below is a page landed on.void main() {- Future<(AppNotifier, PagerConn)> pumpPager(WidgetTester tester) async {+ /// Longer than the pager's keep-set can cover — its reach either side, and the agents just left —+ /// so swiping through it leaves agents behind to close. [pagerAgentIds] is four agents that wrap,+ /// every one of them always within reach.+ const longList = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'];++ void lengthen(AppNotifier app) => app.stateOf('m')!.agents = [+ for (final id in longList)+ Agent(+ id: id,+ name: id,+ engine: 'claude',+ project: const AgentProject(name: 'work', cwd: '/work'),+ terminalAvailable: true,+ ),+ ];++ Future<(AppNotifier, PagerConn)> pumpPager(+ WidgetTester tester, {+ bool long = false,+ }) async {final conn = PagerConn();final app = pagerApp(conn);addTearDown(app.dispose);+ if (long) lengthen(app);final list = pagerList(app);await liveAgent(app, 'b');await tester.pumpWidget(@@ -127,30 +149,45 @@ void main() {expect(app.paneOfAgent('m', 'a'), isNull, reason: 'one swipe behind');});- testWidgets('closes the agent swiped away from, once the swipe has settled', (- tester,- ) async {- final (app, _) = await pumpPager(tester);- expect(app.paneOfAgent('m', 'b'), isNotNull, reason: 'the agent read');+ testWidgets(+ 'keeps the agent just left, and closes it once the swipes leave it behind',+ (tester) async {+ final (app, _) = await pumpPager(tester, long: true);+ expect(app.paneOfAgent('m', 'b'), isNotNull, reason: 'the agent read');- await swipeTo(tester, app, 'c');+ await swipeTo(tester, app, 'c');+ expect(+ app.paneOfAgent('m', 'b'),+ isNotNull,+ reason: 'just left, so going back is instant',+ );+ expect(app.paneOfAgent('m', 'c')?.session, isNotNull);- expect(- app.paneOfAgent('m', 'b'),- isNull,- reason: 'handed back to whoever wants it next',- );- expect(app.paneOfAgent('m', 'c')?.session, isNotNull);- });+ for (final agent in ['d', 'e', 'f']) {+ await swipeTo(tester, app, agent);+ }++ expect(+ app.paneOfAgent('m', 'b'),+ isNull,+ reason: 'out of reach and no longer recent: handed back',+ );+ expect(app.paneOfAgent('m', 'f')?.session, isNotNull);+ },+ );testWidgets('an agent swiped back onto is attached again, in a pushed pager',(tester) async {final (app, _) = await pushPager(tester);await swipeTo(tester, app, 'c');+ // Closed the way the prune closes it, while the page for b is still mounted beside c.+ releaseAgentPanes(app, [+ (machineId: 'm', agentId: 'b'),+ ], heldElsewhere: (_) => false);+ await tester.pump();expect(app.paneOfAgent('m', 'b'), isNull);- // The page for b is still mounted beside c, and its pane is the one just closed.await swipeTo(tester, app, 'b', towards: 400);expect(@@ -159,7 +196,7 @@ void main() {reason: 'a pane closed behind the pager is not the agent going away',);expect(app.paneOfAgent('m', 'b')?.session, isNotNull);- expect(app.paneOfAgent('m', 'c'), isNull, reason: 'closed in its turn');+ expect(app.paneOfAgent('m', 'c'), isNotNull, reason: 'just left, kept');},);}diff --git a/mobile/test/desk_tab_add_test.dart b/mobile/test/desk_tab_add_test.dartindex 9f3f3db54..220789a2f 100644--- a/mobile/test/desk_tab_add_test.dart+++ b/mobile/test/desk_tab_add_test.dart@@ -2,6 +2,8 @@ import 'package:flutter/material.dart';import 'package:flutter_test/flutter_test.dart';import 'package:harness_mobile/phone/agent_home.dart';import 'package:harness_mobile/phone/agent_tile.dart';+import 'package:harness_mobile/phone/desk_groups.dart';+import 'package:harness_mobile/phone/desk_tabs_panel.dart';import 'package:harness_mobile/phone/phone_shell_scope.dart';import 'package:harness_mobile/state/app_state.dart';import 'package:harness_mobile/state/desk_sync.dart';@@ -50,11 +52,14 @@ void main() {return app;}+ /// Open the tabs from the floating Search button — the one door to them+ /// since the header's grid mark went (see [TerminalSearchOverlay]).+ ////// ⚠️ Timed pumps, never `pumpAndSettle`: these pages draw the "Attaching…"/// skeleton, which breathes for ever. The waits are the sheets' own/// animations.Future<void> openPanel(WidgetTester tester) async {- await tester.tap(find.byTooltip('Tabs'));+ await tester.tap(find.byKey(const ValueKey('terminal-search')));await tester.pump();await tester.pump(const Duration(milliseconds: 400));}@@ -80,9 +85,12 @@ void main() {await tester.pump(const Duration(milliseconds: 400));}- /// An agent's row, wherever it is drawn.+ /// An agent's row, wherever it is drawn: a [DeskAgentRow] in the tabs, an+ /// [AgentTile] in the sheet that adds one to a tab.Finder row(String agent) => find.byWidgetPredicate(- (widget) => widget is AgentTile && widget.agent.id == agent,+ (widget) =>+ (widget is DeskAgentRow && widget.entry.agent.id == agent) ||+ (widget is AgentTile && widget.agent.id == agent),);testWidgets('the + on the tab row opens a tab holding the agent picked', (@@ -192,10 +200,12 @@ void main() {) async {await pumpHome(tester, tabs: [deskTab('t1', 'Empty', [])]);+ // Every agent is outside this tab, so the one on screen is in none — and+ // the panel falls back to the first tab, this one.+ //+ // ⚠️ Not tapped to: a tap on the tab already shown arms the rename+ // double-tap, whose timer outlives the test.await openPanel(tester);- // The panel opens on the group holding the agent on screen, which is the- // leftover one — every agent is outside this tab.- await showTab(tester, 'Empty');expect(find.text('This tab has no harnesses yet.'), findsOneWidget);expect(@@ -223,7 +233,8 @@ void main() {await showTab(tester, 'Docker');await doubleTap(tester, 'Docker');- await tester.enterText(find.byType(TextField), 'Servers');+ // The dialog's field: the sheet's own search field is under it.+ await tester.enterText(find.byType(TextField).last, 'Servers');await tester.tap(find.text('Save'));await tester.pump();await tester.pump(const Duration(milliseconds: 400));@@ -250,7 +261,8 @@ void main() {await openPanel(tester);await doubleTap(tester, 'Desktop');- await tester.enterText(find.byType(TextField), ' ');+ // The dialog's field: the sheet's own search field is under it.+ await tester.enterText(find.byType(TextField).last, ' ');await tester.tap(find.text('Save'));await tester.pump();await tester.pump(const Duration(milliseconds: 400));@@ -259,42 +271,35 @@ void main() {expect(find.text('Desktop'), findsOneWidget);});- testWidgets('the agents no tab holds cannot be renamed', (tester) async {- final app = await pumpHome(- tester,- tabs: [- deskTab('t1', 'Desktop', ['a']),- ],- );+ // ⚠️ The agents no tab holds are no group any more (see [deskGroups]); the+ // one group that is not a tab is the single one of an account with no tabs.+ testWidgets('the one group of an account with no tabs cannot be renamed', (+ tester,+ ) async {+ final app = await pumpHome(tester, tabs: []);await openPanel(tester);- await showTab(tester, 'Other');- await doubleTap(tester, 'Other');+ await doubleTap(tester, kEveryAgentGroupName);- // "Other" is not a tab on the desk — there is no name to write.- expect(find.byType(TextField), findsNothing);+ // Not a tab on the desk — there is no name to write.+ expect(find.text('Save'), findsNothing);expect(deskApiOf(app).written, isEmpty);});- testWidgets('the agents no tab holds are offered no + of their own', (- tester,- ) async {- await pumpHome(- tester,- tabs: [- deskTab('t1', 'Desktop', ['a']),- ],- );+ testWidgets('an account with no tabs is offered a new harness, not a + '+ 'into a tab', (tester) async {+ await pumpHome(tester, tabs: []);await openPanel(tester);- await showTab(tester, 'Other');- // "Other" is not a tab — there is nothing on the desk to add an agent to.+ // Not a tab — there is nothing on the desk to add an agent to...expect(find.textContaining('Add harness to'), findsNothing);+ // ...but a harness can still be started from it.+ expect(find.bySemanticsLabel('New harness, in no tab'), findsOneWidget);expect(find.bySemanticsLabel('New tab'),findsOneWidget,- reason: 'the tab row keeps its own +, whichever group is being read',+ reason: 'the tab row keeps its own +, so the first tab can be made',);});}diff --git a/mobile/test/phone_desk_tabs_test.dart b/mobile/test/phone_desk_tabs_test.dartindex c3e003cf3..d3e300482 100644--- a/mobile/test/phone_desk_tabs_test.dart+++ b/mobile/test/phone_desk_tabs_test.dart@@ -4,9 +4,9 @@ import 'package:flutter/material.dart';import 'package:flutter_test/flutter_test.dart';import 'package:harness_mobile/phone/agent_home.dart';import 'package:harness_mobile/phone/agent_swipe.dart';+import 'package:harness_mobile/phone/desk_groups.dart';import 'package:harness_mobile/phone/desk_tab_strip.dart';-import 'package:harness_mobile/phone/agent_tile.dart';-import 'package:harness_mobile/phone/terminal_header.dart';+import 'package:harness_mobile/phone/desk_tabs_panel.dart';import 'package:harness_mobile/phone/phone_shell_scope.dart';import 'package:harness_mobile/state/app_state.dart';import 'package:harness_mobile/state/desk_sync.dart';@@ -16,7 +16,7 @@ import 'desk_fixture.dart';import 'voice_fakes.dart';/// The home screen inside its tab: a swipe walks the tab the phone is in, and-/// the mark beside `⋯` opens the panel that reaches the others.+/// the floating Search button opens the panel that reaches the others.////// ⚠️ **The pager's `neighbours` is the assertion throughout, because it IS the/// swipe.** [AgentSwipeHost] pages through exactly that list and nothing else,@@ -58,7 +58,8 @@ void main() {AgentSwipeHost pager(WidgetTester tester) =>tester.widget<AgentSwipeHost>(find.byType(AgentSwipeHost));- /// Open the tabs panel from the mark in the header — see [showDeskTabsPopup].+ /// Open the tabs panel from the floating Search button — the one door to it+ /// since the header's grid mark went (see [TerminalSearchOverlay]).////// ⚠️ **Timed pumps, never `pumpAndSettle`.** These pages have no terminal/// behind them (see [deskApp]), so each one draws the "Attaching…" skeleton —@@ -66,7 +67,7 @@ void main() {/// never comes. The waits below are the panel's own open and dismiss/// animations.Future<void> openPanel(WidgetTester tester) async {- await tester.tap(find.byTooltip('Tabs'));+ await tester.tap(find.byKey(const ValueKey('terminal-search')));await tester.pump();await tester.pump(const Duration(milliseconds: 400));}@@ -80,7 +81,7 @@ void main() {/// An agent's row in the open panel.Finder row(String agent) => find.byWidgetPredicate(- (widget) => widget is AgentTile && widget.agent.id == agent,+ (widget) => widget is DeskAgentRow && widget.entry.agent.id == agent,);/// Tap an agent's row, which opens it and takes the panel away.@@ -95,8 +96,10 @@ void main() {/// The agents the panel is offering, in the order it lists them.List<String> agentsShown(WidgetTester tester) => [- for (final tile in tester.widgetList<AgentTile>(find.byType(AgentTile)))- tile.agent.id,+ for (final row in tester.widgetList<DeskAgentRow>(+ find.byType(DeskAgentRow),+ ))+ row.entry.agent.id,];List<String> swipesOver(WidgetTester tester) => [@@ -259,7 +262,7 @@ void main() {expect(tester.getTopLeft(find.byType(DeskTabStrip)).dy, names);});- testWidgets('the agent on screen keeps its row, and wears the rim', (+ testWidgets('the agent on screen keeps its row, and wears the check', (tester,) async {await pumpHome(@@ -273,11 +276,11 @@ void main() {await openPanel(tester);expect(- tester.widget<AgentTile>(row('a')).border,- isNotNull,+ tester.widget<DeskAgentRow>(row('a')).onScreen,+ isTrue,reason: 'the agent on screen',);- expect(tester.widget<AgentTile>(row('b')).border, isNull);+ expect(tester.widget<DeskAgentRow>(row('b')).onScreen, isFalse);});testWidgets('a tab this phone cannot reach is listed, and says why', (@@ -299,17 +302,23 @@ void main() {expect(find.textContaining('asleep'), findsOneWidget);});- testWidgets('an account with no tabs is offered none', (tester) async {- // Nothing on the desk: the panel would hold one tab over every agent on- // the account, which is what a swipe already walks. So no mark at all, and- // the header is the row it has always been.+ testWidgets('an account with no tabs is offered one group over them all', (+ tester,+ ) async {+ // Nothing on the desk: the panel holds one group over every agent on the+ // account, which is what a swipe already walks.await pumpHome(tester, tabs: []);-- expect(find.byTooltip('Tabs'), findsNothing);expect(swipesOver(tester), ['a', 'b', 'c', 'd']);++ await openPanel(tester);++ expect(strip(tester).groups.map((group) => group.name), [+ kEveryAgentGroupName,+ ]);+ expect(agentsShown(tester), ['a', 'b', 'c', 'd']);});- testWidgets('the tabs mark sits in the header, not over the terminal', (+ testWidgets('the tabs are a sheet over the terminal, not a row above it', (tester,) async {await pumpHome(@@ -320,15 +329,13 @@ void main() {],);- // One mark, inside the header's own row — nothing is stacked under it, so- // the terminal keeps every line it had before the desk existed.- final mark = find.byTooltip('Tabs');- expect(mark, findsOneWidget);- expect(- tester.getCenter(mark).dy,- lessThan(TerminalHeader.height),- reason: 'the mark rides the header row',- );+ // Nothing is stacked under the header until the Search button is tapped,+ // so the terminal keeps every line it had before the desk existed.+ expect(find.byType(DeskTabStrip), findsNothing);++ await openPanel(tester);++ expect(find.byType(DeskTabStrip), findsOneWidget);});testWidgets('a tab changed on another computer moves the swipe with it', (diff --git a/mobile/test/phone_search_test.dart b/mobile/test/phone_search_test.dartindex 93786de23..925e3d53d 100644--- a/mobile/test/phone_search_test.dart+++ b/mobile/test/phone_search_test.dart@@ -1192,6 +1192,10 @@ void main() {addTearDown(app.dispose);await tester.pumpWidget(MaterialApp(home: field(app)));await tester.pump();+ // The terminal's sheet opens on its tabs, and a tap on the field is what+ // brings the keyboard there — so the field is tapped on both.+ await tester.tap(find.byType(TextField));+ await tester.pump();return tester.testTextInput.setClientArgs!;}@@ -1222,7 +1226,10 @@ void main() {}});- testWidgets('terminal search: the same one bar, its chevron closes it', (+ // ⚠️ **The sheet's own bar, not the page's.** No chevron in it: Cancel ends+ // the SEARCH and leaves the sheet up on its tabs, and Back steps out of the+ // search first and closes the sheet only after — never leaves the agent.+ testWidgets('terminal search: Cancel ends the search, Back then the sheet', (tester,) async {final app = _app([@@ -1242,11 +1249,37 @@ void main() {),);await tester.pump();- expect(find.byType(PhoneSearchField), findsOneWidget);+ expect(find.byType(SheetSearchField), findsOneWidget);+ expect(find.byType(PhoneSearchField), findsNothing);expect(find.text('Cancel'), findsNothing);- await tester.tap(find.bySemanticsLabel('Back'));+ // A tap on the field starts a search; Cancel slides in over 250ms.+ Future<void> search() async {+ await tester.tap(find.byType(TextField));+ await tester.pump();+ await tester.pump(const Duration(milliseconds: 400));+ expect(find.text('Cancel'), findsOneWidget);+ }++ Future<void> back() async {+ await tester.binding.handlePopRoute();+ await tester.pump();+ await tester.pump(const Duration(milliseconds: 400));+ }++ await search();+ await tester.tap(find.text('Cancel'));await tester.pump();+ await tester.pump(const Duration(milliseconds: 400));+ expect(find.text('Cancel'), findsNothing);+ expect(closed, 0);++ await search();+ await back();+ expect(find.text('Cancel'), findsNothing);+ expect(closed, 0);++ await back();expect(closed, 1);});diff --git a/mobile/test/terminal_page_header_fold_test.dart b/mobile/test/terminal_page_header_fold_test.dartindex 38f155b95..7a7be689c 100644--- a/mobile/test/terminal_page_header_fold_test.dart+++ b/mobile/test/terminal_page_header_fold_test.dart@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';import 'package:flutter_test/flutter_test.dart';import 'package:harness_mobile/auth/auth_session.dart';import 'package:harness_mobile/core/config.dart';+import 'package:harness_mobile/phone/phone_search_field.dart';import 'package:harness_mobile/phone/phone_search_results.dart';import 'package:harness_mobile/phone/terminal_action_column.dart';import 'package:harness_mobile/phone/terminal_header.dart';@@ -155,6 +156,16 @@ void main() {await tester.tap(find.byKey(const ValueKey('terminal-search')));await tester.pump();+ await tester.pump(const Duration(milliseconds: 400));+ // The sheet opens on its tabs; a tap on its field is what starts a search+ // and brings the keyboard.+ await tester.tap(+ find.descendant(+ of: find.byType(SheetSearchField),+ matching: find.byType(TextField),+ ),+ );+ await tester.pump();addTearDown(tester.view.resetViewInsets);for (final inset in const [300.0, 600.0, 900.0]) {tester.view.viewInsets = FakeViewPadding(bottom: inset);@@ -173,7 +184,16 @@ void main() {// inset it reports falls over ~0.5s — past the end of search's fade. Every// frame, through the fade AND after it, shows the terminal search opened// over; releasing it with the fade let the falling inset raise its key bar.- await tester.tap(find.bySemanticsLabel('Back'));+ //+ // The sheet has no chevron: it is flung shut from its grip, the one close+ // that leaves with the keyboard still up. The grip is the strip directly+ // above the field.+ final field = tester.getRect(find.byType(SheetSearchField));+ await tester.flingFrom(+ field.topCenter - const Offset(0, 8),+ const Offset(0, 300),+ 2000,+ );await tester.pump();for (var ms = 0; ms <= 700; ms += 16) {tester.view.viewInsets = FakeViewPadding(@@ -184,6 +204,7 @@ void main() {}await tester.pump(const Duration(seconds: 1));expect(find.byType(PhoneSearchResults), findsNothing);+ expect(find.byType(SheetSearchField), findsNothing);expectUntouched();expect(resizes, isEmpty);});diff --git a/mobile/test/voice_input_controller_test.dart b/mobile/test/voice_input_controller_test.dartindex 46a952e1e..6deb5f5b3 100644--- a/mobile/test/voice_input_controller_test.dart+++ b/mobile/test/voice_input_controller_test.dart@@ -3,6 +3,7 @@ import 'dart:async';import 'package:flutter/foundation.dart';import 'package:flutter_test/flutter_test.dart';import 'package:harness_mobile/phone/voice_input_controller.dart';+import 'package:harness_mobile/phone/voice_mic_mode.dart';import 'package:harness_mobile/phone/voice_notice.dart';import 'voice_fakes.dart';@@ -214,6 +215,14 @@ void main() {});group('the retry face, held to talk', () {+ // ⚠️ **A tap is a brushed button only when the mic is held to talk** —+ // [VoiceInputController.minTake] is zero in tap mode, the mode the app is+ // built in ([voiceMicMode]), because a short "yes" IS the message there. In+ // that mode the 120ms takes below are judged as speech (silence, here), and+ // the retry face sends its held words on a plain tap instead — `_tapAction`,+ // covered in `voice_mic_fab_test.dart`.+ final holdOnly = micHoldsToTalk ? null : 'hold-to-talk only';+Future<void> failOneSend() async {backend.replies.add('deploy');await voice.startListening();@@ -242,7 +251,7 @@ void main() {expect(delivered, ['deploy']);expect(voice.isIdle, isTrue);expect(backend.calls, hasLength(1), reason: 'a tap is not uploaded');- });+ }, skip: holdOnly);test('a take that failed still sends none of the message', () async {await failOneSend();@@ -269,7 +278,7 @@ void main() {expect(delivered, isFalse);expect(voice.notice, isNull, reason: 'a brushed button is not reported');- });+ }, skip: holdOnly);});test('clearing mid-transcription drops the words when they arrive', () async {diff --git a/mobile/test/voice_mic_fab_test.dart b/mobile/test/voice_mic_fab_test.dartindex 39566de12..fa85559db 100644--- a/mobile/test/voice_mic_fab_test.dart+++ b/mobile/test/voice_mic_fab_test.dart@@ -111,12 +111,21 @@ void main() {session.notifyListeners();await tester.pump();await tester.tap(mic);- await tester.pumpAndSettle();+ // Timed pumps, not `pumpAndSettle`: the capsule animates for as long as+ // the notice is up, so settling would run the clock past+ // [VoiceInputController.noticeLinger] and read the row after it cleared.+ await tester.pump();+ await tester.pump(const Duration(milliseconds: 400));expect(sentTurns(), isEmpty);expect(voice.transcript, 'ship it');expect(voice.notice, VoiceNotice.notSent);+ // The notice goes by itself; the words it was about stay for the retry.+ await tester.pump(VoiceInputController.noticeLinger);+ expect(voice.notice, isNull);+ expect(voice.transcript, 'ship it');+session.status = TerminalSessionStatus.controlling;session.notifyListeners();await tester.pump();