Side-app use: copy/open links and titles everywhere, version on the Settings tab, known links preview instantly, Ctrl+V adds to Up next
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9572e8457d
commit
1ec4fc8b13
22 files changed
+1190
-236
No files matched your search
@@ -189,6 +189,25 @@ void main() {
|
||||
expect(decodeRecentLinks(jsonEncode([{'url': ''}, {'url': 'https://a/b.mkv'}])).single.title, 'b.mkv');
|
||||
});
|
||||
|
||||
test('kept previews: playable ones only, display text, survive a reload', () async {
|
||||
String? disk;
|
||||
LinkPreviewStore store() => LinkPreviewStore(read: () async => disk, write: (v) async => disk = v);
|
||||
final a = store();
|
||||
await a.put('https://a', const LinkPreview(title: 'A', subtitle: 'a · Chan · 3:07', thumbnail: 'https://i/a.jpg'),
|
||||
at: DateTime.utc(2026, 1, 2));
|
||||
await a.put('https://b', const LinkPreview(title: 'B', subtitle: 'b', problem: 'Not found (404)'));
|
||||
expect(a.lookup('https://b'), isNull);
|
||||
final b = store();
|
||||
await b.ensureLoaded();
|
||||
final kept = b.lookup('https://a')!;
|
||||
expect((kept.preview.title, kept.preview.subtitle, kept.preview.thumbnail),
|
||||
('A', 'a · Chan · 3:07', 'https://i/a.jpg'));
|
||||
expect(kept.at.isAtSameMomentAs(DateTime.utc(2026, 1, 2)), isTrue);
|
||||
// A problem later forgets it.
|
||||
await b.put('https://a', const LinkPreview(title: 'A', subtitle: 'a', problem: 'Not allowed (403)'));
|
||||
expect(b.lookup('https://a'), isNull);
|
||||
});
|
||||
|
||||
test('preview: a page by yt-dlp, a file by its name, else why not', () async {
|
||||
final yt = await previewLink('https://www.youtube.com/watch?v=abc',
|
||||
probe: (url) async => LinkProbe.page(Uri.parse(url),
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:watch_together/src/queue/queue_ui.dart';
|
||||
import 'package:watch_together/src/session/session_coordinator.dart';
|
||||
import 'package:watch_together/src/shell/library_link.dart' show LinkPreview;
|
||||
import 'package:watch_together/src/widgets/text_focus.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Up next popover: holds the keys, Ctrl+V adds with a preview row, + Add link opens a field',
|
||||
(tester) async {
|
||||
final coord = SessionCoordinator();
|
||||
var clip = (files: const <String>[], text: 'look https://example.com/v' as String?);
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
theme: ThemeData.dark(),
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
child: QueuePanel(
|
||||
queue: coord.queue,
|
||||
onClose: () {},
|
||||
readClipboard: () async => clip,
|
||||
preview: (url) async => const LinkPreview(title: 'A video', subtitle: 'example.com'),
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
await tester.pump();
|
||||
expect(textInputFocused(), isTrue, reason: 'the player keys rest while it is open');
|
||||
expect(find.byKey(const ValueKey('queue-add-field')), findsNothing);
|
||||
|
||||
// Ctrl+V: the link goes in at once, as a row with its preview; not in
|
||||
// a server here, so it says why.
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.keyV);
|
||||
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(find.text('A video'), findsOneWidget);
|
||||
expect(find.text('not in a server'), findsOneWidget);
|
||||
|
||||
// Nothing to add on the clipboard.
|
||||
clip = (files: const <String>[], text: 'just words');
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.keyV);
|
||||
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
|
||||
await tester.pump();
|
||||
expect(find.byKey(const ValueKey('queue-add-error')), findsOneWidget);
|
||||
|
||||
// + Add link: a small field with focus; Esc closes it, focus stays.
|
||||
await tester.tap(find.byKey(const ValueKey('queue-add-link')));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(find.byKey(const ValueKey('queue-add-field')), findsOneWidget);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
|
||||
await tester.pump();
|
||||
expect(find.byKey(const ValueKey('queue-add-field')), findsNothing);
|
||||
expect(textInputFocused(), isTrue);
|
||||
});
|
||||
}
|
||||
@@ -30,4 +30,16 @@ void main() {
|
||||
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();
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user