An instance now names a Jellyfin server for its people to learn from (instance.info().jellyfinUrl): its operator's JELLYFIN_URL (`none`: none), else https://jellyfin. on the domain registered for its public host, as learn.halkyon.eu suggests jellyfin.halkyon.eu, once that answers as a Jellyfin server. The registered domain comes from Mozilla's Public Suffix List, kept in the server's data folder, so an instance at example.co.uk never names someone else's jellyfin.co.uk. The instance looks as it starts and again hourly when asked; the app never reaches for a guessed address. In the app, Add material offers From Jellyfin as soon as the instance suggests a server, before anyone signed in to one. The sign-in fills the server in and finds it by itself, and lists the people the server shows on its login screen: one without a password, as a demo's, signs in with a tap; one with a password is named in the form, which asks for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
38 lines
1 KiB
Dart
38 lines
1 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:halkyon_learn_flutter/src/feature/jellyfin/data/jellyfin_suggestion.dart';
|
|
|
|
void main() {
|
|
test('asks the instance once, as it is first needed', () async {
|
|
var asked = 0;
|
|
final suggestion = JellyfinSuggestion(() async {
|
|
asked++;
|
|
return 'https://jellyfin.halkyon.eu/';
|
|
});
|
|
expect(suggestion.server.value, isNull);
|
|
|
|
await suggestion.look();
|
|
await suggestion.look();
|
|
|
|
expect(asked, 1);
|
|
expect(suggestion.server.value, Uri.parse('https://jellyfin.halkyon.eu/'));
|
|
});
|
|
|
|
test('asks again only after asking failed; none named is none', () async {
|
|
var asked = 0;
|
|
final suggestion = JellyfinSuggestion(() async {
|
|
asked++;
|
|
if (asked == 1) {
|
|
throw Exception('offline');
|
|
}
|
|
return null;
|
|
});
|
|
|
|
await suggestion.look();
|
|
expect(suggestion.server.value, isNull);
|
|
await suggestion.look();
|
|
await suggestion.look();
|
|
|
|
expect(asked, 2);
|
|
expect(suggestion.server.value, isNull);
|
|
});
|
|
}
|