Files
sync_replay_project/apps/desktop/test/text_focus_test.dart
T
foxyzandClaude Opus 5.5 4d00b7455e
ci / core (push) Successful in 27s
ci / server (push) Successful in 1m7s
ci / updater-windows (push) Failing after 6m4s
Restructure step 3: your server, Invite, version gate, AppGraph
- One server per app run (loopback, no password); Invite attaches an
  all-interfaces listener to the same server and Stop sharing detaches
  it (guests told with 4016); members, media and Up next never reset.
  No solo mode: you're home on your own server unless in a friend's.
- Navigation: none / yours / friend; a join passes a version gate on
  /health first (clear "they/you need to update", update offer).
- Invite as a value (host, port, name, password flag, version, fp
  reserved); addresses filtered (loopback, link-local, 198.18/15,
  bridges) and ranked; Sharing chip, Copy invite, Stop sharing.
- Alone looks like a plain player (alone replaces solo).
- AppGraph builds and disposes systems; widgets use AppScope;
  SessionState deleted; a test caps the remaining singletons.

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

51 lines
1.5 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:starsync/src/widgets/text_focus.dart';
import 'test_graph.dart';
/// This file's composition root (see test_graph.dart).
final _graph = testGraph();
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(scoped(_graph, 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(scoped(_graph, MaterialApp(
home: KeyboardClaim(child: Focus(focusNode: claimed, child: const SizedBox())),
)));
expect(textInputFocused(), isFalse);
claimed.requestFocus();
await tester.pump();
expect(textInputFocused(), isTrue);
claimed.dispose();
});
}