diff --git a/app/lib/core/servers/chat/machine_sign_in_dialog.dart b/app/lib/core/servers/chat/machine_sign_in_dialog.dart index 4768dbf4..66b2b94f 100644 --- a/app/lib/core/servers/chat/machine_sign_in_dialog.dart +++ b/app/lib/core/servers/chat/machine_sign_in_dialog.dart @@ -1,8 +1,5 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import '../../../ui/adaptive/host.dart'; - /// Asks for one machine's own password. [signIn] returns null on success, /// otherwise the sentence to show; the dialog stays open for a retry. Future showMachineSignIn( @@ -11,9 +8,7 @@ Future showMachineSignIn( required Future Function(String password) signIn, }) { final dialog = MachineSignInDialog(name: name, signIn: signIn); - return usesCupertinoHost(context) - ? showCupertinoDialog(context: context, builder: (_) => dialog) - : showDialog(context: context, builder: (_) => dialog); + return showDialog(context: context, builder: (_) => dialog); } class MachineSignInDialog extends StatefulWidget { @@ -68,24 +63,14 @@ class _MachineSignInDialogState extends State { @override Widget build(BuildContext context) { - final cupertino = usesCupertinoHost(context); - final field = cupertino - ? CupertinoTextField( - key: const Key('machine-password'), - controller: password, - obscureText: true, - autofocus: true, - placeholder: 'Password', - onSubmitted: busy ? null : (_) => submit(), - ) - : TextField( - key: const Key('machine-password'), - controller: password, - obscureText: true, - autofocus: true, - decoration: const InputDecoration(labelText: 'Password'), - onSubmitted: busy ? null : (_) => submit(), - ); + final field = TextField( + key: const Key('machine-password'), + controller: password, + obscureText: true, + autofocus: true, + decoration: const InputDecoration(labelText: 'Password'), + onSubmitted: busy ? null : (_) => submit(), + ); final content = Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, @@ -103,36 +88,20 @@ class _MachineSignInDialogState extends State { ], ); final title = Text('Sign in to ${widget.name}'); - return cupertino - ? CupertinoAlertDialog( - title: title, - content: content, - actions: [ - CupertinoDialogAction( - onPressed: busy ? null : () => Navigator.pop(context), - child: const Text('Cancel'), - ), - CupertinoDialogAction( - key: const Key('machine-sign-in'), - onPressed: busy ? null : submit, - child: Text(busy ? 'Signing in…' : 'Sign in'), - ), - ], - ) - : AlertDialog( - title: title, - content: content, - actions: [ - TextButton( - onPressed: busy ? null : () => Navigator.pop(context), - child: const Text('Cancel'), - ), - FilledButton( - key: const Key('machine-sign-in'), - onPressed: busy ? null : submit, - child: Text(busy ? 'Signing in…' : 'Sign in'), - ), - ], - ); + return AlertDialog( + title: title, + content: content, + actions: [ + TextButton( + onPressed: busy ? null : () => Navigator.pop(context), + child: const Text('Cancel'), + ), + FilledButton( + key: const Key('machine-sign-in'), + onPressed: busy ? null : submit, + child: Text(busy ? 'Signing in…' : 'Sign in'), + ), + ], + ); } } diff --git a/app/lib/core/servers/elevation/elevation_dialog.dart b/app/lib/core/servers/elevation/elevation_dialog.dart index cc22e086..1daeb811 100644 --- a/app/lib/core/servers/elevation/elevation_dialog.dart +++ b/app/lib/core/servers/elevation/elevation_dialog.dart @@ -1,7 +1,5 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import '../../../ui/adaptive/host.dart'; import 'machine_elevation.dart'; /// The app's elevation prompt: the native password dialog over whatever @@ -21,12 +19,10 @@ Future showElevationDialog( MachineElevation machine, ) async { final dialog = ElevationDialog(name: machine.name, submit: machine.submit); - final result = usesCupertinoHost(context) - ? await showCupertinoDialog( - context: context, - builder: (_) => dialog, - ) - : await showDialog(context: context, builder: (_) => dialog); + final result = await showDialog( + context: context, + builder: (_) => dialog, + ); return result ?? false; } @@ -74,24 +70,14 @@ class _ElevationDialogState extends State { @override Widget build(BuildContext context) { - final cupertino = usesCupertinoHost(context); - final field = cupertino - ? CupertinoTextField( - key: const Key('elevation-password'), - controller: password, - obscureText: true, - autofocus: true, - placeholder: 'Password', - onSubmitted: busy ? null : (_) => confirm(), - ) - : TextField( - key: const Key('elevation-password'), - controller: password, - obscureText: true, - autofocus: true, - decoration: const InputDecoration(labelText: 'Password'), - onSubmitted: busy ? null : (_) => confirm(), - ); + final field = TextField( + key: const Key('elevation-password'), + controller: password, + obscureText: true, + autofocus: true, + decoration: const InputDecoration(labelText: 'Password'), + onSubmitted: busy ? null : (_) => confirm(), + ); final content = Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, @@ -111,37 +97,20 @@ class _ElevationDialogState extends State { ); const title = Text('Confirm password'); final confirmLabel = Text(busy ? 'Confirming…' : 'Confirm'); - return cupertino - ? CupertinoAlertDialog( - title: title, - content: content, - actions: [ - CupertinoDialogAction( - onPressed: busy ? null : () => Navigator.pop(context, false), - child: const Text('Cancel'), - ), - CupertinoDialogAction( - key: const Key('elevation-confirm'), - isDefaultAction: true, - onPressed: busy ? null : confirm, - child: confirmLabel, - ), - ], - ) - : AlertDialog( - title: title, - content: content, - actions: [ - TextButton( - onPressed: busy ? null : () => Navigator.pop(context, false), - child: const Text('Cancel'), - ), - FilledButton( - key: const Key('elevation-confirm'), - onPressed: busy ? null : confirm, - child: confirmLabel, - ), - ], - ); + return AlertDialog( + title: title, + content: content, + actions: [ + TextButton( + onPressed: busy ? null : () => Navigator.pop(context, false), + child: const Text('Cancel'), + ), + FilledButton( + key: const Key('elevation-confirm'), + onPressed: busy ? null : confirm, + child: confirmLabel, + ), + ], + ); } } diff --git a/app/lib/features/settings/health/health_header.dart b/app/lib/features/settings/health/health_header.dart index 93139a37..b6389812 100644 --- a/app/lib/features/settings/health/health_header.dart +++ b/app/lib/features/settings/health/health_header.dart @@ -1,7 +1,5 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../../core/api_gateway.dart'; -import '../settings_theme.dart'; import 'health_models.dart'; import 'health_widgets.dart'; @@ -46,12 +44,7 @@ class HealthHeader extends StatelessWidget { const SizedBox(width: 8), Semantics( label: 'Auto-refresh', - child: usesCupertinoControls(context) - ? CupertinoSwitch( - value: autoRefresh, - onChanged: onAutoRefresh, - ) - : Switch(value: autoRefresh, onChanged: onAutoRefresh), + child: Switch(value: autoRefresh, onChanged: onAutoRefresh), ), ], ), diff --git a/app/lib/features/settings/health/health_screen.dart b/app/lib/features/settings/health/health_screen.dart index de72067a..20d3a264 100644 --- a/app/lib/features/settings/health/health_screen.dart +++ b/app/lib/features/settings/health/health_screen.dart @@ -1,9 +1,7 @@ import 'dart:async'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../../core/api_gateway.dart'; import '../settings_page_body.dart'; -import '../settings_theme.dart'; import 'health_controller.dart'; import 'health_models.dart'; import 'health_sections.dart'; @@ -142,16 +140,9 @@ class _HealthScreenState extends State ], ], ); - return usesCupertinoControls(context) - ? CupertinoPageScaffold( - navigationBar: const CupertinoNavigationBar( - middle: Text('Server health'), - ), - child: SafeArea(child: content), - ) - : Scaffold( - appBar: AppBar(title: const Text('Server health')), - body: content, - ); + return Scaffold( + appBar: AppBar(title: const Text('Server health')), + body: content, + ); } } diff --git a/app/lib/features/settings/health/health_widgets.dart b/app/lib/features/settings/health/health_widgets.dart index e1bd626c..3b05a28d 100644 --- a/app/lib/features/settings/health/health_widgets.dart +++ b/app/lib/features/settings/health/health_widgets.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../settings_theme.dart'; import 'health_models.dart'; @@ -20,22 +19,7 @@ class HealthCard extends StatelessWidget { ], ), ); - if (!usesCupertinoControls(context)) return Card(child: content); - return Padding( - padding: const EdgeInsets.symmetric(vertical: 4), - child: DecoratedBox( - decoration: BoxDecoration( - color: CupertinoColors.secondarySystemGroupedBackground.resolveFrom( - context, - ), - borderRadius: BorderRadius.circular(12), - ), - child: DefaultTextStyle( - style: settingsTextStyle(context), - child: content, - ), - ), - ); + return Card(child: content); } } @@ -47,23 +31,13 @@ class HealthMeter extends StatelessWidget { Widget build(BuildContext context) { final scheme = Theme.of(context).colorScheme; final percent = value == null ? null : value! * 100; - final cupertino = usesCupertinoControls(context); - final normal = cupertino - ? CupertinoTheme.of(context).primaryColor - : scheme.primary; - final high = cupertino - ? CupertinoColors.systemOrange.resolveFrom(context) - : scheme.tertiary; - final critical = cupertino - ? CupertinoColors.systemRed.resolveFrom(context) - : scheme.error; final color = percent == null ? scheme.outline : percent >= healthMeterCritical - ? critical + ? scheme.error : percent >= healthMeterHigh - ? high - : normal; + ? scheme.tertiary + : scheme.primary; return Row( children: [ Expanded( @@ -111,7 +85,6 @@ class HealthAction extends StatelessWidget { final String label; final VoidCallback? onPressed; @override - Widget build(BuildContext context) => usesCupertinoControls(context) - ? CupertinoButton(onPressed: onPressed, child: Text(label)) - : TextButton(onPressed: onPressed, child: Text(label)); + Widget build(BuildContext context) => + TextButton(onPressed: onPressed, child: Text(label)); } diff --git a/app/lib/features/settings/health/settings_health_section.dart b/app/lib/features/settings/health/settings_health_section.dart index 64747a41..d6de3747 100644 --- a/app/lib/features/settings/health/settings_health_section.dart +++ b/app/lib/features/settings/health/settings_health_section.dart @@ -1,8 +1,6 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../../core/api_gateway.dart'; import '../settings_row.dart'; -import '../settings_theme.dart'; import 'health_screen.dart'; class SettingsHealthSection extends StatelessWidget { @@ -10,21 +8,13 @@ class SettingsHealthSection extends StatelessWidget { final ApiGateway gateway; @override Widget build(BuildContext context) => SettingsRow( - leading: Icon( - usesCupertinoControls(context) - ? CupertinoIcons.heart - : Icons.monitor_heart_outlined, - ), + leading: const Icon(Icons.monitor_heart_outlined), title: const Text('Server health'), subtitle: const Text('CPU, memory, GPU, storage and process'), chevron: true, onTap: () { final page = HealthScreen(gateway: gateway); - Navigator.of(context).push( - usesCupertinoControls(context) - ? CupertinoPageRoute(builder: (_) => page) - : MaterialPageRoute(builder: (_) => page), - ); + Navigator.of(context).push(MaterialPageRoute(builder: (_) => page)); }, ); } diff --git a/app/lib/features/settings/security/settings_security_section.dart b/app/lib/features/settings/security/settings_security_section.dart index 491549f9..7c053433 100644 --- a/app/lib/features/settings/security/settings_security_section.dart +++ b/app/lib/features/settings/security/settings_security_section.dart @@ -1,9 +1,7 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import '../../../core/session/server_session.dart'; -import '../../../ui/adaptive/host.dart'; import 'session_security_api.dart'; /// The server's sign-in security: a warning when its password predates the @@ -72,28 +70,6 @@ class _SettingsSecuritySectionState extends State { 'Every browser and device signed in to this server, this one ' 'included, must sign in again. Open connections close now.', ); - if (usesCupertinoHost(context)) { - return await showCupertinoDialog( - context: context, - builder: (context) => CupertinoAlertDialog( - title: title, - content: body, - actions: [ - CupertinoDialogAction( - onPressed: () => Navigator.pop(context, false), - child: const Text('Cancel'), - ), - CupertinoDialogAction( - key: const Key('settings-revoke-all-confirm'), - isDestructiveAction: true, - onPressed: () => Navigator.pop(context, true), - child: const Text('Sign out everywhere'), - ), - ], - ), - ) ?? - false; - } return await showDialog( context: context, builder: (context) => AlertDialog( @@ -148,17 +124,11 @@ class _SettingsSecuritySectionState extends State { @override Widget build(BuildContext context) { final security = _security; - final button = usesCupertinoHost(context) - ? CupertinoButton( - key: const Key('settings-revoke-all'), - onPressed: _busy ? null : _revokeAll, - child: const Text('Sign out everywhere'), - ) - : OutlinedButton( - key: const Key('settings-revoke-all'), - onPressed: _busy ? null : _revokeAll, - child: const Text('Sign out everywhere'), - ); + final button = OutlinedButton( + key: const Key('settings-revoke-all'), + onPressed: _busy ? null : _revokeAll, + child: const Text('Sign out everywhere'), + ); return Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ diff --git a/app/lib/features/settings/storage/settings_storage_section.dart b/app/lib/features/settings/storage/settings_storage_section.dart index 16a56504..c1a6b786 100644 --- a/app/lib/features/settings/storage/settings_storage_section.dart +++ b/app/lib/features/settings/storage/settings_storage_section.dart @@ -1,8 +1,6 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../../core/api_gateway.dart'; import '../settings_row.dart'; -import '../settings_theme.dart'; import 'storage_screen.dart'; class SettingsStorageSection extends StatelessWidget { @@ -10,21 +8,13 @@ class SettingsStorageSection extends StatelessWidget { final ApiGateway gateway; @override Widget build(BuildContext context) => SettingsRow( - leading: Icon( - usesCupertinoControls(context) - ? CupertinoIcons.archivebox - : Icons.storage_outlined, - ), + leading: const Icon(Icons.storage_outlined), title: const Text('Storage'), subtitle: const Text('Usage, worktrees and retention policy'), chevron: true, onTap: () { final page = StorageScreen(gateway: gateway); - Navigator.of(context).push( - usesCupertinoControls(context) - ? CupertinoPageRoute(builder: (_) => page) - : MaterialPageRoute(builder: (_) => page), - ); + Navigator.of(context).push(MaterialPageRoute(builder: (_) => page)); }, ); } diff --git a/app/lib/features/settings/storage/storage_controls.dart b/app/lib/features/settings/storage/storage_controls.dart index dbc500fc..192f935c 100644 --- a/app/lib/features/settings/storage/storage_controls.dart +++ b/app/lib/features/settings/storage/storage_controls.dart @@ -1,6 +1,4 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import '../settings_theme.dart'; class StorageAction extends StatelessWidget { const StorageAction({ @@ -13,27 +11,15 @@ class StorageAction extends StatelessWidget { final VoidCallback? onPressed; final bool destructive; @override - Widget build(BuildContext context) => usesCupertinoControls(context) - ? CupertinoButton( - onPressed: onPressed, - child: Text( - label, - style: destructive - ? TextStyle( - color: CupertinoColors.destructiveRed.resolveFrom(context), - ) - : null, - ), - ) - : TextButton( - onPressed: onPressed, - style: destructive - ? TextButton.styleFrom( - foregroundColor: Theme.of(context).colorScheme.error, - ) - : null, - child: Text(label), - ); + Widget build(BuildContext context) => TextButton( + onPressed: onPressed, + style: destructive + ? TextButton.styleFrom( + foregroundColor: Theme.of(context).colorScheme.error, + ) + : null, + child: Text(label), + ); } class StorageSwitch extends StatelessWidget { @@ -52,9 +38,7 @@ class StorageSwitch extends StatelessWidget { Expanded(child: Text(label)), Semantics( label: label, - child: usesCupertinoControls(context) - ? CupertinoSwitch(value: value, onChanged: onChanged) - : Switch(value: value, onChanged: onChanged), + child: Switch(value: value, onChanged: onChanged), ), ], ); @@ -77,35 +61,17 @@ class StorageInput extends StatelessWidget { @override Widget build(BuildContext context) { final keyboard = TextInputType.numberWithOptions(decimal: decimal); - return usesCupertinoControls(context) - ? Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Text(label), - const SizedBox(height: 8), - Semantics( - label: label, - child: CupertinoTextField( - controller: controller, - enabled: enabled, - keyboardType: keyboard, - onChanged: onChanged, - placeholder: 'No limit', - ), - ), - ], - ) - : TextField( - controller: controller, - enabled: enabled, - keyboardType: keyboard, - onChanged: onChanged, - decoration: InputDecoration( - labelText: label, - hintText: 'No limit', - border: const OutlineInputBorder(), - ), - ); + return TextField( + controller: controller, + enabled: enabled, + keyboardType: keyboard, + onChanged: onChanged, + decoration: InputDecoration( + labelText: label, + hintText: 'No limit', + border: const OutlineInputBorder(), + ), + ); } } diff --git a/app/lib/features/settings/storage/storage_screen.dart b/app/lib/features/settings/storage/storage_screen.dart index bc7b1028..22895189 100644 --- a/app/lib/features/settings/storage/storage_screen.dart +++ b/app/lib/features/settings/storage/storage_screen.dart @@ -1,9 +1,7 @@ import 'dart:async'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../../core/api_gateway.dart'; import '../settings_page_body.dart'; -import '../settings_theme.dart'; import 'storage_cleanup.dart'; import 'storage_controller.dart'; import 'storage_controls.dart'; @@ -93,45 +91,23 @@ class _StorageScreenState extends State { final preview = _controller.preview!; final message = 'Permanently remove ${storageInt(preview['candidate_count'])} eligible items and reclaim up to ${storageBytes(storageInt(preview['reclaimable_bytes']))}? This cannot be undone.'; - final bool? confirmed; - if (usesCupertinoControls(context)) { - confirmed = await showCupertinoDialog( - context: context, - builder: (context) => CupertinoAlertDialog( - title: const Text('Apply cleanup?'), - content: Text(message), - actions: [ - CupertinoDialogAction( - onPressed: () => Navigator.pop(context, false), - child: const Text('Cancel'), - ), - CupertinoDialogAction( - isDestructiveAction: true, - onPressed: () => Navigator.pop(context, true), - child: const Text('Remove items'), - ), - ], - ), - ); - } else { - confirmed = await showDialog( - context: context, - builder: (context) => AlertDialog( - title: const Text('Apply cleanup?'), - content: Text(message), - actions: [ - TextButton( - onPressed: () => Navigator.pop(context, false), - child: const Text('Cancel'), - ), - TextButton( - onPressed: () => Navigator.pop(context, true), - child: const Text('Remove items'), - ), - ], - ), - ); - } + final confirmed = await showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text('Apply cleanup?'), + content: Text(message), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context, false), + child: const Text('Cancel'), + ), + TextButton( + onPressed: () => Navigator.pop(context, true), + child: const Text('Remove items'), + ), + ], + ), + ); if (confirmed == true && mounted) await _controller.apply(policy); } @@ -145,7 +121,6 @@ class _StorageScreenState extends State { @override Widget build(BuildContext context) { - final cupertino = usesCupertinoControls(context); final content = SettingsPageBody( children: [ if (_controller.busy) @@ -196,16 +171,9 @@ class _StorageScreenState extends State { ), ], ); - return cupertino - ? CupertinoPageScaffold( - navigationBar: const CupertinoNavigationBar( - middle: Text('Storage'), - ), - child: SafeArea(child: content), - ) - : Scaffold( - appBar: AppBar(title: const Text('Storage')), - body: content, - ); + return Scaffold( + appBar: AppBar(title: const Text('Storage')), + body: content, + ); } } diff --git a/app/lib/features/settings/storage/storage_usage.dart b/app/lib/features/settings/storage/storage_usage.dart index b7337501..333d2f86 100644 --- a/app/lib/features/settings/storage/storage_usage.dart +++ b/app/lib/features/settings/storage/storage_usage.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:flutter/cupertino.dart'; import '../settings_group.dart'; import 'storage_controls.dart'; import 'storage_models.dart'; @@ -67,10 +66,7 @@ class StorageUsage extends StatelessWidget { context, MaterialLocalizations, ); - if (material != null) { - return '${time.day} ${material.formatMonthYear(time)} · ${material.formatTimeOfDay(TimeOfDay.fromDateTime(time), alwaysUse24HourFormat: true)}'; - } - final local = CupertinoLocalizations.of(context); - return '${time.day} ${local.datePickerMonth(time.month)} ${time.year} · ${time.hour.toString().padLeft(2, '0')}:${time.minute.toString().padLeft(2, '0')}'; + if (material == null) return null; + return '${time.day} ${material.formatMonthYear(time)} · ${material.formatTimeOfDay(TimeOfDay.fromDateTime(time), alwaysUse24HourFormat: true)}'; } } diff --git a/app/test/core/servers/elevation/elevation_dialog_test.dart b/app/test/core/servers/elevation/elevation_dialog_test.dart index e499dd7e..b0a3c9ad 100644 --- a/app/test/core/servers/elevation/elevation_dialog_test.dart +++ b/app/test/core/servers/elevation/elevation_dialog_test.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/core/api_gateway.dart'; @@ -15,7 +14,7 @@ void main() { final navigator = GlobalKey(); Future? pending; - Future pump(WidgetTester tester, {bool cupertino = false}) async { + Future pump(WidgetTester tester) async { machine = FakeMachine(); gateway = ElevatingGateway( machine, @@ -35,12 +34,10 @@ void main() { ), ); await tester.pumpWidget( - cupertino - ? CupertinoApp(navigatorKey: navigator, home: home) - : MaterialApp( - navigatorKey: navigator, - home: Scaffold(body: home), - ), + MaterialApp( + navigatorKey: navigator, + home: Scaffold(body: home), + ), ); await tester.tap(find.text('Run')); await tester.pumpAndSettle(); @@ -99,18 +96,6 @@ void main() { expect(machine.calls, ['chat_shell_run']); }); - testWidgets('a Cupertino host gets the Cupertino dialog', (tester) async { - await pump(tester, cupertino: true); - expect(find.byType(CupertinoAlertDialog), findsOneWidget); - await tester.enterText( - find.byKey(const Key('elevation-password')), - 'right', - ); - await tester.tap(find.byKey(const Key('elevation-confirm'))); - await tester.pumpAndSettle(); - expect((await pending!)['type'], 'chat_shell_run_ok'); - }); - testWidgets('without a mounted navigator the refusal is reported', ( tester, ) async { diff --git a/app/test/features/settings/saved_server_sign_in_test.dart b/app/test/features/settings/saved_server_sign_in_test.dart index f6fbb283..fee7c3e3 100644 --- a/app/test/features/settings/saved_server_sign_in_test.dart +++ b/app/test/features/settings/saved_server_sign_in_test.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/core/servers/machine_access.dart'; @@ -64,96 +63,90 @@ Future addServer( } void main() { - for (final cupertino in [false, true]) { - testWidgets('a new machine asks for its own password ($cupertino)', ( - tester, - ) async { - final connections = ServerConnections( - store: MemoryServerCatalogStore( - catalog: ServerCatalog( - servers: [ - SavedServer.validated( - id: 'mac', - name: 'Mac', - endpoints: ['ws://10.0.0.75:8083/connect'], - ), - ], - selectedId: 'mac', - ), + testWidgets('a new machine asks for its own password', (tester) async { + final connections = ServerConnections( + store: MemoryServerCatalogStore( + catalog: ServerCatalog( + servers: [ + SavedServer.validated( + id: 'mac', + name: 'Mac', + endpoints: ['ws://10.0.0.75:8083/connect'], + ), + ], + selectedId: 'mac', ), - onSelected: (_) async {}, - ); - addTearDown(connections.dispose); - await connections.load(); - final auth = FakeAuthenticator() - ..verdicts['mac'] = const MachineAccessResult(MachineAccess.connected); - connections.authenticator = auth; - final body = SingleChildScrollView( - child: SavedServersSection(connections: connections), - ); - await tester.pumpWidget( - cupertino - ? CupertinoApp( - home: CupertinoPageScaffold(child: SafeArea(child: body)), - ) - : MaterialApp(home: Scaffold(body: body)), - ); - expect(find.text('Connected'), findsOneWidget); - // The new machine is unknown to the authenticator until saved; a - // password verdict arrives for whatever id the editor assigned. - auth.verdicts.addAll({ - for (final id in ['pending']) id: const MachineAccessResult( - MachineAccess.needsPassword, - ), - }); - await tester.tap(find.text('Add server')); - await tester.pumpAndSettle(); - await tester.enterText(find.byKey(const Key('server-profile-name')), 'tank'); - await tester.enterText( - find.byKey(const Key('server-profile-addresses')), - 'ws://10.0.0.100:8082/connect', - ); - // Whatever id the editor chose, that machine wants a password. - connections.addListener(() { - for (final server in connections.catalog.servers) { - auth.verdicts.putIfAbsent( - server.id, - () => const MachineAccessResult(MachineAccess.needsPassword), - ); - auth.passwords.putIfAbsent(server.id, () => 'tank-secret'); - } - }); - await revealSave(tester); - await tester.tap(find.text('Save server')); - await tester.pumpAndSettle(); - final tank = connections.catalog.servers.firstWhere((s) => s.name == 'tank'); - expect(auth.probes, [tank.id]); - // Saved, and the editor now asks this machine's password; the first - // machine's sign-in is not reused. - expect(find.byKey(const Key('server-profile-password')), findsOneWidget); - expect(find.textContaining('asks for its own password'), findsOneWidget); - await tester.enterText( - find.byKey(const Key('server-profile-password')), - 'wrong', - ); - await tester.tap(find.byKey(const Key('server-profile-sign-in'))); - await tester.pumpAndSettle(); - expect(find.text('Wrong password.'), findsOneWidget); - expect(find.byKey(const Key('server-profile-password')), findsOneWidget); - await tester.enterText( - find.byKey(const Key('server-profile-password')), - 'tank-secret', - ); - await tester.tap(find.byKey(const Key('server-profile-sign-in'))); - await tester.pumpAndSettle(); - expect(auth.signIns, [(tank.id, 'wrong'), (tank.id, 'tank-secret')]); - // Back on the list: both machines connected, each on its own sign-in. - expect(find.byKey(const Key('server-profile-password')), findsNothing); - expect(find.text('Connected'), findsNWidgets(2)); - expect(find.text('Address: ws://10.0.0.100:8082/connect'), findsOneWidget); - expect(connections.catalog.active?.id, 'mac'); + ), + onSelected: (_) async {}, + ); + addTearDown(connections.dispose); + await connections.load(); + final auth = FakeAuthenticator() + ..verdicts['mac'] = const MachineAccessResult(MachineAccess.connected); + connections.authenticator = auth; + final body = SingleChildScrollView( + child: SavedServersSection(connections: connections), + ); + await tester.pumpWidget(MaterialApp(home: Scaffold(body: body))); + expect(find.text('Connected'), findsOneWidget); + // The new machine is unknown to the authenticator until saved; a + // password verdict arrives for whatever id the editor assigned. + auth.verdicts.addAll({ + for (final id in ['pending']) + id: const MachineAccessResult(MachineAccess.needsPassword), }); - } + await tester.tap(find.text('Add server')); + await tester.pumpAndSettle(); + await tester.enterText( + find.byKey(const Key('server-profile-name')), + 'tank', + ); + await tester.enterText( + find.byKey(const Key('server-profile-addresses')), + 'ws://10.0.0.100:8082/connect', + ); + // Whatever id the editor chose, that machine wants a password. + connections.addListener(() { + for (final server in connections.catalog.servers) { + auth.verdicts.putIfAbsent( + server.id, + () => const MachineAccessResult(MachineAccess.needsPassword), + ); + auth.passwords.putIfAbsent(server.id, () => 'tank-secret'); + } + }); + await revealSave(tester); + await tester.tap(find.text('Save server')); + await tester.pumpAndSettle(); + final tank = connections.catalog.servers.firstWhere( + (s) => s.name == 'tank', + ); + expect(auth.probes, [tank.id]); + // Saved, and the editor now asks this machine's password; the first + // machine's sign-in is not reused. + expect(find.byKey(const Key('server-profile-password')), findsOneWidget); + expect(find.textContaining('asks for its own password'), findsOneWidget); + await tester.enterText( + find.byKey(const Key('server-profile-password')), + 'wrong', + ); + await tester.tap(find.byKey(const Key('server-profile-sign-in'))); + await tester.pumpAndSettle(); + expect(find.text('Wrong password.'), findsOneWidget); + expect(find.byKey(const Key('server-profile-password')), findsOneWidget); + await tester.enterText( + find.byKey(const Key('server-profile-password')), + 'tank-secret', + ); + await tester.tap(find.byKey(const Key('server-profile-sign-in'))); + await tester.pumpAndSettle(); + expect(auth.signIns, [(tank.id, 'wrong'), (tank.id, 'tank-secret')]); + // Back on the list: both machines connected, each on its own sign-in. + expect(find.byKey(const Key('server-profile-password')), findsNothing); + expect(find.text('Connected'), findsNWidgets(2)); + expect(find.text('Address: ws://10.0.0.100:8082/connect'), findsOneWidget); + expect(connections.catalog.active?.id, 'mac'); + }); testWidgets('an unreachable machine stays saved with the reason shown', ( tester, @@ -172,7 +165,8 @@ void main() { server.id, () => const MachineAccessResult( MachineAccess.unreachable, - detail: 'The HTTPS certificate of 100.85.25.33:8443 does not ' + detail: + 'The HTTPS certificate of 100.85.25.33:8443 does not ' 'cover an IP address.', ), ); @@ -198,7 +192,10 @@ void main() { await tester.tap(find.byKey(const Key('server-sign-in-later'))); await tester.pumpAndSettle(); expect(connections.catalog.servers.single.name, 'Mac by IP'); - expect(find.textContaining('Unreachable: The HTTPS certificate'), findsOneWidget); + expect( + find.textContaining('Unreachable: The HTTPS certificate'), + findsOneWidget, + ); }); testWidgets('a saved machine that wants a password offers Sign in', ( @@ -218,7 +215,9 @@ void main() { addTearDown(connections.dispose); await connections.load(); final auth = FakeAuthenticator() - ..verdicts['tank'] = const MachineAccessResult(MachineAccess.needsPassword) + ..verdicts['tank'] = const MachineAccessResult( + MachineAccess.needsPassword, + ) ..passwords['tank'] = 'tank-secret'; connections.authenticator = auth; await tester.pumpWidget( @@ -231,7 +230,10 @@ void main() { await tester.pumpAndSettle(); await tester.tap(find.text('Sign in to tank')); await tester.pumpAndSettle(); - await tester.enterText(find.byKey(const Key('machine-password')), 'tank-secret'); + await tester.enterText( + find.byKey(const Key('machine-password')), + 'tank-secret', + ); await tester.tap(find.byKey(const Key('machine-sign-in'))); await tester.pumpAndSettle(); expect(auth.signIns, [('tank', 'tank-secret')]); @@ -248,7 +250,9 @@ void main() { endpoints: ['ws://10.0.0.75:8083/connect'], ); final auth = FakeAuthenticator() - ..verdicts['mac'] = const MachineAccessResult(MachineAccess.needsPassword); + ..verdicts['mac'] = const MachineAccessResult( + MachineAccess.needsPassword, + ); SavedServer? saved; await tester.pumpWidget( MaterialApp( @@ -269,7 +273,10 @@ void main() { ); await tester.tap(find.text('Edit')); await tester.pumpAndSettle(); - await tester.enterText(find.byKey(const Key('server-profile-name')), 'Studio'); + await tester.enterText( + find.byKey(const Key('server-profile-name')), + 'Studio', + ); await revealSave(tester); await tester.tap(find.text('Save server')); await tester.pumpAndSettle(); diff --git a/app/test/features/settings/storage/storage_screen_test.dart b/app/test/features/settings/storage/storage_screen_test.dart index 4eb577fc..7360a324 100644 --- a/app/test/features/settings/storage/storage_screen_test.dart +++ b/app/test/features/settings/storage/storage_screen_test.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/features/settings/storage/storage_screen.dart'; @@ -7,8 +6,7 @@ import '../../../../tool/storage_probe_fixture.dart'; Future _mount( WidgetTester tester, - StorageProbeGateway gateway, - bool cupertino, { + StorageProbeGateway gateway, { double width = 900, double scale = 1, }) async { @@ -20,11 +18,7 @@ Future _mount( data: MediaQuery.of(context).copyWith(textScaler: TextScaler.linear(scale)), child: child!, ); - await tester.pumpWidget( - cupertino - ? CupertinoApp(builder: builder, home: screen) - : MaterialApp(builder: builder, home: screen), - ); + await tester.pumpWidget(MaterialApp(builder: builder, home: screen)); await tester.pumpAndSettle(); } @@ -43,83 +37,72 @@ Finder _field(String label) => find.descendant( matching: find.byType(EditableText), ); void main() { - for (final cupertino in [false, true]) { - final style = cupertino ? 'Cupertino' : 'Material'; - testWidgets( - '$style usage and partial measurement remain honest at 2x narrow', - (tester) async { - final gateway = StorageProbeGateway(); - await _mount(tester, gateway, cupertino, width: 560, scale: 2); - expect(find.text('At least 15.0 GiB used'), findsOneWidget); - expect( - find.text('Measurement is incomplete. See details below.'), - findsOneWidget, - ); - expect(find.text('Database'), findsOneWidget); - expect(find.textContaining('6 November 2026'), findsOneWidget); - expect(find.text('Worktrees'), findsOneWidget); - await _tap(tester, 'Preview cleanup'); - expect(find.text('Cleanup preview'), findsOneWidget); - expect( - find.text('Protected · worktree active-item · 4.00 GiB'), - findsOneWidget, - ); - expect(tester.takeException(), isNull); - }, + testWidgets('usage and partial measurement remain honest at 2x narrow', ( + tester, + ) async { + final gateway = StorageProbeGateway(); + await _mount(tester, gateway, width: 560, scale: 2); + expect(find.text('At least 15.0 GiB used'), findsOneWidget); + expect( + find.text('Measurement is incomplete. See details below.'), + findsOneWidget, ); - testWidgets( - '$style cleanup cancellation does not mutate and confirmation uses token', - (tester) async { - final gateway = StorageProbeGateway(); - await _mount(tester, gateway, cupertino); - await _tap(tester, 'Preview cleanup'); - await _tap(tester, 'Apply cleanup'); - expect(find.text('Apply cleanup?'), findsOneWidget); - await _tap(tester, 'Cancel'); - expect( - gateway.calls.where((call) => call.type == 'apply_storage_cleanup'), - isEmpty, - ); - await _tap(tester, 'Apply cleanup'); - await _tap(tester, 'Remove items'); - expect( - gateway.calls - .singleWhere((call) => call.type == 'apply_storage_cleanup') - .fields['storage_cleanup_token'], - 'fixture-preview-token', - ); - expect(find.text('Cleanup result'), findsOneWidget); - expect( - find.text('Worktree became active and was kept.'), - findsOneWidget, - ); - expect(tester.takeException(), isNull); - }, + expect(find.text('Database'), findsOneWidget); + expect(find.textContaining('6 November 2026'), findsOneWidget); + expect(find.text('Worktrees'), findsOneWidget); + await _tap(tester, 'Preview cleanup'); + expect(find.text('Cleanup preview'), findsOneWidget); + expect( + find.text('Protected · worktree active-item · 4.00 GiB'), + findsOneWidget, ); - testWidgets('$style invalid limits do not send a policy', (tester) async { + expect(tester.takeException(), isNull); + }); + testWidgets( + 'cleanup cancellation does not mutate and confirmation uses token', + (tester) async { final gateway = StorageProbeGateway(); - await _mount(tester, gateway, cupertino); - await tester.ensureVisible(_field('Retain data for days')); - await tester.enterText(_field('Retain data for days'), '-1'); - await _tap(tester, 'Save policy'); + await _mount(tester, gateway); + await _tap(tester, 'Preview cleanup'); + await _tap(tester, 'Apply cleanup'); + expect(find.text('Apply cleanup?'), findsOneWidget); + await _tap(tester, 'Cancel'); expect( - find.textContaining('Enter a whole number of days'), - findsOneWidget, - ); - expect( - gateway.calls.where((call) => call.type == 'set_storage_policy'), + gateway.calls.where((call) => call.type == 'apply_storage_cleanup'), isEmpty, ); - }); - testWidgets( - '$style unsupported server has an actionable error and no fake usage', - (tester) async { - final gateway = StorageProbeGateway()..unsupported = true; - await _mount(tester, gateway, cupertino); - expect(find.text('Unknown command: get_storage'), findsOneWidget); - expect(find.text('Server storage'), findsNothing); - expect(find.text('Refresh storage'), findsOneWidget); - }, + await _tap(tester, 'Apply cleanup'); + await _tap(tester, 'Remove items'); + expect( + gateway.calls + .singleWhere((call) => call.type == 'apply_storage_cleanup') + .fields['storage_cleanup_token'], + 'fixture-preview-token', + ); + expect(find.text('Cleanup result'), findsOneWidget); + expect(find.text('Worktree became active and was kept.'), findsOneWidget); + expect(tester.takeException(), isNull); + }, + ); + testWidgets('invalid limits do not send a policy', (tester) async { + final gateway = StorageProbeGateway(); + await _mount(tester, gateway); + await tester.ensureVisible(_field('Retain data for days')); + await tester.enterText(_field('Retain data for days'), '-1'); + await _tap(tester, 'Save policy'); + expect(find.textContaining('Enter a whole number of days'), findsOneWidget); + expect( + gateway.calls.where((call) => call.type == 'set_storage_policy'), + isEmpty, ); - } + }); + testWidgets('unsupported server has an actionable error and no fake usage', ( + tester, + ) async { + final gateway = StorageProbeGateway()..unsupported = true; + await _mount(tester, gateway); + expect(find.text('Unknown command: get_storage'), findsOneWidget); + expect(find.text('Server storage'), findsNothing); + expect(find.text('Refresh storage'), findsOneWidget); + }); }