test(#748): fetch the real preset files so a 404 fails CI
Every preset test faked the network, so presets missing from config-profiles main passed them all and reached the owner as "Couldn't update presets" on a test build twice. The live test refreshes from the real URLs and fails on any refresh error; a second live test proves a missing file comes back as HTTP 404. The picker test now checks that a good refresh shows no error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>pull/744/head
parent
1190c49b64
commit
04025cb070
@ -0,0 +1,51 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:meshcore_open/models/radio_preset.dart';
|
||||
import 'package:meshcore_open/services/config_source_service.dart';
|
||||
import 'package:meshcore_open/services/radio_preset_service.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
// Fetches the real preset files from config-profiles (#748). Every other
|
||||
// preset test fakes the network, so a 404 on main passed them all and the
|
||||
// owner saw "Couldn't update presets" on a test build twice. This one fails
|
||||
// whenever the app's own refresh would.
|
||||
void main() {
|
||||
test(
|
||||
'refresh from config-profiles succeeds with no error',
|
||||
() async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
final service = RadioPresetService(
|
||||
prefs: await SharedPreferences.getInstance(),
|
||||
loadAsset: (_) async => throw StateError('bundled copies not used'),
|
||||
);
|
||||
addTearDown(service.dispose);
|
||||
|
||||
final ok = await service.refresh();
|
||||
|
||||
expect(service.refreshError, isNull, reason: 'refresh reported an error');
|
||||
expect(ok, isTrue);
|
||||
expect(service.skipped, 0);
|
||||
final sources = service.presets.map((p) => p.source).toSet();
|
||||
expect(sources, {RadioPresetSource.meshcore, RadioPresetSource.offband});
|
||||
},
|
||||
timeout: const Timeout(Duration(seconds: 60)),
|
||||
);
|
||||
|
||||
test(
|
||||
'a missing file on config-profiles is reported, not ignored',
|
||||
() async {
|
||||
final source = ConfigSourceService();
|
||||
addTearDown(source.dispose);
|
||||
await expectLater(
|
||||
source.fetchText('${kRadioPresetBaseUrl}missing-748.json'),
|
||||
throwsA(
|
||||
isA<ConfigSourceException>().having(
|
||||
(e) => '$e',
|
||||
'message',
|
||||
contains('HTTP 404'),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
timeout: const Timeout(Duration(seconds: 60)),
|
||||
);
|
||||
}
|
||||
Loading…
Reference in new issue