From c1e0de352a79c16b8633ed877e1fb4d9cf52254f Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Fri, 6 Nov 2026 18:15:18 +0000 Subject: [PATCH] Check Cupertino search shortcut focus across query updates --- app/test/shell/search_shortcuts_test.dart | 55 +++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/app/test/shell/search_shortcuts_test.dart b/app/test/shell/search_shortcuts_test.dart index e788a6fa..69d3e381 100644 --- a/app/test/shell/search_shortcuts_test.dart +++ b/app/test/shell/search_shortcuts_test.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/core/api_gateway.dart'; @@ -129,4 +130,58 @@ void main() { variant: TargetPlatformVariant.only(platform), ); } + testWidgets( + 'Cupertino Command slash retains primary focus after query updates', + (tester) async { + final composer = TextEditingController(text: 'draft'); + final focus = FocusNode(); + addTearDown(composer.dispose); + addTearDown(focus.dispose); + await tester.pumpWidget( + CupertinoApp( + home: AdaptiveShell( + cupertino: true, + destination: AppDestination.chat, + destinationBodies: { + AppDestination.chat: (_) => + CupertinoTextField(controller: composer, focusNode: focus), + AppDestination.search: (_) => SearchScreen( + gateway: _Gateway(), + onOpen: (_) {}, + embedded: true, + ), + }, + ), + ), + ); + await tester.pumpAndSettle(); + focus.requestFocus(); + await tester.pump(); + await _chord(tester, [ + LogicalKeyboardKey.metaLeft, + ], LogicalKeyboardKey.slash); + EditableText field() => tester.widget( + find.descendant( + of: find.byKey(searchFieldKey), + matching: find.byType(EditableText), + ), + ); + expect(field().focusNode.hasPrimaryFocus, isTrue); + await tester.enterText(find.byKey(searchFieldKey), 'release'); + await tester.pumpAndSettle(const Duration(milliseconds: 300)); + await tester.pump(const Duration(seconds: 1)); + expect(field().controller.text, 'release'); + expect(field().focusNode.hasPrimaryFocus, isTrue); + await tester.tap(find.byKey(const ValueKey('shell.destination.chat'))); + await tester.pumpAndSettle(); + focus.requestFocus(); + await tester.pump(); + await _chord(tester, [ + LogicalKeyboardKey.metaLeft, + ], LogicalKeyboardKey.slash); + expect(field().controller.text, 'release'); + expect(field().focusNode.hasPrimaryFocus, isTrue); + }, + variant: TargetPlatformVariant.only(TargetPlatform.macOS), + ); }