Feedback: the blank 'web address' field was unusable — nobody knows what to put, so the market never worked at first launch. - SocialSettings ships default public relays (nos.lol, relay.damus.io), applied automatically for new users so the market works day one. An explicitly empty choice still turns the network off (privacy). Exposure is minimal: offers are opt-in and carry only a coarse geohash. - Sharing setup now shows the servers as a short PICK-LIST (checkboxes, pre- selected) instead of a blank field; a community's own server goes under a small 'add another' escape hatch. Intro reworded — no need to know a community. - Tests updated (defaults) and pinned offline (setRelayUrls([])) so widget tests don't hit the network. 22 green, analyzer clean.
50 lines
1.7 KiB
Dart
50 lines
1.7 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:tane/security/secret_store.dart';
|
|
import 'package:tane/services/social_settings.dart';
|
|
|
|
/// In-memory [SecretStore] for tests.
|
|
class FakeSecretStore implements SecretStore {
|
|
final Map<String, String> _data = {};
|
|
@override
|
|
Future<String?> read(String key) async => _data[key];
|
|
@override
|
|
Future<void> write(String key, String value) async => _data[key] = value;
|
|
}
|
|
|
|
void main() {
|
|
late SocialSettings settings;
|
|
setUp(() => settings = SocialSettings(FakeSecretStore()));
|
|
|
|
test('defaults: empty area, but relays fall back to the defaults', () async {
|
|
expect(await settings.areaGeohash(), '');
|
|
expect(await settings.relayUrls(), SocialSettings.defaultRelays);
|
|
// Not configured yet: the area is still unset.
|
|
expect(await settings.isConfigured, isFalse);
|
|
});
|
|
|
|
test('an explicitly empty relay choice turns the network off', () async {
|
|
await settings.setRelayUrls(const []);
|
|
expect(await settings.relayUrls(), isEmpty);
|
|
});
|
|
|
|
test('stores and normalises the area geohash (trim + lowercase)', () async {
|
|
await settings.setAreaGeohash(' SP3E9 ');
|
|
expect(await settings.areaGeohash(), 'sp3e9');
|
|
});
|
|
|
|
test('stores relay urls, dropping blanks', () async {
|
|
await settings.setRelayUrls([
|
|
'wss://relay.comunes.org',
|
|
' ',
|
|
'wss://seeds.example.org',
|
|
]);
|
|
expect(await settings.relayUrls(),
|
|
['wss://relay.comunes.org', 'wss://seeds.example.org']);
|
|
});
|
|
|
|
test('is configured once an area is set (relays are defaulted)', () async {
|
|
expect(await settings.isConfigured, isFalse); // no area yet
|
|
await settings.setAreaGeohash('sp3e9');
|
|
expect(await settings.isConfigured, isTrue);
|
|
});
|
|
}
|