feat(app): the web page offers the server's Android APK in Settings
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_android_download_section.dart';
|
||||
import 'package:pipelines_app/features/updates/app_updates.dart';
|
||||
|
||||
void main() {
|
||||
final base = Uri.parse('https://host.ts.net:8443/updates/');
|
||||
|
||||
testWidgets('offers the server APK for download', (tester) async {
|
||||
final opened = <Uri>[];
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: SettingsAndroidDownloadSection(
|
||||
base: base,
|
||||
read: (feed) async => AppUpdate.parse(
|
||||
'{"versionCode": 29879834, "apk": "pipelines.apk", "notes": "New icon"}',
|
||||
feed,
|
||||
),
|
||||
open: (uri) async {
|
||||
opened.add(uri);
|
||||
return true;
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Pipelines for Android · build 29879834'), findsOneWidget);
|
||||
expect(find.text('New icon'), findsOneWidget);
|
||||
await tester.tap(find.byKey(const Key('settings-android-download')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(opened, [
|
||||
Uri.parse('https://host.ts.net:8443/updates/pipelines.apk'),
|
||||
]);
|
||||
});
|
||||
|
||||
testWidgets('says when the server offers no APK', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: SettingsAndroidDownloadSection(
|
||||
base: base,
|
||||
read: (_) async => null,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.textContaining('./install --apk'), findsOneWidget);
|
||||
expect(find.byKey(const Key('settings-android-download')), findsNothing);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user