Support Command conversation shortcuts in Mac browsers
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
@@ -136,6 +137,43 @@ void main() {
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
});
|
||||
|
||||
testWidgets('macOS Command+number opens and focuses the Nth conversation', (
|
||||
tester,
|
||||
) async {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.macOS;
|
||||
addTearDown(() => debugDefaultTargetPlatformOverride = null);
|
||||
await _pumpShell(
|
||||
tester,
|
||||
const Size(1280, 800),
|
||||
// Browser presentation stays Material while shortcuts use the real OS.
|
||||
platform: TargetPlatform.android,
|
||||
);
|
||||
Future<void> command(LogicalKeyboardKey digit) async {
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.metaLeft);
|
||||
await tester.sendKeyEvent(digit);
|
||||
await tester.sendKeyUpEvent(LogicalKeyboardKey.metaLeft);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
await command(LogicalKeyboardKey.digit1);
|
||||
expect(_thread('a'), findsOneWidget);
|
||||
expect(_composerFocused(tester, 'a'), isTrue);
|
||||
tester.testTextInput.enterText('keep this draft');
|
||||
await tester.pump();
|
||||
await command(LogicalKeyboardKey.digit3);
|
||||
expect(_thread('r'), findsOneWidget);
|
||||
expect(_composerFocused(tester, 'r'), isTrue);
|
||||
await command(LogicalKeyboardKey.digit9);
|
||||
expect(_thread('r'), findsOneWidget);
|
||||
await command(LogicalKeyboardKey.digit1);
|
||||
expect(_composerText(tester, 'a'), 'keep this draft');
|
||||
await _ctrl(tester, LogicalKeyboardKey.digit2);
|
||||
expect(_thread('z'), findsOneWidget);
|
||||
expect(_composerFocused(tester, 'z'), isTrue);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
});
|
||||
|
||||
testWidgets('Ctrl+N puts the keyboard in the opened chat\'s composer', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
Reference in New Issue
Block a user