Files
sync_replay_project/apps/desktop/test/now_playing_info_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

67 lines
3.2 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:starsync/src/session/now_playing.dart';
import 'package:starsync/src/session/now_playing_info.dart';
void main() {
group('jellyfinTitle', () {
test('episodes: series on top, "S1 E2 · Name" below', () {
expect(jellyfinTitle('The Pilot', 'Show · S1E2'), ('Show', 'S1 E2 · The Pilot'));
expect(jellyfinTitle('The Pilot', 'Show - S01E02'), ('Show', 'S1 E2 · The Pilot'));
expect(jellyfinTitle('Ep', 'Re:Zero - Starting Life · S2E10'), ('Re:Zero - Starting Life', 'S2 E10 · Ep'));
});
test('movies and partial subtitles', () {
expect(jellyfinTitle('Movie', '2019'), ('Movie', null));
expect(jellyfinTitle('Movie', null), ('Movie', null));
expect(jellyfinTitle('Pilot', 'S1E1'), ('Pilot', 'S1 E1'));
expect(jellyfinTitle('Special', 'Show'), ('Show', 'Special'));
});
});
group('fileTitle', () {
test('release names', () {
expect(fileTitle('[SubsPlease] Frieren - 05 (1080p) [ABCD1234].mkv'), ('Frieren', 'E5'));
expect(fileTitle('Show.Name.S01E03.1080p.WEB-DL.x264-GRP.mkv'), ('Show Name', 'S1 E3'));
expect(fileTitle('[Grp] Show - NCOP1 [1080p].mkv'), ('Show', 'NCOP1'));
expect(fileTitle('Some Movie (2019).mkv'), ('Some Movie', null));
});
test('nothing sensible: the raw name minus extension', () {
expect(fileTitle('[1080p].mkv').$1, '[1080p]');
});
});
test('nowPlayingOf: media map with ref and art', () {
expect(nowPlayingOf(null), isNull);
expect(
nowPlayingOf({
'name': 'The Pilot',
'jellyfin': {'serverId': 's', 'itemId': 'i', 'title': 'The Pilot', 'subtitle': 'Show · S1E2'},
'art': {'poster': 'aaaa', 'banner': 'bbbb'},
}),
const NowPlaying(title: 'Show', episode: 'S1 E2 · The Pilot', posterHash: 'aaaa', bannerHash: 'bbbb'));
expect(nowPlayingOf({'name': 'Show - 12.mkv'}), const NowPlaying(title: 'Show', episode: 'E12'));
});
test('web videos: name as is and wide from the start, before the thumbnail', () {
const title = 'Frieren - 05 | reaction';
// Everyone opens it, passed on by a member, fetched by the server.
for (final media in [
{'name': title, 'url': 'https://www.youtube.com/watch?v=x'},
{'name': title, 'relay': {'source': 'm2', 'live': true}},
{'name': title, 'relay': {'fetch': true}},
]) {
expect(nowPlayingOf(media), const NowPlaying(title: title, thumbnail: true));
expect(nowPlayingOf({...media, 'art': {'poster': 'aa', 'banner': 'aa'}}),
const NowPlaying(title: title, posterHash: 'aa', bannerHash: 'aa', thumbnail: true));
}
// Files (a link to one, a relayed one) and Jellyfin keep their parsing.
expect(nowPlayingOf({'name': 'Show - 12.mkv', 'url': 'https://cdn.example/Show%20-%2012.mkv'}),
const NowPlaying(title: 'Show', episode: 'E12'));
expect(nowPlayingOf({'name': 'Show - 12.mkv', 'relay': {'source': 'm2'}}),
const NowPlaying(title: 'Show', episode: 'E12'));
expect(nowPlayingOf({'name': 'Show - 12', 'relay': {}, 'art': {'poster': 'p', 'banner': 'b'}}),
const NowPlaying(title: 'Show', episode: 'E12', posterHash: 'p', bannerHash: 'b'));
});
}