Files
sync_replay_project/apps/desktop/test/text_focus_test.dart
T
foxyzandClaude Opus 5.5 51c1c5ab78
ci / core (push) Successful in 31s
ci / server (push) Successful in 1m3s
ci / updater-windows (push) Successful in 6m6s
Restructure step R: the app is Starsync (dev.foxyz.starsync)
- Linux app id dev.foxyz.starsync, binary starsync; Windows starsync.exe,
  company foxyz; server starsync-server; Dart package starsync; archives
  starsync-<ver>-*.
- 1.2.x compatibility: watch_together and watch-together-server
  launchers (Linux) / copies (Windows) in the archive; the updater
  accepts both names and relaunches the new binary; update.sh/.bat use
  whichever server exists.
- First start copies (never moves) the old support folder and this
  app's Hive boxes out of ~/Documents into <support>/hive; a marker
  makes it run once; AppDirs is a port; settings schema version with
  ordered migrations.
- Launcher entry dev.foxyz.starsync.desktop; the old one removed.
- Repository name and URLs unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 20:21:20 +03:00

46 lines
1.4 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:starsync/src/widgets/text_focus.dart';
void main() {
// Regression: the old FocusNode-parent walk never met EditableText, so
// session shortcuts (Space, arrows, F) fired while typing in chat.
testWidgets('text field focus is detected, buttons are not', (tester) async {
final field = FocusNode();
final button = FocusNode();
await tester.pumpWidget(MaterialApp(
home: Scaffold(
body: Column(children: [
TextField(focusNode: field),
TextButton(focusNode: button, onPressed: () {}, child: const Text('b')),
]),
),
));
expect(textInputFocused(), isFalse);
field.requestFocus();
await tester.pump();
expect(field.hasPrimaryFocus, isTrue);
expect(textInputFocused(), isTrue);
button.requestFocus();
await tester.pump();
expect(textInputFocused(), isFalse);
field.dispose();
button.dispose();
});
testWidgets('focus under a KeyboardClaim counts as typing', (tester) async {
final claimed = FocusNode();
await tester.pumpWidget(MaterialApp(
home: KeyboardClaim(child: Focus(focusNode: claimed, child: const SizedBox())),
));
expect(textInputFocused(), isFalse);
claimed.requestFocus();
await tester.pump();
expect(textInputFocused(), isTrue);
claimed.dispose();
});
}