test: remove redundant coverage and shorten timers
This commit is contained in:
@@ -130,71 +130,3 @@ MediaItem testMediaItem({
|
||||
raw: raw,
|
||||
);
|
||||
}
|
||||
|
||||
/// Season fixture with canonical show linkage.
|
||||
MediaItem testSeason({
|
||||
String id = 'season-1',
|
||||
MediaItem? show,
|
||||
int index = 1,
|
||||
String? title,
|
||||
MediaBackend? backend,
|
||||
String? serverId,
|
||||
String? libraryId,
|
||||
int? leafCount,
|
||||
int? viewedLeafCount,
|
||||
}) {
|
||||
return testMediaItem(
|
||||
id: id,
|
||||
backend: backend ?? show?.backend ?? MediaBackend.plex,
|
||||
kind: MediaKind.season,
|
||||
title: title,
|
||||
parentId: show?.id,
|
||||
parentTitle: show?.title,
|
||||
index: index,
|
||||
serverId: serverId ?? show?.serverId,
|
||||
serverName: show?.serverName,
|
||||
libraryId: libraryId ?? show?.libraryId,
|
||||
libraryTitle: show?.libraryTitle,
|
||||
leafCount: leafCount,
|
||||
viewedLeafCount: viewedLeafCount,
|
||||
);
|
||||
}
|
||||
|
||||
/// Episode fixture with canonical show and season linkage.
|
||||
MediaItem testEpisode({
|
||||
String id = 'episode-1',
|
||||
MediaItem? show,
|
||||
MediaItem? season,
|
||||
int index = 1,
|
||||
String? title,
|
||||
MediaBackend? backend,
|
||||
String? serverId,
|
||||
String? libraryId,
|
||||
int? durationMs,
|
||||
int? viewOffsetMs,
|
||||
int? viewCount,
|
||||
String? originallyAvailableAt,
|
||||
List<MediaVersion>? mediaVersions,
|
||||
}) {
|
||||
return testMediaItem(
|
||||
id: id,
|
||||
backend: backend ?? season?.backend ?? show?.backend ?? MediaBackend.plex,
|
||||
kind: MediaKind.episode,
|
||||
title: title,
|
||||
parentId: season?.id,
|
||||
parentTitle: season?.title,
|
||||
parentIndex: season?.index,
|
||||
index: index,
|
||||
grandparentId: show?.id,
|
||||
grandparentTitle: show?.title,
|
||||
serverId: serverId ?? season?.serverId ?? show?.serverId,
|
||||
serverName: season?.serverName ?? show?.serverName,
|
||||
libraryId: libraryId ?? season?.libraryId ?? show?.libraryId,
|
||||
libraryTitle: season?.libraryTitle ?? show?.libraryTitle,
|
||||
durationMs: durationMs,
|
||||
viewOffsetMs: viewOffsetMs,
|
||||
viewCount: viewCount,
|
||||
originallyAvailableAt: originallyAvailableAt,
|
||||
mediaVersions: mediaVersions,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:plezy/media/media_backend.dart';
|
||||
import 'package:plezy/media/media_kind.dart';
|
||||
|
||||
import 'media_items.dart';
|
||||
|
||||
void main() {
|
||||
test('default fixture is a minimal Plex movie', () {
|
||||
final item = testMediaItem();
|
||||
|
||||
expect(item.id, 'item-1');
|
||||
expect(item.backend, MediaBackend.plex);
|
||||
expect(item.kind, MediaKind.movie);
|
||||
expect(item.serverId, isNull);
|
||||
expect(item.parentId, isNull);
|
||||
expect(item.viewCount, isNull);
|
||||
});
|
||||
|
||||
test('season and episode fixtures preserve canonical hierarchy and scope', () {
|
||||
final show = testMediaItem(
|
||||
id: 'show-1',
|
||||
kind: MediaKind.show,
|
||||
backend: MediaBackend.jellyfin,
|
||||
title: 'Show',
|
||||
serverId: 'server-1',
|
||||
serverName: 'Server',
|
||||
libraryId: 'library-1',
|
||||
libraryTitle: 'Library',
|
||||
);
|
||||
final season = testSeason(id: 'season-2', show: show, index: 2, title: 'Season 2');
|
||||
final episode = testEpisode(id: 'episode-3', show: show, season: season, index: 3, title: 'Episode 3');
|
||||
|
||||
expect(season.backend, show.backend);
|
||||
expect(season.parentId, show.id);
|
||||
expect(season.parentTitle, show.title);
|
||||
expect(episode.parentId, season.id);
|
||||
expect(episode.parentTitle, season.title);
|
||||
expect(episode.parentIndex, season.index);
|
||||
expect(episode.grandparentId, show.id);
|
||||
expect(episode.grandparentTitle, show.title);
|
||||
expect(episode.serverId, show.serverId);
|
||||
expect(episode.libraryId, show.libraryId);
|
||||
});
|
||||
}
|
||||
@@ -186,57 +186,6 @@ class FakeSyncPlayer implements Player {
|
||||
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
||||
}
|
||||
|
||||
/// Standalone recording fake peer service (no relay behind it).
|
||||
class FakeWatchTogetherPeerService extends WatchTogetherPeerService {
|
||||
FakeWatchTogetherPeerService({required this.peerId}) : super(customBaseUrl: 'http://localhost');
|
||||
|
||||
final String peerId;
|
||||
final _messages = StreamController<SyncMessage>.broadcast();
|
||||
final _peerConnected = StreamController<String>.broadcast();
|
||||
final _peerDisconnected = StreamController<String>.broadcast();
|
||||
|
||||
final List<SyncMessage> broadcasts = [];
|
||||
final Map<String, List<SyncMessage>> sent = {};
|
||||
|
||||
@override
|
||||
String? get myPeerId => peerId;
|
||||
|
||||
@override
|
||||
Stream<SyncMessage> get onMessageReceived => _messages.stream;
|
||||
|
||||
@override
|
||||
Stream<String> get onPeerConnected => _peerConnected.stream;
|
||||
|
||||
@override
|
||||
Stream<String> get onPeerDisconnected => _peerDisconnected.stream;
|
||||
|
||||
@override
|
||||
void broadcast(SyncMessage message) {
|
||||
broadcasts.add(message);
|
||||
}
|
||||
|
||||
@override
|
||||
void sendTo(String peerId, SyncMessage message) {
|
||||
sent.putIfAbsent(peerId, () => []).add(message);
|
||||
}
|
||||
|
||||
/// All recorded outgoing messages of [type], broadcast and targeted.
|
||||
Iterable<SyncMessage> outgoing(SyncMessageType type) =>
|
||||
[...broadcasts, ...sent.values.expand((m) => m)].where((m) => m.type == type);
|
||||
|
||||
void emit(SyncMessage message) => _messages.add(message);
|
||||
|
||||
void emitPeerConnected(String peerId) => _peerConnected.add(peerId);
|
||||
|
||||
void emitPeerDisconnected(String peerId) => _peerDisconnected.add(peerId);
|
||||
|
||||
Future<void> close() async {
|
||||
await _messages.close();
|
||||
await _peerConnected.close();
|
||||
await _peerDisconnected.close();
|
||||
}
|
||||
}
|
||||
|
||||
/// In-memory relay linking [HubPeerService]s for duplex end-to-end tests.
|
||||
///
|
||||
/// Mirrors the real relay's contract: broadcasts fan out to every other
|
||||
|
||||
Reference in New Issue
Block a user