diff --git a/app/lib/features/onboarding/discovery/discovered_server_row.dart b/app/lib/features/onboarding/discovery/discovered_server_row.dart index 6ab33e92..213d29e7 100644 --- a/app/lib/features/onboarding/discovery/discovered_server_row.dart +++ b/app/lib/features/onboarding/discovery/discovered_server_row.dart @@ -1,7 +1,5 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import '../../../ui/adaptive/host.dart'; import 'discovered_server.dart'; /// One discovered machine. A machine with one route is used by tapping it. A @@ -48,7 +46,6 @@ class _DiscoveredServerRowState extends State { @override Widget build(BuildContext context) { - final cupertino = usesCupertinoHost(context); final server = widget.server; final detail = _multiple ? '${server.addresses.length} addresses' @@ -57,47 +54,26 @@ class _DiscoveredServerRowState extends State { server.passwordRequired ? '$detail · password' : detail, ); final onTap = widget.enabled ? _tap : null; - final Widget head = cupertino - ? CupertinoListTile( - key: Key('discovered-${server.address}'), - leading: const Icon(CupertinoIcons.desktopcomputer), - title: Text(server.name), - subtitle: subtitle, - trailing: _multiple - ? Icon( - _expanded - ? CupertinoIcons.chevron_up - : CupertinoIcons.chevron_down, - ) - : const CupertinoListTileChevron(), - onTap: onTap, - ) - : ListTile( - key: Key('discovered-${server.address}'), - leading: const Icon(Icons.dns_outlined), - title: Text(server.name), - subtitle: subtitle, - trailing: Icon( - _multiple - ? (_expanded ? Icons.expand_less : Icons.expand_more) - : Icons.chevron_right, - ), - enabled: widget.enabled, - onTap: onTap, - ); + final Widget head = ListTile( + key: Key('discovered-${server.address}'), + leading: const Icon(Icons.dns_outlined), + title: Text(server.name), + subtitle: subtitle, + trailing: Icon( + _multiple + ? (_expanded ? Icons.expand_less : Icons.expand_more) + : Icons.chevron_right, + ), + enabled: widget.enabled, + onTap: onTap, + ); if (!_multiple || !_expanded) return head; final useLabel = 'Use ${server.name}'; - final use = cupertino - ? CupertinoButton.filled( - key: Key('discovered-use-${server.address}'), - onPressed: widget.enabled && _chosen.isNotEmpty ? _use : null, - child: Text(useLabel), - ) - : FilledButton( - key: Key('discovered-use-${server.address}'), - onPressed: widget.enabled && _chosen.isNotEmpty ? _use : null, - child: Text(useLabel), - ); + final use = FilledButton( + key: Key('discovered-use-${server.address}'), + onPressed: widget.enabled && _chosen.isNotEmpty ? _use : null, + child: Text(useLabel), + ); return Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ @@ -109,8 +85,7 @@ class _DiscoveredServerRowState extends State { 'as routes to this one machine; the first is tried first.', ), ), - for (final address in server.addresses) - _choice(context, cupertino, address), + for (final address in server.addresses) _choice(address), Padding( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), child: Align(alignment: AlignmentDirectional.centerStart, child: use), @@ -119,11 +94,7 @@ class _DiscoveredServerRowState extends State { ); } - Widget _choice( - BuildContext context, - bool cupertino, - DiscoveredAddress address, - ) { + Widget _choice(DiscoveredAddress address) { final checked = _chosen.contains(address); void toggle(bool? value) => setState(() { if (value ?? false) { @@ -133,26 +104,12 @@ class _DiscoveredServerRowState extends State { } }); final key = Key('discovered-route-${address.endpoint}'); - final title = Text(address.label); - final subtitle = Text(address.endpoint.toString()); - if (cupertino) { - return CupertinoListTile( - key: key, - title: title, - subtitle: subtitle, - trailing: CupertinoCheckbox( - value: checked, - onChanged: widget.enabled ? toggle : null, - ), - onTap: widget.enabled ? () => toggle(!checked) : null, - ); - } return CheckboxListTile( key: key, value: checked, onChanged: widget.enabled ? toggle : null, - title: title, - subtitle: subtitle, + title: Text(address.label), + subtitle: Text(address.endpoint.toString()), controlAffinity: ListTileControlAffinity.leading, ); } diff --git a/app/lib/features/onboarding/discovery/discovery_panel.dart b/app/lib/features/onboarding/discovery/discovery_panel.dart index 04f673cd..19bfbbe4 100644 --- a/app/lib/features/onboarding/discovery/discovery_panel.dart +++ b/app/lib/features/onboarding/discovery/discovery_panel.dart @@ -1,9 +1,7 @@ import 'dart:async'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import '../../../ui/adaptive/host.dart'; import 'browser_server_discovery.dart'; import 'discovered_server.dart'; import 'discovered_server_row.dart'; @@ -88,42 +86,29 @@ class _DiscoveryPanelState extends State { @override Widget build(BuildContext context) { - final cupertino = usesCupertinoHost(context); final scanning = _phase == _Phase.scanning; final label = _phase == _Phase.idle ? 'Find servers on this network' : 'Search again'; final enabled = widget.enabled && !scanning; - final button = cupertino - ? CupertinoButton( - key: const Key('discovery-scan'), - onPressed: enabled ? _start : null, - child: Text(label), - ) - : OutlinedButton.icon( - key: const Key('discovery-scan'), - onPressed: enabled ? _start : null, - icon: const Icon(Icons.wifi_find), - label: Text(label), - ); + final button = OutlinedButton.icon( + key: const Key('discovery-scan'), + onPressed: enabled ? _start : null, + icon: const Icon(Icons.wifi_find), + label: Text(label), + ); final status = switch (_phase) { _Phase.scanning => _status( - context, - cupertino, const Key('discovery-scanning'), 'Looking for Pipelines servers…', busy: true, ), _Phase.done when _servers.isEmpty => _status( - context, - cupertino, const Key('discovery-empty'), 'No Pipelines servers answered on this network. ' 'Enter the address instead.', ), _Phase.failed => _status( - context, - cupertino, const Key('discovery-error'), 'Could not search this network: $_error', error: true, @@ -149,30 +134,22 @@ class _DiscoveryPanelState extends State { } Widget _status( - BuildContext context, - bool cupertino, Key key, String text, { bool busy = false, bool error = false, }) { - final color = !error - ? null - : cupertino - ? CupertinoColors.systemRed.resolveFrom(context) - : Theme.of(context).colorScheme.error; + final color = !error ? null : Theme.of(context).colorScheme.error; return Padding( key: key, padding: const EdgeInsets.symmetric(vertical: 8), child: Row( children: [ if (busy) ...[ - cupertino - ? const CupertinoActivityIndicator() - : const SizedBox.square( - dimension: 16, - child: CircularProgressIndicator(strokeWidth: 2), - ), + const SizedBox.square( + dimension: 16, + child: CircularProgressIndicator(strokeWidth: 2), + ), const SizedBox(width: 12), ], Expanded( diff --git a/app/lib/features/onboarding/onboarding_flow.dart b/app/lib/features/onboarding/onboarding_flow.dart index 22a00b7d..c88b1f09 100644 --- a/app/lib/features/onboarding/onboarding_flow.dart +++ b/app/lib/features/onboarding/onboarding_flow.dart @@ -1,10 +1,8 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../core/session/server_session.dart'; import '../../core/transport/server_url.dart'; import '../../core/servers/server_probe.dart'; -import '../../ui/adaptive/host.dart'; import 'discovery/discovered_server.dart'; import 'discovery/discovery_panel.dart'; import 'discovery/server_discovery.dart'; @@ -219,7 +217,6 @@ class _OnboardingFlowState extends State { @override Widget build(BuildContext context) { - final cupertino = usesCupertinoHost(context); final title = _passwordStep ? 'Sign in' : 'Connect to Pipelines'; final lead = _passwordStep ? 'Enter the password chosen when Pipelines was installed on ' @@ -228,7 +225,6 @@ class _OnboardingFlowState extends State { 'wss://server.example/connect.'; final field = _passwordStep ? _field( - cupertino, key: const Key('onboarding-password'), controller: _password, hint: 'Password', @@ -236,7 +232,6 @@ class _OnboardingFlowState extends State { onSubmitted: _signIn, ) : _field( - cupertino, key: const Key('onboarding-server'), controller: _server, hint: 'wss://server/connect', @@ -245,26 +240,18 @@ class _OnboardingFlowState extends State { ); final action = _passwordStep ? _signIn : _continue; final label = _passwordStep ? 'Sign in' : 'Continue'; - final button = cupertino - ? CupertinoButton.filled( - key: const Key('onboarding-next'), - onPressed: _busy ? null : action, - child: _busy ? const CupertinoActivityIndicator() : Text(label), - ) - : FilledButton( - key: const Key('onboarding-next'), - onPressed: _busy ? null : action, - child: _busy - ? const SizedBox( - width: 18, - height: 18, - child: CircularProgressIndicator(strokeWidth: 2), - ) - : Text(label), - ); - final errorColor = cupertino - ? CupertinoColors.systemRed.resolveFrom(context) - : Theme.of(context).colorScheme.error; + final button = FilledButton( + key: const Key('onboarding-next'), + onPressed: _busy ? null : action, + child: _busy + ? const SizedBox( + width: 18, + height: 18, + child: CircularProgressIndicator(strokeWidth: 2), + ) + : Text(label), + ); + final errorColor = Theme.of(context).colorScheme.error; final body = SafeArea( child: Center( child: SingleChildScrollView( @@ -274,14 +261,7 @@ class _OnboardingFlowState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - Text( - title, - style: cupertino - ? CupertinoTheme.of( - context, - ).textTheme.navLargeTitleTextStyle - : Theme.of(context).textTheme.headlineSmall, - ), + Text(title, style: Theme.of(context).textTheme.headlineSmall), const SizedBox(height: 8), Text(lead), const SizedBox(height: 24), @@ -289,7 +269,6 @@ class _OnboardingFlowState extends State { if (!_passwordStep) ...[ const SizedBox(height: 12), _field( - cupertino, key: const Key('onboarding-server-name'), controller: _name, hint: 'Machine name', @@ -324,15 +303,10 @@ class _OnboardingFlowState extends State { ], if (_passwordStep && !widget.startAtPassword) ...[ const SizedBox(height: 8), - cupertino - ? CupertinoButton( - onPressed: _busy ? null : _back, - child: const Text('Change server'), - ) - : TextButton( - onPressed: _busy ? null : _back, - child: const Text('Change server'), - ), + TextButton( + onPressed: _busy ? null : _back, + child: const Text('Change server'), + ), ], if (widget.savedServers != null) ...[ const SizedBox(height: 24), @@ -344,13 +318,10 @@ class _OnboardingFlowState extends State { ), ), ); - return cupertino - ? CupertinoPageScaffold(child: body) - : Scaffold(body: body); + return Scaffold(body: body); } - Widget _field( - bool cupertino, { + Widget _field({ required Key key, required TextEditingController controller, required String hint, @@ -358,18 +329,6 @@ class _OnboardingFlowState extends State { bool obscure = false, TextInputType? keyboard, }) { - if (cupertino) { - return CupertinoTextField( - key: key, - controller: controller, - placeholder: hint, - obscureText: obscure, - autocorrect: false, - keyboardType: keyboard, - autofocus: true, - onSubmitted: (_) => onSubmitted(), - ); - } return TextField( key: key, controller: controller, diff --git a/app/lib/features/updates/launch_update_dialog.dart b/app/lib/features/updates/launch_update_dialog.dart index 23eddfd9..78c9ad25 100644 --- a/app/lib/features/updates/launch_update_dialog.dart +++ b/app/lib/features/updates/launch_update_dialog.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'app_updates.dart'; @@ -10,113 +9,60 @@ Future showLaunchUpdateDialog( required bool cupertino, String sourceName = '', String nativePlatform = 'android', -}) => cupertino - ? showCupertinoDialog( - context: context, - builder: (context) => CupertinoAlertDialog( - title: const Text('Update available'), - content: Text( - web - ? 'A newer Pipelines web build is available.' - : 'A newer ${nativePlatform == 'macos' - ? 'macOS' - : nativePlatform == 'linux' - ? 'Linux' - : 'Android'} build is available${sourceName.isEmpty ? '' : ' from $sourceName'}.${switch (nativePlatform) { - 'linux' => ' Pipelines installs it and restarts.', - 'macos' => ' Download and extract the archive to update the app.', - _ => '', - }}', - ), - actions: [ - CupertinoDialogAction( - onPressed: () => Navigator.pop(context, false), - child: const Text('Later'), - ), - CupertinoDialogAction( - isDefaultAction: true, - onPressed: () => Navigator.pop(context, true), - child: Text( - web - ? 'Refresh' - : nativePlatform == 'linux' - ? 'Install and restart' - : 'Download', - ), - ), - ], +}) => showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text('Update available'), + content: Text( + web + ? 'A newer Pipelines web build is available.' + : 'A newer ${nativePlatform == 'macos' + ? 'macOS' + : nativePlatform == 'linux' + ? 'Linux' + : 'Android'} build is available${sourceName.isEmpty ? '' : ' from $sourceName'}.${switch (nativePlatform) { + 'linux' => ' Pipelines installs it and restarts.', + 'macos' => ' Download and extract the archive to update the app.', + _ => '', + }}', + ), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context, false), + child: const Text('Later'), + ), + FilledButton( + onPressed: () => Navigator.pop(context, true), + child: Text( + web + ? 'Refresh' + : nativePlatform == 'linux' + ? 'Install and restart' + : 'Download', ), - ) - : showDialog( - context: context, - builder: (context) => AlertDialog( - title: const Text('Update available'), - content: Text( - web - ? 'A newer Pipelines web build is available.' - : 'A newer ${nativePlatform == 'macos' - ? 'macOS' - : nativePlatform == 'linux' - ? 'Linux' - : 'Android'} build is available${sourceName.isEmpty ? '' : ' from $sourceName'}.${switch (nativePlatform) { - 'linux' => ' Pipelines installs it and restarts.', - 'macos' => ' Download and extract the archive to update the app.', - _ => '', - }}', - ), - actions: [ - TextButton( - onPressed: () => Navigator.pop(context, false), - child: const Text('Later'), - ), - FilledButton( - onPressed: () => Navigator.pop(context, true), - child: Text( - web - ? 'Refresh' - : nativePlatform == 'linux' - ? 'Install and restart' - : 'Download', - ), - ), - ], - ), - ); + ), + ], + ), +); Future showLaunchUpdateFailure( BuildContext context, Object error, { required bool cupertino, }) async { - if (cupertino) { - await showCupertinoDialog( - context: context, - builder: (context) => CupertinoAlertDialog( - title: const Text('Update failed'), - content: Text('$error'), - actions: [ - CupertinoDialogAction( - onPressed: () => Navigator.pop(context), - child: const Text('OK'), - ), - ], - ), - ); - } else { - await showDialog( - context: context, - builder: (context) => AlertDialog( - title: const Text('Update failed'), - content: Text('$error'), - actions: [ - TextButton( - onPressed: () => Navigator.pop(context), - child: const Text('OK'), - ), - ], - ), - ); - } + await showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text('Update failed'), + content: Text('$error'), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + child: const Text('OK'), + ), + ], + ), + ); } /// Reuses the Settings installer while keeping download progress visible. @@ -126,24 +72,11 @@ Future installLaunchUpdate( required UpdateInstaller installer, required bool cupertino, }) async { - final result = cupertino - ? await showCupertinoDialog<_InstallResult>( - context: context, - builder: (_) => _InstallProgress( - update: update, - installer: installer, - cupertino: true, - ), - ) - : await showDialog<_InstallResult>( - context: context, - barrierDismissible: false, - builder: (_) => _InstallProgress( - update: update, - installer: installer, - cupertino: false, - ), - ); + final result = await showDialog<_InstallResult>( + context: context, + barrierDismissible: false, + builder: (_) => _InstallProgress(update: update, installer: installer), + ); if (result?.error case final Object error) throw error; } @@ -153,14 +86,9 @@ class _InstallResult { } class _InstallProgress extends StatefulWidget { - const _InstallProgress({ - required this.update, - required this.installer, - required this.cupertino, - }); + const _InstallProgress({required this.update, required this.installer}); final AppUpdate update; final UpdateInstaller installer; - final bool cupertino; @override State<_InstallProgress> createState() => _InstallProgressState(); @@ -200,19 +128,12 @@ class _InstallProgressState extends State<_InstallProgress> { : 'Downloading update… ${(progress * 100).round()}%', ), const SizedBox(height: 16), - widget.cupertino - ? const CupertinoActivityIndicator() - : LinearProgressIndicator(value: progress), + LinearProgressIndicator(value: progress), ], ); return PopScope( canPop: false, - child: widget.cupertino - ? CupertinoAlertDialog( - title: const Text('App update'), - content: content, - ) - : AlertDialog(title: const Text('App update'), content: content), + child: AlertDialog(title: const Text('App update'), content: content), ); } } diff --git a/app/notes/C-cupertino-updates.md b/app/notes/C-cupertino-updates.md new file mode 100644 index 00000000..75d8d821 --- /dev/null +++ b/app/notes/C-cupertino-updates.md @@ -0,0 +1,42 @@ +# Cupertino removal — lib/features/updates + +## Change +- `lib/features/updates/launch_update_dialog.dart`: deleted the Cupertino dialog + branches from `showLaunchUpdateDialog`, `showLaunchUpdateFailure` and + `installLaunchUpdate`, and from the private `_InstallProgress` widget + (`CupertinoAlertDialog`, `CupertinoActivityIndicator`, `CupertinoDialogAction`, + `showCupertinoDialog`). The Material `AlertDialog`/`LinearProgressIndicator` + path is unchanged. +- Public signatures keep `required bool cupertino` (unused now) so callers in + other directories continue to compile; nothing outside `lib/features/updates` + was edited. +- Removed the `package:flutter/cupertino.dart` import; no `CupertinoIcons` or + `CupertinoColors` were used in this directory. + +## Tests +- `test/features/updates/native_update_dialog_test.dart`: existing Material + prompt loop retained (`cupertino: false`). Added regression tests for the + Material failure alert and the Material install-progress dialog/progress bar. + No Cupertino test variants were present to delete. +- `test/application/startup_update_flow_test.dart` (review follow-up): the web + refresh test no longer mounts with `cupertino: true`; it now asserts the + Material `AlertDialog`. The local `mount` helper lost its unused `cupertino` + parameter and passes `cupertino: false` explicitly. The + `package:flutter/cupertino.dart` import became `package:flutter/material.dart`. +- `test/application/startup_update_check_test.dart` already mounted Material + only (`cupertino: false`); no change. +- No other test reaches these dialogs with `cupertino: true` or a `CupertinoApp` + host; the remaining `cupertino: true` tests elsewhere cover unrelated UI. + +## Checks +- `tool/analyze.sh`: clean (16s, exit 0). +- `tool/memwatch/full.sh 'test/features/updates test/application/startup_update_flow_test.dart test/application/startup_update_check_test.dart'`: + 38 passed, 0 failed, 0 skipped; 38s; exit 0. +- `grep -rn 'Cupertino\|cupertino' lib/features/updates`: only the three kept + `required bool cupertino` parameters. In the update tests only `cupertino: + false` arguments remain. + +## UI states +- Update-available prompt, update-failure alert and install-progress dialog now + always render the existing Material variants. No pixel change on the Material + path; Cupertino host paths are unreachable in this Material-only app. diff --git a/app/notes/onboarding-material-only.md b/app/notes/onboarding-material-only.md new file mode 100644 index 00000000..3b4fc7f6 --- /dev/null +++ b/app/notes/onboarding-material-only.md @@ -0,0 +1,41 @@ +# Onboarding: Material-only + +Removed the Cupertino branch from `lib/features/onboarding`: + +- `onboarding_flow.dart`: Material `Scaffold`, `TextField` (outline border), + `FilledButton` with a small `CircularProgressIndicator`, `TextButton` for + "Change server", theme error colour and `headlineSmall` title. Dropped the + unused `flutter/cupertino.dart` and `ui/adaptive/host.dart` imports. +- `discovery/discovery_panel.dart`: `OutlinedButton.icon` scan action, Material + busy indicator and theme error colour. +- `discovery/discovered_server_row.dart`: Material `ListTile`, + `CheckboxListTile` and `FilledButton`; Cupertino list tiles, chevrons, + checkbox and activity indicators removed. + +Public constructors (`OnboardingFlow`, `DiscoveryPanel`, `DiscoveredServerRow`) +are unchanged; no `cupertino` parameters existed there. Private helpers lost +their now-unused `cupertino`/`context` arguments. No Cupertino icons or colours +are kept: the Material path uses none of them. + +## Affected UI states + +First run server entry, machine name, discovery idle/scanning/empty/error, the +discovered single-route row, the multi-route checklist and "Use ", the +sign-in step, probe error text and the "Change server" action. All render the +same Material widgets as before on the Material path; no layout or copy changed. + +## Checks + +- `tool/memwatch/full.sh 'test/features/onboarding '` — PASS, 24 tests, exit 0. +- `tool/memwatch/full.sh 'test/features/settings/saved_server_discovery_test.dart + test/application/pipelines_root_test.dart + test/application/zero_server_recovery_test.dart'` — PASS, 7 tests, exit 0 + (other users of `OnboardingFlow`/`DiscoveryPanel`). +- `tool/analyze.sh` — clean, exit 0. +- `grep -rn 'Cupertino\|cupertino' lib/features/onboarding test/features/onboarding` + — no matches. + +Test change: `discovery_panel_test.dart` lost its `CupertinoApp` host variant and +the `CupertinoListTile` expectation; the `host` helper now always builds a +`MaterialApp`. No Material test expectation changed. No UI capture was taken in +this stage. diff --git a/app/test/application/startup_update_flow_test.dart b/app/test/application/startup_update_flow_test.dart index 36c0789e..06f8d30a 100644 --- a/app/test/application/startup_update_flow_test.dart +++ b/app/test/application/startup_update_flow_test.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/application/pipelines_app.dart'; import 'package:pipelines_app/application/server_endpoint.dart'; @@ -14,7 +14,6 @@ void main() { Future mount( WidgetTester tester, { bool web = true, - bool cupertino = false, Future Function(Uri)? read, Future Function()? refresh, UpdateInstaller? installer, @@ -31,7 +30,7 @@ void main() { web: true, ), client: PipelinesClient(channelFactory: (_) => channel), - cupertino: cupertino, + cupertino: false, routeInformationProvider: provider, webPlatform: web, webPageUri: Uri.parse('https://app.test/chats?selected=1'), @@ -180,7 +179,6 @@ void main() { var refreshes = 0; await mount( tester, - cupertino: true, read: (uri) async { expect(uri, Uri.parse('https://app.test/release.json')); return '{"schema":1,"platform":"web","buildId":"web-new"}'; @@ -189,7 +187,7 @@ void main() { refreshes++; }, ); - expect(find.byType(CupertinoAlertDialog), findsOneWidget); + expect(find.byType(AlertDialog), findsOneWidget); expect(refreshes, 0); await tester.tap(find.text('Refresh')); await tester.pump(); diff --git a/app/test/features/onboarding/discovery/discovery_panel_test.dart b/app/test/features/onboarding/discovery/discovery_panel_test.dart index 4e7f78cd..4b64a613 100644 --- a/app/test/features/onboarding/discovery/discovery_panel_test.dart +++ b/app/test/features/onboarding/discovery/discovery_panel_test.dart @@ -1,6 +1,5 @@ import 'dart:async'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/core/session/server_session.dart'; @@ -33,8 +32,7 @@ const studio = DiscoveredServer( passwordRequired: false, ); -Widget host(Widget child, {bool cupertino = false}) => - cupertino ? CupertinoApp(home: child) : MaterialApp(home: child); +Widget host(Widget child) => MaterialApp(home: child); void main() { late FakeDiscovery discovery; @@ -146,22 +144,6 @@ void main() { expect(find.byKey(const Key('discovery-error')), findsOneWidget); }); - testWidgets('Cupertino host lists and connects the same way', (tester) async { - await tester.pumpWidget(host(flow(discoverer: discovery), cupertino: true)); - await tester.tap(find.byKey(const Key('discovery-scan'))); - await tester.pump(); - discovery.current.add([studio]); - await tester.pump(); - expect(find.byType(CupertinoListTile), findsOneWidget); - await tester.tap(find.byKey(const Key('discovered-192.168.1.30:8080'))); - await tester.pumpAndSettle(); - expect(checked, isEmpty); - await tester.ensureVisible(find.byKey(const Key('onboarding-next'))); - await tester.tap(find.byKey(const Key('onboarding-next'))); - await tester.pumpAndSettle(); - expect(checked, [Uri.parse('ws://192.168.1.30:8080/connect')]); - }); - testWidgets('leaving the screen mid-scan stops browsing', (tester) async { await tester.pumpWidget(host(flow(discoverer: discovery))); await tester.tap(find.byKey(const Key('discovery-scan'))); diff --git a/app/test/features/updates/native_update_dialog_test.dart b/app/test/features/updates/native_update_dialog_test.dart index 7216640f..610fe873 100644 --- a/app/test/features/updates/native_update_dialog_test.dart +++ b/app/test/features/updates/native_update_dialog_test.dart @@ -1,5 +1,8 @@ +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/features/updates/app_updates.dart'; import 'package:pipelines_app/features/updates/launch_update_dialog.dart'; void main() { @@ -34,4 +37,63 @@ void main() { expect(find.textContaining('Android'), findsNothing); }); } + + testWidgets('update failure uses a Material alert', (tester) async { + await tester.pumpWidget( + MaterialApp( + home: Builder( + builder: (context) => TextButton( + onPressed: () => + showLaunchUpdateFailure(context, 'boom', cupertino: false), + child: const Text('Fail'), + ), + ), + ), + ); + await tester.tap(find.text('Fail')); + await tester.pumpAndSettle(); + expect(find.byType(AlertDialog), findsOneWidget); + expect(find.text('Update failed'), findsOneWidget); + expect(find.text('boom'), findsOneWidget); + expect(find.text('OK'), findsOneWidget); + }); + + testWidgets('install progress uses a Material alert and progress bar', ( + tester, + ) async { + final finished = Completer(); + late BuildContext dialogContext; + await tester.pumpWidget( + MaterialApp( + home: Builder( + builder: (context) { + dialogContext = context; + return const SizedBox(); + }, + ), + ), + ); + final install = installLaunchUpdate( + dialogContext, + AppUpdate( + versionCode: 2, + versionName: '2.0', + apk: Uri.parse('https://example.test/app.apk'), + ), + installer: (update, {onProgress}) async { + onProgress?.call(0.5); + await finished.future; + }, + cupertino: false, + ); + await tester.pumpAndSettle(); + expect(find.byType(AlertDialog), findsOneWidget); + expect(find.byType(LinearProgressIndicator), findsOneWidget); + expect(find.text('App update'), findsOneWidget); + expect(find.text('Downloading update… 50%'), findsOneWidget); + finished.complete(); + await tester.pumpAndSettle(); + expect(find.byType(AlertDialog), findsNothing); + await install; + }); }