Server and core: version ranges on both sides with a coded refusal; a client id maps to the same member and token for the server's life; a drop is `gone` for a 10-minute grace keeping ready, presence, queue items, relay and avatar; `bye` leaves at once; ordered takeover (seq, replaced/stale); presence joining/in/away/gone with one PresencePolicy; joiners never pause playback and hold a held gate at most ~15 s; state.hold; feed ids, seq and replay; the relay lives through its source's grace and continues on re-dial; queue `by` lasting, auto items and cancel; MediaRef carried; client ids never logged. App: persisted client id and seq; Connection with unstable/lost/ replaced states, backoff with jitter, no lost/back pair per flap; a drop keeps the session (state, player, media, relay source); presence in the strip and members card; sit out = away intent; feed matched by id; auto sit-out (idle when not playing, minimised for a while; never when alone) replaces auto-unready; bye on close and Leave, not on update restart; relay source re-dials through its grace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
89 lines
3.3 KiB
Dart
89 lines
3.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:sync_relay_core/core.dart';
|
|
import 'package:starsync/src/shell/app_shell.dart';
|
|
import 'package:starsync/src/state/session_state.dart';
|
|
import 'package:starsync/src/update/update_controller.dart';
|
|
import 'package:starsync/src/widgets/app_keys.dart';
|
|
import 'package:starsync/src/widgets/text_focus.dart';
|
|
|
|
void main() {
|
|
final session = SessionState.instance;
|
|
final coord = session.coordinator;
|
|
|
|
tearDown(() {
|
|
session.route.value = AppRoute.home;
|
|
coord.serverState.value = null;
|
|
});
|
|
|
|
// Regression: Tab moved focus (out of the chat field onto a button) and
|
|
// Space, the ready key, then pressed that button.
|
|
testWidgets('Tab opens and closes chat without moving focus; Space is ready', (tester) async {
|
|
tester.view.physicalSize = const Size(1280, 800);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
var readies = 0;
|
|
await tester.pumpWidget(MaterialApp(
|
|
theme: ThemeData.dark(),
|
|
shortcuts: appShortcuts,
|
|
home: AppKeys(
|
|
onToggleReady: () => readies++,
|
|
child: AppShell(
|
|
updates: UpdateController(currentVersion: '0.0.0-dev'),
|
|
autoUpdateCheck: false,
|
|
windowControls: false,
|
|
videoBuilder: (context, controls) => const SizedBox(),
|
|
),
|
|
),
|
|
));
|
|
coord.serverState.value = StateBroadcast(
|
|
eventId: 1,
|
|
transport: 'held',
|
|
position: 0,
|
|
serverTime: DateTime.now().toUtc(),
|
|
mediaId: 0,
|
|
members: [MemberView(id: 'a', name: 'Alex', ready: false, inSet: false, buffered: 0)],
|
|
);
|
|
session.route.value = AppRoute.session;
|
|
await tester.pumpAndSettle();
|
|
final panel = find.byKey(const ValueKey('chat-panel'));
|
|
|
|
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
|
|
await tester.pumpAndSettle();
|
|
expect(panel, findsOneWidget);
|
|
expect(textInputFocused(), isTrue, reason: 'opening the chat focuses its field');
|
|
|
|
// From the field: closes the chat, focus goes back, not to a button.
|
|
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
|
|
await tester.pumpAndSettle();
|
|
expect(panel, findsNothing);
|
|
expect(textInputFocused(), isFalse);
|
|
|
|
await tester.sendKeyEvent(LogicalKeyboardKey.space);
|
|
await tester.pumpAndSettle();
|
|
expect(readies, 1);
|
|
expect(panel, findsNothing, reason: 'Space pressed a focused chat button');
|
|
});
|
|
|
|
testWidgets('Ctrl+Shift+B opens Mark a problem; Esc closes it unmarked', (tester) async {
|
|
await tester.pumpWidget(MaterialApp(
|
|
theme: ThemeData.dark(),
|
|
shortcuts: appShortcuts,
|
|
home: const AppKeys(child: Scaffold(body: SizedBox())),
|
|
));
|
|
final card = find.byKey(const ValueKey('mark-problem-card'));
|
|
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
|
|
await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft);
|
|
await tester.sendKeyEvent(LogicalKeyboardKey.keyB);
|
|
await tester.sendKeyUpEvent(LogicalKeyboardKey.shiftLeft);
|
|
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
|
|
await tester.pumpAndSettle();
|
|
expect(card, findsOneWidget);
|
|
expect(textInputFocused(), isTrue, reason: 'the note field takes the keys');
|
|
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
|
|
await tester.pumpAndSettle();
|
|
expect(card, findsNothing);
|
|
});
|
|
}
|