Files
pipelines/app/test/application/startup_update_check_test.dart
alan 9551eceaed Complete Material-only APIs and fixtures
Remove obsolete control-family flags and icon metadata across all callers, dead alternate themes and host helpers, obsolete test setup, and the unused icon-font dependency. Preserve native Material Back transitions. Make navigation fixtures independent of update plugins and answer auxiliary shell snapshots so the complete application suite can run deterministically.
2026-11-11 21:55:39 +00:00

103 lines
3.2 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/widgets.dart';
import 'package:pipelines_app/application/pipelines_app.dart';
import 'package:pipelines_app/application/server_endpoint.dart';
import 'package:pipelines_app/core/transport/pipelines_client.dart';
import 'package:pipelines_app/features/updates/app_updates.dart';
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
ServerEndpoint server() => ServerEndpoint.resolve(
base: Uri.parse('http://127.0.0.1:8096/'),
web: true,
);
void main() {
testWidgets('web launch check is injected, asks once, and does not refresh', (
tester,
) async {
final channel = FakeChannel()..readyCompleter.complete();
final client = PipelinesClient(channelFactory: (_) => channel);
final provider = PlatformRouteInformationProvider(
initialRouteInformation: RouteInformation(uri: Uri.parse('/pipelines')),
);
addTearDown(provider.dispose);
var reads = 0;
var refreshes = 0;
await tester.pumpWidget(
PipelinesApp(
server: server(),
client: client,
routeInformationProvider: provider,
webPlatform: true,
webBuildId: 'web-old',
webReleaseReader: (_) async {
reads++;
return '{"schema":1,"platform":"web","buildId":"web-new"}';
},
webRefresher: () async => refreshes++,
),
);
await tester.pump();
await tester.pump();
expect(find.text('Update available'), findsOneWidget);
expect(reads, 1);
await tester.tap(find.text('Later'));
await tester.pump();
await tester.pumpWidget(
PipelinesApp(
server: server(),
client: client,
routeInformationProvider: provider,
webPlatform: true,
webBuildId: 'web-old',
webReleaseReader: (_) async {
reads++;
return '{"schema":1,"platform":"web","buildId":"web-new"}';
},
webRefresher: () async => refreshes++,
),
);
await tester.pump();
expect(find.text('Update available'), findsNothing);
expect(refreshes, 0);
});
testWidgets('Android launch choice uses the injected installer', (
tester,
) async {
final channel = FakeChannel()..readyCompleter.complete();
final client = PipelinesClient(channelFactory: (_) => channel);
final provider = PlatformRouteInformationProvider(
initialRouteInformation: RouteInformation(uri: Uri.parse('/pipelines')),
);
addTearDown(provider.dispose);
var installs = 0;
final update = AppUpdate(
versionCode: 4,
versionName: '4',
apk: Uri.parse('https://example.test/pipelines.apk'),
);
await tester.pumpWidget(
PipelinesApp(
server: server(),
client: client,
routeInformationProvider: provider,
webPlatform: false,
androidSupported: true,
installedVersionReader: () async => 3,
androidFeedReader: (_) async => update,
androidInstaller: (_, {onProgress}) async => installs++,
),
);
await tester.pump();
await tester.pump();
expect(find.text('Download'), findsOneWidget);
await tester.tap(find.text('Download'));
await tester.pump();
expect(installs, 1);
});
}