diff --git a/app/lib/features/runs/actions/cancel_dialog.dart b/app/lib/features/runs/actions/cancel_dialog.dart index 1654f442..6a80880d 100644 --- a/app/lib/features/runs/actions/cancel_dialog.dart +++ b/app/lib/features/runs/actions/cancel_dialog.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'action_refusal.dart'; @@ -21,16 +20,8 @@ Future showCancelRunPrompt({ }) { final prompt = _CancelPrompt( runId: runId, - cupertino: cupertino, onSubmit: onSubmit, ); - if (cupertino) { - return showCupertinoDialog( - context: context, - barrierDismissible: false, - builder: (_) => prompt, - ); - } return showDialog( context: context, barrierDismissible: false, @@ -39,14 +30,9 @@ Future showCancelRunPrompt({ } class _CancelPrompt extends StatefulWidget { - const _CancelPrompt({ - required this.runId, - required this.cupertino, - required this.onSubmit, - }); + const _CancelPrompt({required this.runId, required this.onSubmit}); final num runId; - final bool cupertino; final CancelSubmit onSubmit; @override @@ -97,8 +83,7 @@ class _CancelPromptState extends State<_CancelPrompt> { @override Widget build(BuildContext context) { - final dialog = widget.cupertino ? _cupertino(context) : _material(context); - return PopScope(canPop: !_sending, child: dialog); + return PopScope(canPop: !_sending, child: _material(context)); } bool get _confirmDisabled => _sending || _checking || _blocked; @@ -124,30 +109,6 @@ class _CancelPromptState extends State<_CancelPrompt> { ); } - Widget _cupertino(BuildContext context) { - return CupertinoAlertDialog( - title: Text(cancelDialogTitle(widget.runId)), - content: _body( - errorStyle: TextStyle( - color: CupertinoColors.systemRed.resolveFrom(context), - ), - ), - actions: [ - CupertinoDialogAction( - key: cancelKeepKey, - onPressed: _sending ? null : _keep, - child: const Text(cancelKeepLabel), - ), - CupertinoDialogAction( - key: cancelConfirmKey, - isDestructiveAction: true, - onPressed: _confirmDisabled ? null : _confirm, - child: const Text(cancelConfirmLabel), - ), - ], - ); - } - Widget _body({required TextStyle errorStyle}) { return Column( mainAxisSize: MainAxisSize.min, diff --git a/app/lib/features/runs/actions/cancel_run_action.dart b/app/lib/features/runs/actions/cancel_run_action.dart index 68c4ecc3..38a687e9 100644 --- a/app/lib/features/runs/actions/cancel_run_action.dart +++ b/app/lib/features/runs/actions/cancel_run_action.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../../core/api_gateway.dart'; @@ -36,14 +35,6 @@ class _CancelRunActionState extends State { bool _dialogOpen = false; Future? _resync; - bool _usesCupertino(BuildContext context) { - final material = Localizations.of( - context, - MaterialLocalizations, - ); - return material == null; - } - Future _open() async { final id = cancelRunId(widget.run); if (id == null || !canCancelRun(widget.run) || _dialogOpen) return; @@ -52,7 +43,7 @@ class _CancelRunActionState extends State { await showCancelRunPrompt( context: context, runId: id, - cupertino: _usesCupertino(context), + cupertino: false, onSubmit: () => _submit(id), ); } finally { @@ -103,16 +94,6 @@ class _CancelRunActionState extends State { if (cancelRunId(widget.run) == null || !canCancelRun(widget.run)) { return const SizedBox.shrink(); } - if (_usesCupertino(context)) { - // The web tints Cancel as the one destructive run action. - return CupertinoButton.tinted( - sizeStyle: CupertinoButtonSize.small, - key: cancelActionKey, - color: CupertinoColors.systemRed, - onPressed: _open, - child: const Text(cancelActionLabel), - ); - } return OutlinedButton( key: cancelActionKey, style: OutlinedButton.styleFrom( diff --git a/app/lib/features/runs/actions/decision_action.dart b/app/lib/features/runs/actions/decision_action.dart index 7635f1c4..3c1f2bdd 100644 --- a/app/lib/features/runs/actions/decision_action.dart +++ b/app/lib/features/runs/actions/decision_action.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../../core/api_gateway.dart'; @@ -30,7 +29,8 @@ class HumanDecisionAction extends StatefulWidget { final ApiGateway gateway; final ValueChanged onRunChanged; - /// Overrides the platform style; by default it follows the enclosing app. + /// Retained for callers that still pass a host style; the Material prompt is + /// used everywhere now. final bool? cupertino; @override @@ -53,15 +53,6 @@ class _HumanDecisionActionState extends State { _pending = pendingDecision(widget.run); } - bool _usesCupertino(BuildContext context) { - if (widget.cupertino != null) return widget.cupertino!; - final material = Localizations.of( - context, - MaterialLocalizations, - ); - return material == null; - } - Future _open() async { final decision = _pending; if (decision == null || _dialogOpen) return; @@ -71,7 +62,7 @@ class _HumanDecisionActionState extends State { context: context, run: widget.run, gateway: widget.gateway, - cupertino: _usesCupertino(context), + cupertino: widget.cupertino ?? false, onRunChanged: _acceptRun, isCurrent: () => _owns(decision.runId), ); @@ -93,13 +84,6 @@ class _HumanDecisionActionState extends State { Widget build(BuildContext context) { final decision = _pending; if (decision == null) return const SizedBox.shrink(); - if (_usesCupertino(context)) { - return CupertinoButton.filled( - key: decisionActionKey, - onPressed: _open, - child: const Text(decisionActionLabel), - ); - } return FilledButton( key: decisionActionKey, onPressed: _open, diff --git a/app/lib/features/runs/actions/decision_dialog.dart b/app/lib/features/runs/actions/decision_dialog.dart index c1ceea50..9f477a5e 100644 --- a/app/lib/features/runs/actions/decision_dialog.dart +++ b/app/lib/features/runs/actions/decision_dialog.dart @@ -1,10 +1,8 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../domain/run_decisions.dart'; import '../domain/run_models.dart'; import 'action_refusal.dart'; -import 'decision_option_row.dart'; import 'decision_wording.dart'; /// Sends the draft to the server. Returns null on success, or an @@ -19,18 +17,7 @@ Future showHumanDecisionPrompt({ required bool cupertino, required DecisionSubmit onSubmit, }) { - final prompt = _DecisionPrompt( - decision: decision, - cupertino: cupertino, - onSubmit: onSubmit, - ); - if (cupertino) { - return showCupertinoDialog( - context: context, - barrierDismissible: false, - builder: (_) => prompt, - ); - } + final prompt = _DecisionPrompt(decision: decision, onSubmit: onSubmit); return showDialog( context: context, barrierDismissible: false, @@ -39,14 +26,9 @@ Future showHumanDecisionPrompt({ } class _DecisionPrompt extends StatefulWidget { - const _DecisionPrompt({ - required this.decision, - required this.cupertino, - required this.onSubmit, - }); + const _DecisionPrompt({required this.decision, required this.onSubmit}); final PendingDecision decision; - final bool cupertino; final DecisionSubmit onSubmit; @override @@ -112,8 +94,7 @@ class _DecisionPromptState extends State<_DecisionPrompt> { @override Widget build(BuildContext context) { - final dialog = widget.cupertino ? _cupertino(context) : _material(context); - return PopScope(canPop: !_sending, child: dialog); + return PopScope(canPop: !_sending, child: _material(context)); } bool get _confirmDisabled => _sending || _checking || _blocked; @@ -166,52 +147,6 @@ class _DecisionPromptState extends State<_DecisionPrompt> { ); } - Widget _cupertino(BuildContext context) { - return CupertinoAlertDialog( - title: const Text(decisionWaitingTitle), - content: _body( - errorStyle: TextStyle( - color: CupertinoColors.systemRed.resolveFrom(context), - ), - options: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - for (final (index, option) in widget.decision.options.indexed) - DecisionOptionRow( - key: decisionOptionKey(option.key), - label: option.key, - target: _targetText(option), - selected: _draft.selected == option.key, - divider: index > 0, - onTap: _sending ? null : () => _select(option.key), - ), - ], - ), - feedback: CupertinoTextField( - key: decisionFeedbackKey, - controller: _feedback, - enabled: !_sending, - placeholder: decisionFeedbackLabel, - textInputAction: TextInputAction.done, - onChanged: _feedbackChanged, - onSubmitted: (_) => _confirm(), - ), - ), - actions: [ - CupertinoDialogAction( - onPressed: _sending ? null : _cancel, - child: const Text(decisionCancelLabel), - ), - CupertinoDialogAction( - isDefaultAction: true, - onPressed: _confirmDisabled || !_draft.canSubmit ? null : _confirm, - child: Text(_sending ? decisionSendingLabel : decisionConfirmLabel), - ), - ], - ); - } - Widget _body({ required TextStyle errorStyle, required Widget options, diff --git a/app/lib/features/runs/actions/decision_option_row.dart b/app/lib/features/runs/actions/decision_option_row.dart deleted file mode 100644 index 94e4e800..00000000 --- a/app/lib/features/runs/actions/decision_option_row.dart +++ /dev/null @@ -1,109 +0,0 @@ -import 'package:flutter/cupertino.dart'; - -/// One option row in the Cupertino decision prompt, keyed by the option. -ValueKey decisionOptionKey(String option) => - ValueKey('human-decision-option-$option'); - -/// One choice of the Cupertino decision prompt: a check-list row. -/// -/// The option reads as text in the label colour, not as a blue link, with its -/// target underneath in the secondary colour. An empty circle marks an -/// unpicked row and a filled check circle the picked one, so the choice is -/// visible before Confirm. The whole row is the tap target; semantics report -/// it as a selectable member of one exclusive group. A null [onTap] (while -/// sending) dims the row. -class DecisionOptionRow extends StatelessWidget { - const DecisionOptionRow({ - super.key, - required this.label, - required this.selected, - required this.onTap, - this.target, - this.divider = false, - }); - - final String label; - final String? target; - final bool selected; - final bool divider; - final VoidCallback? onTap; - - @override - Widget build(BuildContext context) { - final theme = CupertinoTheme.of(context); - final enabled = onTap != null; - final labelColor = enabled - ? CupertinoColors.label.resolveFrom(context) - : CupertinoColors.tertiaryLabel.resolveFrom(context); - final mark = selected - ? Icon( - CupertinoIcons.checkmark_circle_fill, - color: enabled - ? theme.primaryColor - : CupertinoColors.tertiaryLabel.resolveFrom(context), - ) - : Icon( - CupertinoIcons.circle, - color: CupertinoColors.tertiaryLabel.resolveFrom(context), - ); - final row = Padding( - padding: const EdgeInsets.symmetric(vertical: 10), - child: Row( - children: [ - mark, - const SizedBox(width: 10), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - label, - textAlign: TextAlign.start, - style: theme.textTheme.textStyle.copyWith( - color: labelColor, - fontWeight: selected ? FontWeight.w600 : null, - ), - ), - if (target case final target?) - Text( - target, - textAlign: TextAlign.start, - style: theme.textTheme.textStyle.copyWith( - fontSize: 13, - color: CupertinoColors.secondaryLabel.resolveFrom( - context, - ), - ), - ), - ], - ), - ), - ], - ), - ); - return Semantics( - inMutuallyExclusiveGroup: true, - selected: selected, - checked: selected, - button: true, - enabled: enabled, - child: DecoratedBox( - decoration: BoxDecoration( - border: divider - ? Border( - top: BorderSide( - color: CupertinoColors.separator.resolveFrom(context), - width: 0, - ), - ) - : null, - ), - child: GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: onTap, - child: row, - ), - ), - ); - } -} diff --git a/app/lib/features/runs/actions/delete_runs_action.dart b/app/lib/features/runs/actions/delete_runs_action.dart index aa3685d5..d0fd904e 100644 --- a/app/lib/features/runs/actions/delete_runs_action.dart +++ b/app/lib/features/runs/actions/delete_runs_action.dart @@ -1,7 +1,6 @@ import 'package:flutter/widgets.dart'; import '../../../core/api_gateway.dart'; -import '../../../ui/adaptive/host.dart'; import '../data/runs_repository.dart'; import '../domain/run_deletion.dart'; import 'delete_runs_dialog.dart'; @@ -25,7 +24,7 @@ Future confirmDeleteRuns( context: context, count: ids.length, size: runsSizeLabel(deletable), - cupertino: cupertino ?? usesCupertinoHost(context), + cupertino: cupertino ?? false, onSubmit: () async { try { onDeleted(await RunsRepository(gateway).deleteRuns(ids)); diff --git a/app/lib/features/runs/actions/delete_runs_dialog.dart b/app/lib/features/runs/actions/delete_runs_dialog.dart index ef28ee3d..44e48bac 100644 --- a/app/lib/features/runs/actions/delete_runs_dialog.dart +++ b/app/lib/features/runs/actions/delete_runs_dialog.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../domain/run_deletion.dart'; @@ -22,23 +21,12 @@ Future showDeleteRunsPrompt({ required bool cupertino, required DeleteRunsSubmit onSubmit, }) async { - final prompt = _DeleteRunsPrompt( - count: count, - size: size, - cupertino: cupertino, - onSubmit: onSubmit, + final prompt = _DeleteRunsPrompt(count: count, size: size, onSubmit: onSubmit); + final result = await showDialog( + context: context, + barrierDismissible: false, + builder: (_) => prompt, ); - final result = cupertino - ? await showCupertinoDialog( - context: context, - barrierDismissible: false, - builder: (_) => prompt, - ) - : await showDialog( - context: context, - barrierDismissible: false, - builder: (_) => prompt, - ); return result ?? false; } @@ -46,13 +34,11 @@ class _DeleteRunsPrompt extends StatefulWidget { const _DeleteRunsPrompt({ required this.count, required this.size, - required this.cupertino, required this.onSubmit, }); final int count; final String? size; - final bool cupertino; final DeleteRunsSubmit onSubmit; @override @@ -88,7 +74,7 @@ class _DeleteRunsPromptState extends State<_DeleteRunsPrompt> { @override Widget build(BuildContext context) => PopScope( canPop: !_sending, - child: widget.cupertino ? _cupertinoDialog(context) : _material(context), + child: _material(context), ); Widget _material(BuildContext context) { @@ -116,26 +102,6 @@ class _DeleteRunsPromptState extends State<_DeleteRunsPrompt> { ); } - Widget _cupertinoDialog(BuildContext context) => CupertinoAlertDialog( - title: Text(deleteRunsTitle(widget.count)), - content: _body( - TextStyle(color: CupertinoColors.systemRed.resolveFrom(context)), - ), - actions: [ - CupertinoDialogAction( - key: deleteRunsKeepKey, - onPressed: _sending ? null : _keep, - child: const Text('Cancel'), - ), - CupertinoDialogAction( - key: deleteRunsConfirmKey, - isDestructiveAction: true, - onPressed: _sending ? null : _confirm, - child: Text(_sending ? 'Deleting…' : 'Delete'), - ), - ], - ); - Widget _body(TextStyle errorStyle) => Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, diff --git a/app/lib/features/runs/actions/retry_action.dart b/app/lib/features/runs/actions/retry_action.dart index 8fec7a34..c38ef52c 100644 --- a/app/lib/features/runs/actions/retry_action.dart +++ b/app/lib/features/runs/actions/retry_action.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../../core/api_gateway.dart'; @@ -42,8 +41,6 @@ class RetryRunAction extends StatefulWidget { class _RetryRunActionState extends State { bool _dialogOpen = false; - bool _usesCupertino(BuildContext context) => _cupertinoLocale(context); - Future _open() async { if (_dialogOpen) return; _dialogOpen = true; @@ -67,14 +64,6 @@ class _RetryRunActionState extends State { if (retryRunId(widget.run) == null || !canRetryRun(widget.run)) { return const SizedBox.shrink(); } - if (_usesCupertino(context)) { - return CupertinoButton.tinted( - sizeStyle: CupertinoButtonSize.small, - key: retryActionKey, - onPressed: _open, - child: const Text(retryActionLabel), - ); - } return OutlinedButton( key: retryActionKey, onPressed: _open, @@ -83,10 +72,6 @@ class _RetryRunActionState extends State { } } -bool _cupertinoLocale(BuildContext context) => - Localizations.of(context, MaterialLocalizations) == - null; - /// Opens the retry prompt for a failed [run]; only its confirm sends /// `retry_run`. An accepted reply reaches [onRunChanged] while [owns] still /// holds, and a new run id opens through [onRunOpened]. A refusal re-reads the @@ -121,7 +106,7 @@ Future openRetryRunPrompt( await showRetryRunPrompt( context: context, runId: id, - cupertino: _cupertinoLocale(context), + cupertino: false, onSubmit: (intent) async { try { final updated = await repository.retryRun( diff --git a/app/lib/features/runs/actions/retry_dialog.dart b/app/lib/features/runs/actions/retry_dialog.dart index 846133a1..c0f8d1a3 100644 --- a/app/lib/features/runs/actions/retry_dialog.dart +++ b/app/lib/features/runs/actions/retry_dialog.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'action_refusal.dart'; @@ -24,16 +23,8 @@ Future showRetryRunPrompt({ }) { final prompt = _RetryPrompt( runId: runId, - cupertino: cupertino, onSubmit: onSubmit, ); - if (cupertino) { - return showCupertinoDialog( - context: context, - barrierDismissible: false, - builder: (_) => prompt, - ); - } return showDialog( context: context, barrierDismissible: false, @@ -42,14 +33,9 @@ Future showRetryRunPrompt({ } class _RetryPrompt extends StatefulWidget { - const _RetryPrompt({ - required this.runId, - required this.cupertino, - required this.onSubmit, - }); + const _RetryPrompt({required this.runId, required this.onSubmit}); final num runId; - final bool cupertino; final RetrySubmit onSubmit; @override @@ -116,8 +102,7 @@ class _RetryPromptState extends State<_RetryPrompt> { @override Widget build(BuildContext context) { - final dialog = widget.cupertino ? _cupertino(context) : _material(context); - return PopScope(canPop: !_sending, child: dialog); + return PopScope(canPop: !_sending, child: _material(context)); } bool get _confirmDisabled => _sending || _checking || _blocked; @@ -150,36 +135,6 @@ class _RetryPromptState extends State<_RetryPrompt> { ); } - Widget _cupertino(BuildContext context) { - return CupertinoAlertDialog( - title: Text(_dialogTitle), - content: _body( - errorStyle: TextStyle( - color: CupertinoColors.systemRed.resolveFrom(context), - ), - ), - actions: [ - if (_showRestart) - CupertinoDialogAction( - key: retryRestartKey, - onPressed: _sending || _checking ? null : _restart, - child: const Text(restartConfirmLabel), - ), - CupertinoDialogAction( - key: retryKeepKey, - onPressed: _sending ? null : _keep, - child: const Text(retryKeepLabel), - ), - CupertinoDialogAction( - key: retryConfirmKey, - isDestructiveAction: _mode == RetryMode.restart, - onPressed: _confirmDisabled ? null : _confirm, - child: Text(_confirmLabel), - ), - ], - ); - } - Widget _body({required TextStyle errorStyle}) { return Column( mainAxisSize: MainAxisSize.min, diff --git a/app/lib/features/runs/actions/session_export_repair_action.dart b/app/lib/features/runs/actions/session_export_repair_action.dart index 140c80c4..75e7a3f2 100644 --- a/app/lib/features/runs/actions/session_export_repair_action.dart +++ b/app/lib/features/runs/actions/session_export_repair_action.dart @@ -1,9 +1,7 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../../core/api_gateway.dart'; import '../../../core/error_reason.dart'; -import '../../../ui/adaptive/host.dart'; import '../data/runs_repository.dart'; /// The browser client's export-only repair wording, kept verbatim. @@ -131,22 +129,15 @@ class _SessionExportRepairActionState extends State { final label = _sending ? sessionExportRepairBusyLabel : sessionExportRepairLabel; - final cupertino = usesCupertinoHost(context); - final button = cupertino - ? CupertinoButton( - padding: EdgeInsets.zero, - onPressed: enabled ? _send : null, - child: Text(label), - ) - : TextButton(onPressed: enabled ? _send : null, child: Text(label)); + final button = TextButton( + onPressed: enabled ? _send : null, + child: Text(label), + ); return Column( key: sessionExportRepairKey, crossAxisAlignment: CrossAxisAlignment.start, children: [ - if (cupertino) - button - else - Tooltip(message: sessionExportRepairHelp, child: button), + Tooltip(message: sessionExportRepairHelp, child: button), if (_refusal != null) Padding( padding: const EdgeInsets.only(top: 8), diff --git a/app/lib/features/runs/actions/title_action.dart b/app/lib/features/runs/actions/title_action.dart index f09eb585..e4e01d0e 100644 --- a/app/lib/features/runs/actions/title_action.dart +++ b/app/lib/features/runs/actions/title_action.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../../core/api_gateway.dart'; @@ -33,8 +32,6 @@ class RunTitleAction extends StatefulWidget { class _RunTitleActionState extends State { bool _dialogOpen = false; - bool _usesCupertino(BuildContext context) => _cupertinoLocale(context); - Future _open() async { if (_dialogOpen) return; _dialogOpen = true; @@ -55,14 +52,6 @@ class _RunTitleActionState extends State { @override Widget build(BuildContext context) { if (runTitleId(widget.run) == null) return const SizedBox.shrink(); - if (_usesCupertino(context)) { - return CupertinoButton.tinted( - sizeStyle: CupertinoButtonSize.small, - key: runTitleActionKey, - onPressed: _open, - child: const Text(runTitleActionLabel), - ); - } return OutlinedButton( key: runTitleActionKey, onPressed: _open, @@ -71,10 +60,6 @@ class _RunTitleActionState extends State { } } -bool _cupertinoLocale(BuildContext context) => - Localizations.of(context, MaterialLocalizations) == - null; - /// Opens the rename prompt for [run]; only Save sends `set_run_title`, and the /// server's returned detail reaches [onRunChanged] while [owns] still holds /// for that run id. Shared by the button and the run detail's more menu. @@ -92,7 +77,7 @@ Future openRunTitleEditor( context: context, runId: id, initialTitle: storedRunTitle(run), - cupertino: _cupertinoLocale(context), + cupertino: false, onSubmit: (title) async { if (saving) return const ActionRefusal(actionAlreadySending); saving = true; diff --git a/app/lib/features/runs/actions/title_dialog.dart b/app/lib/features/runs/actions/title_dialog.dart index 9ae03a11..d9dd0302 100644 --- a/app/lib/features/runs/actions/title_dialog.dart +++ b/app/lib/features/runs/actions/title_dialog.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'action_refusal.dart'; @@ -26,16 +25,8 @@ Future showRunTitlePrompt({ final prompt = _TitlePrompt( runId: runId, initialTitle: initialTitle, - cupertino: cupertino, onSubmit: onSubmit, ); - if (cupertino) { - return showCupertinoDialog( - context: context, - barrierDismissible: false, - builder: (_) => prompt, - ); - } return showDialog( context: context, barrierDismissible: false, @@ -47,13 +38,11 @@ class _TitlePrompt extends StatefulWidget { const _TitlePrompt({ required this.runId, required this.initialTitle, - required this.cupertino, required this.onSubmit, }); final num runId; final String initialTitle; - final bool cupertino; final TitleSubmit onSubmit; @override @@ -97,8 +86,7 @@ class _TitlePromptState extends State<_TitlePrompt> { @override Widget build(BuildContext context) { - final dialog = widget.cupertino ? _cupertino(context) : _material(context); - return PopScope(canPop: !_sending, child: dialog); + return PopScope(canPop: !_sending, child: _material(context)); } Widget _material(BuildContext context) { @@ -133,39 +121,6 @@ class _TitlePromptState extends State<_TitlePrompt> { ); } - Widget _cupertino(BuildContext context) { - return CupertinoAlertDialog( - title: const Text(runTitleDialogTitle), - content: _body( - field: CupertinoTextField( - key: runTitleFieldKey, - controller: _title, - enabled: !_sending, - autofocus: true, - placeholder: runTitleFieldLabel, - textInputAction: TextInputAction.done, - onSubmitted: (_) => _save(), - ), - errorStyle: TextStyle( - color: CupertinoColors.systemRed.resolveFrom(context), - ), - ), - actions: [ - CupertinoDialogAction( - key: runTitleCancelKey, - onPressed: _sending ? null : _cancel, - child: const Text(runTitleCancelLabel), - ), - CupertinoDialogAction( - key: runTitleSaveKey, - isDefaultAction: true, - onPressed: _sending ? null : _save, - child: const Text(runTitleSaveLabel), - ), - ], - ); - } - Widget _body({required Widget field, required TextStyle errorStyle}) { return Column( mainAxisSize: MainAxisSize.min, diff --git a/app/lib/shell/adaptive_shell.dart b/app/lib/shell/adaptive_shell.dart index dd81fd6f..9427c9da 100644 --- a/app/lib/shell/adaptive_shell.dart +++ b/app/lib/shell/adaptive_shell.dart @@ -1,10 +1,8 @@ import '../ui/motion/fade_through_stack.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import '../ui/adaptive/segmented_bar.dart'; -import '../ui/adaptive/floating_bar_layout.dart'; import '../ui/adaptive/floating_destination_bar.dart'; import 'attention_badge.dart'; import 'destination.dart'; @@ -37,6 +35,9 @@ class AdaptiveShell extends StatefulWidget { final ListPaneWidthStore listPaneWidthStore; final Map destinationBodies; + + /// Retained for callers that still pass it; the shell always draws the + /// Material controls and scaffold whether this is set or not. final bool cupertino; /// The destination a route owner selected. When null the shell keeps its own @@ -120,7 +121,7 @@ class _AdaptiveShellState extends State { key: const ValueKey('shell.badge.chat.unread'), count: _bar.badge(destination, ShellBadgeKind.unread), label: 'unread chats', - cupertino: widget.cupertino, + cupertino: false, child: icon, ); } @@ -130,12 +131,12 @@ class _AdaptiveShellState extends State { final attention = widget.attentionCount > 0; return AttentionDestinationIcon( count: widget.attentionCount, - cupertino: widget.cupertino, + cupertino: false, child: ActivityBadge( key: const ValueKey('shell.badge.runs.running'), count: attention ? 0 : _bar.badge(destination, ShellBadgeKind.running), label: 'runs in progress', - cupertino: widget.cupertino, + cupertino: false, child: icon, ), ); @@ -202,7 +203,7 @@ class _AdaptiveShellState extends State { alignment: AlignmentDirectional.bottomStart, child: FloatingDestinationBar( showLabels: true, - cupertino: widget.cupertino, + cupertino: false, currentIndex: index, onTap: (value) => _select(shellTabDestinations[value]), items: _destinationItems(), @@ -240,24 +241,6 @@ class _AdaptiveShellState extends State { }, child: child, ); - if (widget.cupertino) { - return backable( - ShellSystemInsets( - padding: system, - child: CupertinoPageScaffold( - navigationBar: topBar, - child: SafeArea( - top: false, - bottom: false, - child: FloatingBarOverlay( - bar: bar, - child: _destinationStack(contents), - ), - ), - ), - ), - ); - } return backable( ShellSystemInsets( padding: system, @@ -352,10 +335,7 @@ class _AdaptiveShellState extends State { final item = destinationDetails(destination); return FloatingDestinationItem( key: ValueKey('shell.destination.${destination.name}'), - icon: _icon( - destination, - widget.cupertino ? item.cupertinoIcon : item.icon, - ), + icon: _icon(destination, item.icon), label: item.label, ); }).toList(); @@ -367,18 +347,17 @@ class _AdaptiveShellState extends State { String label, { required bool page, }) { - final cupertino = widget.cupertino; final onBack = spec?.onBack ?? (page ? _closePage : null); final published = spec?.actions ?? const []; final onSearch = widget.onSearch; return SegmentedBar( - cupertino: cupertino, + cupertino: false, automaticallyImplyLeading: false, leading: onBack == null ? null : SegmentedBackButton( key: const ValueKey('shell.back'), - cupertino: cupertino, + cupertino: false, onPressed: onBack, ), title: spec?.title ?? label, @@ -401,22 +380,12 @@ class _AdaptiveShellState extends State { // A screen whose main pill is its own field (Search) needs no // separate Search action. else if (onSearch != null && spec?.titleWidget == null && !page) - cupertino - ? CupertinoButton( - key: const ValueKey('shell.search'), - padding: EdgeInsets.zero, - onPressed: onSearch, - child: const Icon( - CupertinoIcons.search, - semanticLabel: 'Search', - ), - ) - : IconButton( - key: const ValueKey('shell.search'), - onPressed: onSearch, - tooltip: 'Search', - icon: const Icon(Icons.search), - ), + IconButton( + key: const ValueKey('shell.search'), + onPressed: onSearch, + tooltip: 'Search', + icon: const Icon(Icons.search), + ), ...widget.barActions, ], ); @@ -438,10 +407,9 @@ class _AdaptiveShellState extends State { /// split never remounts it. /// /// It rebuilds itself when [listenable] (the focused destination's published -/// bar) changes; [initial] supplies the size and obstruction, which do not -/// depend on the published contents. -class _ListPaneBar extends StatelessWidget - implements ObstructingPreferredSizeWidget { +/// bar) changes; [initial] supplies the size, which does not depend on the +/// published contents. +class _ListPaneBar extends StatelessWidget implements PreferredSizeWidget { const _ListPaneBar({ required this.listenable, required this.initial, @@ -461,10 +429,6 @@ class _ListPaneBar extends StatelessWidget @override Size get preferredSize => initial.preferredSize; - @override - bool shouldFullyObstruct(BuildContext context) => - initial.shouldFullyObstruct(context); - @override Widget build(BuildContext context) => ListenableBuilder( listenable: listenable, diff --git a/app/lib/shell/attention_badge.dart b/app/lib/shell/attention_badge.dart index 24662a34..53507407 100644 --- a/app/lib/shell/attention_badge.dart +++ b/app/lib/shell/attention_badge.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../features/attention/domain/attention_models.dart'; @@ -8,9 +7,8 @@ import '../ui/motion/motion.dart'; /// /// The bell itself lives in the Runs heading, so without this the count would /// be visible only on that destination; the web mirrors it on the rail and -/// dock tab. Material hosts use the framework [Badge]; Cupertino has no badge -/// control, so its tab bar and sidebar get the host's red count overlay. Zero -/// draws the bare icon, and a count labels the item exactly like the bell: +/// dock tab. Material hosts use the framework [Badge]. Zero draws the bare +/// icon, and a count labels the item exactly like the bell: /// `Notifications, {n} needing attention`. class AttentionDestinationIcon extends StatelessWidget { const AttentionDestinationIcon({ @@ -21,24 +19,25 @@ class AttentionDestinationIcon extends StatelessWidget { }); final int count; + + /// Retained for callers that still pass it; the icon is always the Material + /// [Badge] whether this is set or not. final bool cupertino; final Widget child; @override Widget build(BuildContext context) { final visible = count > 0; - final Widget icon = cupertino - ? _CupertinoCountOverlay(count: count, visible: visible, child: child) - : Badge( - label: visible - ? MotionSwitcher( - scale: true, - child: Text('$count', key: ValueKey(count)), - ) - : null, - isLabelVisible: visible, - child: child, - ); + final Widget icon = Badge( + label: visible + ? MotionSwitcher( + scale: true, + child: Text('$count', key: ValueKey(count)), + ) + : null, + isLabelVisible: visible, + child: child, + ); if (!visible) return icon; // The number alone would read as a stray "3"; the item carries the bell's // full label instead. @@ -49,51 +48,6 @@ class AttentionDestinationIcon extends StatelessWidget { } } -/// The iOS tab-badge idiom: a red stadium with the count over the icon's -/// trailing corner. Content-driven size; only the overlap offset is fixed. -class _CupertinoCountOverlay extends StatelessWidget { - const _CupertinoCountOverlay({ - required this.count, - required this.visible, - required this.child, - }); - - final int count; - final bool visible; - final Widget child; - - @override - Widget build(BuildContext context) { - if (!visible) return child; - final style = CupertinoTheme.of( - context, - ).textTheme.tabLabelTextStyle.copyWith(color: CupertinoColors.white); - return Stack( - clipBehavior: Clip.none, - children: [ - child, - PositionedDirectional( - top: -6, - end: -10, - child: DecoratedBox( - decoration: ShapeDecoration( - color: CupertinoColors.systemRed.resolveFrom(context), - shape: const StadiumBorder(), - ), - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 1), - child: MotionSwitcher( - scale: true, - child: Text('$count', key: ValueKey(count), style: style), - ), - ), - ), - ), - ], - ); - } -} - /// A small count on a tab icon: blue for activity (runs in progress, unread /// chats), so it reads apart from the red needs-you count. class ActivityBadge extends StatelessWidget { @@ -108,6 +62,9 @@ class ActivityBadge extends StatelessWidget { final int count; final String label; + + /// Retained for callers that still pass it; the badge uses the Material + /// theme colours whether this is set or not. final bool cupertino; final bool bottom; final Widget child; @@ -115,12 +72,8 @@ class ActivityBadge extends StatelessWidget { @override Widget build(BuildContext context) { final visible = count > 0; - final color = cupertino - ? CupertinoColors.systemBlue.resolveFrom(context) - : Theme.of(context).colorScheme.primary; - final text = cupertino - ? CupertinoColors.white - : Theme.of(context).colorScheme.onPrimary; + final color = Theme.of(context).colorScheme.primary; + final text = Theme.of(context).colorScheme.onPrimary; final stack = Stack( clipBehavior: Clip.none, children: [ diff --git a/app/lib/shell/destination.dart b/app/lib/shell/destination.dart index fd53f6c8..3d5283cb 100644 --- a/app/lib/shell/destination.dart +++ b/app/lib/shell/destination.dart @@ -1,5 +1,5 @@ -import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; enum AppDestination { pipelines, runs, chat, search, settings } @@ -20,6 +20,10 @@ AppDestination shellTabFor(AppDestination destination) => ? destination : AppDestination.pipelines; +/// The label and icons for [value]. +/// +/// [cupertinoIcon] is retained in the record for callers that still read it; +/// the shell itself draws [icon] on its Material path. ({String label, IconData icon, IconData cupertinoIcon}) destinationDetails( AppDestination value, ) => switch (value) { diff --git a/app/lib/shell/detail_page.dart b/app/lib/shell/detail_page.dart index 11941427..375f2aae 100644 --- a/app/lib/shell/detail_page.dart +++ b/app/lib/shell/detail_page.dart @@ -1,7 +1,5 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import '../ui/adaptive/host.dart'; import '../ui/adaptive/segmented_bar.dart'; import '../ui/motion/container_transform_route.dart'; import '../ui/motion/container_transform_source.dart'; @@ -93,17 +91,14 @@ PageRoute detailPageRoute( ContainerTransformLink? growFrom, }) { final page = DetailPane(destination: destination, builder: builder); - final cupertino = usesCupertinoHost(context); if (growFrom != null) { return ContainerTransformPageRoute( link: growFrom, - cupertino: cupertino, + cupertino: false, builder: (_) => page, ); } - return cupertino - ? CupertinoPageRoute(builder: (_) => page) - : MaterialPageRoute(builder: (_) => page); + return MaterialPageRoute(builder: (_) => page); } /// An open item's own bar over its content: what the content publishes @@ -151,11 +146,10 @@ class _DetailPaneState extends State { // status-bar inset itself. The scaffold and the body's place in it stay // the same either way, so switching never remounts the content. final barless = spec?.barless ?? false; - final cupertino = usesCupertinoHost(context); final bar = barless ? null : SegmentedBar( - cupertino: cupertino, + cupertino: false, automaticallyImplyLeading: widget.implyBack, title: title, subtitle: spec?.subtitle, @@ -171,9 +165,6 @@ class _DetailPaneState extends State { // pads its lists by the bar's height (top) and by the system's or a // floating tab bar's (bottom), floating its own tabs clear of them. final content = SafeArea(top: false, bottom: false, child: body); - if (cupertino) { - return CupertinoPageScaffold(navigationBar: bar, child: content); - } return Scaffold( extendBodyBehindAppBar: true, appBar: bar, diff --git a/app/lib/shell/detail_pane_navigator.dart b/app/lib/shell/detail_pane_navigator.dart index abeec02b..f2cb096d 100644 --- a/app/lib/shell/detail_pane_navigator.dart +++ b/app/lib/shell/detail_pane_navigator.dart @@ -1,7 +1,5 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import '../ui/adaptive/host.dart'; import '../ui/motion/surface_visibility.dart'; /// The open item's own navigator beside a list on a wide window. @@ -43,9 +41,10 @@ class _DetailPaneNavigatorState extends State { @override Widget build(BuildContext context) { - final Page root = usesCupertinoHost(context) - ? CupertinoPage(key: _rootKey, child: widget.child) - : MaterialPage(key: _rootKey, child: widget.child); + final Page root = MaterialPage( + key: _rootKey, + child: widget.child, + ); // Only the shown tab's pane answers the system Back: a page left open in // another tab's pane stays there while Back acts on the current tab. The // route asks every handler on it, so a hidden pane also ignores the call. diff --git a/app/lib/shell/empty_detail_pane.dart b/app/lib/shell/empty_detail_pane.dart index 935718f3..01b71a94 100644 --- a/app/lib/shell/empty_detail_pane.dart +++ b/app/lib/shell/empty_detail_pane.dart @@ -1,7 +1,5 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import '../ui/adaptive/host.dart'; import 'destination.dart'; /// The detail pane beside a list before anything is chosen: the @@ -19,22 +17,15 @@ class EmptyDetailPane extends StatelessWidget { @override Widget build(BuildContext context) { - final cupertino = usesCupertinoHost(context); final details = destinationDetails(destination); - final color = cupertino - ? CupertinoColors.secondaryLabel.resolveFrom(context) - : Theme.of(context).colorScheme.onSurfaceVariant; + final color = Theme.of(context).colorScheme.onSurfaceVariant; return Center( child: Padding( padding: const EdgeInsets.all(24), child: Column( mainAxisSize: MainAxisSize.min, children: [ - Icon( - cupertino ? details.cupertinoIcon : details.icon, - size: 32, - color: color, - ), + Icon(details.icon, size: 32, color: color), const SizedBox(height: 12), Text( message, diff --git a/app/lib/shell/list_pane_divider.dart b/app/lib/shell/list_pane_divider.dart index cc19c2be..2abddf31 100644 --- a/app/lib/shell/list_pane_divider.dart +++ b/app/lib/shell/list_pane_divider.dart @@ -1,9 +1,7 @@ import 'package:flutter/gestures.dart' show DragStartBehavior; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import '../ui/adaptive/host.dart'; import '../ui/adaptive/resize_grip.dart'; /// How wide the divider's invisible grab area is, centred on its line. @@ -17,12 +15,7 @@ class ListPaneDividerLine extends StatelessWidget { const ListPaneDividerLine({super.key}); @override - Widget build(BuildContext context) => usesCupertinoHost(context) - ? Container( - width: 1, - color: CupertinoColors.separator.resolveFrom(context), - ) - : const VerticalDivider(width: 1); + Widget build(BuildContext context) => const VerticalDivider(width: 1); } /// The grab area over [ListPaneDividerLine]: dragging it (mouse or touch) diff --git a/app/lib/shell/shell_destination_menu.dart b/app/lib/shell/shell_destination_menu.dart index be07d499..04b13daa 100644 --- a/app/lib/shell/shell_destination_menu.dart +++ b/app/lib/shell/shell_destination_menu.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'destination.dart'; @@ -10,48 +9,19 @@ class ShellDestinationMenu extends StatelessWidget { required this.current, required this.onSelected, }); + + /// Retained for callers that still pass it; the menu is always the Material + /// popup whether this is set or not. final bool cupertino; final AppDestination current; final ValueChanged onSelected; - Future _choose(BuildContext context) async { - final value = await showCupertinoModalPopup( - context: context, - builder: (context) => CupertinoActionSheet( - title: const Text('Main navigation'), - actions: [ - for (final destination in AppDestination.values) - CupertinoActionSheetAction( - isDefaultAction: destination == current, - onPressed: () => Navigator.pop(context, destination), - child: Text(destinationDetails(destination).label), - ), - ], - cancelButton: CupertinoActionSheetAction( - onPressed: () => Navigator.pop(context), - child: const Text('Cancel'), - ), - ), - ); - if (value != null && context.mounted) onSelected(value); - } - @override Widget build(BuildContext context) { final child = Column( mainAxisSize: MainAxisSize.min, - children: [ - Icon(cupertino ? CupertinoIcons.square_grid_2x2 : Icons.apps), - const Text('Menu'), - ], + children: const [Icon(Icons.apps), Text('Menu')], ); - if (cupertino) { - return Semantics( - button: true, - label: 'Main navigation', - child: CupertinoButton(onPressed: () => _choose(context), child: child), - ); - } return PopupMenuButton( tooltip: 'Main navigation', onSelected: onSelected, diff --git a/app/test/application/list_detail_consistency_test.dart b/app/test/application/list_detail_consistency_test.dart index 9ea22c32..d39a67d3 100644 --- a/app/test/application/list_detail_consistency_test.dart +++ b/app/test/application/list_detail_consistency_test.dart @@ -2,7 +2,6 @@ import 'dart:math' as math; import 'dart:ui' show Tristate; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/shell/list_detail.dart'; @@ -18,266 +17,247 @@ import 'package:pipelines_app/ui/theme/app_theme.dart'; import '../features/pipelines/fixtures.dart'; void main() { - for (final cupertino in [false, true]) { - for (final brightness in Brightness.values) { - for (final width in [640.0, 840.0, 1280.0]) { - for (final scale in [1.0, 2.0]) { - testWidgets('shared body-priority panes and selected rows: $cupertino ' - '$brightness at $width @${scale}x', (tester) async { - SharedPreferences.setMockInitialValues({}); - tester.view.physicalSize = Size(width, 900); - tester.view.devicePixelRatio = 1; - addTearDown(tester.view.reset); - tester.platformDispatcher.textScaleFactorTestValue = scale; - addTearDown( - tester.platformDispatcher.clearTextScaleFactorTestValue, - ); - final fixture = PipelineFixture(); - final gateway = FakeGateway( - (type, fields) => switch (type) { - 'list_pipelines' => pipelineListReply(fixture.summaries), - 'get_pipeline' => pipelineDetailReply( - fixture.detailFor( - fields['pipeline_id'] as int, - fields['version'] as int, - )!, - ), - 'list_runs' => { - 'runs': [ - for (final id in [1, 2]) - { - 'id': id, - 'title': 'Run item $id', - 'status': 'succeeded', - }, - ], + for (final brightness in Brightness.values) { + for (final width in [640.0, 840.0, 1280.0]) { + for (final scale in [1.0, 2.0]) { + testWidgets('shared body-priority panes and selected rows: ' + '$brightness at $width @${scale}x', (tester) async { + SharedPreferences.setMockInitialValues({}); + tester.view.physicalSize = Size(width, 900); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + tester.platformDispatcher.textScaleFactorTestValue = scale; + addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue); + final fixture = PipelineFixture(); + final gateway = FakeGateway( + (type, fields) => switch (type) { + 'list_pipelines' => pipelineListReply(fixture.summaries), + 'get_pipeline' => pipelineDetailReply( + fixture.detailFor( + fields['pipeline_id'] as int, + fields['version'] as int, + )!, + ), + 'list_runs' => { + 'runs': [ + for (final id in [1, 2]) + {'id': id, 'title': 'Run item $id', 'status': 'succeeded'}, + ], + }, + 'get_run' => { + 'run_detail': { + 'id': fields['run_id'], + 'title': 'Run item ${fields['run_id']}', + 'status': 'succeeded', + 'input': {'prompt': 'Recorded input'}, }, - 'get_run' => { - 'run_detail': { - 'id': fields['run_id'], - 'title': 'Run item ${fields['run_id']}', - 'status': 'succeeded', - 'input': {'prompt': 'Recorded input'}, + }, + 'chat_sessions' => { + 'chat_sessions': [ + { + 'id': 'a', + 'title': 'Chat item a', + 'backend': 'claude', + 'model': 'claude-opus', + 'mode': 'auto', + 'mode_name': 'Auto', }, - }, - 'chat_sessions' => { - 'chat_sessions': [ - { - 'id': 'a', - 'title': 'Chat item a', - 'backend': 'claude', - 'model': 'claude-opus', - 'mode': 'auto', - 'mode_name': 'Auto', - }, - { - 'id': 'b', - 'title': 'Chat item b', - 'backend': 'claude', - 'model': 'claude-opus', - 'mode': 'auto', - 'mode_name': 'Auto', - }, - ], - }, - 'chat_messages' => { - 'chat_history': {'messages': []}, - }, - _ => {}, + { + 'id': 'b', + 'title': 'Chat item b', + 'backend': 'claude', + 'model': 'claude-opus', + 'mode': 'auto', + 'mode_name': 'Auto', + }, + ], }, - ); - final shell = AdaptiveShell( - cupertino: cupertino, - destinationBodies: { - AppDestination.pipelines: (_) => - PipelinesScreen(gateway: gateway, embedded: true), - AppDestination.runs: (_) => RunsScreen(gateway: gateway), - AppDestination.chat: (_) => ChatScreen(gateway: gateway), + 'chat_messages' => { + 'chat_history': {'messages': []}, }, - ); - await tester.pumpWidget( - cupertino - ? CupertinoApp( - theme: CupertinoThemeData(brightness: brightness), - home: shell, - ) - : MaterialApp( - theme: brightness == Brightness.dark - ? appDarkTheme() - : appLightTheme(), - home: shell, - ), - ); - await tester.pumpAndSettle(); - final paneWidths = []; - final bodyWidths = []; - for (final destination in ['Pipelines', 'Runs', 'Chat']) { - if (destination != 'Pipelines') { - await tester.tap( - find.byKey( - ValueKey('shell.destination.${destination.toLowerCase()}'), - ), - ); - await tester.pumpAndSettle(); - expect( - tester.takeException(), - isNull, - reason: '$destination list', - ); - } - final list = find.byKey(const ValueKey('list-detail-list')); - final detail = find.byKey(const ValueKey('list-detail-body')); - expect(list, findsOneWidget); - expect(detail, findsOneWidget); - final before = tester.getSize(list).width; - final bodyBefore = tester.getSize(detail).width; - paneWidths.add(before); - bodyWidths.add(bodyBefore); - expect(bodyBefore, greaterThanOrEqualTo(width * 0.5)); - // 60% of the window, or more once the list reaches its cap. - expect( - bodyBefore, - lessThanOrEqualTo( - math.max(width * 0.6, width - 1 - kListPaneMaxWidth) + 0.5, + _ => {}, + }, + ); + final shell = AdaptiveShell( + destinationBodies: { + AppDestination.pipelines: (_) => + PipelinesScreen(gateway: gateway, embedded: true), + AppDestination.runs: (_) => RunsScreen(gateway: gateway), + AppDestination.chat: (_) => ChatScreen(gateway: gateway), + }, + ); + await tester.pumpWidget( + MaterialApp( + theme: brightness == Brightness.dark + ? appDarkTheme() + : appLightTheme(), + home: shell, + ), + ); + await tester.pumpAndSettle(); + final paneWidths = []; + final bodyWidths = []; + for (final destination in ['Pipelines', 'Runs', 'Chat']) { + if (destination != 'Pipelines') { + await tester.tap( + find.byKey( + ValueKey('shell.destination.${destination.toLowerCase()}'), ), ); - expect(bodyBefore, greaterThan(before)); - final rowKeys = switch (destination) { - 'Pipelines' => ['pipeline-row-1', 'pipeline-row-2'], - 'Runs' => ['run-row-1', 'run-row-2'], - _ => ['chat-row-a', 'chat-row-b'], - }; - for (final key in rowKeys) { - final target = find.byKey(ValueKey(key)); - // In a narrow Cupertino list the row center can be a star/menu - // control. Open the chat through its title, not a trailing action. - final opener = destination == 'Chat' - ? find.descendant( - of: target, - matching: find.text('Chat item ${key.split('-').last}'), - ) - : target; - await tester.ensureVisible(opener); - await tester.tap(opener); - await tester.pumpAndSettle(); - expect( - tester.takeException(), - isNull, - reason: '$destination after opening $key', - ); - expect(tester.getSize(list).width, closeTo(before, 0.01)); - expect(tester.getSize(detail).width, closeTo(bodyBefore, 0.01)); - expect( - tester - .state(find.byType(Navigator).first) - .canPop(), - isFalse, - ); - for (final rowKey in rowKeys) { - final row = find.byKey(ValueKey(rowKey)); - expect( - row, - findsOneWidget, - reason: 'the list must remain visible', - ); - final selected = rowKey == key; - expect( - tester.getSemantics(row).flagsCollection.isSelected == - Tristate.isTrue, - selected, - reason: '$destination: $rowKey after opening $key', - ); - // Every list retains shared row semantics; features may supply their own fill. - final context = tester.element(row); - expect(tester.widget(row).selected, selected); - final surface = find.descendant( - of: row, - matching: find.byKey(appListRowSurfaceKey), - ); - expect( - cupertino - ? tester.widget(surface).color - : tester.widget(surface).color, - selected - ? tester.widget(row).selectedFill ?? - AppListRow.selectedColor( - context, - cupertino: cupertino, - ) - : const Color(0x00000000), - ); - } - } - if (destination == 'Chat') { - // Starring lives in the row's actions menu. - final menu = find.byKey(const Key('chat-actions-b')); - await tester.ensureVisible(menu); - await tester.tap(menu); - await tester.pumpAndSettle(); - await tester.tap(find.text('Star')); - await tester.pumpAndSettle(); - expect( - gateway - .callsOf('chat_star') - .last - .fields['chat_query']['session_id'], - 'b', - ); - final actions = find.byKey(const Key('chat-actions-b')); - await tester.ensureVisible(actions); - await tester.tap(actions); - await tester.pumpAndSettle(); - expect(find.text('Rename…'), findsOneWidget); - await tester.binding.handlePopRoute(); - await tester.pumpAndSettle(); - } - // A phone still uses stock page navigation; returning to a wide - // window must keep the selected item without clearing its route. - tester.view.physicalSize = const Size(390, 900); await tester.pumpAndSettle(); expect( - tester - .state(find.byType(Navigator).first) - .canPop(), - isTrue, - reason: '$destination should push its selected item on a phone', + tester.takeException(), + isNull, + reason: '$destination list', ); - expect( - find.byKey(const ValueKey('list-detail-list')), - findsNothing, - ); - tester.view.physicalSize = Size(width, 900); + } + final list = find.byKey(const ValueKey('list-detail-list')); + final detail = find.byKey(const ValueKey('list-detail-body')); + expect(list, findsOneWidget); + expect(detail, findsOneWidget); + final before = tester.getSize(list).width; + final bodyBefore = tester.getSize(detail).width; + paneWidths.add(before); + bodyWidths.add(bodyBefore); + expect(bodyBefore, greaterThanOrEqualTo(width * 0.5)); + // 60% of the window, or more once the list reaches its cap. + expect( + bodyBefore, + lessThanOrEqualTo( + math.max(width * 0.6, width - 1 - kListPaneMaxWidth) + 0.5, + ), + ); + expect(bodyBefore, greaterThan(before)); + final rowKeys = switch (destination) { + 'Pipelines' => ['pipeline-row-1', 'pipeline-row-2'], + 'Runs' => ['run-row-1', 'run-row-2'], + _ => ['chat-row-a', 'chat-row-b'], + }; + for (final key in rowKeys) { + final target = find.byKey(ValueKey(key)); + // The row center can be a star/menu control. Open the chat + // through its title, not a trailing action. + final opener = destination == 'Chat' + ? find.descendant( + of: target, + matching: find.text('Chat item ${key.split('-').last}'), + ) + : target; + await tester.ensureVisible(opener); + await tester.tap(opener); await tester.pumpAndSettle(); + expect( + tester.takeException(), + isNull, + reason: '$destination after opening $key', + ); + expect(tester.getSize(list).width, closeTo(before, 0.01)); + expect(tester.getSize(detail).width, closeTo(bodyBefore, 0.01)); expect( tester .state(find.byType(Navigator).first) .canPop(), isFalse, ); - expect(tester.getSize(list).width, closeTo(before, 0.01)); - expect( - tester - .getSemantics(find.byKey(ValueKey(rowKeys.last))) - .flagsCollection - .isSelected, - Tristate.isTrue, - ); + for (final rowKey in rowKeys) { + final row = find.byKey(ValueKey(rowKey)); + expect( + row, + findsOneWidget, + reason: 'the list must remain visible', + ); + final selected = rowKey == key; + expect( + tester.getSemantics(row).flagsCollection.isSelected == + Tristate.isTrue, + selected, + reason: '$destination: $rowKey after opening $key', + ); + // Every list retains shared row semantics; features may supply their own fill. + final context = tester.element(row); + expect(tester.widget(row).selected, selected); + final surface = find.descendant( + of: row, + matching: find.byKey(appListRowSurfaceKey), + ); + expect( + tester.widget(surface).color, + selected + ? tester.widget(row).selectedFill ?? + AppListRow.selectedColor(context, cupertino: false) + : const Color(0x00000000), + ); + } } + if (destination == 'Chat') { + // Starring lives in the row's actions menu. + final menu = find.byKey(const Key('chat-actions-b')); + await tester.ensureVisible(menu); + await tester.tap(menu); + await tester.pumpAndSettle(); + await tester.tap(find.text('Star')); + await tester.pumpAndSettle(); + expect( + gateway + .callsOf('chat_star') + .last + .fields['chat_query']['session_id'], + 'b', + ); + final actions = find.byKey(const Key('chat-actions-b')); + await tester.ensureVisible(actions); + await tester.tap(actions); + await tester.pumpAndSettle(); + expect(find.text('Rename…'), findsOneWidget); + await tester.binding.handlePopRoute(); + await tester.pumpAndSettle(); + } + // A phone still uses stock page navigation; returning to a wide + // window must keep the selected item without clearing its route. + tester.view.physicalSize = const Size(390, 900); + await tester.pumpAndSettle(); expect( - paneWidths, - everyElement(closeTo(paneWidths.first, 0.01)), - reason: 'Pipelines, Runs and Chat must use identical pane widths', + tester + .state(find.byType(Navigator).first) + .canPop(), + isTrue, + reason: '$destination should push its selected item on a phone', ); - expect(tester.takeException(), isNull); expect( - bodyWidths, - everyElement(closeTo(bodyWidths.first, 0.01)), - reason: - 'Every destination must share the body-priority sizing policy', + find.byKey(const ValueKey('list-detail-list')), + findsNothing, ); - await tester.pumpWidget(const SizedBox.shrink()); - }); - } + tester.view.physicalSize = Size(width, 900); + await tester.pumpAndSettle(); + expect( + tester + .state(find.byType(Navigator).first) + .canPop(), + isFalse, + ); + expect(tester.getSize(list).width, closeTo(before, 0.01)); + expect( + tester + .getSemantics(find.byKey(ValueKey(rowKeys.last))) + .flagsCollection + .isSelected, + Tristate.isTrue, + ); + } + expect( + paneWidths, + everyElement(closeTo(paneWidths.first, 0.01)), + reason: 'Pipelines, Runs and Chat must use identical pane widths', + ); + expect(tester.takeException(), isNull); + expect( + bodyWidths, + everyElement(closeTo(bodyWidths.first, 0.01)), + reason: + 'Every destination must share the body-priority sizing policy', + ); + await tester.pumpWidget(const SizedBox.shrink()); + }); } } } diff --git a/app/test/application/search_artifact_open_test.dart b/app/test/application/search_artifact_open_test.dart index 478660b1..1de84a3e 100644 --- a/app/test/application/search_artifact_open_test.dart +++ b/app/test/application/search_artifact_open_test.dart @@ -41,7 +41,6 @@ void main() { channel: channel, client: PipelinesClient(channelFactory: (_) => channel), provider: provider, - cupertino: false, ); await replyRunList(tester, channel); return provider; diff --git a/app/test/application/search_chat_open_test.dart b/app/test/application/search_chat_open_test.dart index 8b443eb2..1ebd3025 100644 --- a/app/test/application/search_chat_open_test.dart +++ b/app/test/application/search_chat_open_test.dart @@ -45,7 +45,6 @@ void main() { channel: channel, client: PipelinesClient(channelFactory: (_) => channel), provider: provider, - cupertino: false, ); await replyRunList(tester, channel); diff --git a/app/test/application/search_wiring_test.dart b/app/test/application/search_wiring_test.dart index 9ec6e1fb..66e6286b 100644 --- a/app/test/application/search_wiring_test.dart +++ b/app/test/application/search_wiring_test.dart @@ -332,14 +332,12 @@ Future pumpApp( required FakeChannel channel, required PipelinesClient client, required PlatformRouteInformationProvider provider, - required bool cupertino, }) async { await tester.pumpWidget( PipelinesApp( androidSupported: false, server: webServer(), client: client, - cupertino: cupertino, routeInformationProvider: provider, ), ); @@ -373,7 +371,6 @@ void main() { channel: channel, client: client, provider: provider, - cupertino: false, ); await replyRunList(tester, channel); await replyRunDetail(tester, channel, 2); @@ -439,13 +436,7 @@ void main() { ); addTearDown(provider.dispose); - await pumpApp( - tester, - channel: channel, - client: client, - provider: provider, - cupertino: false, - ); + await pumpApp(tester, channel: channel, client: client, provider: provider); await replyRunList(tester, channel); await replyRunDetail(tester, channel, 2); @@ -519,13 +510,7 @@ void main() { ); addTearDown(provider.dispose); - await pumpApp( - tester, - channel: channel, - client: client, - provider: provider, - cupertino: false, - ); + await pumpApp(tester, channel: channel, client: client, provider: provider); await replyRunList(tester, channel); await replyRunDetailFor(tester, channel, searchSelectionDetail()); expect(find.text('Run 7'), findsWidgets); @@ -631,13 +616,7 @@ void main() { ); addTearDown(provider.dispose); - await pumpApp( - tester, - channel: channel, - client: client, - provider: provider, - cupertino: false, - ); + await pumpApp(tester, channel: channel, client: client, provider: provider); await replyRunList(tester, channel); await tapTab(tester, 'Search'); @@ -706,13 +685,7 @@ void main() { ); addTearDown(provider.dispose); - await pumpApp( - tester, - channel: channel, - client: client, - provider: provider, - cupertino: false, - ); + await pumpApp(tester, channel: channel, client: client, provider: provider); await replyRun7List(tester, channel); // The hit navigates to run 7, but its detail is never loaded: the operator @@ -763,13 +736,7 @@ void main() { ); addTearDown(provider.dispose); - await pumpApp( - tester, - channel: channel, - client: client, - provider: provider, - cupertino: false, - ); + await pumpApp(tester, channel: channel, client: client, provider: provider); await replyRun7List(tester, channel); await openArtifactHit(tester, channel); diff --git a/app/test/features/chat/chat_sidebar_clearance_test.dart b/app/test/features/chat/chat_sidebar_clearance_test.dart index c9a4f8ef..2ed3b3be 100644 --- a/app/test/features/chat/chat_sidebar_clearance_test.dart +++ b/app/test/features/chat/chat_sidebar_clearance_test.dart @@ -1,7 +1,5 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:pipelines_app/features/chat/ui/sessions/session_list_cupertino.dart'; import 'package:pipelines_app/features/chat/ui/sessions/session_list_material.dart'; import 'package:pipelines_app/shell/adaptive_shell.dart'; import 'package:pipelines_app/shell/destination.dart'; @@ -9,114 +7,88 @@ import 'package:pipelines_app/shell/list_detail.dart'; import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart'; void main() { - for (final cupertino in [false, true]) { - for (final scale in [1.0, 2.0]) { - testWidgets( - 'chat list stays above labeled navigation ($cupertino, $scale)', - (tester) async { - tester.view.physicalSize = const Size(1200, 900); - tester.view.devicePixelRatio = 1; - tester.platformDispatcher.textScaleFactorTestValue = scale; - addTearDown(tester.view.reset); - addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue); - String? opened; - final sessions = [ - for (var i = 0; i < 14; i++) - { - 'id': 's$i', - 'title': 'Chat item $i', - 'model': 'model', - 'directory': '/work/project-$i', - }, - ]; - Widget list() => cupertino - ? CupertinoSessionList( - sections: [(title: 'Chats', sessions: sessions)], - emptyMessage: null, - duplicateTitles: const {}, - onOpen: (row) => opened = row['id'] as String, - onRename: (_) {}, - onClose: (_) {}, - onReopen: (_) {}, - onStar: (_) {}, - onHide: (_) {}, - onClearSearch: null, - isUnseen: (_) => false, - errorFor: (_) => null, - ) - : MaterialSessionList( - sections: [(title: 'Chats', sessions: sessions)], - emptyMessage: null, - duplicateTitles: const {}, - onOpen: (row) => opened = row['id'] as String, - onRename: (_) {}, - onClose: (_) {}, - onReopen: (_) {}, - onStar: (_) {}, - onHide: (_) {}, - onClearSearch: null, - isUnseen: (_) => false, - errorFor: (_) => null, - ); - final shell = AdaptiveShell( - cupertino: cupertino, - destination: AppDestination.chat, - destinationBodies: { - AppDestination.chat: (_) => ListDetailPanes( - list: list(), - detail: const SizedBox.expand(), - ), - }, - ); - await tester.pumpWidget( - cupertino ? CupertinoApp(home: shell) : MaterialApp(home: shell), - ); - await tester.pumpAndSettle(); - final navigation = tester.getRect( - find.byKey(FloatingDestinationBar.rowKey), - ); - final scrollView = find.byType(CustomScrollView); - final viewport = tester.getRect(scrollView); - expect(viewport.bottom, lessThanOrEqualTo(navigation.top + .5)); - expect(viewport.width, greaterThan(0)); - final scrollable = tester.state( - find.descendant(of: scrollView, matching: find.byType(Scrollable)), - ); - scrollable.position.jumpTo(scrollable.position.maxScrollExtent); - await tester.pumpAndSettle(); - final last = find.byKey(const Key('chat-row-s13')); - expect( - tester.getRect(last).bottom, - lessThanOrEqualTo(navigation.top + .5), - ); - final metadata = find.descendant( - of: last, - matching: find.text('model · /work/project-13'), - ); - expect(metadata, findsOneWidget); - expect( - tester.getRect(metadata).bottom, - lessThanOrEqualTo(navigation.top + .5), - ); - await tester.tap(find.text('Chat item 13')); - await tester.pump(); - expect(opened, 's13'); - final retainedOffset = scrollable.position.pixels; - tester.view.physicalSize = const Size(1440, 900); - await tester.pumpAndSettle(); - expect( - tester.state( - find.descendant( - of: scrollView, - matching: find.byType(Scrollable), - ), - ), - same(scrollable), - ); - expect(scrollable.position.pixels, closeTo(retainedOffset, .5)); - expect(tester.takeException(), isNull); + for (final scale in [1.0, 2.0]) { + testWidgets('chat list stays above labeled navigation ($scale)', ( + tester, + ) async { + tester.view.physicalSize = const Size(1200, 900); + tester.view.devicePixelRatio = 1; + tester.platformDispatcher.textScaleFactorTestValue = scale; + addTearDown(tester.view.reset); + addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue); + String? opened; + final sessions = [ + for (var i = 0; i < 14; i++) + { + 'id': 's$i', + 'title': 'Chat item $i', + 'model': 'model', + 'directory': '/work/project-$i', + }, + ]; + Widget list() => MaterialSessionList( + sections: [(title: 'Chats', sessions: sessions)], + emptyMessage: null, + duplicateTitles: const {}, + onOpen: (row) => opened = row['id'] as String, + onRename: (_) {}, + onClose: (_) {}, + onReopen: (_) {}, + onStar: (_) {}, + onHide: (_) {}, + onClearSearch: null, + isUnseen: (_) => false, + errorFor: (_) => null, + ); + final shell = AdaptiveShell( + destination: AppDestination.chat, + destinationBodies: { + AppDestination.chat: (_) => + ListDetailPanes(list: list(), detail: const SizedBox.expand()), }, ); - } + await tester.pumpWidget(MaterialApp(home: shell)); + await tester.pumpAndSettle(); + final navigation = tester.getRect( + find.byKey(FloatingDestinationBar.rowKey), + ); + final scrollView = find.byType(CustomScrollView); + final viewport = tester.getRect(scrollView); + expect(viewport.bottom, lessThanOrEqualTo(navigation.top + .5)); + expect(viewport.width, greaterThan(0)); + final scrollable = tester.state( + find.descendant(of: scrollView, matching: find.byType(Scrollable)), + ); + scrollable.position.jumpTo(scrollable.position.maxScrollExtent); + await tester.pumpAndSettle(); + final last = find.byKey(const Key('chat-row-s13')); + expect( + tester.getRect(last).bottom, + lessThanOrEqualTo(navigation.top + .5), + ); + final metadata = find.descendant( + of: last, + matching: find.text('model · /work/project-13'), + ); + expect(metadata, findsOneWidget); + expect( + tester.getRect(metadata).bottom, + lessThanOrEqualTo(navigation.top + .5), + ); + await tester.tap(find.text('Chat item 13')); + await tester.pump(); + expect(opened, 's13'); + final retainedOffset = scrollable.position.pixels; + tester.view.physicalSize = const Size(1440, 900); + await tester.pumpAndSettle(); + expect( + tester.state( + find.descendant(of: scrollView, matching: find.byType(Scrollable)), + ), + same(scrollable), + ); + expect(scrollable.position.pixels, closeTo(retainedOffset, .5)); + expect(tester.takeException(), isNull); + }); } } diff --git a/app/test/features/runs/actions/cancel_action_test.dart b/app/test/features/runs/actions/cancel_action_test.dart index 09354fc1..937f2be2 100644 --- a/app/test/features/runs/actions/cancel_action_test.dart +++ b/app/test/features/runs/actions/cancel_action_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'; @@ -60,7 +59,6 @@ void main() { initial: executingRun(), changed: changed, ), - cupertino: false, ), ); @@ -96,55 +94,6 @@ void main() { }, ); - testWidgets( - 'cupertino cancel uses a native prompt and sends only on confirm', - (tester) async { - final accepted = acceptedCancelRun(); - final gateway = FakeCancelGateway( - (type, fields) async => {'run_detail': accepted}, - ); - final changed = []; - await tester.pumpWidget( - cancelApp( - CancelHost( - gateway: gateway, - initial: executingRun(), - changed: changed, - ), - cupertino: true, - ), - ); - - expect(find.byKey(cancelActionKey), findsOneWidget); - expect(find.byType(CupertinoButton), findsOneWidget); - expect(find.byType(OutlinedButton), findsNothing); - - await tester.tap(find.byKey(cancelActionKey)); - await tester.pumpAndSettle(); - expect(find.byType(CupertinoAlertDialog), findsOneWidget); - expect(find.byType(AlertDialog), findsNothing); - expect(find.text(cancelDialogTitle(7)), findsOneWidget); - expect(find.text(cancelDialogMessage), findsOneWidget); - expect(gateway.calls, isEmpty); - - await tester.tap(find.byKey(cancelKeepKey)); - await tester.pumpAndSettle(); - expect(gateway.calls, isEmpty); - expect(find.byType(CupertinoAlertDialog), findsNothing); - - await tester.tap(find.byKey(cancelActionKey)); - await tester.pumpAndSettle(); - await tester.tap(find.byKey(cancelConfirmKey)); - await tester.pumpAndSettle(); - - expect(gateway.calls.map((call) => call.type), ['cancel_run']); - expect(gateway.calls.single.fields, {'run_id': 7}); - expect(changed.single, equals(accepted)); - expect(find.byType(CupertinoAlertDialog), findsNothing); - expect(find.byKey(cancelActionKey), findsNothing); - }, - ); - testWidgets('the action is absent for runs the web does not cancel', ( tester, ) async { @@ -178,7 +127,6 @@ void main() { initial: run, changed: changed, ), - cupertino: false, ), ); expect( diff --git a/app/test/features/runs/actions/cancel_resilience_test.dart b/app/test/features/runs/actions/cancel_resilience_test.dart index 675c58b2..111db6cc 100644 --- a/app/test/features/runs/actions/cancel_resilience_test.dart +++ b/app/test/features/runs/actions/cancel_resilience_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/api_gateway.dart'; @@ -13,7 +12,6 @@ Future _pump( WidgetTester tester, FakeCancelGateway gateway, List changed, { - bool cupertino = false, double textScale = 1, JsonMap? run, }) async { @@ -24,7 +22,6 @@ Future _pump( initial: run ?? executingRun(), changed: changed, ), - cupertino: cupertino, textScale: textScale, ), ); @@ -239,33 +236,20 @@ void main() { addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); - for (final cupertino in [false, true]) { - final gateway = FakeCancelGateway( - (type, fields) async => {'run_detail': acceptedCancelRun()}, - ); - await _pump( - tester, - gateway, - [], - cupertino: cupertino, - textScale: 2, - ); - await tester.tap(find.byKey(cancelActionKey)); - await tester.pumpAndSettle(); + final gateway = FakeCancelGateway( + (type, fields) async => {'run_detail': acceptedCancelRun()}, + ); + await _pump(tester, gateway, [], textScale: 2); + await tester.tap(find.byKey(cancelActionKey)); + await tester.pumpAndSettle(); - expect(tester.takeException(), isNull, reason: 'cupertino=$cupertino'); - expect(find.text(cancelDialogTitle(7)), findsOneWidget); - expect(find.text(cancelDialogMessage), findsOneWidget); - expect( - cupertino - ? find.byType(CupertinoAlertDialog) - : find.byType(AlertDialog), - findsOneWidget, - ); - expect(gateway.calls, isEmpty); + expect(tester.takeException(), isNull); + expect(find.text(cancelDialogTitle(7)), findsOneWidget); + expect(find.text(cancelDialogMessage), findsOneWidget); + expect(find.byType(AlertDialog), findsOneWidget); + expect(gateway.calls, isEmpty); - await tester.tap(find.byKey(cancelKeepKey)); - await tester.pumpAndSettle(); - } + await tester.tap(find.byKey(cancelKeepKey)); + await tester.pumpAndSettle(); }); } diff --git a/app/test/features/runs/actions/cancel_test_support.dart b/app/test/features/runs/actions/cancel_test_support.dart index 7acee8d9..7edb882f 100644 --- a/app/test/features/runs/actions/cancel_test_support.dart +++ b/app/test/features/runs/actions/cancel_test_support.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:pipelines_app/core/api_gateway.dart'; import 'package:pipelines_app/features/runs/actions/cancel_run_action.dart'; @@ -77,23 +76,13 @@ class _CancelHostState extends State { } } -Widget cancelApp( - Widget child, { - required bool cupertino, - double textScale = 1, -}) { +Widget cancelApp(Widget child, {double textScale = 1}) { Widget media(BuildContext context, Widget? app) => MediaQuery( data: MediaQuery.of( context, ).copyWith(textScaler: TextScaler.linear(textScale)), child: app!, ); - if (cupertino) { - return CupertinoApp( - builder: media, - home: CupertinoPageScaffold(child: Center(child: child)), - ); - } return MaterialApp( builder: media, home: Scaffold(body: Center(child: child)), diff --git a/app/test/features/runs/actions/decision_action_test.dart b/app/test/features/runs/actions/decision_action_test.dart index 9f4c4b45..217e4e96 100644 --- a/app/test/features/runs/actions/decision_action_test.dart +++ b/app/test/features/runs/actions/decision_action_test.dart @@ -1,9 +1,7 @@ -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'; import 'package:pipelines_app/features/runs/actions/decision_action.dart'; -import 'package:pipelines_app/features/runs/actions/decision_option_row.dart'; import 'package:pipelines_app/features/runs/actions/decision_wording.dart'; typedef _Handler = Future Function(String type, JsonMap fields); @@ -63,18 +61,7 @@ JsonMap _decided() => { 'steps': const [], }; -Widget _app(Widget child, {required bool cupertino, double textScale = 1}) { - if (cupertino) { - return CupertinoApp( - builder: (context, app) => MediaQuery( - data: MediaQuery.of( - context, - ).copyWith(textScaler: TextScaler.linear(textScale)), - child: app!, - ), - home: CupertinoPageScaffold(child: Center(child: child)), - ); - } +Widget _app(Widget child, {double textScale = 1}) { return MaterialApp( builder: (context, app) => MediaQuery( data: MediaQuery.of( @@ -90,7 +77,6 @@ Future _pump( WidgetTester tester, _FakeGateway gateway, JsonMap run, { - required bool cupertino, required List changed, double textScale = 1, }) async { @@ -101,7 +87,6 @@ Future _pump( gateway: gateway, onRunChanged: changed.add, ), - cupertino: cupertino, textScale: textScale, ), ); @@ -126,7 +111,6 @@ void main() { tester, gateway, _waitingRun(), - cupertino: false, changed: changed, ); @@ -166,76 +150,41 @@ void main() { }, ); - testWidgets( - 'cupertino decision uses a native dialog and omits empty feedback', - (tester) async { - final gateway = _FakeGateway( - (type, fields) async => { - 'run_detail': type == 'decide_run' ? _decided() : _waitingRun(), - }, - ); - final changed = []; - await _pump( - tester, - gateway, - _waitingRun(), - cupertino: true, - changed: changed, - ); + testWidgets('a decision without feedback omits the field', (tester) async { + final gateway = _FakeGateway( + (type, fields) async => { + 'run_detail': type == 'decide_run' ? _decided() : _waitingRun(), + }, + ); + final changed = []; + await _pump(tester, gateway, _waitingRun(), changed: changed); - expect(find.byKey(decisionActionKey), findsOneWidget); - expect(find.byType(FilledButton), findsNothing); - await _open(tester); - expect(find.byType(CupertinoAlertDialog), findsOneWidget); - expect(find.text(decisionWaitingTitle), findsOneWidget); - expect(gateway.calls, isEmpty); + expect(find.byKey(decisionActionKey), findsOneWidget); + expect(find.byType(FilledButton), findsOneWidget); + await _open(tester); + expect(find.byType(AlertDialog), findsOneWidget); + expect(find.text(decisionWaitingTitle), findsOneWidget); + expect(gateway.calls, isEmpty); - final confirm = find.widgetWithText( - CupertinoDialogAction, - decisionConfirmLabel, - ); - expect(tester.widget(confirm).onPressed, isNull); - // Options are check-list rows, not blue link buttons: an empty circle - // until one is picked, then a filled check on that row only. - final skip = find.byKey(decisionOptionKey('skip')); - expect(skip, findsOneWidget); - expect( - find.ancestor( - of: find.text('skip'), - matching: find.byType(CupertinoButton), - ), - findsNothing, - ); - expect(find.byIcon(CupertinoIcons.checkmark_circle_fill), findsNothing); - expect( - find.descendant(of: skip, matching: find.byIcon(CupertinoIcons.circle)), - findsOneWidget, - ); - await tester.tap(find.text('skip')); - await tester.pump(); - expect(gateway.calls, isEmpty); - expect( - find.descendant( - of: skip, - matching: find.byIcon(CupertinoIcons.checkmark_circle_fill), - ), - findsOneWidget, - ); - expect(find.byIcon(CupertinoIcons.checkmark_circle_fill), findsOneWidget); + final confirm = find.widgetWithText(FilledButton, decisionConfirmLabel); + expect(tester.widget(confirm).onPressed, isNull); + await tester.tap(find.text('skip')); + await tester.pump(); + expect(gateway.calls, isEmpty); + expect(tester.widget(confirm).onPressed, isNotNull); - await tester.tap(find.text(decisionConfirmLabel)); - await tester.pumpAndSettle(); + await tester.tap(find.text(decisionConfirmLabel)); + await tester.pumpAndSettle(); - expect(gateway.calls.map((call) => call.type), ['decide_run']); - expect(gateway.calls.single.fields, { - 'run_id': 7, - 'stage': 'human', - 'option': 'skip', - }); - expect(changed.single['status'], 'succeeded'); - expect(find.byType(CupertinoAlertDialog), findsNothing); - }, - ); + expect(gateway.calls.map((call) => call.type), ['decide_run']); + expect(gateway.calls.single.fields, { + 'run_id': 7, + 'stage': 'human', + 'option': 'skip', + }); + expect(changed.single['status'], 'succeeded'); + expect(find.byType(AlertDialog), findsNothing); + }); testWidgets('Cancel dismisses the draft without sending anything', ( tester, @@ -248,7 +197,6 @@ void main() { tester, gateway, _waitingRun(), - cupertino: false, changed: changed, ); @@ -277,7 +225,7 @@ void main() { ('export pending', _waitingRun(exportPending: 2)), ('model stage', _waitingRun(type: 'model')), ]) { - await _pump(tester, gateway, run, cupertino: false, changed: changed); + await _pump(tester, gateway, run, changed: changed); expect( find.byKey(decisionActionKey), findsNothing, diff --git a/app/test/features/runs/actions/decision_resilience_test.dart b/app/test/features/runs/actions/decision_resilience_test.dart index e755ddc5..da490421 100644 --- a/app/test/features/runs/actions/decision_resilience_test.dart +++ b/app/test/features/runs/actions/decision_resilience_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/api_gateway.dart'; @@ -61,19 +60,13 @@ JsonMap _decided() => { 'steps': const [], }; -Widget _app(Widget child, {required bool cupertino, double textScale = 1}) { +Widget _app(Widget child, {double textScale = 1}) { Widget media(BuildContext context, Widget? app) => MediaQuery( data: MediaQuery.of( context, ).copyWith(textScaler: TextScaler.linear(textScale)), child: app!, ); - if (cupertino) { - return CupertinoApp( - builder: media, - home: CupertinoPageScaffold(child: Center(child: child)), - ); - } return MaterialApp( builder: media, home: Scaffold(body: Center(child: child)), @@ -84,7 +77,6 @@ Future _pump( WidgetTester tester, _FakeGateway gateway, List changed, { - bool cupertino = false, double textScale = 1, }) async { await tester.pumpWidget( @@ -94,7 +86,6 @@ Future _pump( gateway: gateway, onRunChanged: changed.add, ), - cupertino: cupertino, textScale: textScale, ), ); @@ -323,29 +314,16 @@ void main() { addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); - for (final cupertino in [false, true]) { - final gateway = _FakeGateway( - (type, fields) async => {'run_detail': _decided()}, - ); - await _pump( - tester, - gateway, - [], - cupertino: cupertino, - textScale: 2, - ); - await tester.tap(find.byKey(decisionActionKey)); - await tester.pumpAndSettle(); + final gateway = _FakeGateway( + (type, fields) async => {'run_detail': _decided()}, + ); + await _pump(tester, gateway, [], textScale: 2); + await tester.tap(find.byKey(decisionActionKey)); + await tester.pumpAndSettle(); - expect(tester.takeException(), isNull, reason: 'cupertino=$cupertino'); - expect(find.text(decisionWaitingTitle), findsOneWidget); - expect(find.text('Ship it?'), findsOneWidget); - expect( - cupertino - ? find.byType(CupertinoAlertDialog) - : find.byType(AlertDialog), - findsOneWidget, - ); - } + expect(tester.takeException(), isNull); + expect(find.text(decisionWaitingTitle), findsOneWidget); + expect(find.text('Ship it?'), findsOneWidget); + expect(find.byType(AlertDialog), findsOneWidget); }); } diff --git a/app/test/features/runs/actions/retry_action_test.dart b/app/test/features/runs/actions/retry_action_test.dart index ad6f6623..5bd9f666 100644 --- a/app/test/features/runs/actions/retry_action_test.dart +++ b/app/test/features/runs/actions/retry_action_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'; @@ -146,81 +145,6 @@ void main() { }, ); - testWidgets( - 'cupertino retry uses a native prompt and sends only on confirm', - (tester) async { - final accepted = retriedRun(); - final gateway = FakeRetryGateway( - (type, fields) async => {'run_detail': accepted}, - ); - final changed = []; - await pumpRetry( - tester, - gateway: gateway, - changed: changed, - cupertino: true, - ); - - expect(find.byKey(retryActionKey), findsOneWidget); - expect(find.byType(CupertinoButton), findsOneWidget); - expect(find.byType(OutlinedButton), findsNothing); - - await tester.tap(find.byKey(retryActionKey)); - await tester.pumpAndSettle(); - expect(find.byType(CupertinoAlertDialog), findsOneWidget); - expect(find.byType(AlertDialog), findsNothing); - expect(find.text(retryDialogTitle(7)), findsOneWidget); - expect(find.text(retryDialogMessage), findsOneWidget); - expect(gateway.calls, isEmpty); - - await tester.tap(find.byKey(retryKeepKey)); - await tester.pumpAndSettle(); - expect(gateway.calls, isEmpty); - expect(find.byType(CupertinoAlertDialog), findsNothing); - - await tester.tap(find.byKey(retryActionKey)); - await tester.pumpAndSettle(); - await tester.tap(find.byKey(retryConfirmKey)); - await tester.pumpAndSettle(); - - expect(gateway.retries, hasLength(1)); - final fields = gateway.retries.single.fields; - expect(fields['run_id'], 7); - expect(fields.containsKey('retry_mode'), isFalse); - expect(fields['request_key'], startsWith('app-retry-7-')); - expect(changed.single, equals(accepted)); - expect(find.byType(CupertinoAlertDialog), findsNothing); - }, - ); - - testWidgets('cupertino restart switches to the restart confirmation', ( - tester, - ) async { - final gateway = FakeRetryGateway( - (type, fields) async => {'run_detail': retriedRun()}, - ); - await pumpRetry( - tester, - gateway: gateway, - changed: [], - cupertino: true, - ); - - await tester.tap(find.byKey(retryActionKey)); - await tester.pumpAndSettle(); - await tester.tap(find.byKey(retryRestartKey)); - await tester.pumpAndSettle(); - - expect(find.byType(CupertinoAlertDialog), findsOneWidget); - expect(find.text(restartDialogTitle(7)), findsOneWidget); - expect(find.text(restartDialogMessage), findsOneWidget); - expect(gateway.calls, isEmpty); - - await tester.tap(find.byKey(retryConfirmKey)); - await tester.pumpAndSettle(); - expect(gateway.retries.single.fields['retry_mode'], 'restart'); - }); - testWidgets('the action is absent for runs the web does not retry', ( tester, ) async { @@ -236,25 +160,22 @@ void main() { ('succeeded', failedRun(status: 'succeeded'), false), ('canceled', failedRun(status: 'canceled'), false), ]; - for (final cupertino in [false, true]) { - for (final (label, run, visible) in cases) { - await tester.pumpWidget( - retryApp( - RetryHost( - key: ValueKey('$label-$cupertino'), - gateway: gateway, - initial: run, - changed: changed, - ), - cupertino: cupertino, + for (final (label, run, visible) in cases) { + await tester.pumpWidget( + retryApp( + RetryHost( + key: ValueKey(label), + gateway: gateway, + initial: run, + changed: changed, ), - ); - expect( - find.byKey(retryActionKey), - visible ? findsOneWidget : findsNothing, - reason: '$label cupertino=$cupertino', - ); - } + ), + ); + expect( + find.byKey(retryActionKey), + visible ? findsOneWidget : findsNothing, + reason: label, + ); } expect(gateway.calls, isEmpty); expect(changed, isEmpty); diff --git a/app/test/features/runs/actions/retry_safety_test.dart b/app/test/features/runs/actions/retry_safety_test.dart index df9e7e88..73c115df 100644 --- a/app/test/features/runs/actions/retry_safety_test.dart +++ b/app/test/features/runs/actions/retry_safety_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/api_gateway.dart'; @@ -95,39 +94,31 @@ void main() { addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); - for (final cupertino in [false, true]) { - final gateway = FakeRetryGateway( - (type, fields) async => {'run_detail': retriedRun()}, - ); - await pumpRetry( - tester, - gateway: gateway, - changed: [], - cupertino: cupertino, - textScale: 2, - ); + final gateway = FakeRetryGateway( + (type, fields) async => {'run_detail': retriedRun()}, + ); + await pumpRetry( + tester, + gateway: gateway, + changed: [], + textScale: 2, + ); - await tester.tap(find.byKey(retryActionKey)); - await tester.pumpAndSettle(); - expect(tester.takeException(), isNull, reason: 'cupertino=$cupertino'); - expect(find.text(retryDialogTitle(7)), findsOneWidget); - expect(find.text(retryDialogMessage), findsOneWidget); - expect( - cupertino - ? find.byType(CupertinoAlertDialog) - : find.byType(AlertDialog), - findsOneWidget, - ); + await tester.tap(find.byKey(retryActionKey)); + await tester.pumpAndSettle(); + expect(tester.takeException(), isNull); + expect(find.text(retryDialogTitle(7)), findsOneWidget); + expect(find.text(retryDialogMessage), findsOneWidget); + expect(find.byType(AlertDialog), findsOneWidget); - await tester.tap(find.byKey(retryRestartKey)); - await tester.pumpAndSettle(); - expect(tester.takeException(), isNull, reason: 'restart=$cupertino'); - expect(find.text(restartDialogTitle(7)), findsOneWidget); - expect(find.text(restartDialogMessage), findsOneWidget); + await tester.tap(find.byKey(retryRestartKey)); + await tester.pumpAndSettle(); + expect(tester.takeException(), isNull); + expect(find.text(restartDialogTitle(7)), findsOneWidget); + expect(find.text(restartDialogMessage), findsOneWidget); - await tester.tap(find.byKey(retryKeepKey)); - await tester.pumpAndSettle(); - expect(gateway.calls, isEmpty); - } + await tester.tap(find.byKey(retryKeepKey)); + await tester.pumpAndSettle(); + expect(gateway.calls, isEmpty); }); } diff --git a/app/test/features/runs/actions/retry_test_support.dart b/app/test/features/runs/actions/retry_test_support.dart index 67556d05..59ca3d77 100644 --- a/app/test/features/runs/actions/retry_test_support.dart +++ b/app/test/features/runs/actions/retry_test_support.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'; @@ -71,19 +70,13 @@ class _RetryHostState extends State { } } -Widget retryApp(Widget child, {required bool cupertino, double textScale = 1}) { +Widget retryApp(Widget child, {double textScale = 1}) { Widget media(BuildContext context, Widget? app) => MediaQuery( data: MediaQuery.of( context, ).copyWith(textScaler: TextScaler.linear(textScale)), child: app!, ); - if (cupertino) { - return CupertinoApp( - builder: media, - home: CupertinoPageScaffold(child: Center(child: child)), - ); - } return MaterialApp( builder: media, home: Scaffold(body: Center(child: child)), @@ -94,7 +87,6 @@ Future pumpRetry( WidgetTester tester, { required FakeRetryGateway gateway, required List changed, - bool cupertino = false, double textScale = 1, JsonMap? run, }) async { @@ -105,7 +97,6 @@ Future pumpRetry( initial: run ?? failedRun(), changed: changed, ), - cupertino: cupertino, textScale: textScale, ), ); diff --git a/app/test/features/runs/actions/title_action_test.dart b/app/test/features/runs/actions/title_action_test.dart index 110fda20..b56f4753 100644 --- a/app/test/features/runs/actions/title_action_test.dart +++ b/app/test/features/runs/actions/title_action_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'; @@ -11,11 +10,6 @@ import 'title_test_support.dart'; String _materialFieldText(WidgetTester tester) => tester.widget(find.byKey(runTitleFieldKey)).controller!.text; -String _cupertinoFieldText(WidgetTester tester) => tester - .widget(find.byKey(runTitleFieldKey)) - .controller! - .text; - void main() { testWidgets( 'material rename starts from the stored title, typing sends nothing, ' @@ -29,7 +23,6 @@ void main() { await tester.pumpWidget( titleApp( TitleHost(gateway: gateway, initial: titledRun(), changed: changed), - cupertino: false, ), ); @@ -85,55 +78,6 @@ void main() { }, ); - testWidgets('cupertino rename is native and sends only on Save', ( - tester, - ) async { - final accepted = renamedRun(title: 'Release build'); - final gateway = FakeTitleGateway( - (type, fields) async => {'run_detail': accepted}, - ); - final changed = []; - await tester.pumpWidget( - titleApp( - TitleHost(gateway: gateway, initial: titledRun(), changed: changed), - cupertino: true, - ), - ); - - expect(find.byKey(runTitleActionKey), findsOneWidget); - expect(find.byType(CupertinoButton), findsOneWidget); - expect(find.byType(OutlinedButton), findsNothing); - expect(gateway.calls, isEmpty); - - await tester.tap(find.byKey(runTitleActionKey)); - await tester.pumpAndSettle(); - expect(find.byType(CupertinoAlertDialog), findsOneWidget); - expect(find.byType(AlertDialog), findsNothing); - expect(_cupertinoFieldText(tester), 'Nightly build'); - - await tester.enterText(find.byKey(runTitleFieldKey), 'Typed only'); - await tester.pump(); - expect(gateway.calls, isEmpty); - await tester.tap(find.byKey(runTitleCancelKey)); - await tester.pumpAndSettle(); - expect(find.byType(CupertinoAlertDialog), findsNothing); - expect(gateway.calls, isEmpty); - - await tester.tap(find.byKey(runTitleActionKey)); - await tester.pumpAndSettle(); - await tester.enterText(find.byKey(runTitleFieldKey), 'Release build'); - await tester.tap(find.byKey(runTitleSaveKey)); - await tester.pumpAndSettle(); - - expect(gateway.calls.map((call) => call.type), ['set_run_title']); - expect(gateway.calls.single.fields, { - 'run_id': 7, - 'title': 'Release build', - }); - expect(changed.single, equals(accepted)); - expect(find.byType(CupertinoAlertDialog), findsNothing); - }); - testWidgets('a blank title is sent exactly and the server refusal is shown', ( tester, ) async { @@ -145,7 +89,6 @@ void main() { await tester.pumpWidget( titleApp( TitleHost(gateway: gateway, initial: titledRun(), changed: changed), - cupertino: false, ), ); @@ -189,7 +132,6 @@ void main() { ), changed: changed, ), - cupertino: false, ), ); await tester.tap(find.byKey(runTitleActionKey)); @@ -206,7 +148,6 @@ void main() { initial: titledRun(title: null, prompt: 'prompt is not a title'), changed: changed, ), - cupertino: false, ), ); await tester.tap(find.byKey(runTitleActionKey)); @@ -231,7 +172,6 @@ void main() { initial: {'title': 'No id'}, changed: [], ), - cupertino: false, ), ); diff --git a/app/test/features/runs/actions/title_resilience_test.dart b/app/test/features/runs/actions/title_resilience_test.dart index 32a566c3..97eb4b7e 100644 --- a/app/test/features/runs/actions/title_resilience_test.dart +++ b/app/test/features/runs/actions/title_resilience_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/api_gateway.dart'; @@ -13,7 +12,6 @@ Future _pump( WidgetTester tester, FakeTitleGateway gateway, List changed, { - bool cupertino = false, double textScale = 1, JsonMap? run, }) async { @@ -24,7 +22,6 @@ Future _pump( initial: run ?? titledRun(), changed: changed, ), - cupertino: cupertino, textScale: textScale, ), ); @@ -35,18 +32,10 @@ Future _open(WidgetTester tester) async { await tester.pumpAndSettle(); } -String _fieldText(WidgetTester tester, {required bool cupertino}) { - if (cupertino) { - return tester - .widget(find.byKey(runTitleFieldKey)) - .controller! - .text; - } - return tester - .widget(find.byKey(runTitleFieldKey)) - .controller! - .text; -} +String _fieldText(WidgetTester tester) => tester + .widget(find.byKey(runTitleFieldKey)) + .controller! + .text; void main() { testWidgets('a failed save keeps the prompt open with the draft intact', ( @@ -71,7 +60,7 @@ void main() { }); expect(find.text(refusal), findsOneWidget); expect(find.byKey(runTitleErrorKey), findsOneWidget); - expect(_fieldText(tester, cupertino: false), ' Renamed draft '); + expect(_fieldText(tester), ' Renamed draft '); expect(find.byType(AlertDialog), findsOneWidget); expect(changed, isEmpty); expect( @@ -87,7 +76,7 @@ void main() { (type, fields) async => throw const NotConnectedError(), ); final changed = []; - await _pump(tester, gateway, changed, cupertino: true); + await _pump(tester, gateway, changed); await _open(tester); await tester.enterText(find.byKey(runTitleFieldKey), 'Unsent title'); @@ -95,8 +84,8 @@ void main() { await tester.pumpAndSettle(); expect(find.byKey(runTitleErrorKey), findsOneWidget); - expect(_fieldText(tester, cupertino: true), 'Unsent title'); - expect(find.byType(CupertinoAlertDialog), findsOneWidget); + expect(_fieldText(tester), 'Unsent title'); + expect(find.byType(AlertDialog), findsOneWidget); expect(changed, isEmpty); }); @@ -172,7 +161,6 @@ void main() { initial: titledRun(id: 8, title: 'Another run'), changed: changed, ), - cupertino: false, ), ); await tester.pump(); @@ -198,46 +186,32 @@ void main() { addTearDown(tester.view.resetDevicePixelRatio); const refusal = 'the title is too long for this run; shorten it'; - for (final cupertino in [false, true]) { - final gateway = FakeTitleGateway( - (type, fields) async => throw const ProtocolError(refusal), - ); - await _pump( - tester, - gateway, - [], - cupertino: cupertino, - textScale: 2, - ); - await _open(tester); + final gateway = FakeTitleGateway( + (type, fields) async => throw const ProtocolError(refusal), + ); + await _pump(tester, gateway, [], textScale: 2); + await _open(tester); - expect(tester.takeException(), isNull, reason: 'cupertino=$cupertino'); - expect( - cupertino - ? find.byType(CupertinoAlertDialog) - : find.byType(AlertDialog), - findsOneWidget, - ); - expect(find.text(runTitleFieldLabel), findsOneWidget); - expect(gateway.calls, isEmpty); + expect(tester.takeException(), isNull); + expect(find.byType(AlertDialog), findsOneWidget); + expect(find.text(runTitleFieldLabel), findsOneWidget); + expect(gateway.calls, isEmpty); - await tester.enterText( - find.byKey(runTitleFieldKey), - 'A deliberately long title that must scroll rather than overflow', - ); - await tester.tap(find.byKey(runTitleSaveKey)); - await tester.pumpAndSettle(); - expect(tester.takeException(), isNull, reason: 'cupertino=$cupertino'); - expect(find.text(refusal), findsOneWidget); - expect( - _fieldText(tester, cupertino: cupertino), - 'A deliberately long title that must scroll rather than overflow', - ); + await tester.enterText( + find.byKey(runTitleFieldKey), + 'A deliberately long title that must scroll rather than overflow', + ); + await tester.tap(find.byKey(runTitleSaveKey)); + await tester.pumpAndSettle(); + expect(tester.takeException(), isNull); + expect(find.text(refusal), findsOneWidget); + expect( + _fieldText(tester), + 'A deliberately long title that must scroll rather than overflow', + ); - await tester.tap(find.byKey(runTitleCancelKey)); - await tester.pumpAndSettle(); - expect(find.byType(AlertDialog), findsNothing); - expect(find.byType(CupertinoAlertDialog), findsNothing); - } + await tester.tap(find.byKey(runTitleCancelKey)); + await tester.pumpAndSettle(); + expect(find.byType(AlertDialog), findsNothing); }); } diff --git a/app/test/features/runs/actions/title_test_support.dart b/app/test/features/runs/actions/title_test_support.dart index b566a2d8..461c8823 100644 --- a/app/test/features/runs/actions/title_test_support.dart +++ b/app/test/features/runs/actions/title_test_support.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:pipelines_app/core/api_gateway.dart'; import 'package:pipelines_app/features/runs/actions/title_action.dart'; @@ -89,22 +88,15 @@ class _TitleHostState extends State { const titleHostTitleKey = ValueKey('rename-host-title'); -Widget titleApp(Widget child, {required bool cupertino, double textScale = 1}) { +Widget titleApp(Widget child, {double textScale = 1}) { Widget media(BuildContext context, Widget? app) => MediaQuery( data: MediaQuery.of( context, ).copyWith(textScaler: TextScaler.linear(textScale)), child: app!, ); - final body = Center(child: child); - if (cupertino) { - return CupertinoApp( - builder: media, - home: CupertinoPageScaffold(child: body), - ); - } return MaterialApp( builder: media, - home: Scaffold(body: body), + home: Scaffold(body: Center(child: child)), ); } diff --git a/app/test/features/runs/ui/run_cancel_wiring_test.dart b/app/test/features/runs/ui/run_cancel_wiring_test.dart index e4870152..3c4ea0c3 100644 --- a/app/test/features/runs/ui/run_cancel_wiring_test.dart +++ b/app/test/features/runs/ui/run_cancel_wiring_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/ui/status/run_status_icon.dart'; @@ -39,57 +38,49 @@ class _Gateway implements ApiGateway { } void main() { - for (final cupertino in [false, true]) { - testWidgets( - 'actual detail confirms cancel and folds accepted state ($cupertino)', - (tester) async { - final gateway = _Gateway(); - addTearDown(gateway.events.close); - final screen = RunsScreen(gateway: gateway, initialRunId: 7); - await tester.pumpWidget( - cupertino - ? CupertinoApp(home: CupertinoPageScaffold(child: screen)) - : MaterialApp(home: Scaffold(body: screen)), - ); - await tester.pumpAndSettle(); - await tester.tap(find.byKey(cancelActionKey)); - await tester.pumpAndSettle(); - expect(find.text('Cancel run 7?'), findsOneWidget); - expect(gateway.requests.where((r) => r.type == 'cancel_run'), isEmpty); - await tester.tap(find.byKey(cancelKeepKey)); - await tester.pumpAndSettle(); - expect(gateway.requests.where((r) => r.type == 'cancel_run'), isEmpty); + testWidgets('actual detail confirms cancel and folds accepted state', ( + tester, + ) async { + final gateway = _Gateway(); + addTearDown(gateway.events.close); + final screen = RunsScreen(gateway: gateway, initialRunId: 7); + await tester.pumpWidget(MaterialApp(home: Scaffold(body: screen))); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(cancelActionKey)); + await tester.pumpAndSettle(); + expect(find.text('Cancel run 7?'), findsOneWidget); + expect(gateway.requests.where((r) => r.type == 'cancel_run'), isEmpty); + await tester.tap(find.byKey(cancelKeepKey)); + await tester.pumpAndSettle(); + expect(gateway.requests.where((r) => r.type == 'cancel_run'), isEmpty); - await tester.tap(find.byKey(cancelActionKey)); - await tester.pumpAndSettle(); - await tester.tap(find.byKey(cancelConfirmKey)); - await tester.pump(); - expect( - gateway.requests.where((r) => r.type == 'cancel_run').single.fields, - {'run_id': 7}, - ); - expect(find.text('canceled'), findsNothing); - gateway.canceled.complete({ - 'run_detail': { - ...gateway.run, - 'status': 'canceled', - 'executing': false, - }, - }); - await tester.pumpAndSettle(); - expect(find.byKey(cancelActionKey), findsNothing); - expect(find.text('canceled'), findsOneWidget); - // The held list is already visible beside the detail. - expect( - find.byWidgetPredicate( - (widget) => widget is RunStatusIcon && widget.label == 'canceled', - ), - findsWidgets, - reason: - 'The accepted server state must also update the held list row', - ); - await tester.pumpWidget(const SizedBox.shrink()); - }, + await tester.tap(find.byKey(cancelActionKey)); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(cancelConfirmKey)); + await tester.pump(); + expect( + gateway.requests.where((r) => r.type == 'cancel_run').single.fields, + {'run_id': 7}, ); - } + expect(find.text('canceled'), findsNothing); + gateway.canceled.complete({ + 'run_detail': { + ...gateway.run, + 'status': 'canceled', + 'executing': false, + }, + }); + await tester.pumpAndSettle(); + expect(find.byKey(cancelActionKey), findsNothing); + expect(find.text('canceled'), findsOneWidget); + // The held list is already visible beside the detail. + expect( + find.byWidgetPredicate( + (widget) => widget is RunStatusIcon && widget.label == 'canceled', + ), + findsWidgets, + reason: 'The accepted server state must also update the held list row', + ); + await tester.pumpWidget(const SizedBox.shrink()); + }); } diff --git a/app/test/features/runs/ui/run_decide_deep_link_test.dart b/app/test/features/runs/ui/run_decide_deep_link_test.dart index 62c0d1b1..d05ce10b 100644 --- a/app/test/features/runs/ui/run_decide_deep_link_test.dart +++ b/app/test/features/runs/ui/run_decide_deep_link_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 'run_detail_finders.dart'; @@ -90,41 +89,30 @@ Future _pump( } void main() { - for (final cupertino in [false, true]) { - testWidgets('a decide route opens the waiting prompt ($cupertino)', ( - tester, - ) async { - final gateway = _Gateway(_waitingRun()); - addTearDown(gateway.close); - tester.view.physicalSize = const Size(900, 1000); - tester.view.devicePixelRatio = 1; - addTearDown(tester.view.reset); - final screen = RunsScreen( - gateway: gateway, - initialRunId: 9, - initialDecide: true, - ); - await tester.pumpWidget( - cupertino - ? CupertinoApp(home: CupertinoPageScaffold(child: screen)) - : MaterialApp(home: Scaffold(body: screen)), - ); - await tester.pumpAndSettle(); + testWidgets('a decide route opens the waiting prompt', (tester) async { + final gateway = _Gateway(_waitingRun()); + addTearDown(gateway.close); + tester.view.physicalSize = const Size(900, 1000); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + final screen = RunsScreen( + gateway: gateway, + initialRunId: 9, + initialDecide: true, + ); + await tester.pumpWidget(MaterialApp(home: Scaffold(body: screen))); + await tester.pumpAndSettle(); - expect(find.byKey(decisionFeedbackKey), findsOneWidget); - expect( - find.text('Please review this recorded checkpoint.'), - findsOneWidget, - ); + expect(find.byKey(decisionFeedbackKey), findsOneWidget); + expect(find.text('Please review this recorded checkpoint.'), findsOneWidget); - // Closing the prompt leaves the loaded detail underneath. - await tester.tap(find.text(decisionCancelLabel)); - await tester.pumpAndSettle(); - expect(find.byKey(decisionFeedbackKey), findsNothing); - expect(runDetailText('Human checkpoint'), findsOneWidget); - expect(find.byKey(decisionActionKey), findsOneWidget); - }); - } + // Closing the prompt leaves the loaded detail underneath. + await tester.tap(find.text(decisionCancelLabel)); + await tester.pumpAndSettle(); + expect(find.byKey(decisionFeedbackKey), findsNothing); + expect(runDetailText('Human checkpoint'), findsOneWidget); + expect(find.byKey(decisionActionKey), findsOneWidget); + }); testWidgets('a decide route on a non-waiting run invents no prompt', ( tester, diff --git a/app/test/features/runs/ui/run_decision_wiring_test.dart b/app/test/features/runs/ui/run_decision_wiring_test.dart index d4e27fbf..6d1d8c0a 100644 --- a/app/test/features/runs/ui/run_decision_wiring_test.dart +++ b/app/test/features/runs/ui/run_decision_wiring_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/api_gateway.dart'; @@ -60,74 +59,63 @@ class _DecisionGateway implements ApiGateway { } void main() { - for (final cupertino in [false, true]) { - testWidgets( - 'actual detail exposes and confirms recorded decision ($cupertino)', - (tester) async { - final gateway = _DecisionGateway(); - addTearDown(gateway.events.close); - final screen = RunsScreen(gateway: gateway, initialRunId: 9); - await tester.pumpWidget( - cupertino - ? CupertinoApp(home: CupertinoPageScaffold(child: screen)) - : MaterialApp(home: Scaffold(body: screen)), - ); - await tester.pumpAndSettle(); - expect(find.text(decisionWaitingTitle), findsOneWidget); - // The web's decision banner spans the header's glass strip (under - // the top bar, 12 in from the pane) at the strip's 12px inset, with - // Decide trailing. - final banner = tester.getRect( - find.byKey(const Key('run-decision-banner')), - ); - final strip = tester.getRect( - find.descendant( - of: find.byKey(const Key('run-detail-header')), - matching: find.byType(GlassPill), - ), - ); - final pane = tester.getRect( - find.byKey(const ValueKey('list-detail-body')), - ); - expect(strip.left, pane.left + 12); - expect(strip.right, pane.right - 12); - expect(banner.left, strip.left + 12); - expect(banner.right, strip.right - 12); - expect( - tester.getCenter(find.byKey(decisionActionKey)).dx, - greaterThan(banner.center.dx), - ); - await tester.tap(find.byKey(decisionActionKey)); - await tester.pumpAndSettle(); - expect( - find.text('Please review this recorded checkpoint.'), - findsOneWidget, - ); - await tester.tap(find.text('approve')); - await tester.enterText(find.byKey(decisionFeedbackKey), ' checked '); - await tester.pump(); - expect(gateway.decisions, isEmpty); - await tester.tap(find.text(decisionConfirmLabel)); - await tester.pump(); - expect(gateway.decisions.single, { - 'run_id': 9, - 'stage': 'gate', - 'option': 'approve', - 'feedback': 'checked', - }); - gateway.reply.complete({ - 'run_detail': { - ...gateway.run, - 'status': 'succeeded', - 'executing': false, - }, - }); - await tester.pumpAndSettle(); - expect(find.byKey(decisionActionKey), findsNothing); - expect(find.text(decisionWaitingTitle), findsNothing); - expect(find.text('succeeded'), findsOneWidget); - await tester.pumpWidget(const SizedBox.shrink()); - }, + testWidgets('actual detail exposes and confirms recorded decision', ( + tester, + ) async { + final gateway = _DecisionGateway(); + addTearDown(gateway.events.close); + final screen = RunsScreen(gateway: gateway, initialRunId: 9); + await tester.pumpWidget(MaterialApp(home: Scaffold(body: screen))); + await tester.pumpAndSettle(); + expect(find.text(decisionWaitingTitle), findsOneWidget); + // The web's decision banner spans the header's glass strip (under + // the top bar, 12 in from the pane) at the strip's 12px inset, with + // Decide trailing. + final banner = tester.getRect(find.byKey(const Key('run-decision-banner'))); + final strip = tester.getRect( + find.descendant( + of: find.byKey(const Key('run-detail-header')), + matching: find.byType(GlassPill), + ), ); - } + final pane = tester.getRect(find.byKey(const ValueKey('list-detail-body'))); + expect(strip.left, pane.left + 12); + expect(strip.right, pane.right - 12); + expect(banner.left, strip.left + 12); + expect(banner.right, strip.right - 12); + expect( + tester.getCenter(find.byKey(decisionActionKey)).dx, + greaterThan(banner.center.dx), + ); + await tester.tap(find.byKey(decisionActionKey)); + await tester.pumpAndSettle(); + expect( + find.text('Please review this recorded checkpoint.'), + findsOneWidget, + ); + await tester.tap(find.text('approve')); + await tester.enterText(find.byKey(decisionFeedbackKey), ' checked '); + await tester.pump(); + expect(gateway.decisions, isEmpty); + await tester.tap(find.text(decisionConfirmLabel)); + await tester.pump(); + expect(gateway.decisions.single, { + 'run_id': 9, + 'stage': 'gate', + 'option': 'approve', + 'feedback': 'checked', + }); + gateway.reply.complete({ + 'run_detail': { + ...gateway.run, + 'status': 'succeeded', + 'executing': false, + }, + }); + await tester.pumpAndSettle(); + expect(find.byKey(decisionActionKey), findsNothing); + expect(find.text(decisionWaitingTitle), findsNothing); + expect(find.text('succeeded'), findsOneWidget); + await tester.pumpWidget(const SizedBox.shrink()); + }); } diff --git a/app/test/features/runs/ui/run_retry_guard_test.dart b/app/test/features/runs/ui/run_retry_guard_test.dart index 96c767bc..e4cd1944 100644 --- a/app/test/features/runs/ui/run_retry_guard_test.dart +++ b/app/test/features/runs/ui/run_retry_guard_test.dart @@ -17,7 +17,6 @@ void main() { await mountRetryScreen( tester, gateway, - cupertino: false, onRunSelected: opened.add, ); @@ -40,7 +39,6 @@ void main() { await mountRetryScreen( tester, gateway, - cupertino: false, onRunSelected: opened.add, ); @@ -65,7 +63,6 @@ void main() { await mountRetryScreen( tester, gateway, - cupertino: false, onRunSelected: opened.add, ); @@ -87,7 +84,6 @@ void main() { await mountRetryScreen( tester, gateway, - cupertino: false, onRunSelected: opened.add, ); @@ -107,7 +103,7 @@ void main() { ) async { final gateway = RetryWiringGateway(executing: true); addTearDown(gateway.framesController.close); - await mountRetryScreen(tester, gateway, cupertino: false); + await mountRetryScreen(tester, gateway); expect(find.byKey(runMoreMenuKey), findsOneWidget); expect(await retryOffered(tester), isFalse); diff --git a/app/test/features/runs/ui/run_retry_layout_test.dart b/app/test/features/runs/ui/run_retry_layout_test.dart index 23fe1fa2..6ef10dd4 100644 --- a/app/test/features/runs/ui/run_retry_layout_test.dart +++ b/app/test/features/runs/ui/run_retry_layout_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/runs/actions/cancel_wording.dart'; @@ -36,57 +35,48 @@ void main() { expect(cancel.left, closeTo(16, 0.5)); }); - for (final cupertino in [false, true]) { - testWidgets('320 px at 2x keeps Retry reachable ($cupertino)', ( - tester, - ) async { - tester.view.physicalSize = const Size(320, 480); - tester.view.devicePixelRatio = 1; - addTearDown(tester.view.resetPhysicalSize); - addTearDown(tester.view.resetDevicePixelRatio); + testWidgets('320 px at 2x keeps Retry reachable', (tester) async { + tester.view.physicalSize = const Size(320, 480); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); - final gateway = RetryWiringGateway(); - addTearDown(gateway.framesController.close); - Widget scale(BuildContext context, Widget? app) => MediaQuery( - data: MediaQuery.of( - context, - ).copyWith(textScaler: const TextScaler.linear(2)), - child: app!, - ); - // The action row itself, in the detail's 16 px inset, so the narrow - // accessibility state is measured without unrelated header controls. - final row = Padding( - padding: const EdgeInsets.all(16), - child: RunDetailActions( - run: retryFailedDetail(), - gateway: gateway, - onRunChanged: (_) {}, - ), - ); - await tester.pumpWidget( - cupertino - ? CupertinoApp( - builder: scale, - home: CupertinoPageScaffold(child: SafeArea(child: row)), - ) - : MaterialApp( - builder: scale, - home: Scaffold(body: row), - ), - ); - await tester.pumpAndSettle(); + final gateway = RetryWiringGateway(); + addTearDown(gateway.framesController.close); + Widget scale(BuildContext context, Widget? app) => MediaQuery( + data: MediaQuery.of( + context, + ).copyWith(textScaler: const TextScaler.linear(2)), + child: app!, + ); + // The action row itself, in the detail's 16 px inset, so the narrow + // accessibility state is measured without unrelated header controls. + final row = Padding( + padding: const EdgeInsets.all(16), + child: RunDetailActions( + run: retryFailedDetail(), + gateway: gateway, + onRunChanged: (_) {}, + ), + ); + await tester.pumpWidget( + MaterialApp( + builder: scale, + home: Scaffold(body: row), + ), + ); + await tester.pumpAndSettle(); - expect(find.byKey(retryActionKey).hitTestable(), findsOneWidget); - final rect = tester.getRect(find.byKey(retryActionKey)); - expect(rect.left, greaterThanOrEqualTo(0)); - expect(rect.right, lessThanOrEqualTo(320)); + expect(find.byKey(retryActionKey).hitTestable(), findsOneWidget); + final rect = tester.getRect(find.byKey(retryActionKey)); + expect(rect.left, greaterThanOrEqualTo(0)); + expect(rect.right, lessThanOrEqualTo(320)); - await tester.tap(find.byKey(retryActionKey)); - await tester.pumpAndSettle(); - expect(find.text(retryDialogTitle(7)), findsOneWidget); - await tester.tap(find.byKey(retryKeepKey)); - await tester.pumpAndSettle(); - expect(gateway.retryCalls, isEmpty); - }); - } + await tester.tap(find.byKey(retryActionKey)); + await tester.pumpAndSettle(); + expect(find.text(retryDialogTitle(7)), findsOneWidget); + await tester.tap(find.byKey(retryKeepKey)); + await tester.pumpAndSettle(); + expect(gateway.retryCalls, isEmpty); + }); } diff --git a/app/test/features/runs/ui/run_retry_wiring_support.dart b/app/test/features/runs/ui/run_retry_wiring_support.dart index 688e6283..6def348f 100644 --- a/app/test/features/runs/ui/run_retry_wiring_support.dart +++ b/app/test/features/runs/ui/run_retry_wiring_support.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/features/runs/ui/run_more_menu.dart'; @@ -88,7 +87,6 @@ class RetryWiringGateway implements ApiGateway { Future mountRetryScreen( WidgetTester tester, RetryWiringGateway gateway, { - required bool cupertino, ValueChanged? onRunSelected, }) async { final screen = RunsScreen( @@ -96,13 +94,7 @@ Future mountRetryScreen( initialRunId: 7, onRunSelected: onRunSelected, ); - await tester.pumpWidget( - cupertino - ? CupertinoApp( - home: CupertinoPageScaffold(child: SafeArea(child: screen)), - ) - : MaterialApp(home: Scaffold(body: screen)), - ); + await tester.pumpWidget(MaterialApp(home: Scaffold(body: screen))); await tester.pumpAndSettle(); } diff --git a/app/test/features/runs/ui/run_retry_wiring_test.dart b/app/test/features/runs/ui/run_retry_wiring_test.dart index 6893b1d2..a88d843e 100644 --- a/app/test/features/runs/ui/run_retry_wiring_test.dart +++ b/app/test/features/runs/ui/run_retry_wiring_test.dart @@ -7,65 +7,55 @@ import 'run_retry_wiring_support.dart'; import 'run_detail_finders.dart'; void main() { - for (final cupertino in [false, true]) { - testWidgets( - 'accepted retry reply opens the server-identified run ($cupertino)', - (tester) async { - final gateway = RetryWiringGateway(); - addTearDown(gateway.framesController.close); - final opened = []; - await mountRetryScreen( - tester, - gateway, - cupertino: cupertino, - onRunSelected: opened.add, - ); + testWidgets( + 'accepted retry reply opens the server-identified run', + (tester) async { + final gateway = RetryWiringGateway(); + addTearDown(gateway.framesController.close); + final opened = []; + await mountRetryScreen(tester, gateway, onRunSelected: opened.add); - expect(runDetailText(retryFailedTitle), findsOneWidget); - expect(find.byKey(runMoreMenuKey), findsOneWidget); - expect(await retryOffered(tester), isTrue); - expect(find.byKey(cancelActionKey), findsNothing); - expect(gateway.retryCalls, isEmpty); + expect(runDetailText(retryFailedTitle), findsOneWidget); + expect(find.byKey(runMoreMenuKey), findsOneWidget); + expect(await retryOffered(tester), isTrue); + expect(find.byKey(cancelActionKey), findsNothing); + expect(gateway.retryCalls, isEmpty); - await openRetry(tester); - expect(find.text(retryDialogTitle(7)), findsOneWidget); - expect(find.text(retryDialogMessage), findsOneWidget); - expect(gateway.retryCalls, isEmpty); + await openRetry(tester); + expect(find.text(retryDialogTitle(7)), findsOneWidget); + expect(find.text(retryDialogMessage), findsOneWidget); + expect(gateway.retryCalls, isEmpty); - await tester.tap(find.byKey(retryKeepKey)); - await tester.pumpAndSettle(); - expect(gateway.retryCalls, isEmpty); - expect(opened, isEmpty); - expect(await retryOffered(tester), isTrue); + await tester.tap(find.byKey(retryKeepKey)); + await tester.pumpAndSettle(); + expect(gateway.retryCalls, isEmpty); + expect(opened, isEmpty); + expect(await retryOffered(tester), isTrue); - await confirmRetry(tester); - expect(gateway.retryCalls, hasLength(1)); - final fields = gateway.retryCalls.single.fields; - expect(fields.keys.toSet(), {'run_id', 'request_key'}); - expect(fields['run_id'], 7); - expect(fields['request_key'], startsWith('app-retry-7-')); - expect( - (fields['request_key'] as String).length, - lessThanOrEqualTo(128), - ); - // The prompt closes only from server truth; no navigation is guessed. - expect(opened, isEmpty); - expect(runDetailText(retryFailedTitle), findsOneWidget); + await confirmRetry(tester); + expect(gateway.retryCalls, hasLength(1)); + final fields = gateway.retryCalls.single.fields; + expect(fields.keys.toSet(), {'run_id', 'request_key'}); + expect(fields['run_id'], 7); + expect(fields['request_key'], startsWith('app-retry-7-')); + expect((fields['request_key'] as String).length, lessThanOrEqualTo(128)); + // The prompt closes only from server truth; no navigation is guessed. + expect(opened, isEmpty); + expect(runDetailText(retryFailedTitle), findsOneWidget); - gateway.acceptRetry(retryCreatedDetail()); - await tester.pumpAndSettle(); + gateway.acceptRetry(retryCreatedDetail()); + await tester.pumpAndSettle(); - expect(opened, [8]); - expect(runDetailText(retryCreatedTitle), findsOneWidget); - expect(runDetailText(retryFailedTitle), findsNothing); - expect(await retryOffered(tester), isFalse); - expect( - gateway.calls.where((call) => call.type == 'get_run').last.fields, - {'run_id': 8}, - ); - }, - ); - } + expect(opened, [8]); + expect(runDetailText(retryCreatedTitle), findsOneWidget); + expect(runDetailText(retryFailedTitle), findsNothing); + expect(await retryOffered(tester), isFalse); + expect( + gateway.calls.where((call) => call.type == 'get_run').last.fields, + {'run_id': 8}, + ); + }, + ); testWidgets('restart sends its explicit mode through the real detail row', ( tester, @@ -73,12 +63,7 @@ void main() { final gateway = RetryWiringGateway(); addTearDown(gateway.framesController.close); final opened = []; - await mountRetryScreen( - tester, - gateway, - cupertino: false, - onRunSelected: opened.add, - ); + await mountRetryScreen(tester, gateway, onRunSelected: opened.add); await openRetry(tester); await tester.tap(find.byKey(retryRestartKey)); diff --git a/app/test/features/runs/ui/run_session_repair_action_test.dart b/app/test/features/runs/ui/run_session_repair_action_test.dart index 3d05e399..671edef4 100644 --- a/app/test/features/runs/ui/run_session_repair_action_test.dart +++ b/app/test/features/runs/ui/run_session_repair_action_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/api_gateway.dart'; @@ -100,16 +99,9 @@ Future _pumpSession( WidgetTester tester, _RepairGateway gateway, { JsonMap? run, - bool cupertino = false, }) { final host = _SessionHost(run: run ?? partialRun(), gateway: gateway); - return tester.pumpWidget( - cupertino - ? CupertinoApp( - home: CupertinoPageScaffold(child: SafeArea(child: host)), - ) - : MaterialApp(home: Scaffold(body: host)), - ); + return tester.pumpWidget(MaterialApp(home: Scaffold(body: host))); } TextButton _materialButton(WidgetTester tester) => tester.widget( @@ -254,18 +246,15 @@ void main() { expect(find.text('partial'), findsOneWidget); }); - testWidgets('the Cupertino host uses a native Cupertino button', ( - tester, - ) async { + testWidgets('the repair control is a Material text button', (tester) async { final gateway = _RepairGateway( (_, _) => Future.error(StateError('unexpected')), ); - await _pumpSession(tester, gateway, cupertino: true); + await _pumpSession(tester, gateway); expect( - find.widgetWithText(CupertinoButton, 'Retry export only'), + find.widgetWithText(TextButton, 'Retry export only'), findsOneWidget, ); - expect(find.widgetWithText(TextButton, 'Retry export only'), findsNothing); }); } diff --git a/app/test/features/runs/ui/run_title_wiring_test.dart b/app/test/features/runs/ui/run_title_wiring_test.dart index 7c641203..1f3118f2 100644 --- a/app/test/features/runs/ui/run_title_wiring_test.dart +++ b/app/test/features/runs/ui/run_title_wiring_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 'run_detail_finders.dart'; @@ -65,28 +64,17 @@ class _Gateway implements ApiGateway { Future<_Gateway> _mount( WidgetTester tester, { - required bool cupertino, int initialRunId = 1, }) async { final gateway = _Gateway(); final screen = RunsScreen(gateway: gateway, initialRunId: initialRunId); - await tester.pumpWidget( - cupertino - ? CupertinoApp( - home: CupertinoPageScaffold(child: SafeArea(child: screen)), - ) - : MaterialApp(home: Scaffold(body: screen)), - ); + await tester.pumpWidget(MaterialApp(home: Scaffold(body: screen))); await tester.pumpAndSettle(); return gateway; } -String _fieldText(WidgetTester tester, {required bool cupertino}) => cupertino - ? tester - .widget(find.byKey(runTitleFieldKey)) - .controller! - .text - : tester.widget(find.byKey(runTitleFieldKey)).controller!.text; +String _fieldText(WidgetTester tester) => + tester.widget(find.byKey(runTitleFieldKey)).controller!.text; /// Rename lives in the run detail's more menu. Future _openRename(WidgetTester tester) async { @@ -99,7 +87,7 @@ Future _openRename(WidgetTester tester) async { void main() { testWidgets('material detail renames through the shared gateway and folds ' 'only the server reply into the detail and list', (tester) async { - final gateway = await _mount(tester, cupertino: false); + final gateway = await _mount(tester); expect(runDetailText('Nightly build'), findsOneWidget); expect(find.byKey(runMoreMenuKey), findsOneWidget); @@ -107,7 +95,7 @@ void main() { await _openRename(tester); expect(find.byType(AlertDialog), findsOneWidget); - expect(_fieldText(tester, cupertino: false), 'Nightly build'); + expect(_fieldText(tester), 'Nightly build'); await tester.enterText(find.byKey(runTitleFieldKey), 'Draft only'); await tester.pump(); @@ -146,35 +134,10 @@ void main() { ); }); - testWidgets('cupertino detail shows the native rename entry point', ( - tester, - ) async { - final gateway = await _mount(tester, cupertino: true); - - expect(find.byKey(runMoreMenuKey), findsOneWidget); - - await _openRename(tester); - expect(find.byType(CupertinoAlertDialog), findsOneWidget); - expect(find.byType(AlertDialog), findsNothing); - - await tester.enterText(find.byKey(runTitleFieldKey), 'Release build'); - await tester.tap(find.byKey(runTitleSaveKey)); - await tester.pump(); - expect(gateway.saves.single.fields, { - 'run_id': 1, - 'title': 'Release build', - }); - gateway.accept('Release build'); - await tester.pumpAndSettle(); - - expect(find.byType(CupertinoAlertDialog), findsNothing); - expect(runDetailText('Release build'), findsOneWidget); - }); - testWidgets('a refused rename keeps the typed title and the stored detail', ( tester, ) async { - final gateway = await _mount(tester, cupertino: false); + final gateway = await _mount(tester); await _openRename(tester); await tester.enterText(find.byKey(runTitleFieldKey), ' locked '); @@ -184,7 +147,7 @@ void main() { await tester.pumpAndSettle(); expect(find.text('rename refused by the server'), findsOneWidget); - expect(_fieldText(tester, cupertino: false), ' locked '); + expect(_fieldText(tester), ' locked '); expect(find.byType(AlertDialog), findsOneWidget); expect(runDetailText('Nightly build'), findsOneWidget); }); diff --git a/app/test/features/runs/ui/runs_delete_test.dart b/app/test/features/runs/ui/runs_delete_test.dart index 6082ac34..8e56bf0e 100644 --- a/app/test/features/runs/ui/runs_delete_test.dart +++ b/app/test/features/runs/ui/runs_delete_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/api_gateway.dart'; @@ -78,7 +77,6 @@ List _fixture() { Future _mount( WidgetTester tester, _Gateway gateway, { - bool cupertino = false, int? initialRunId, RunsSortStore? store, ValueChanged? onBack, @@ -92,11 +90,7 @@ Future _mount( onBack: onBack, sortStore: store ?? MemoryRunsSortStore(), ); - await tester.pumpWidget( - cupertino - ? CupertinoApp(home: CupertinoPageScaffold(child: screen)) - : MaterialApp(home: Scaffold(body: screen)), - ); + await tester.pumpWidget(MaterialApp(home: Scaffold(body: screen))); await tester.pumpAndSettle(); } @@ -200,14 +194,14 @@ void main() { testWidgets('Cancel in the prompt sends nothing', (tester) async { final gateway = _Gateway(_fixture()); - await _mount(tester, gateway, cupertino: true); + await _mount(tester, gateway); await tester.tap(find.byKey(runsSelectKey)); await tester.pumpAndSettle(); await tester.tap(find.text('Yesterday done')); await tester.pumpAndSettle(); await tester.tap(find.byKey(runsDeleteSelectedKey)); await tester.pumpAndSettle(); - expect(find.byType(CupertinoAlertDialog), findsOneWidget); + expect(find.byType(AlertDialog), findsOneWidget); expect(find.text('Delete 1 run?'), findsOneWidget); await tester.tap(find.byKey(deleteRunsKeepKey)); await tester.pumpAndSettle(); diff --git a/app/test/features/runs/ui/runs_screen_test.dart b/app/test/features/runs/ui/runs_screen_test.dart index 60483824..5d064a39 100644 --- a/app/test/features/runs/ui/runs_screen_test.dart +++ b/app/test/features/runs/ui/runs_screen_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 '../../../native_back.dart'; @@ -9,7 +8,6 @@ import 'package:pipelines_app/features/runs/screen.dart'; import 'package:pipelines_app/features/runs/ui/run_detail_view.dart'; import 'run_detail_finders.dart'; import 'package:pipelines_app/shell/empty_detail_pane.dart'; -import 'package:pipelines_app/ui/adaptive/segmented_bar.dart'; class _Gateway implements ApiGateway { final framesController = StreamController.broadcast(); @@ -345,32 +343,6 @@ void main() { }); } - testWidgets( - 'wide Cupertino host keeps list and detail bars while pending', - (tester) async { - await tester.pumpWidget( - CupertinoApp( - home: CupertinoPageScaffold( - navigationBar: const CupertinoNavigationBar(middle: Text('Runs')), - child: SafeArea( - child: RunsScreen(gateway: gateway, initialRunId: 1), - ), - ), - ), - ); - await _mountList(tester, gateway); - - expect(find.byType(CupertinoPageScaffold), findsNWidgets(2)); - // The host's own bar and the detail pane's segmented bar. - expect(find.byType(CupertinoNavigationBar), findsOneWidget); - expect(find.byType(SegmentedBar), findsOneWidget); - expect(find.text('Loading run details…'), findsOneWidget); - expect(find.byType(CupertinoActivityIndicator), findsOneWidget); - expect(find.text('Back to list'), findsOneWidget); - }, - variant: TargetPlatformVariant.only(TargetPlatform.iOS), - ); - testWidgets('on a phone an open run is its own page and Back returns', ( tester, ) async { diff --git a/app/test/features/settings/settings_shell_background_test.dart b/app/test/features/settings/settings_shell_background_test.dart index b7e3c89f..707b2ab3 100644 --- a/app/test/features/settings/settings_shell_background_test.dart +++ b/app/test/features/settings/settings_shell_background_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/transport/pipelines_client.dart' @@ -9,22 +8,18 @@ import 'package:pipelines_app/features/settings/settings_store.dart'; import 'package:pipelines_app/shell/adaptive_shell.dart'; import 'package:pipelines_app/shell/destination.dart'; import 'package:pipelines_app/ui/adaptive/segmented_bar.dart'; -import 'package:pipelines_app/ui/theme/app_theme.dart'; import 'fake_channel.dart'; -/// Settings as the shell's tab: the page runs behind the shell's bar, and on -/// Cupertino the grouped background reaches the top edge with the bar's -/// scrim in the same colour, so no white band or seam shows under the bar. +/// Settings as the shell's tab: the page runs behind the shell's bar. void main() { - Future pump(WidgetTester tester, {required bool cupertino}) async { + Future pump(WidgetTester tester) async { await tester.binding.setSurfaceSize(const Size(560, 1000)); addTearDown(() => tester.binding.setSurfaceSize(null)); final factory = FakeChannelFactory(); final client = transport.PipelinesClient(channelFactory: factory.call); addTearDown(client.dispose); final shell = AdaptiveShell( - cupertino: cupertino, destination: AppDestination.settings, destinationBodies: { AppDestination.settings: (_) => SettingsScreen( @@ -34,9 +29,7 @@ void main() { ), }, ); - await tester.pumpWidget( - cupertino ? CupertinoApp(home: shell) : MaterialApp(home: shell), - ); + await tester.pumpWidget(MaterialApp(home: shell)); await tester.pump(); await tester.pump(); } @@ -52,34 +45,8 @@ void main() { ) .color; - testWidgets('Cupertino: the grouped background runs under the bar', ( - tester, - ) async { - await pump(tester, cupertino: true); - - final grouped = AppColors.groupedBackground.color.toARGB32(); - expect(scrimOf(tester).toARGB32(), grouped); - // The page's background starts at the top edge, behind the bar. - final page = find.ancestor( - of: find.byKey(const ValueKey('settings.scroll')), - matching: find.byWidgetPredicate( - (widget) => widget is ColoredBox && widget.color.toARGB32() == grouped, - ), - ); - expect(page, findsWidgets); - expect(tester.getTopLeft(page.last).dy, 0); - // The groups start below the bar and persistent category selector. - final bar = tester.getRect(find.byType(SegmentedBar)); - expect( - tester.getTopLeft(find.byType(SettingsGroup).first).dy, - greaterThanOrEqualTo(bar.bottom - 8), - ); - }); - - testWidgets('Material: the bar keeps the shell page background', ( - tester, - ) async { - await pump(tester, cupertino: false); + testWidgets('the bar keeps the shell page background', (tester) async { + await pump(tester); final context = tester.element(find.byType(SettingsGroup).first); expect( diff --git a/app/test/shell/attention_badge_test.dart b/app/test/shell/attention_badge_test.dart index c6a18b5f..a02d7907 100644 --- a/app/test/shell/attention_badge_test.dart +++ b/app/test/shell/attention_badge_test.dart @@ -1,13 +1,11 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/shell/adaptive_shell.dart'; import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart'; -/// The Runs tab mirrors the attention count in every mount of both hosts: -/// the floating tab bar at full width on a phone and right-aligned on a wide -/// window. Zero draws the -/// bare icon with no count and no attention semantics. +/// The Runs tab mirrors the attention count in every mount: the floating tab +/// bar at full width on a phone and right-aligned on a wide window. Zero draws +/// the bare icon with no count and no attention semantics. void main() { final needingAttention = RegExp('Notifications, 3 needing attention'); final anyAttention = RegExp('needing attention'); @@ -15,27 +13,22 @@ void main() { Future pumpShell( WidgetTester tester, { required double width, - required bool cupertino, required int count, }) async { tester.view.physicalSize = Size(width, 900); tester.view.devicePixelRatio = 1; addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); - final shell = AdaptiveShell(cupertino: cupertino, attentionCount: count); - await tester.pumpWidget( - cupertino ? CupertinoApp(home: shell) : MaterialApp(home: shell), - ); + final shell = AdaptiveShell(attentionCount: count); + await tester.pumpWidget(MaterialApp(home: shell)); } for (final width in [390.0, 1000.0]) { final mount = width < 600 ? 'bottom bar' : 'wide bar'; - testWidgets('Material $mount shows the count on the Runs tab', ( - tester, - ) async { + testWidgets('$mount shows the count on the Runs tab', (tester) async { final semantics = tester.ensureSemantics(); - await pumpShell(tester, width: width, cupertino: false, count: 3); + await pumpShell(tester, width: width, count: 3); expect(find.byType(FloatingDestinationBar), findsOneWidget); expect(find.byType(NavigationRail), findsNothing); final badge = find.byType(Badge); @@ -49,9 +42,9 @@ void main() { semantics.dispose(); }); - testWidgets('Material $mount hides the badge at zero', (tester) async { + testWidgets('$mount hides the badge at zero', (tester) async { final semantics = tester.ensureSemantics(); - await pumpShell(tester, width: width, cupertino: false, count: 0); + await pumpShell(tester, width: width, count: 0); final badge = find.byType(Badge); expect(badge, findsOneWidget); expect(tester.widget(badge).isLabelVisible, isFalse); @@ -67,32 +60,8 @@ void main() { }); } - for (final width in [390.0, 1280.0]) { - final mount = width < 600 ? 'tab bar' : 'wide tab bar'; - - testWidgets('Cupertino $mount shows the count on the Runs item', ( - tester, - ) async { - final semantics = tester.ensureSemantics(); - await pumpShell(tester, width: width, cupertino: true, count: 3); - expect(find.byType(FloatingDestinationBar), findsOneWidget); - expect(find.byType(Badge), findsNothing, reason: 'no Material badge'); - expect(find.text('3'), findsOneWidget); - expect(find.bySemanticsLabel(needingAttention), findsOneWidget); - semantics.dispose(); - }); - - testWidgets('Cupertino $mount hides the count at zero', (tester) async { - final semantics = tester.ensureSemantics(); - await pumpShell(tester, width: width, cupertino: true, count: 0); - expect(find.text('0'), findsNothing); - expect(find.bySemanticsLabel(anyAttention), findsNothing); - semantics.dispose(); - }); - } - testWidgets('the badge stays visible from every destination', (tester) async { - await pumpShell(tester, width: 1000, cupertino: false, count: 2); + await pumpShell(tester, width: 1000, count: 2); for (final name in ['runs', 'chat', 'search']) { await tester.tap(find.byKey(ValueKey('shell.destination.$name'))); await tester.pumpAndSettle(); diff --git a/app/test/shell/destination_shortcuts_test.dart b/app/test/shell/destination_shortcuts_test.dart index bca4fca9..e9c4dedb 100644 --- a/app/test/shell/destination_shortcuts_test.dart +++ b/app/test/shell/destination_shortcuts_test.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -6,89 +5,73 @@ import 'package:pipelines_app/shell/adaptive_shell.dart'; import 'package:pipelines_app/shell/destination.dart'; void main() { - for (final cupertino in [false, true]) { - final host = cupertino ? 'Cupertino' : 'Material'; - - testWidgets( - '$host Ctrl+Tab and Ctrl+Shift+Tab leave destinations unchanged', - (tester) async { - final app = AdaptiveShell( - cupertino: cupertino, - destinationBodies: { - for (final destination in shellTabDestinations) - destination: (_) => Focus( - autofocus: destination == AppDestination.pipelines, - child: Text(destination.name), - ), - }, - ); - await tester.pumpWidget( - cupertino ? CupertinoApp(home: app) : MaterialApp(home: app), - ); - - Future press({required bool shift}) async { - await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft); - if (shift) { - await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft); - } - await tester.sendKeyEvent(LogicalKeyboardKey.tab); - if (shift) { - await tester.sendKeyUpEvent(LogicalKeyboardKey.shiftLeft); - } - await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft); - await tester.pump(); - } - - expect(find.text('pipelines'), findsOneWidget); - await press(shift: true); - expect(find.text('pipelines'), findsOneWidget); - await press(shift: false); - expect(find.text('pipelines'), findsOneWidget); + testWidgets('Ctrl+Tab and Ctrl+Shift+Tab leave destinations unchanged', ( + tester, + ) async { + final app = AdaptiveShell( + destinationBodies: { + for (final destination in shellTabDestinations) + destination: (_) => Focus( + autofocus: destination == AppDestination.pipelines, + child: Text(destination.name), + ), }, ); + await tester.pumpWidget(MaterialApp(home: app)); - testWidgets( - '$host plain Tab traverses and Ctrl+Tab does not change destinations', - (tester) async { - final first = FocusNode(); - final second = FocusNode(); - addTearDown(first.dispose); - addTearDown(second.dispose); - final app = AdaptiveShell( - cupertino: cupertino, - destinationBodies: { - AppDestination.pipelines: (_) => Column( - children: [ - cupertino - ? CupertinoTextField(focusNode: first) - : TextField(focusNode: first), - cupertino - ? CupertinoTextField(focusNode: second) - : TextField(focusNode: second), - ], - ), - AppDestination.runs: (_) => const Text('runs'), - }, - ); - await tester.pumpWidget( - cupertino ? CupertinoApp(home: app) : MaterialApp(home: app), - ); - first.requestFocus(); - await tester.pump(); + Future press({required bool shift}) async { + await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft); + if (shift) { + await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft); + } + await tester.sendKeyEvent(LogicalKeyboardKey.tab); + if (shift) { + await tester.sendKeyUpEvent(LogicalKeyboardKey.shiftLeft); + } + await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft); + await tester.pump(); + } - // Plain Tab retains normal traversal semantics and does not select a tab. - await tester.sendKeyEvent(LogicalKeyboardKey.tab); - await tester.pump(); - expect(second.hasFocus, isTrue); + expect(find.text('pipelines'), findsOneWidget); + await press(shift: true); + expect(find.text('pipelines'), findsOneWidget); + await press(shift: false); + expect(find.text('pipelines'), findsOneWidget); + }); - first.requestFocus(); - await tester.pump(); - await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft); - await tester.sendKeyEvent(LogicalKeyboardKey.tab); - await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft); - await tester.pump(); - expect(find.text('runs'), findsNothing); + testWidgets('plain Tab traverses and Ctrl+Tab does not change destinations', ( + tester, + ) async { + final first = FocusNode(); + final second = FocusNode(); + addTearDown(first.dispose); + addTearDown(second.dispose); + final app = AdaptiveShell( + destinationBodies: { + AppDestination.pipelines: (_) => Column( + children: [ + TextField(focusNode: first), + TextField(focusNode: second), + ], + ), + AppDestination.runs: (_) => const Text('runs'), }, ); - } + await tester.pumpWidget(MaterialApp(home: app)); + first.requestFocus(); + await tester.pump(); + + // Plain Tab retains normal traversal semantics and does not select a tab. + await tester.sendKeyEvent(LogicalKeyboardKey.tab); + await tester.pump(); + expect(second.hasFocus, isTrue); + + first.requestFocus(); + await tester.pump(); + await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft); + await tester.sendKeyEvent(LogicalKeyboardKey.tab); + await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft); + await tester.pump(); + expect(find.text('runs'), findsNothing); + }); } diff --git a/app/test/shell/detail_pane_reset_test.dart b/app/test/shell/detail_pane_reset_test.dart index becdb31f..87e59e79 100644 --- a/app/test/shell/detail_pane_reset_test.dart +++ b/app/test/shell/detail_pane_reset_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/shell/adaptive_shell.dart'; @@ -9,66 +8,62 @@ import 'package:pipelines_app/shell/list_detail.dart'; /// page) closes when another item is selected, so the pane shows the newly /// selected item instead of the old item's page. void main() { - for (final cupertino in [false, true]) { - testWidgets('selecting another item closes the previous item\'s page ' - '(${cupertino ? 'cupertino' : 'material'})', (tester) async { - tester.view.physicalSize = const Size(1200, 800); - tester.view.devicePixelRatio = 1; - addTearDown(tester.view.reset); - final selected = ValueNotifier(1); - addTearDown(selected.dispose); + testWidgets("selecting another item closes the previous item's page", ( + tester, + ) async { + tester.view.physicalSize = const Size(1200, 800); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + final selected = ValueNotifier(1); + addTearDown(selected.dispose); - Widget detail(int id) => Builder( - builder: (context) => Center( - child: GestureDetector( - key: const Key('open-page'), - onTap: () => Navigator.of(context).push( - PageRouteBuilder( - pageBuilder: (_, _, _) => Text('page of item $id'), - ), + Widget detail(int id) => Builder( + builder: (context) => Center( + child: GestureDetector( + key: const Key('open-page'), + onTap: () => Navigator.of(context).push( + PageRouteBuilder( + pageBuilder: (_, _, _) => Text('page of item $id'), ), - child: Text('item $id'), + ), + child: Text('item $id'), + ), + ), + ); + + final shell = AdaptiveShell( + destination: AppDestination.runs, + destinationBodies: { + AppDestination.runs: (_) => ValueListenableBuilder( + valueListenable: selected, + builder: (_, id, _) => ListDetailPanes( + list: const Text('list'), + detailIdentity: id, + detail: detail(id), ), ), - ); + }, + ); + await tester.pumpWidget( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.android), + home: shell, + ), + ); + await tester.pumpAndSettle(); - final shell = AdaptiveShell( - cupertino: cupertino, - destination: AppDestination.runs, - destinationBodies: { - AppDestination.runs: (_) => ValueListenableBuilder( - valueListenable: selected, - builder: (_, id, _) => ListDetailPanes( - list: const Text('list'), - detailIdentity: id, - detail: detail(id), - ), - ), - }, - ); - await tester.pumpWidget( - cupertino - ? CupertinoApp(home: shell) - : MaterialApp( - theme: ThemeData(platform: TargetPlatform.android), - home: shell, - ), - ); - await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('open-page'))); + await tester.pumpAndSettle(); + expect(find.text('page of item 1'), findsOneWidget); - await tester.tap(find.byKey(const Key('open-page'))); - await tester.pumpAndSettle(); - expect(find.text('page of item 1'), findsOneWidget); + // The same item rebuilt keeps its page open. + selected.value = 1; + await tester.pumpAndSettle(); + expect(find.text('page of item 1'), findsOneWidget); - // The same item rebuilt keeps its page open. - selected.value = 1; - await tester.pumpAndSettle(); - expect(find.text('page of item 1'), findsOneWidget); - - selected.value = 2; - await tester.pumpAndSettle(); - expect(find.text('page of item 1'), findsNothing); - expect(find.text('item 2'), findsOneWidget); - }); - } + selected.value = 2; + await tester.pumpAndSettle(); + expect(find.text('page of item 1'), findsNothing); + expect(find.text('item 2'), findsOneWidget); + }); } diff --git a/app/test/shell/empty_detail_pane_test.dart b/app/test/shell/empty_detail_pane_test.dart index 81f5eedc..a466a8c6 100644 --- a/app/test/shell/empty_detail_pane_test.dart +++ b/app/test/shell/empty_detail_pane_test.dart @@ -1,52 +1,37 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/shell/destination.dart'; import 'package:pipelines_app/shell/empty_detail_pane.dart'; /// One placeholder for an empty detail pane: the destination's icon above a -/// short muted line, centred, on both hosts. +/// short muted line, centred. void main() { - for (final cupertino in [false, true]) { - final host = cupertino ? 'Cupertino' : 'Material'; - for (final destination in [ - AppDestination.runs, - AppDestination.chat, - AppDestination.pipelines, - ]) { - testWidgets('$host ${destination.name}: icon over a muted line', ( - tester, - ) async { - final content = EmptyDetailPane( - destination: destination, - message: 'Select one to open it here.', - ); - await tester.pumpWidget( - cupertino - ? CupertinoApp(home: CupertinoPageScaffold(child: content)) - : MaterialApp(home: Scaffold(body: content)), - ); - final details = destinationDetails(destination); - final icon = find.byIcon( - cupertino ? details.cupertinoIcon : details.icon, - ); - expect(icon, findsOneWidget); - final text = find.text('Select one to open it here.'); - expect( - tester.getTopLeft(text).dy, - greaterThan(tester.getRect(icon).bottom), - ); - // Centred in the pane. - final size = tester.view.physicalSize / tester.view.devicePixelRatio; - expect(tester.getCenter(text).dx, closeTo(size.width / 2, 1)); - // Muted: the same secondary colour on the icon and the line. - final context = tester.element(text); - final muted = cupertino - ? CupertinoColors.secondaryLabel.resolveFrom(context) - : Theme.of(context).colorScheme.onSurfaceVariant; - expect(tester.widget(icon).color, muted); - expect(tester.widget(text).style?.color, muted); - }); - } + for (final destination in [ + AppDestination.runs, + AppDestination.chat, + AppDestination.pipelines, + ]) { + testWidgets('${destination.name}: icon over a muted line', (tester) async { + final content = EmptyDetailPane( + destination: destination, + message: 'Select one to open it here.', + ); + await tester.pumpWidget(MaterialApp(home: Scaffold(body: content))); + final icon = find.byIcon(destinationDetails(destination).icon); + expect(icon, findsOneWidget); + final text = find.text('Select one to open it here.'); + expect( + tester.getTopLeft(text).dy, + greaterThan(tester.getRect(icon).bottom), + ); + // Centred in the pane. + final size = tester.view.physicalSize / tester.view.devicePixelRatio; + expect(tester.getCenter(text).dx, closeTo(size.width / 2, 1)); + // Muted: the same secondary colour on the icon and the line. + final context = tester.element(text); + final muted = Theme.of(context).colorScheme.onSurfaceVariant; + expect(tester.widget(icon).color, muted); + expect(tester.widget(text).style?.color, muted); + }); } } diff --git a/app/test/shell/floating_tab_bar_test.dart b/app/test/shell/floating_tab_bar_test.dart index d4ca75c1..00672cf1 100644 --- a/app/test/shell/floating_tab_bar_test.dart +++ b/app/test/shell/floating_tab_bar_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/shell/list_detail_policy.dart'; @@ -67,9 +66,8 @@ void main() { var taps = 0; double? contentBottomPadding; - Widget shell({required bool cupertino}) { + Widget shell() { final app = AdaptiveShell( - cupertino: cupertino, destinationBodies: { AppDestination.pipelines: (_) => Builder( builder: (context) { @@ -86,184 +84,156 @@ void main() { ), }, ); - return cupertino ? CupertinoApp(home: app) : MaterialApp(home: app); + return MaterialApp(home: app); } - for (final cupertino in [false, true]) { - final host = cupertino ? 'Cupertino' : 'Material'; + testWidgets('phone bar hugs its tabs at the bottom right too, and ' + 'taps beside it reach the content', (tester) async { + taps = 0; + await setSize(tester, const Size(390, 844)); + await tester.pumpWidget(shell()); + final rect = tester.getRect(pill()); + await expectLabeledTargets(tester, rect); + await expectNoSharedBackdrop(tester); + expect(rect.width, lessThanOrEqualTo(390 - 2 * 16)); + expect(rect.right, 390 - 16); + expect(rect.bottom, 844 - 16); + expect(find.byType(NavigationRail), findsNothing); + await tester.tapAt(Offset(rect.left - 40, rect.center.dy)); + await tester.pump(); + expect(taps, 1); + await tester.tap(find.byKey(const ValueKey('shell.destination.chat'))); + await tester.pumpAndSettle(); + expect(find.text('Chat — Not implemented'), findsOneWidget); + }); - testWidgets('$host: phone bar hugs its tabs at the bottom right too, and ' - 'taps beside it reach the content', (tester) async { - taps = 0; - await setSize(tester, const Size(390, 844)); - await tester.pumpWidget(shell(cupertino: cupertino)); - final rect = tester.getRect(pill()); - await expectLabeledTargets(tester, rect); - await expectNoSharedBackdrop(tester); - expect(rect.width, lessThanOrEqualTo(390 - 2 * 16)); - expect(rect.right, 390 - 16); - expect(rect.bottom, 844 - 16); - expect(find.byType(NavigationRail), findsNothing); - await tester.tapAt(Offset(rect.left - 40, rect.center.dy)); - await tester.pump(); - expect(taps, 1); - await tester.tap(find.byKey(const ValueKey('shell.destination.chat'))); - await tester.pumpAndSettle(); - expect(find.text('Chat — Not implemented'), findsOneWidget); - }); - - testWidgets('$host: wide leading bar under the list, content ' - 'keeps the width and taps beside the bar reach it', (tester) async { - taps = 0; - await setSize(tester, const Size(1200, 800)); - await tester.pumpWidget(shell(cupertino: cupertino)); - final rect = tester.getRect(pill()); - // With no item open the bar still sits under the list column, where it - // sits beside an open item, so it never jumps sides. - expect(rect.left, moreOrLessEquals(kFloatingBarMargin, epsilon: 0.5)); - expect(rect.bottom, 800 - 16); - expect(rect.width, lessThan(1200 * 0.6)); - // Captions participate in the bar's content-driven width. - await expectLabeledTargets(tester, rect); - await expectNoSharedBackdrop(tester); - expect( - rect.width, - lessThanOrEqualTo(listDetailListWidth(1200, 1200, null) - 2 * 16), - ); - // No rail or sidebar: the content starts at the left edge. - expect(find.byType(NavigationRail), findsNothing); - expect(find.byType(CupertinoListTile), findsNothing); - expect(tester.getRect(find.byKey(const Key('content'))).left, 0); - // Beside the bar, at the bar's height, the content takes the tap. - await tester.tapAt(Offset(rect.right + 40, rect.center.dy)); - await tester.pump(); - expect(taps, 1); - // On the bar, the tab takes it. - await tester.tap(find.byKey(const ValueKey('shell.destination.chat'))); - await tester.pumpAndSettle(); - expect(find.text('Chat — Not implemented'), findsOneWidget); - }); - - testWidgets('$host: content learns the bar height as bottom padding', ( - tester, - ) async { - for (final size in const [Size(390, 844), Size(1200, 800)]) { - await setSize(tester, size); - await tester.pumpWidget(shell(cupertino: cupertino)); - await tester.pump(); - final rect = tester.getRect(pill()); - // The content's bottom padding clears the whole bar and its margin. - expect( - contentBottomPadding, - moreOrLessEquals(size.height - rect.top, epsilon: 0.5), - reason: '$size', - ); - } - }); - - testWidgets('$host: resizing moves the bar without remounting content', ( - tester, - ) async { - taps = 0; - await setSize(tester, const Size(390, 844)); - await tester.pumpWidget(shell(cupertino: cupertino)); - await tester.tap(find.byKey(const Key('content'))); - await tester.pump(); - expect(find.text('taps 1'), findsOneWidget); - final state = tester.state(find.byType(StatefulBuilder)); - - tester.view.physicalSize = const Size(1200, 800); - await tester.pump(); - expect( - tester.getRect(pill()).left, - moreOrLessEquals(kFloatingBarMargin, epsilon: 0.5), - ); - expect(tester.getRect(pill()).width, lessThan(1200 * 0.6)); - expect(tester.state(find.byType(StatefulBuilder)), same(state)); - - tester.view.physicalSize = const Size(390, 844); - await tester.pump(); - await expectLabeledTargets(tester, tester.getRect(pill())); - expect(tester.getRect(pill()).width, lessThanOrEqualTo(390 - 2 * 16)); - expect(tester.getRect(pill()).right, 390 - 16); - expect(tester.state(find.byType(StatefulBuilder)), same(state)); - }); - - testWidgets('$host: the bar respects the bottom safe area', (tester) async { - await setSize(tester, const Size(390, 844)); - tester.view.padding = const FakeViewPadding(bottom: 34); - await tester.pumpWidget(shell(cupertino: cupertino)); - expect(tester.getRect(pill()).bottom, 844 - 34); - }); - - testWidgets('$host: the selected tab is marked selected for assistive ' - 'technology', (tester) async { - final semantics = tester.ensureSemantics(); - await setSize(tester, const Size(1200, 800)); - await tester.pumpWidget(shell(cupertino: cupertino)); - await tester.tap(find.byKey(const ValueKey('shell.destination.runs'))); - await tester.pumpAndSettle(); - final runs = tester.getSemantics( - find.byKey(const ValueKey('shell.destination.runs')), - ); - expect(runs, isSemantics(isSelected: true)); - // Captions do not duplicate the tab name for assistive technology. - expect(runs.label, startsWith('Runs')); - expect( - tester.getSemantics( - find.byKey(const ValueKey('shell.destination.chat')), - ), - isNot(isSemantics(isSelected: true)), - ); - semantics.dispose(); - }); - } - - testWidgets('Cupertino bar builds no Material widget', (tester) async { + testWidgets('wide leading bar under the list, content ' + 'keeps the width and taps beside the bar reach it', (tester) async { + taps = 0; await setSize(tester, const Size(1200, 800)); - await tester.pumpWidget(shell(cupertino: true)); + await tester.pumpWidget(shell()); + final rect = tester.getRect(pill()); + // With no item open the bar still sits under the list column, where it + // sits beside an open item, so it never jumps sides. + expect(rect.left, moreOrLessEquals(kFloatingBarMargin, epsilon: 0.5)); + expect(rect.bottom, 800 - 16); + expect(rect.width, lessThan(1200 * 0.6)); + // Captions participate in the bar's content-driven width. + await expectLabeledTargets(tester, rect); + await expectNoSharedBackdrop(tester); expect( - find.descendant( - of: find.byType(FloatingDestinationBar), - matching: find.byWidgetPredicate( - (widget) => - widget is Material || - widget is NavigationBar || - widget is InkWell, - ), - ), - findsNothing, + rect.width, + lessThanOrEqualTo(listDetailListWidth(1200, 1200, null) - 2 * 16), ); + // No rail or sidebar: the content starts at the left edge. + expect(find.byType(NavigationRail), findsNothing); + expect(tester.getRect(find.byKey(const Key('content'))).left, 0); + // Beside the bar, at the bar's height, the content takes the tap. + await tester.tapAt(Offset(rect.right + 40, rect.center.dy)); + await tester.pump(); + expect(taps, 1); + // On the bar, the tab takes it. + await tester.tap(find.byKey(const ValueKey('shell.destination.chat'))); + await tester.pumpAndSettle(); + expect(find.text('Chat — Not implemented'), findsOneWidget); + }); + + testWidgets('content learns the bar height as bottom padding', ( + tester, + ) async { + for (final size in const [Size(390, 844), Size(1200, 800)]) { + await setSize(tester, size); + await tester.pumpWidget(shell()); + await tester.pump(); + final rect = tester.getRect(pill()); + // The content's bottom padding clears the whole bar and its margin. + expect( + contentBottomPadding, + moreOrLessEquals(size.height - rect.top, epsilon: 0.5), + reason: '$size', + ); + } + }); + + testWidgets('resizing moves the bar without remounting content', ( + tester, + ) async { + taps = 0; + await setSize(tester, const Size(390, 844)); + await tester.pumpWidget(shell()); + await tester.tap(find.byKey(const Key('content'))); + await tester.pump(); + expect(find.text('taps 1'), findsOneWidget); + final state = tester.state(find.byType(StatefulBuilder)); + + tester.view.physicalSize = const Size(1200, 800); + await tester.pump(); + expect( + tester.getRect(pill()).left, + moreOrLessEquals(kFloatingBarMargin, epsilon: 0.5), + ); + expect(tester.getRect(pill()).width, lessThan(1200 * 0.6)); + expect(tester.state(find.byType(StatefulBuilder)), same(state)); + + tester.view.physicalSize = const Size(390, 844); + await tester.pump(); + await expectLabeledTargets(tester, tester.getRect(pill())); + expect(tester.getRect(pill()).width, lessThanOrEqualTo(390 - 2 * 16)); + expect(tester.getRect(pill()).right, 390 - 16); + expect(tester.state(find.byType(StatefulBuilder)), same(state)); + }); + + testWidgets('the bar respects the bottom safe area', (tester) async { + await setSize(tester, const Size(390, 844)); + tester.view.padding = const FakeViewPadding(bottom: 34); + await tester.pumpWidget(shell()); + expect(tester.getRect(pill()).bottom, 844 - 34); + }); + + testWidgets('the selected tab is marked selected for assistive ' + 'technology', (tester) async { + final semantics = tester.ensureSemantics(); + await setSize(tester, const Size(1200, 800)); + await tester.pumpWidget(shell()); + await tester.tap(find.byKey(const ValueKey('shell.destination.runs'))); + await tester.pumpAndSettle(); + final runs = tester.getSemantics( + find.byKey(const ValueKey('shell.destination.runs')), + ); + expect(runs, isSemantics(isSelected: true)); + // Captions do not duplicate the tab name for assistive technology. + expect(runs.label, startsWith('Runs')); + expect( + tester.getSemantics(find.byKey(const ValueKey('shell.destination.chat'))), + isNot(isSemantics(isSelected: true)), + ); + semantics.dispose(); }); testWidgets('phone at 320 with 2x text does not overflow', (tester) async { - for (final cupertino in [false, true]) { - await setSize(tester, const Size(320, 568)); - tester.platformDispatcher.textScaleFactorTestValue = 2; - addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue); - await tester.pumpWidget(shell(cupertino: cupertino)); - await tester.pumpAndSettle(); - expect(tester.takeException(), isNull); - // Large captions wrap rather than shrinking the tap targets. - final bounds = tester.getRect(pill()); - await expectLabeledTargets(tester, bounds); - expect(bounds.width, lessThanOrEqualTo(320 - 2 * 16)); - for (final destination in shellTabDestinations) { - final caption = find.descendant( - of: find.byType(FloatingDestinationBar), - matching: find.text(destinationDetails(destination).label), - ); - final text = tester.widget(caption); - final size = text.style!.fontSize!; - expect(tester.getSize(caption).height, greaterThanOrEqualTo(size * 2)); - } - expect( - bounds.height, - greaterThan( - FloatingDestinationBar.selectedButtonSize(cupertino: cupertino), - ), + await setSize(tester, const Size(320, 568)); + tester.platformDispatcher.textScaleFactorTestValue = 2; + addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue); + await tester.pumpWidget(shell()); + await tester.pumpAndSettle(); + expect(tester.takeException(), isNull); + // Large captions wrap rather than shrinking the tap targets. + final bounds = tester.getRect(pill()); + await expectLabeledTargets(tester, bounds); + expect(bounds.width, lessThanOrEqualTo(320 - 2 * 16)); + for (final destination in shellTabDestinations) { + final caption = find.descendant( + of: find.byType(FloatingDestinationBar), + matching: find.text(destinationDetails(destination).label), ); - expect(tester.getRect(pill()).right, 320 - 16); + final text = tester.widget(caption); + final size = text.style!.fontSize!; + expect(tester.getSize(caption).height, greaterThanOrEqualTo(size * 2)); } + expect( + bounds.height, + greaterThan(FloatingDestinationBar.selectedButtonSize(cupertino: false)), + ); + expect(tester.getRect(pill()).right, 320 - 16); }); } diff --git a/app/test/shell/list_pane_resize_test.dart b/app/test/shell/list_pane_resize_test.dart index 60e2d1c3..1e961bfb 100644 --- a/app/test/shell/list_pane_resize_test.dart +++ b/app/test/shell/list_pane_resize_test.dart @@ -1,6 +1,5 @@ import 'dart:ui' show SemanticsAction; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -27,12 +26,10 @@ void main() { ); Widget shell({ - required bool cupertino, required ListPaneWidthStore store, AppDestination destination = AppDestination.runs, }) { final app = AdaptiveShell( - cupertino: cupertino, destination: destination, listPaneWidthStore: store, destinationBodies: { @@ -40,7 +37,7 @@ void main() { AppDestination.chat: (_) => panes('chat'), }, ); - return cupertino ? CupertinoApp(home: app) : MaterialApp(home: app); + return MaterialApp(home: app); } Future settle(WidgetTester tester) async { @@ -66,172 +63,158 @@ void main() { .width; final divider = find.byKey(const ValueKey('list-detail-divider')); - for (final cupertino in [false, true]) { - final host = cupertino ? 'Cupertino' : 'Material'; + testWidgets('dragging resizes the list live, the shell bar ' + 'follows, and the width clamps', (tester) async { + await setSize(tester, const Size(1200, 800)); + final store = MemoryListPaneWidthStore(); + await tester.pumpWidget(shell(store: store)); + await settle(tester); + expect(listWidth(tester), kListPaneMaxWidth); + expect(shellBarWidth(tester), kListPaneMaxWidth); - testWidgets('$host: dragging resizes the list live, the shell bar ' - 'follows, and the width clamps', (tester) async { - await setSize(tester, const Size(1200, 800)); - final store = MemoryListPaneWidthStore(); - await tester.pumpWidget(shell(cupertino: cupertino, store: store)); - await settle(tester); - expect(listWidth(tester), kListPaneMaxWidth); - expect(shellBarWidth(tester), kListPaneMaxWidth); + final gesture = await tester.startGesture(tester.getCenter(divider)); + await gesture.moveBy(const Offset(-50, 0)); + await gesture.moveBy(const Offset(-50, 0)); + await tester.pump(); + // Live, before the drag ends; nothing saved yet. + expect(listWidth(tester), closeTo(340, 0.5)); + expect(shellBarWidth(tester), closeTo(340, 0.5)); + expect(bodyWidth(tester), closeTo(1200 - 1 - 340, 0.5)); + expect(store.values, isEmpty); + await gesture.up(); + await tester.pump(); + expect(store.values['runs'], closeTo(340, 0.5)); - final gesture = await tester.startGesture(tester.getCenter(divider)); - await gesture.moveBy(const Offset(-50, 0)); - await gesture.moveBy(const Offset(-50, 0)); - await tester.pump(); - // Live, before the drag ends; nothing saved yet. - expect(listWidth(tester), closeTo(340, 0.5)); - expect(shellBarWidth(tester), closeTo(340, 0.5)); - expect(bodyWidth(tester), closeTo(1200 - 1 - 340, 0.5)); - expect(store.values, isEmpty); - await gesture.up(); - await tester.pump(); - expect(store.values['runs'], closeTo(340, 0.5)); + // Never narrower than the minimum... + await tester.drag(divider, const Offset(-400, 0)); + await settle(tester); + expect(listWidth(tester), kListPaneMinWidth); + // ...nor wider than leaves the open item half the window. + await tester.drag(divider, const Offset(900, 0)); + await settle(tester); + expect(listWidth(tester), closeTo(1200 - 1 - 600, 0.5)); + expect(shellBarWidth(tester), closeTo(599, 0.5)); + expect(store.values['runs'], closeTo(599, 0.5)); + }); - // Never narrower than the minimum... - await tester.drag(divider, const Offset(-400, 0)); - await settle(tester); - expect(listWidth(tester), kListPaneMinWidth); - // ...nor wider than leaves the open item half the window. - await tester.drag(divider, const Offset(900, 0)); - await settle(tester); - expect(listWidth(tester), closeTo(1200 - 1 - 600, 0.5)); - expect(shellBarWidth(tester), closeTo(599, 0.5)); - expect(store.values['runs'], closeTo(599, 0.5)); - }); + testWidgets('a double tap returns to the default policy', (tester) async { + await setSize(tester, const Size(1200, 800)); + final store = MemoryListPaneWidthStore({'runs': 300}); + await tester.pumpWidget(shell(store: store)); + await settle(tester); + expect(listWidth(tester), 300); - testWidgets('$host: a double tap returns to the default policy', ( - tester, - ) async { - await setSize(tester, const Size(1200, 800)); - final store = MemoryListPaneWidthStore({'runs': 300}); - await tester.pumpWidget(shell(cupertino: cupertino, store: store)); - await settle(tester); - expect(listWidth(tester), 300); + await tester.tap(divider); + await tester.pump(const Duration(milliseconds: 50)); + await tester.tap(divider); + await settle(tester); + expect(listWidth(tester), kListPaneMaxWidth); + expect(shellBarWidth(tester), kListPaneMaxWidth); + expect(store.values, isEmpty); + }); - await tester.tap(divider); - await tester.pump(const Duration(milliseconds: 50)); - await tester.tap(divider); - await settle(tester); - expect(listWidth(tester), kListPaneMaxWidth); - expect(shellBarWidth(tester), kListPaneMaxWidth); - expect(store.values, isEmpty); - }); + testWidgets('widths are kept per destination and restored', (tester) async { + await setSize(tester, const Size(1200, 800)); + final store = MemoryListPaneWidthStore({'runs': 300, 'chat': 500}); + await tester.pumpWidget(shell(store: store)); + await settle(tester); + expect(listWidth(tester), 300); + expect(shellBarWidth(tester), 300); - testWidgets('$host: widths are kept per destination and restored', ( - tester, - ) async { - await setSize(tester, const Size(1200, 800)); - final store = MemoryListPaneWidthStore({'runs': 300, 'chat': 500}); - await tester.pumpWidget(shell(cupertino: cupertino, store: store)); - await settle(tester); - expect(listWidth(tester), 300); - expect(shellBarWidth(tester), 300); + await tester.pumpWidget( + shell(store: store, destination: AppDestination.chat), + ); + await settle(tester); + final chatList = find.byKey(const ValueKey('list-detail-list')).last; + expect(tester.getSize(chatList).width, 500); + expect(shellBarWidth(tester), 500); - await tester.pumpWidget( - shell( - cupertino: cupertino, - store: store, - destination: AppDestination.chat, - ), - ); - await settle(tester); - final chatList = find.byKey(const ValueKey('list-detail-list')).last; - expect(tester.getSize(chatList).width, 500); - expect(shellBarWidth(tester), 500); + // A destination nobody resized keeps the default policy. + final fresh = MemoryListPaneWidthStore({'chat': 500}); + await tester.pumpWidget(const SizedBox()); + await tester.pumpWidget(shell(store: fresh)); + await settle(tester); + expect(listWidth(tester), kListPaneMaxWidth); + }); - // A destination nobody resized keeps the default policy. - final fresh = MemoryListPaneWidthStore({'chat': 500}); - await tester.pumpWidget(const SizedBox()); - await tester.pumpWidget(shell(cupertino: cupertino, store: fresh)); - await settle(tester); - expect(listWidth(tester), kListPaneMaxWidth); - }); + testWidgets('a small window clamps the saved width without ' + 'overwriting it', (tester) async { + await setSize(tester, const Size(1000, 800)); + final store = MemoryListPaneWidthStore({'runs': 600}); + await tester.pumpWidget(shell(store: store)); + await settle(tester); + expect(listWidth(tester), closeTo(1000 - 1 - 500, 0.5)); + expect(shellBarWidth(tester), closeTo(499, 0.5)); + expect(store.values['runs'], 600); - testWidgets('$host: a small window clamps the saved width without ' - 'overwriting it', (tester) async { - await setSize(tester, const Size(1000, 800)); - final store = MemoryListPaneWidthStore({'runs': 600}); - await tester.pumpWidget(shell(cupertino: cupertino, store: store)); - await settle(tester); - expect(listWidth(tester), closeTo(1000 - 1 - 500, 0.5)); - expect(shellBarWidth(tester), closeTo(499, 0.5)); - expect(store.values['runs'], 600); + await setSize(tester, const Size(1600, 800)); + await settle(tester); + expect(listWidth(tester), 600); + expect(shellBarWidth(tester), 600); + }); - await setSize(tester, const Size(1600, 800)); - await settle(tester); - expect(listWidth(tester), 600); - expect(shellBarWidth(tester), 600); - }); + testWidgets('arrow keys move the divider and it reads as a ' + 'slider', (tester) async { + await setSize(tester, const Size(1200, 800)); + final store = MemoryListPaneWidthStore(); + final semantics = tester.ensureSemantics(); + await tester.pumpWidget(shell(store: store)); + await settle(tester); + Focus.of(tester.element(divider)).requestFocus(); + await tester.pump(); - testWidgets('$host: arrow keys move the divider and it reads as a ' - 'slider', (tester) async { - await setSize(tester, const Size(1200, 800)); - final store = MemoryListPaneWidthStore(); - final semantics = tester.ensureSemantics(); - await tester.pumpWidget(shell(cupertino: cupertino, store: store)); - await settle(tester); - Focus.of(tester.element(divider)).requestFocus(); - await tester.pump(); + await tester.sendKeyEvent(LogicalKeyboardKey.arrowLeft); + await settle(tester); + expect(listWidth(tester), kListPaneMaxWidth - kListPaneDividerKeyStep); + expect(store.values['runs'], kListPaneMaxWidth - kListPaneDividerKeyStep); + await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight); + await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight); + await settle(tester); + expect(listWidth(tester), kListPaneMaxWidth + kListPaneDividerKeyStep); - await tester.sendKeyEvent(LogicalKeyboardKey.arrowLeft); - await settle(tester); - expect(listWidth(tester), kListPaneMaxWidth - kListPaneDividerKeyStep); - expect(store.values['runs'], kListPaneMaxWidth - kListPaneDividerKeyStep); - await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight); - await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight); - await settle(tester); - expect(listWidth(tester), kListPaneMaxWidth + kListPaneDividerKeyStep); + expect( + tester.getSemantics(divider), + matchesSemantics( + label: 'List width', + hint: 'Drag, or use the arrow keys, to resize the list', + value: '456 pixels', + increasedValue: '472 pixels', + decreasedValue: '440 pixels', + isSlider: true, + isFocusable: true, + isFocused: true, + hasIncreaseAction: true, + hasDecreaseAction: true, + hasFocusAction: true, + ), + ); + tester.semantics.performAction( + find.semantics.byLabel('List width'), + SemanticsAction.decrease, + ); + await settle(tester); + expect(listWidth(tester), kListPaneMaxWidth); + semantics.dispose(); + }); - expect( - tester.getSemantics(divider), - matchesSemantics( - label: 'List width', - hint: 'Drag, or use the arrow keys, to resize the list', - value: '456 pixels', - increasedValue: '472 pixels', - decreasedValue: '440 pixels', - isSlider: true, - isFocusable: true, - isFocused: true, - hasIncreaseAction: true, - hasDecreaseAction: true, - hasFocusAction: true, - ), - ); - tester.semantics.performAction( - find.semantics.byLabel('List width'), - SemanticsAction.decrease, - ); - await settle(tester); - expect(listWidth(tester), kListPaneMaxWidth); - semantics.dispose(); - }); + testWidgets('the native resize grip is visible at rest and gains ' + 'emphasis on focus', (tester) async { + await setSize(tester, const Size(1200, 800)); + await tester.pumpWidget(shell(store: MemoryListPaneWidthStore())); + await settle(tester); - testWidgets('$host: the native resize grip is visible at rest and gains ' - 'emphasis on focus', (tester) async { - await setSize(tester, const Size(1200, 800)); - await tester.pumpWidget( - shell(cupertino: cupertino, store: MemoryListPaneWidthStore()), - ); - await settle(tester); + AdaptiveResizeGrip grip() => tester.widget( + find.descendant( + of: find.byType(ListPaneDivider), + matching: find.byType(AdaptiveResizeGrip), + ), + ); + expect(grip().emphasized, isFalse); - AdaptiveResizeGrip grip() => tester.widget( - find.descendant( - of: find.byType(ListPaneDivider), - matching: find.byType(AdaptiveResizeGrip), - ), - ); - expect(grip().emphasized, isFalse); - - Focus.of(tester.element(divider)).requestFocus(); - await tester.pump(); - expect(grip().emphasized, isTrue); - }); - } + Focus.of(tester.element(divider)).requestFocus(); + await tester.pump(); + expect(grip().emphasized, isTrue); + }); test('bounds: list at least 240, open item at least half the window', () { expect(listPaneWidthBounds(1200, 1200), (min: 240.0, max: 599.0)); diff --git a/app/test/shell/pane_bar_row_test.dart b/app/test/shell/pane_bar_row_test.dart index 149d7a66..22f856ff 100644 --- a/app/test/shell/pane_bar_row_test.dart +++ b/app/test/shell/pane_bar_row_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/shell/adaptive_shell.dart'; @@ -28,7 +27,7 @@ void main() { /// An open item: its title published to the pane's bar, its own tabs /// floating where the pane says, and a list padded clear of both bars. - Widget item({bool cupertino = false}) => ShellBar( + Widget item() => ShellBar( title: 'Open item', subtitle: 'Its context', actions: const [Icon(Icons.more_vert, semanticLabel: 'More')], @@ -40,7 +39,7 @@ void main() { bar: KeyedSubtree( key: const Key('item-tabs'), child: FloatingDestinationBar( - cupertino: cupertino, + cupertino: false, edge: edge, currentIndex: 0, onTap: (_) {}, @@ -68,9 +67,8 @@ void main() { ), ); - Widget shell({bool cupertino = false, int attention = 0}) { + Widget shell({int attention = 0}) { final app = AdaptiveShell( - cupertino: cupertino, attentionCount: attention, destinationBodies: { AppDestination.runs: (_) => ShellBadge( @@ -89,14 +87,14 @@ void main() { detail: DetailPane( destination: AppDestination.runs, implyBack: false, - builder: (_) => item(cupertino: cupertino), + builder: (_) => item(), ), ), ), }, destination: AppDestination.runs, ); - return cupertino ? CupertinoApp(home: app) : MaterialApp(home: app); + return MaterialApp(home: app); } Finder shellBar() => find.byWidgetPredicate( @@ -107,100 +105,88 @@ void main() { matching: find.byType(SegmentedBar), ); - for (final cupertino in [false, true]) { - final host = cupertino ? 'Cupertino' : 'Material'; + testWidgets('1200: the shell bar covers the list pane and the ' + 'item\'s bar shares its row', (tester) async { + await setSize(tester, const Size(1200, 800)); + await tester.pumpWidget(shell()); + await tester.pump(); + await tester.pump(); - testWidgets('$host 1200: the shell bar covers the list pane and the ' - 'item\'s bar shares its row', (tester) async { - await setSize(tester, const Size(1200, 800)); - await tester.pumpWidget(shell(cupertino: cupertino)); - await tester.pump(); - await tester.pump(); - - final list = tester.getRect( - find.byKey(const ValueKey('list-detail-list')), - ); - final body = tester.getRect( - find.byKey(const ValueKey('list-detail-body')), - ); - final shellPills = find.descendant( - of: shellBar(), - matching: find.byType(GlassPill), - ); - for (final element in shellPills.evaluate()) { - expect( - rectOf(element).right, - lessThanOrEqualTo(list.right), - reason: 'no shell piece sits over the open item', - ); - } - // Both titles on the same top row. - final shellTitle = tester.getRect( - find.descendant(of: shellBar(), matching: find.text('Runs')), - ); - final paneTitle = tester.getRect(find.text('Open item')); - expect(paneTitle.left, greaterThanOrEqualTo(body.left)); - final paneTop = tester.getRect( - find.descendant(of: paneBar(), matching: find.byType(GlassPill)).first, - ); - final shellTop = tester.getRect(shellPills.first); - expect(paneTop.top, shellTop.top); - expect(paneTitle.top, lessThan(shellTitle.bottom)); - // The title pill carries the item's context too. - expect(find.text('Its context'), findsOneWidget); - }); - - testWidgets('$host 1200: the item\'s tabs float at the bottom of its ' - 'pane, the shell\'s tab bar under the list', (tester) async { - await setSize(tester, const Size(1200, 800)); - await tester.pumpWidget(shell(cupertino: cupertino)); - await tester.pump(); - await tester.pump(); - - final shellTabs = tester.getRect( - find - .ancestor( - of: find.byKey(const ValueKey('shell.destination.runs')).first, - matching: find.byKey(FloatingDestinationBar.rowKey), - ) - .first, - ); - final itemTabs = tester.getRect( - find.descendant( - of: find.byKey(const Key('item-tabs')), - matching: find.byKey(FloatingDestinationBar.rowKey), - ), - ); - final body = tester.getRect( - find.byKey(const ValueKey('list-detail-body')), - ); - // The shell's tabs sit at the bottom of the list pane; the item's at - // the bottom right of the detail pane, never on them. - final list = tester.getRect( - find.byKey(const ValueKey('list-detail-list')), - ); - expect(shellTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); - expect(shellTabs.right, lessThanOrEqualTo(list.right)); - expect(itemTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); - expect(itemTabs.right, closeTo(1200 - kFloatingBarMargin, 0.5)); - expect(itemTabs.left, greaterThanOrEqualTo(body.left)); - expect(itemTabs.overlaps(shellTabs), isFalse); - // The item's list starts below its bar and clears its tabs at rest. - final paneBarPill = tester.getRect( - find.descendant(of: paneBar(), matching: find.byType(GlassPill)).first, - ); + final list = tester.getRect(find.byKey(const ValueKey('list-detail-list'))); + final body = tester.getRect(find.byKey(const ValueKey('list-detail-body'))); + final shellPills = find.descendant( + of: shellBar(), + matching: find.byType(GlassPill), + ); + for (final element in shellPills.evaluate()) { expect( - tester.getTopLeft(find.text('item row 0')).dy, - greaterThanOrEqualTo(paneBarPill.bottom), + rectOf(element).right, + lessThanOrEqualTo(list.right), + reason: 'no shell piece sits over the open item', ); - expect( - MediaQuery.paddingOf( - tester.element(find.byKey(const Key('item-list'))), - ).bottom, - greaterThanOrEqualTo(800 - itemTabs.top), - ); - }); - } + } + // Both titles on the same top row. + final shellTitle = tester.getRect( + find.descendant(of: shellBar(), matching: find.text('Runs')), + ); + final paneTitle = tester.getRect(find.text('Open item')); + expect(paneTitle.left, greaterThanOrEqualTo(body.left)); + final paneTop = tester.getRect( + find.descendant(of: paneBar(), matching: find.byType(GlassPill)).first, + ); + final shellTop = tester.getRect(shellPills.first); + expect(paneTop.top, shellTop.top); + expect(paneTitle.top, lessThan(shellTitle.bottom)); + // The title pill carries the item's context too. + expect(find.text('Its context'), findsOneWidget); + }); + + testWidgets('1200: the item\'s tabs float at the bottom of its ' + 'pane, the shell\'s tab bar under the list', (tester) async { + await setSize(tester, const Size(1200, 800)); + await tester.pumpWidget(shell()); + await tester.pump(); + await tester.pump(); + + final shellTabs = tester.getRect( + find + .ancestor( + of: find.byKey(const ValueKey('shell.destination.runs')).first, + matching: find.byKey(FloatingDestinationBar.rowKey), + ) + .first, + ); + final itemTabs = tester.getRect( + find.descendant( + of: find.byKey(const Key('item-tabs')), + matching: find.byKey(FloatingDestinationBar.rowKey), + ), + ); + final body = tester.getRect(find.byKey(const ValueKey('list-detail-body'))); + // The shell's tabs sit at the bottom of the list pane; the item's at + // the bottom right of the detail pane, never on them. + final list = tester.getRect(find.byKey(const ValueKey('list-detail-list'))); + expect(shellTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); + expect(shellTabs.right, lessThanOrEqualTo(list.right)); + expect(itemTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); + expect(itemTabs.right, closeTo(1200 - kFloatingBarMargin, 0.5)); + expect(itemTabs.left, greaterThanOrEqualTo(body.left)); + expect(itemTabs.overlaps(shellTabs), isFalse); + // The item's list starts below its bar and clears its tabs at rest. + final paneBarPill = tester.getRect( + find.descendant(of: paneBar(), matching: find.byType(GlassPill)).first, + ); + expect( + tester.getTopLeft(find.text('item row 0')).dy, + greaterThanOrEqualTo(paneBarPill.bottom), + ); + expect( + MediaQuery.paddingOf( + tester.element(find.byKey(const Key('item-list'))), + ).bottom, + greaterThanOrEqualTo(800 - itemTabs.top), + ); + }); testWidgets('390: an open item is its own page with its tabs at the bottom', ( tester, diff --git a/app/test/shell/shell_bar_test.dart b/app/test/shell/shell_bar_test.dart index 262acbb4..542cf384 100644 --- a/app/test/shell/shell_bar_test.dart +++ b/app/test/shell/shell_bar_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/shell/adaptive_shell.dart'; @@ -6,9 +5,8 @@ import 'package:pipelines_app/shell/destination.dart'; import 'package:pipelines_app/shell/shell_bar.dart'; import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart'; -Widget _app({required bool cupertino, required bool open, VoidCallback? back}) { +Widget _app({required bool open, VoidCallback? back}) { final shell = AdaptiveShell( - cupertino: cupertino, destination: AppDestination.runs, destinationBodies: { AppDestination.runs: (_) => open @@ -21,102 +19,97 @@ Widget _app({required bool cupertino, required bool open, VoidCallback? back}) { : const Text('list'), }, ); - return cupertino ? CupertinoApp(home: shell) : MaterialApp(home: shell); + return MaterialApp(home: shell); } void main() { - for (final cupertino in [false, true]) { - final host = cupertino ? 'cupertino' : 'material'; - testWidgets('$host: an open screen takes over the bar and gives it back', ( - tester, - ) async { - tester.view.physicalSize = const Size(390, 844); - tester.view.devicePixelRatio = 1; - addTearDown(tester.view.reset); - var backs = 0; - await tester.pumpWidget( - _app(cupertino: cupertino, open: true, back: () => backs++), - ); - await tester.pump(); + testWidgets('an open screen takes over the bar and gives it back', ( + tester, + ) async { + tester.view.physicalSize = const Size(390, 844); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + var backs = 0; + await tester.pumpWidget(_app(open: true, back: () => backs++)); + await tester.pump(); - expect(find.text('Run 7'), findsOneWidget); - expect(find.byKey(const Key('run-more')), findsOneWidget); - await tester.tap(find.byKey(const ValueKey('shell.back'))); - expect(backs, 1); + expect(find.text('Run 7'), findsOneWidget); + expect(find.byKey(const Key('run-more')), findsOneWidget); + await tester.tap(find.byKey(const ValueKey('shell.back'))); + expect(backs, 1); - await tester.pumpWidget(_app(cupertino: cupertino, open: false)); - await tester.pump(); - expect(find.text('Run 7'), findsNothing); - expect(find.byKey(const ValueKey('shell.back')), findsNothing); - expect(find.byKey(const Key('run-more')), findsNothing); - }); + await tester.pumpWidget(_app(open: false)); + await tester.pump(); + expect(find.text('Run 7'), findsNothing); + expect(find.byKey(const ValueKey('shell.back')), findsNothing); + expect(find.byKey(const Key('run-more')), findsNothing); + }); - testWidgets('$host: Search is the fourth tab; Settings is not a tab', ( - tester, - ) async { - tester.view.physicalSize = const Size(390, 844); - tester.view.devicePixelRatio = 1; - addTearDown(tester.view.reset); - await tester.pumpWidget(_app(cupertino: cupertino, open: false)); - expect(AppDestination.values, hasLength(5)); - expect(shellTabDestinations, [ - AppDestination.pipelines, - AppDestination.runs, - AppDestination.chat, - AppDestination.search, - ]); - expect( - find.byKey(const ValueKey('shell.destination.search')), - findsOneWidget, - ); - expect( - find.byKey(const ValueKey('shell.destination.settings')), - findsNothing, - ); - expect(find.byKey(const ValueKey('shell.search')), findsNothing); - expect(find.byType(FloatingDestinationBar), findsOneWidget); - }); + testWidgets('Search is the fourth tab; Settings is not a tab', ( + tester, + ) async { + tester.view.physicalSize = const Size(390, 844); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + await tester.pumpWidget(_app(open: false)); + expect(AppDestination.values, hasLength(5)); + expect(shellTabDestinations, [ + AppDestination.pipelines, + AppDestination.runs, + AppDestination.chat, + AppDestination.search, + ]); + expect( + find.byKey(const ValueKey('shell.destination.search')), + findsOneWidget, + ); + expect( + find.byKey(const ValueKey('shell.destination.settings')), + findsNothing, + ); + expect(find.byKey(const ValueKey('shell.search')), findsNothing); + expect(find.byType(FloatingDestinationBar), findsOneWidget); + }); - testWidgets('$host: floating tabs stay inset and select destinations', ( - tester, - ) async { - tester.view.physicalSize = const Size(390, 844); - tester.view.devicePixelRatio = 1; - addTearDown(tester.view.reset); - await tester.pumpWidget(_app(cupertino: cupertino, open: false)); + testWidgets('floating tabs stay inset and select destinations', ( + tester, + ) async { + tester.view.physicalSize = const Size(390, 844); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + await tester.pumpWidget(_app(open: false)); - final destinationPill = find.descendant( + final destinationPill = find.descendant( + of: find.byType(FloatingDestinationBar), + matching: find.byKey(FloatingDestinationBar.rowKey), + ); + // Visible captions determine the width while full-size targets stay inset. + final rect = tester.getRect(destinationPill); + expect(rect.width, lessThanOrEqualTo(390 - 2 * 16)); + expect( + tester + .widget(find.byType(FloatingDestinationBar)) + .showLabels, + isTrue, + ); + for (final destination in shellTabDestinations) { + final caption = find.descendant( of: find.byType(FloatingDestinationBar), - matching: find.byKey(FloatingDestinationBar.rowKey), + matching: find.text(destinationDetails(destination).label), ); - // Visible captions determine the width while full-size targets stay inset. - final rect = tester.getRect(destinationPill); - expect(rect.width, lessThanOrEqualTo(390 - 2 * 16)); - expect( - tester - .widget(find.byType(FloatingDestinationBar)) - .showLabels, - isTrue, + expect(caption, findsOneWidget); + expect(rect.contains(tester.getRect(caption).center), isTrue); + final target = tester.getSize( + find.byKey(ValueKey('shell.destination.${destination.name}')), ); - for (final destination in shellTabDestinations) { - final caption = find.descendant( - of: find.byType(FloatingDestinationBar), - matching: find.text(destinationDetails(destination).label), - ); - expect(caption, findsOneWidget); - expect(rect.contains(tester.getRect(caption).center), isTrue); - final target = tester.getSize( - find.byKey(ValueKey('shell.destination.${destination.name}')), - ); - expect(target.width, greaterThanOrEqualTo(44)); - expect(target.height, greaterThanOrEqualTo(44)); - } - expect(tester.getRect(destinationPill).right, 390 - 16); - await tester.tap(find.byKey(const ValueKey('shell.destination.chat'))); - await tester.pump(); - expect(find.text('Chat — Not implemented'), findsOneWidget); - }); - } + expect(target.width, greaterThanOrEqualTo(44)); + expect(target.height, greaterThanOrEqualTo(44)); + } + expect(tester.getRect(destinationPill).right, 390 - 16); + await tester.tap(find.byKey(const ValueKey('shell.destination.chat'))); + await tester.pump(); + expect(find.text('Chat — Not implemented'), findsOneWidget); + }); testWidgets('tabs show the running and unread counts their screens publish', ( tester, diff --git a/app/test/shell/shell_destination_menu_test.dart b/app/test/shell/shell_destination_menu_test.dart index e9da9d0a..b9a3dd49 100644 --- a/app/test/shell/shell_destination_menu_test.dart +++ b/app/test/shell/shell_destination_menu_test.dart @@ -1,34 +1,25 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/shell/shell_destination_menu.dart'; import 'package:pipelines_app/shell/destination.dart'; void main() { - for (final cupertino in [false, true]) { - testWidgets('compact menu exposes all named destinations ($cupertino)', ( - tester, - ) async { - AppDestination? selected; - final menu = ShellDestinationMenu( - cupertino: cupertino, - current: AppDestination.chat, - onSelected: (value) => selected = value, - ); - await tester.pumpWidget( - cupertino - ? CupertinoApp(home: CupertinoPageScaffold(child: menu)) - : MaterialApp(home: Scaffold(body: menu)), - ); - await tester.tap(find.text('Menu')); - await tester.pumpAndSettle(); - for (final name in ['Pipelines', 'Runs', 'Chat', 'Search', 'Settings']) { - expect(find.text(name), findsOneWidget); - } - await tester.tap(find.text('Runs')); - await tester.pumpAndSettle(); - expect(selected, AppDestination.runs); - expect(tester.takeException(), isNull); - }); - } + testWidgets('compact menu exposes all named destinations', (tester) async { + AppDestination? selected; + final menu = ShellDestinationMenu( + cupertino: false, + current: AppDestination.chat, + onSelected: (value) => selected = value, + ); + await tester.pumpWidget(MaterialApp(home: Scaffold(body: menu))); + await tester.tap(find.text('Menu')); + await tester.pumpAndSettle(); + for (final name in ['Pipelines', 'Runs', 'Chat', 'Search', 'Settings']) { + expect(find.text(name), findsOneWidget); + } + await tester.tap(find.text('Runs')); + await tester.pumpAndSettle(); + expect(selected, AppDestination.runs); + expect(tester.takeException(), isNull); + }); } diff --git a/app/test/shell/split_destination_bar_test.dart b/app/test/shell/split_destination_bar_test.dart index 4f8f0374..538da54a 100644 --- a/app/test/shell/split_destination_bar_test.dart +++ b/app/test/shell/split_destination_bar_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/shell/adaptive_shell.dart'; @@ -46,11 +45,11 @@ void main() { ); /// A detail with its own floating tabs over a list, like run detail. - Widget tabsDetail(bool cupertino) => FloatingBarOverlay( + Widget tabsDetail() => FloatingBarOverlay( bar: KeyedSubtree( key: const Key('detail-tabs'), child: FloatingDestinationBar( - cupertino: cupertino, + cupertino: false, currentIndex: 0, onTap: (_) {}, items: const [ @@ -72,7 +71,6 @@ void main() { ); Widget shell({ - required bool cupertino, bool split = true, bool tabs = false, double textScale = 1, @@ -80,7 +78,6 @@ void main() { AppDestination destination = AppDestination.chat, }) { final app = AdaptiveShell( - cupertino: cupertino, listPaneWidthStore: store ?? MemoryListPaneWidthStore(), destination: destination, destinationBodies: { @@ -88,7 +85,7 @@ void main() { AppDestination.chat: (_) => split ? ListDetailPanes( list: listBody(), - detail: tabs ? tabsDetail(cupertino) : composerDetail(), + detail: tabs ? tabsDetail() : composerDetail(), ) : listBody(), }, @@ -97,7 +94,7 @@ void main() { data: MediaQueryData.fromView( WidgetsBinding.instance.platformDispatcher.views.first, ).copyWith(textScaler: TextScaler.linear(textScale)), - child: cupertino ? CupertinoApp(home: app) : MaterialApp(home: app), + child: MaterialApp(home: app), ); } @@ -110,204 +107,191 @@ void main() { .first, ); - for (final cupertino in [false, true]) { - final host = cupertino ? 'Cupertino' : 'Material'; + for (final width in [1200.0, 1600.0]) { + testWidgets('$width split: the destination bar sits under the ' + 'list and the composer at the detail\'s bottom edge', (tester) async { + await setSize(tester, Size(width, 800)); + await tester.pumpWidget(shell()); + await tester.pump(); + await tester.pump(); - for (final width in [1200.0, 1600.0]) { - testWidgets('$host $width split: the destination bar sits under the ' - 'list and the composer at the detail\'s bottom edge', (tester) async { - await setSize(tester, Size(width, 800)); - await tester.pumpWidget(shell(cupertino: cupertino)); - await tester.pump(); - await tester.pump(); + final list = tester.getRect( + find.byKey(const ValueKey('list-detail-list')), + ); + final body = tester.getRect( + find.byKey(const ValueKey('list-detail-body')), + ); + final pill = destinationPill(tester); + // Leading at the bottom of the list pane, never over the detail. + expect(pill.left, closeTo(list.left + kFloatingBarMargin, 0.5)); + expect(pill.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); + expect(pill.right, lessThanOrEqualTo(list.right)); + expect(pill.overlaps(body), isFalse, reason: 'never over the detail'); + expect( + pill.width, + lessThanOrEqualTo(list.width - 2 * kFloatingBarMargin), + ); + for (final destination in shellTabDestinations) { + final caption = find.byKey( + ValueKey( + 'destination-label-${destinationDetails(destination).label}', + ), + ); + expect(caption, findsOneWidget); + expect(pill.contains(tester.getRect(caption).center), isTrue); + } - final list = tester.getRect( - find.byKey(const ValueKey('list-detail-list')), - ); - final body = tester.getRect( - find.byKey(const ValueKey('list-detail-body')), - ); - final pill = destinationPill(tester); - // Leading at the bottom of the list pane, never over the detail. - expect(pill.left, closeTo(list.left + kFloatingBarMargin, 0.5)); - expect(pill.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); - expect(pill.right, lessThanOrEqualTo(list.right)); - expect(pill.overlaps(body), isFalse, reason: 'never over the detail'); + // The composer reaches the detail's bottom edge: nothing is reserved + // there for the shell's bar any more. + final composer = tester.getRect(find.byKey(const Key('composer'))); + expect(composer.left, body.left); + expect(composer.bottom, closeTo(800, 0.5)); + expect(composer.overlaps(pill), isFalse); + + // The list clears the bar, so its last rows scroll out from under it. + final listContext = tester.element(find.byKey(const Key('list'))); + expect( + MediaQuery.paddingOf(listContext).bottom, + greaterThanOrEqualTo(800 - pill.top), + ); + await tester.drag(find.byKey(const Key('list')), const Offset(0, -4000)); + await tester.pumpAndSettle(); + final last = tester.getRect(find.text('row 39')); + expect(last.bottom, lessThanOrEqualTo(pill.top)); + }); + + testWidgets('$width split: the item tabs sit at the bottom right ' + 'of the detail, and its content clears only them', (tester) async { + await setSize(tester, Size(width, 800)); + await tester.pumpWidget(shell(tabs: true)); + await tester.pump(); + await tester.pump(); + + final body = tester.getRect( + find.byKey(const ValueKey('list-detail-body')), + ); + final pill = destinationPill(tester); + final tabs = tester.getRect( + find + .descendant( + of: find.byKey(const Key('detail-tabs')), + matching: find.byKey(FloatingDestinationBar.rowKey), + ) + .first, + ); + expect(tabs.right, closeTo(width - kFloatingBarMargin, 0.5)); + expect(tabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); + expect(tabs.left, greaterThan(body.left)); + expect(tabs.overlaps(pill), isFalse); + // Page tabs retain their dense icon-only presentation; only app + // destinations gain visible captions. + final detailBar = tester.widget( + find.descendant( + of: find.byKey(const Key('detail-tabs')), + matching: find.byType(FloatingDestinationBar), + ), + ); + expect(detailBar.showLabels, isFalse); + for (final label in ['One', 'Two', 'Three']) { expect( - pill.width, - lessThanOrEqualTo(list.width - 2 * kFloatingBarMargin), - ); - for (final destination in shellTabDestinations) { - final caption = find.byKey( - ValueKey( - 'destination-label-${destinationDetails(destination).label}', - ), - ); - expect(caption, findsOneWidget); - expect(pill.contains(tester.getRect(caption).center), isTrue); - } - - // The composer reaches the detail's bottom edge: nothing is reserved - // there for the shell's bar any more. - final composer = tester.getRect(find.byKey(const Key('composer'))); - expect(composer.left, body.left); - expect(composer.bottom, closeTo(800, 0.5)); - expect(composer.overlaps(pill), isFalse); - - // The list clears the bar, so its last rows scroll out from under it. - final listContext = tester.element(find.byKey(const Key('list'))); - expect( - MediaQuery.paddingOf(listContext).bottom, - greaterThanOrEqualTo(800 - pill.top), - ); - await tester.drag( - find.byKey(const Key('list')), - const Offset(0, -4000), - ); - await tester.pumpAndSettle(); - final last = tester.getRect(find.text('row 39')); - expect(last.bottom, lessThanOrEqualTo(pill.top)); - }); - - testWidgets('$host $width split: the item tabs sit at the bottom right ' - 'of the detail, and its content clears only them', (tester) async { - await setSize(tester, Size(width, 800)); - await tester.pumpWidget(shell(cupertino: cupertino, tabs: true)); - await tester.pump(); - await tester.pump(); - - final body = tester.getRect( - find.byKey(const ValueKey('list-detail-body')), - ); - final pill = destinationPill(tester); - final tabs = tester.getRect( - find - .descendant( - of: find.byKey(const Key('detail-tabs')), - matching: find.byKey(FloatingDestinationBar.rowKey), - ) - .first, - ); - expect(tabs.right, closeTo(width - kFloatingBarMargin, 0.5)); - expect(tabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); - expect(tabs.left, greaterThan(body.left)); - expect(tabs.overlaps(pill), isFalse); - // Page tabs retain their dense icon-only presentation; only app - // destinations gain visible captions. - final detailBar = tester.widget( find.descendant( of: find.byKey(const Key('detail-tabs')), - matching: find.byType(FloatingDestinationBar), + matching: find.text(label), ), + findsNothing, ); - expect(detailBar.showLabels, isFalse); - for (final label in ['One', 'Two', 'Three']) { - expect( - find.descendant( - of: find.byKey(const Key('detail-tabs')), - matching: find.text(label), - ), - findsNothing, - ); - } - expect(pill.right, lessThan(body.left)); - - // The item's list pads its end clear of its own tabs. - final listContext = tester.element( - find.byKey(const Key('detail-list')), - ); - expect( - MediaQuery.paddingOf(listContext).bottom, - closeTo(800 - tabs.top, 0.5), - ); - }); - } - - testWidgets('$host 1200 split: the bar follows a dragged list width', ( - tester, - ) async { - await setSize(tester, const Size(1200, 800)); - for (final width in [300.0, 520.0]) { - final store = MemoryListPaneWidthStore({'chat': width}); - await tester.pumpWidget( - KeyedSubtree( - key: ValueKey(width), - child: shell(cupertino: cupertino, store: store), - ), - ); - await tester.pumpAndSettle(); - final list = tester.getRect( - find.byKey(const ValueKey('list-detail-list')), - ); - expect(list.width, closeTo(width, 0.5)); - final pill = destinationPill(tester); - expect(pill.left, closeTo(list.left + kFloatingBarMargin, 0.5)); - expect(pill.left, greaterThanOrEqualTo(kFloatingBarMargin - 0.5)); - expect(pill.right, lessThanOrEqualTo(list.right - kFloatingBarMargin)); } - }); + expect(pill.right, lessThan(body.left)); - testWidgets('$host 1200 Settings: a page without a list keeps the bar ' - 'at the right edge', (tester) async { - await setSize(tester, const Size(1200, 800)); - await tester.pumpWidget( - shell(cupertino: cupertino, destination: AppDestination.settings), + // The item's list pads its end clear of its own tabs. + final listContext = tester.element(find.byKey(const Key('detail-list'))); + expect( + MediaQuery.paddingOf(listContext).bottom, + closeTo(800 - tabs.top, 0.5), ); - await tester.pump(); - final pill = destinationPill(tester); - expect(pill.right, closeTo(1200 - kFloatingBarMargin, 0.5)); }); + } - testWidgets('$host 1200 unsplit: the bar stays under the list column', ( - tester, - ) async { - await setSize(tester, const Size(1200, 800)); - await tester.pumpWidget(shell(cupertino: cupertino, split: false)); - await tester.pump(); + testWidgets('1200 split: the bar follows a dragged list width', ( + tester, + ) async { + await setSize(tester, const Size(1200, 800)); + for (final width in [300.0, 520.0]) { + final store = MemoryListPaneWidthStore({'chat': width}); + await tester.pumpWidget( + KeyedSubtree( + key: ValueKey(width), + child: shell(store: store), + ), + ); + await tester.pumpAndSettle(); + final list = tester.getRect( + find.byKey(const ValueKey('list-detail-list')), + ); + expect(list.width, closeTo(width, 0.5)); final pill = destinationPill(tester); - // Same place as beside an open item (Search has no split), so opening - // or closing an item never moves the bar across the window. - expect(pill.left, closeTo(kFloatingBarMargin, 0.5)); - expect(pill.width, lessThan(1200 * 0.6)); - }); - - testWidgets('$host 390: the bar hugs its tabs at the phone\'s bottom ' - 'right', (tester) async { - await setSize(tester, const Size(390, 844)); - await tester.pumpWidget(shell(cupertino: cupertino, split: false)); - await tester.pump(); - final pill = destinationPill(tester); - expect(pill.width, lessThanOrEqualTo(390 - 2 * kFloatingBarMargin)); - for (final destination in shellTabDestinations) { - expect( - find.byKey( - ValueKey( - 'destination-label-${destinationDetails(destination).label}', - ), - ), - findsOneWidget, - ); - } - expect(pill.right, closeTo(390 - kFloatingBarMargin, 0.5)); - }); - - for (final width in [600.0, 840.0]) { - testWidgets('$host $width split at 2x: the bar fits the list pane and ' - 'the item tabs the detail, without overflow', (tester) async { - await setSize(tester, Size(width, 800)); - await tester.pumpWidget( - shell(cupertino: cupertino, tabs: true, textScale: 2), - ); - await tester.pump(); - await tester.pump(); - expect(tester.takeException(), isNull); - final list = tester.getRect( - find.byKey(const ValueKey('list-detail-list')), - ); - final pill = destinationPill(tester); - expect(pill.left, greaterThanOrEqualTo(list.left)); - expect(pill.right, lessThanOrEqualTo(list.right)); - }); + expect(pill.left, closeTo(list.left + kFloatingBarMargin, 0.5)); + expect(pill.left, greaterThanOrEqualTo(kFloatingBarMargin - 0.5)); + expect(pill.right, lessThanOrEqualTo(list.right - kFloatingBarMargin)); } + }); + + testWidgets('1200 Settings: a page without a list keeps the bar ' + 'at the right edge', (tester) async { + await setSize(tester, const Size(1200, 800)); + await tester.pumpWidget(shell(destination: AppDestination.settings)); + await tester.pump(); + final pill = destinationPill(tester); + expect(pill.right, closeTo(1200 - kFloatingBarMargin, 0.5)); + }); + + testWidgets('1200 unsplit: the bar stays under the list column', ( + tester, + ) async { + await setSize(tester, const Size(1200, 800)); + await tester.pumpWidget(shell(split: false)); + await tester.pump(); + final pill = destinationPill(tester); + // Same place as beside an open item (Search has no split), so opening + // or closing an item never moves the bar across the window. + expect(pill.left, closeTo(kFloatingBarMargin, 0.5)); + expect(pill.width, lessThan(1200 * 0.6)); + }); + + testWidgets('390: the bar hugs its tabs at the phone\'s bottom ' + 'right', (tester) async { + await setSize(tester, const Size(390, 844)); + await tester.pumpWidget(shell(split: false)); + await tester.pump(); + final pill = destinationPill(tester); + expect(pill.width, lessThanOrEqualTo(390 - 2 * kFloatingBarMargin)); + for (final destination in shellTabDestinations) { + expect( + find.byKey( + ValueKey( + 'destination-label-${destinationDetails(destination).label}', + ), + ), + findsOneWidget, + ); + } + expect(pill.right, closeTo(390 - kFloatingBarMargin, 0.5)); + }); + + for (final width in [600.0, 840.0]) { + testWidgets('$width split at 2x: the bar fits the list pane and ' + 'the item tabs the detail, without overflow', (tester) async { + await setSize(tester, Size(width, 800)); + await tester.pumpWidget(shell(tabs: true, textScale: 2)); + await tester.pump(); + await tester.pump(); + expect(tester.takeException(), isNull); + final list = tester.getRect( + find.byKey(const ValueKey('list-detail-list')), + ); + final pill = destinationPill(tester); + expect(pill.left, greaterThanOrEqualTo(list.left)); + expect(pill.right, lessThanOrEqualTo(list.right)); + }); } } diff --git a/app/test/shell/split_detail_pages_test.dart b/app/test/shell/split_detail_pages_test.dart index 4c75d3e0..cef81444 100644 --- a/app/test/shell/split_detail_pages_test.dart +++ b/app/test/shell/split_detail_pages_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/runs/data/runs_repository.dart'; @@ -36,7 +35,7 @@ void main() { .first, ); - Future pumpSplitRun(WidgetTester tester, bool cupertino) async { + Future pumpSplitRun(WidgetTester tester) async { tester.view.physicalSize = const Size(1200, 800); tester.view.devicePixelRatio = 1; addTearDown(tester.view.reset); @@ -45,7 +44,6 @@ void main() { addTearDown(controller.dispose); await controller.select(77); final shell = AdaptiveShell( - cupertino: cupertino, destination: AppDestination.runs, destinationBodies: { AppDestination.runs: (_) => ListDetailPanes( @@ -65,78 +63,68 @@ void main() { }, ); await tester.pumpWidget( - cupertino - ? CupertinoApp(home: shell) - : MaterialApp( - theme: ThemeData(platform: TargetPlatform.android), - home: shell, - ), + MaterialApp( + theme: ThemeData(platform: TargetPlatform.android), + home: shell, + ), ); await tester.pumpAndSettle(); } - for (final cupertino in [false, true]) { - final host = cupertino ? 'Cupertino' : 'Material'; + testWidgets('1200: run tabs float at the pane\'s bottom beside the ' + 'shell bar under the list, and the stage page opens in the pane', ( + tester, + ) async { + await pumpSplitRun(tester); + final body = tester.getRect(find.byKey(const ValueKey('list-detail-body'))); + final list = tester.getRect(find.byKey(const ValueKey('list-detail-list'))); + var main = shellPill(tester); + expect(main.left, closeTo(list.left + kFloatingBarMargin, 0.5)); + expect(main.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); - testWidgets('$host 1200: run tabs float at the pane\'s bottom beside the ' - 'shell bar under the list, and the stage page opens in the pane', ( + final runTabs = pillOf(tester, find.byKey(const Key('run-detail-tabs'))); + expect(runTabs.left, greaterThanOrEqualTo(body.left)); + expect(runTabs.right, closeTo(1200 - kFloatingBarMargin, 0.5)); + expect(runTabs.overlaps(main), isFalse); + expect(runTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); + + // Open the stage page from the timeline. + await openRunDetailTab(tester, RunDetailTab.timeline); + final row = find.byKey(const ValueKey('run-timeline-visit-1')); + await tester.ensureVisible(row); + await tester.pumpAndSettle(); + await tester.tap(row); + await tester.pumpAndSettle(); + + expect(find.byKey(const Key('run-visit-back')), findsOneWidget); + // The page covers only the detail pane: the root navigator has nothing + // pushed, and the list and the shell's tab bar stay in place. + expect( + tester.state(find.byType(Navigator).first).canPop(), + isFalse, + ); + expect(find.text('run row 0'), findsOneWidget); + final back = tester.getRect(find.byKey(const Key('run-visit-back'))); + expect(back.left, greaterThanOrEqualTo(body.left)); + main = shellPill(tester); + expect(main.left, closeTo(list.left + kFloatingBarMargin, 0.5)); + final visitTabs = pillOf( tester, - ) async { - await pumpSplitRun(tester, cupertino); - final body = tester.getRect( - find.byKey(const ValueKey('list-detail-body')), - ); - final list = tester.getRect( - find.byKey(const ValueKey('list-detail-list')), - ); - var main = shellPill(tester); - expect(main.left, closeTo(list.left + kFloatingBarMargin, 0.5)); - expect(main.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); + find.byKey(const Key('run-visit-tabs')).last, + ); + expect(visitTabs.left, greaterThanOrEqualTo(body.left)); + expect(visitTabs.overlaps(main), isFalse); + expect(visitTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); + expect(tester.takeException(), isNull); - final runTabs = pillOf(tester, find.byKey(const Key('run-detail-tabs'))); - expect(runTabs.left, greaterThanOrEqualTo(body.left)); - expect(runTabs.right, closeTo(1200 - kFloatingBarMargin, 0.5)); - expect(runTabs.overlaps(main), isFalse); - expect(runTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); + // The shell's tabs still work over the open stage page. + await tester.tap(find.byKey(const ValueKey('shell.destination.runs'))); + await tester.pumpAndSettle(); - // Open the stage page from the timeline. - await openRunDetailTab(tester, RunDetailTab.timeline); - final row = find.byKey(const ValueKey('run-timeline-visit-1')); - await tester.ensureVisible(row); - await tester.pumpAndSettle(); - await tester.tap(row); - await tester.pumpAndSettle(); - - expect(find.byKey(const Key('run-visit-back')), findsOneWidget); - // The page covers only the detail pane: the root navigator has nothing - // pushed, and the list and the shell's tab bar stay in place. - expect( - tester.state(find.byType(Navigator).first).canPop(), - isFalse, - ); - expect(find.text('run row 0'), findsOneWidget); - final back = tester.getRect(find.byKey(const Key('run-visit-back'))); - expect(back.left, greaterThanOrEqualTo(body.left)); - main = shellPill(tester); - expect(main.left, closeTo(list.left + kFloatingBarMargin, 0.5)); - final visitTabs = pillOf( - tester, - find.byKey(const Key('run-visit-tabs')).last, - ); - expect(visitTabs.left, greaterThanOrEqualTo(body.left)); - expect(visitTabs.overlaps(main), isFalse); - expect(visitTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); - expect(tester.takeException(), isNull); - - // The shell's tabs still work over the open stage page. - await tester.tap(find.byKey(const ValueKey('shell.destination.runs'))); - await tester.pumpAndSettle(); - - // Back closes the page inside the pane, back to the run. - await tester.tap(find.byKey(const Key('run-visit-back'))); - await tester.pumpAndSettle(); - expect(find.byKey(const Key('run-visit-back')), findsNothing); - expect(find.byKey(const Key('run-detail-tabs')), findsOneWidget); - }); - } + // Back closes the page inside the pane, back to the run. + await tester.tap(find.byKey(const Key('run-visit-back'))); + await tester.pumpAndSettle(); + expect(find.byKey(const Key('run-visit-back')), findsNothing); + expect(find.byKey(const Key('run-detail-tabs')), findsOneWidget); + }); } diff --git a/app/test/shell/split_stage_page_width_test.dart b/app/test/shell/split_stage_page_width_test.dart index 795ce7e2..d811e6d4 100644 --- a/app/test/shell/split_stage_page_width_test.dart +++ b/app/test/shell/split_stage_page_width_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/runs/data/runs_repository.dart'; @@ -18,11 +17,7 @@ import '../features/runs/ui/run_detail_visit_support.dart'; /// edge at an unfolded foldable's width and on a wide window: its content /// spans the pane minus the page's own padding, with no reading-width cap. void main() { - Future openStagePage( - WidgetTester tester, { - required bool cupertino, - required Size size, - }) async { + Future openStagePage(WidgetTester tester, {required Size size}) async { tester.view.physicalSize = size; tester.view.devicePixelRatio = 1; addTearDown(tester.view.reset); @@ -31,7 +26,6 @@ void main() { addTearDown(controller.dispose); await controller.select(77); final shell = AdaptiveShell( - cupertino: cupertino, destination: AppDestination.runs, destinationBodies: { AppDestination.runs: (_) => ListDetailPanes( @@ -49,12 +43,10 @@ void main() { }, ); await tester.pumpWidget( - cupertino - ? CupertinoApp(home: shell) - : MaterialApp( - theme: ThemeData(platform: TargetPlatform.android), - home: shell, - ), + MaterialApp( + theme: ThemeData(platform: TargetPlatform.android), + home: shell, + ), ); await tester.pumpAndSettle(); await openRunDetailTab(tester, RunDetailTab.timeline); @@ -65,48 +57,45 @@ void main() { await tester.pumpAndSettle(); } - for (final cupertino in [false, true]) { - final host = cupertino ? 'Cupertino' : 'Material'; - for (final size in const [Size(880, 1000), Size(1400, 900)]) { - testWidgets('$host ${size.width.toInt()}: the stage page spans the ' - 'detail pane edge to edge', (tester) async { - await openStagePage(tester, cupertino: cupertino, size: size); - expect(find.byKey(const Key('run-visit-back')), findsOneWidget); - final body = tester.getRect( - find.byKey(const ValueKey('list-detail-body')), - ); - // The pane is the detail's whole share of the window, up to its - // right edge. - expect(body.right, size.width); - final pane = tester.getRect(find.byKey(const Key('run-visit-pane'))); - expect(pane.left, body.left); - expect(pane.right, body.right); - // The facts block and the Input and Output sections span the whole - // pane; only the page's own padding insets their content. - final facts = tester.getRect(find.byKey(const Key('run-visit-facts'))); - expect(facts.left, body.left); - expect(facts.right, body.right); - final titles = find.descendant( - of: find.byKey(const Key('run-visit-pane')), - matching: find.byType(StickySectionTitle), - ); - expect(titles, findsNWidgets(2)); - for (final title in tester.widgetList(titles)) { - final rect = tester.getRect(find.byWidget(title)); - expect(rect.left, body.left); - expect(rect.right, body.right); - } - // The heading starts at the page padding and the chevron ends at it. - final input = tester.getRect( - find.descendant(of: titles.first, matching: find.text('Input')), - ); - expect(input.left, body.left + 16); - final chevron = tester.getRect( - find.descendant(of: titles.first, matching: find.byType(Icon)).last, - ); - expect(chevron.right, closeTo(body.right - 8, 0.5)); - expect(tester.takeException(), isNull); - }); - } + for (final size in const [Size(880, 1000), Size(1400, 900)]) { + testWidgets('${size.width.toInt()}: the stage page spans the ' + 'detail pane edge to edge', (tester) async { + await openStagePage(tester, size: size); + expect(find.byKey(const Key('run-visit-back')), findsOneWidget); + final body = tester.getRect( + find.byKey(const ValueKey('list-detail-body')), + ); + // The pane is the detail's whole share of the window, up to its + // right edge. + expect(body.right, size.width); + final pane = tester.getRect(find.byKey(const Key('run-visit-pane'))); + expect(pane.left, body.left); + expect(pane.right, body.right); + // The facts block and the Input and Output sections span the whole + // pane; only the page's own padding insets their content. + final facts = tester.getRect(find.byKey(const Key('run-visit-facts'))); + expect(facts.left, body.left); + expect(facts.right, body.right); + final titles = find.descendant( + of: find.byKey(const Key('run-visit-pane')), + matching: find.byType(StickySectionTitle), + ); + expect(titles, findsNWidgets(2)); + for (final title in tester.widgetList(titles)) { + final rect = tester.getRect(find.byWidget(title)); + expect(rect.left, body.left); + expect(rect.right, body.right); + } + // The heading starts at the page padding and the chevron ends at it. + final input = tester.getRect( + find.descendant(of: titles.first, matching: find.text('Input')), + ); + expect(input.left, body.left + 16); + final chevron = tester.getRect( + find.descendant(of: titles.first, matching: find.byType(Icon)).last, + ); + expect(chevron.right, closeTo(body.right - 8, 0.5)); + expect(tester.takeException(), isNull); + }); } } diff --git a/app/test/shell/split_status_bar_test.dart b/app/test/shell/split_status_bar_test.dart index 89e4e810..3d6682e0 100644 --- a/app/test/shell/split_status_bar_test.dart +++ b/app/test/shell/split_status_bar_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/shell/adaptive_shell.dart'; @@ -38,7 +37,7 @@ void main() { /// An item publishing its bar to the pane, with its own floating tabs /// placed where the pane says (like run and pipeline detail). - Widget tabbedItem(bool cupertino) => ShellBar( + Widget tabbedItem() => ShellBar( title: 'Open item', child: Builder( builder: (context) { @@ -48,7 +47,7 @@ void main() { bar: KeyedSubtree( key: const Key('item-tabs'), child: FloatingDestinationBar( - cupertino: cupertino, + cupertino: false, edge: edge, currentIndex: 0, onTap: (_) {}, @@ -71,12 +70,12 @@ void main() { ); /// An item drawing its own header over itself (like the chat thread). - Widget overlayItem(bool cupertino) => ShellBar( + Widget overlayItem() => ShellBar( barless: true, child: SegmentedBarOverlay( bar: SegmentedBar( key: const Key('own-header'), - cupertino: cupertino, + cupertino: false, automaticallyImplyLeading: false, title: 'Own header', ), @@ -84,9 +83,8 @@ void main() { ), ); - Widget shell(bool cupertino, Widget Function(bool) item) { + Widget shell(Widget item) { final app = AdaptiveShell( - cupertino: cupertino, destination: AppDestination.runs, destinationBodies: { AppDestination.runs: (_) => ListDetailPanes( @@ -96,12 +94,12 @@ void main() { detail: DetailPane( destination: AppDestination.runs, implyBack: false, - builder: (_) => item(cupertino), + builder: (_) => item, ), ), }, ); - return cupertino ? CupertinoApp(home: app) : MaterialApp(home: app); + return MaterialApp(home: app); } Iterable pillsOf(WidgetTester tester, Finder bar) => find @@ -112,99 +110,93 @@ void main() { return box.localToGlobal(Offset.zero) & box.size; }); - for (final cupertino in [false, true]) { - final host = cupertino ? 'Cupertino' : 'Material'; + testWidgets('split under a status bar: list and pane bars sit ' + 'below it, content reaches the top edge', (tester) async { + await setUp(tester, const Size(1200, 800)); + await tester.pumpWidget(shell(tabbedItem())); + await tester.pump(); + await tester.pump(); - testWidgets('$host split under a status bar: list and pane bars sit ' - 'below it, content reaches the top edge', (tester) async { - await setUp(tester, const Size(1200, 800)); - await tester.pumpWidget(shell(cupertino, tabbedItem)); - await tester.pump(); - await tester.pump(); - - final listBar = find.byWidgetPredicate( - (widget) => widget is SegmentedBar && widget.title == 'Runs', - ); - final paneBar = find.byWidgetPredicate( - (widget) => widget is SegmentedBar && widget.title == 'Open item', - ); - for (final bar in [listBar, paneBar]) { - final pills = pillsOf(tester, bar); - expect(pills, isNotEmpty); - for (final pill in pills) { - expect(pill.top, greaterThanOrEqualTo(statusBar)); - } - } - // Content may still extend under the bars and the status bar. - expect(tester.getTopLeft(find.byKey(const Key('list'))).dy, 0); - expect(tester.getTopLeft(find.byKey(const Key('item-list'))).dy, 0); - // At rest (the bars' pieces have popped in) the first rows start - // below the bars. - await tester.pump(const Duration(seconds: 1)); - final paneBottom = pillsOf(tester, paneBar).first.bottom; - expect( - tester.getTopLeft(find.text('item 0')).dy, - greaterThanOrEqualTo(paneBottom), - ); - }); - - testWidgets('$host split under a status bar: a self-drawn header (chat) ' - 'sits below it', (tester) async { - await setUp(tester, const Size(1200, 800)); - await tester.pumpWidget(shell(cupertino, overlayItem)); - await tester.pump(); - await tester.pump(); - final pills = pillsOf(tester, find.byKey(const Key('own-header'))); + final listBar = find.byWidgetPredicate( + (widget) => widget is SegmentedBar && widget.title == 'Runs', + ); + final paneBar = find.byWidgetPredicate( + (widget) => widget is SegmentedBar && widget.title == 'Open item', + ); + for (final bar in [listBar, paneBar]) { + final pills = pillsOf(tester, bar); expect(pills, isNotEmpty); for (final pill in pills) { expect(pill.top, greaterThanOrEqualTo(statusBar)); } - expect(tester.getTopLeft(find.byKey(const Key('item-list'))).dy, 0); - }); + } + // Content may still extend under the bars and the status bar. + expect(tester.getTopLeft(find.byKey(const Key('list'))).dy, 0); + expect(tester.getTopLeft(find.byKey(const Key('item-list'))).dy, 0); + // At rest (the bars' pieces have popped in) the first rows start + // below the bars. + await tester.pump(const Duration(seconds: 1)); + final paneBottom = pillsOf(tester, paneBar).first.bottom; + expect( + tester.getTopLeft(find.text('item 0')).dy, + greaterThanOrEqualTo(paneBottom), + ); + }); - testWidgets('$host split: the item tabs sit at the bottom right of the ' - 'detail pane, the shell tab bar under the list', (tester) async { - // A gesture-navigation inset as on the unfolded foldable. - await setUp(tester, const Size(1200, 800), bottom: 24); - await tester.pumpWidget(shell(cupertino, tabbedItem)); - await tester.pump(); - await tester.pump(); + testWidgets('split under a status bar: a self-drawn header (chat) ' + 'sits below it', (tester) async { + await setUp(tester, const Size(1200, 800)); + await tester.pumpWidget(shell(overlayItem())); + await tester.pump(); + await tester.pump(); + final pills = pillsOf(tester, find.byKey(const Key('own-header'))); + expect(pills, isNotEmpty); + for (final pill in pills) { + expect(pill.top, greaterThanOrEqualTo(statusBar)); + } + expect(tester.getTopLeft(find.byKey(const Key('item-list'))).dy, 0); + }); - final body = tester.getRect( - find.byKey(const ValueKey('list-detail-body')), - ); - final tabs = tester.getRect( - find.descendant( - of: find.byKey(const Key('item-tabs')), - matching: find.byKey(FloatingDestinationBar.rowKey), - ), - ); - expect(tabs.left, greaterThanOrEqualTo(body.left)); - expect(tabs.right, lessThanOrEqualTo(body.right)); - final shellTabs = tester.getRect( - find - .ancestor( - of: find.byKey(const ValueKey('shell.destination.runs')).first, - matching: find.byKey(FloatingDestinationBar.rowKey), - ) - .first, - ); - // Both bars sit above the system inset: the shell's under the list - // pane, the item's at the detail pane's trailing edge. - final listPane = tester.getRect( - find.byKey(const ValueKey('list-detail-list')), - ); - expect(shellTabs.bottom, closeTo(800 - 24, 0.5)); - expect(shellTabs.right, lessThanOrEqualTo(listPane.right)); - expect(tabs.bottom, closeTo(800 - 24, 0.5)); - expect(tabs.right, closeTo(1200 - kFloatingBarMargin, 0.5)); - expect(shellTabs.overlaps(tabs), isFalse); - // The item's list clears its tabs at rest. - final list = tester.element(find.byKey(const Key('item-list'))); - expect( - MediaQuery.paddingOf(list).bottom, - greaterThanOrEqualTo(800 - tabs.top), - ); - }); - } + testWidgets('split: the item tabs sit at the bottom right of the ' + 'detail pane, the shell tab bar under the list', (tester) async { + // A gesture-navigation inset as on the unfolded foldable. + await setUp(tester, const Size(1200, 800), bottom: 24); + await tester.pumpWidget(shell(tabbedItem())); + await tester.pump(); + await tester.pump(); + + final body = tester.getRect(find.byKey(const ValueKey('list-detail-body'))); + final tabs = tester.getRect( + find.descendant( + of: find.byKey(const Key('item-tabs')), + matching: find.byKey(FloatingDestinationBar.rowKey), + ), + ); + expect(tabs.left, greaterThanOrEqualTo(body.left)); + expect(tabs.right, lessThanOrEqualTo(body.right)); + final shellTabs = tester.getRect( + find + .ancestor( + of: find.byKey(const ValueKey('shell.destination.runs')).first, + matching: find.byKey(FloatingDestinationBar.rowKey), + ) + .first, + ); + // Both bars sit above the system inset: the shell's under the list + // pane, the item's at the detail pane's trailing edge. + final listPane = tester.getRect( + find.byKey(const ValueKey('list-detail-list')), + ); + expect(shellTabs.bottom, closeTo(800 - 24, 0.5)); + expect(shellTabs.right, lessThanOrEqualTo(listPane.right)); + expect(tabs.bottom, closeTo(800 - 24, 0.5)); + expect(tabs.right, closeTo(1200 - kFloatingBarMargin, 0.5)); + expect(shellTabs.overlaps(tabs), isFalse); + // The item's list clears its tabs at rest. + final list = tester.element(find.byKey(const Key('item-list'))); + expect( + MediaQuery.paddingOf(list).bottom, + greaterThanOrEqualTo(800 - tabs.top), + ); + }); } diff --git a/app/test/shell/window_margins_shell_test.dart b/app/test/shell/window_margins_shell_test.dart index ffbd711c..66ff3868 100644 --- a/app/test/shell/window_margins_shell_test.dart +++ b/app/test/shell/window_margins_shell_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/shell/adaptive_shell.dart'; @@ -50,9 +49,8 @@ void main() { ), ); - Widget app({required bool cupertino, required bool split}) { + Widget app({required bool split}) { final shell = AdaptiveShell( - cupertino: cupertino, destinationBodies: { AppDestination.runs: (_) => split ? ListDetailPanes( @@ -69,9 +67,7 @@ void main() { ); Widget margins(BuildContext context, Widget? child) => WindowMargins(child: child!); - return cupertino - ? CupertinoApp(builder: margins, home: shell) - : MaterialApp(builder: margins, home: shell); + return MaterialApp(builder: margins, home: shell); } Finder pills(Finder bar) => @@ -94,107 +90,92 @@ void main() { return rects.reduce((a, b) => a.expandToInclude(b)); } - for (final cupertino in [false, true]) { - final host = cupertino ? 'Cupertino' : 'Material'; + testWidgets('1280: list and detail bars keep 16 px from the top ' + 'and every side', (tester) async { + await setSize(tester, const Size(1280, 800)); + await tester.pumpWidget(app(split: true)); + await tester.pump(); + // The pieces pop in; measure them at rest. + await tester.pump(const Duration(seconds: 2)); - testWidgets('$host 1280: list and detail bars keep 16 px from the top ' - 'and every side', (tester) async { - await setSize(tester, const Size(1280, 800)); - await tester.pumpWidget(app(cupertino: cupertino, split: true)); - await tester.pump(); - // The pieces pop in; measure them at rest. - await tester.pump(const Duration(seconds: 2)); + final listPane = tester.getRect( + find.byKey(const ValueKey('list-detail-list')), + ); + final body = tester.getRect(find.byKey(const ValueKey('list-detail-body'))); + final listBar = span(tester, shellBar); + final itemBar = span(tester, paneBar); + expect(listBar.top, closeTo(16, 0.5)); + expect(listBar.left, closeTo(listPane.left + 16, 0.5)); + expect(listBar.right, closeTo(listPane.right - 16, 0.5)); + expect(itemBar.top, closeTo(16, 0.5)); + expect(itemBar.left, closeTo(body.left + 16, 0.5)); + expect(itemBar.right, closeTo(body.right - 16, 0.5)); - final listPane = tester.getRect( - find.byKey(const ValueKey('list-detail-list')), - ); - final body = tester.getRect( - find.byKey(const ValueKey('list-detail-body')), - ); - final listBar = span(tester, shellBar); - final itemBar = span(tester, paneBar); - expect(listBar.top, closeTo(16, 0.5)); - expect(listBar.left, closeTo(listPane.left + 16, 0.5)); - expect(listBar.right, closeTo(listPane.right - 16, 0.5)); - expect(itemBar.top, closeTo(16, 0.5)); - expect(itemBar.left, closeTo(body.left + 16, 0.5)); - expect(itemBar.right, closeTo(body.right - 16, 0.5)); + // Each pane's content still starts below its bar (and its 8 px gap) + // at rest, so nothing hides behind the taller margin. + expect( + tester.getTopLeft(find.text('list row 0')).dy, + greaterThanOrEqualTo(listBar.bottom + 8 - 0.5), + ); + expect( + tester.getTopLeft(find.text('item row 0')).dy, + greaterThanOrEqualTo(itemBar.bottom + 8 - 0.5), + ); + expect(tester.takeException(), isNull); + }); - // Each pane's content still starts below its bar (and its 8 px gap) - // at rest, so nothing hides behind the taller margin. - expect( - tester.getTopLeft(find.text('list row 0')).dy, - greaterThanOrEqualTo(listBar.bottom + 8 - 0.5), - ); - expect( - tester.getTopLeft(find.text('item row 0')).dy, - greaterThanOrEqualTo(itemBar.bottom + 8 - 0.5), - ); - expect(tester.takeException(), isNull); - }); + testWidgets('390: the phone keeps the bar at 8 px from the top and ' + '12 px from the sides', (tester) async { + await setSize(tester, const Size(390, 844)); + await tester.pumpWidget(app(split: false)); + await tester.pump(); + // The pieces pop in; measure them at rest. + await tester.pump(const Duration(seconds: 2)); - testWidgets('$host 390: the phone keeps the bar at 8 px from the top and ' - '12 px from the sides', (tester) async { - await setSize(tester, const Size(390, 844)); - await tester.pumpWidget(app(cupertino: cupertino, split: false)); - await tester.pump(); - // The pieces pop in; measure them at rest. - await tester.pump(const Duration(seconds: 2)); + final bar = span(tester, shellBar); + expect(bar.top, closeTo(8, 0.5)); + expect(bar.left, closeTo(12, 0.5)); + expect(bar.right, closeTo(390 - 12, 0.5)); + expect( + tester.getTopLeft(find.text('list row 0')).dy, + greaterThanOrEqualTo(bar.bottom + 8 - 0.5), + ); + expect(tester.takeException(), isNull); + }); - final bar = span(tester, shellBar); - expect(bar.top, closeTo(8, 0.5)); - expect(bar.left, closeTo(12, 0.5)); - expect(bar.right, closeTo(390 - 12, 0.5)); - expect( - tester.getTopLeft(find.text('list row 0')).dy, - greaterThanOrEqualTo(bar.bottom + 8 - 0.5), - ); - expect(tester.takeException(), isNull); - }); + testWidgets('1280: a pushed page\'s bar keeps the wide margins', ( + tester, + ) async { + await setSize(tester, const Size(1280, 800)); + final bar = SegmentedBar( + cupertino: false, + title: 'Settings', + actions: const [Icon(Icons.more_vert, semanticLabel: 'More')], + ); + final body = Builder( + builder: (context) => ListView( + padding: withTopBarClearance(context, EdgeInsets.zero), + children: const [SizedBox(height: 40, child: Text('first row'))], + ), + ); + Widget margins(BuildContext context, Widget? child) => + WindowMargins(child: child!); + await tester.pumpWidget( + MaterialApp( + builder: margins, + home: Scaffold(extendBodyBehindAppBar: true, appBar: bar, body: body), + ), + ); + await tester.pump(const Duration(seconds: 2)); - testWidgets('$host 1280: a pushed page\'s bar keeps the wide margins', ( - tester, - ) async { - await setSize(tester, const Size(1280, 800)); - final bar = SegmentedBar( - cupertino: cupertino, - title: 'Settings', - actions: const [Icon(Icons.more_vert, semanticLabel: 'More')], - ); - final body = Builder( - builder: (context) => ListView( - padding: withTopBarClearance(context, EdgeInsets.zero), - children: const [SizedBox(height: 40, child: Text('first row'))], - ), - ); - Widget margins(BuildContext context, Widget? child) => - WindowMargins(child: child!); - await tester.pumpWidget( - cupertino - ? CupertinoApp( - builder: margins, - home: CupertinoPageScaffold(navigationBar: bar, child: body), - ) - : MaterialApp( - builder: margins, - home: Scaffold( - extendBodyBehindAppBar: true, - appBar: bar, - body: body, - ), - ), - ); - await tester.pump(const Duration(seconds: 2)); - - final pieces = span(tester, find.byType(SegmentedBar)); - expect(pieces.top, closeTo(16, 0.5)); - expect(pieces.left, closeTo(16, 0.5)); - expect(pieces.right, closeTo(1280 - 16, 0.5)); - expect( - tester.getTopLeft(find.text('first row')).dy, - closeTo(pieces.bottom + 8, 0.5), - ); - expect(tester.takeException(), isNull); - }); - } + final pieces = span(tester, find.byType(SegmentedBar)); + expect(pieces.top, closeTo(16, 0.5)); + expect(pieces.left, closeTo(16, 0.5)); + expect(pieces.right, closeTo(1280 - 16, 0.5)); + expect( + tester.getTopLeft(find.text('first row')).dy, + closeTo(pieces.bottom + 8, 0.5), + ); + expect(tester.takeException(), isNull); + }); } diff --git a/app/test/ui/adaptive/floating_tab_motion_test.dart b/app/test/ui/adaptive/floating_tab_motion_test.dart index 32db1326..0c8fae42 100644 --- a/app/test/ui/adaptive/floating_tab_motion_test.dart +++ b/app/test/ui/adaptive/floating_tab_motion_test.dart @@ -300,54 +300,48 @@ void main() { ); expect(iconWidth(tester, 0), moreOrLessEquals(iconSize)); }); + } - testWidgets('$host: switching the shell tabs never replays the main ' - "bar's entrance", (tester) async { - animate(tester, on: true); - var destination = AppDestination.runs; - final shell = StatefulBuilder( - builder: (context, setState) => AdaptiveShell( - cupertino: cupertino, - destination: destination, - onDestinationSelected: (value) => setState(() => destination = value), - ), - ); - await tester.pumpWidget( - cupertino ? CupertinoApp(home: shell) : MaterialApp(home: shell), - ); - await tester.pumpAndSettle(); - for (final next in [ - AppDestination.pipelines, - AppDestination.chat, - AppDestination.runs, - ]) { - await tester.tap( - find.byKey(ValueKey('shell.destination.${next.name}')), - ); - for (var frame = 0; frame < 12; frame += 1) { - await tester.pump(const Duration(milliseconds: 25)); - for (final tab in shellTabDestinations) { - final finder = find.byKey( - ValueKey('shell.destination.${tab.name}'), - ); + testWidgets('switching the shell tabs never replays the main ' + "bar's entrance", (tester) async { + final size = FloatingDestinationBar.buttonSize(cupertino: false); + animate(tester, on: true); + var destination = AppDestination.runs; + final shell = StatefulBuilder( + builder: (context, setState) => AdaptiveShell( + destination: destination, + onDestinationSelected: (value) => setState(() => destination = value), + ), + ); + await tester.pumpWidget(MaterialApp(home: shell)); + await tester.pumpAndSettle(); + for (final next in [ + AppDestination.pipelines, + AppDestination.chat, + AppDestination.runs, + ]) { + await tester.tap(find.byKey(ValueKey('shell.destination.${next.name}'))); + for (var frame = 0; frame < 12; frame += 1) { + await tester.pump(const Duration(milliseconds: 25)); + for (final tab in shellTabDestinations) { + final finder = find.byKey(ValueKey('shell.destination.${tab.name}')); + expect( + opacityOf(tester, finder), + 1, + reason: '${tab.name} faded switching to ${next.name}', + ); + if (tab != next) { + // The previous selection shrinks back to its size; nothing + // pops again from 0.6. expect( - opacityOf(tester, finder), - 1, - reason: '${tab.name} faded switching to ${next.name}', + widthOf(tester, finder), + greaterThan(size * 0.9), + reason: tab.name, ); - if (tab != next) { - // The previous selection shrinks back to its size; nothing - // pops again from 0.6. - expect( - widthOf(tester, finder), - greaterThan(size * 0.9), - reason: tab.name, - ); - } } } - await tester.pumpAndSettle(); } - }); - } + await tester.pumpAndSettle(); + } + }); } diff --git a/app/test/ui/adaptive/platform_test.dart b/app/test/ui/adaptive/platform_test.dart index ae18324f..88e9a8a3 100644 --- a/app/test/ui/adaptive/platform_test.dart +++ b/app/test/ui/adaptive/platform_test.dart @@ -27,12 +27,4 @@ void main() { debugDefaultTargetPlatformOverride = null; }); } - - testWidgets('an explicit cupertino choice still builds the Cupertino host', ( - tester, - ) async { - await tester.pumpWidget(const MyApp(cupertino: true)); - expect(find.byType(CupertinoApp), findsOneWidget); - await tester.pumpWidget(const SizedBox.shrink()); - }); } diff --git a/app/test/ui/adaptive/segmented_bar_title_widget_test.dart b/app/test/ui/adaptive/segmented_bar_title_widget_test.dart index 36250f90..cbc6c408 100644 --- a/app/test/ui/adaptive/segmented_bar_title_widget_test.dart +++ b/app/test/ui/adaptive/segmented_bar_title_widget_test.dart @@ -105,47 +105,42 @@ void main() { // The actions keep to the trailing edge. expect(pillOf(tester, find.byKey(const Key('action'))).right, 1200 - 12); }); - - testWidgets('$host: a shell tab publishing a field gets it in place of ' - 'the title, without the Search action', (tester) async { - setSize(tester, 560); - await tester.pumpWidget( - _shellApp( - cupertino, - AdaptiveShell( - cupertino: cupertino, - destination: AppDestination.search, - onSearch: () {}, - destinationBodies: { - AppDestination.search: (_) => ShellBar( - titleWidget: field(cupertino), - titleWidgetMaxWidth: 840, - child: const SizedBox.expand(), - ), - }, - ), - ), - ); - await tester.pump(); - - final bar = find.byType(SegmentedBar); - expect( - find.descendant(of: bar, matching: find.byKey(fieldKey)), - findsOneWidget, - ); - expect( - find.descendant(of: bar, matching: find.text('Search')), - findsNothing, - ); - expect(find.byKey(const ValueKey('shell.search')), findsNothing); - // Measured at rest, after the pieces' entrance. - await tester.pump(const Duration(seconds: 1)); - final pill = pillOf(tester, find.byKey(fieldKey)); - expect(pill.left, 12); - expect(pill.right, 560 - 12); - }); } -} -Widget _shellApp(bool cupertino, Widget shell) => - cupertino ? CupertinoApp(home: shell) : MaterialApp(home: shell); + testWidgets('a shell tab publishing a field gets it in place of the title, ' + 'without the Search action', (tester) async { + setSize(tester, 560); + await tester.pumpWidget( + MaterialApp( + home: AdaptiveShell( + destination: AppDestination.search, + onSearch: () {}, + destinationBodies: { + AppDestination.search: (_) => ShellBar( + titleWidget: const TextField(key: fieldKey), + titleWidgetMaxWidth: 840, + child: const SizedBox.expand(), + ), + }, + ), + ), + ); + await tester.pump(); + + final bar = find.byType(SegmentedBar); + expect( + find.descendant(of: bar, matching: find.byKey(fieldKey)), + findsOneWidget, + ); + expect( + find.descendant(of: bar, matching: find.text('Search')), + findsNothing, + ); + expect(find.byKey(const ValueKey('shell.search')), findsNothing); + // Measured at rest, after the pieces' entrance. + await tester.pump(const Duration(seconds: 1)); + final pill = pillOf(tester, find.byKey(fieldKey)); + expect(pill.left, 12); + expect(pill.right, 560 - 12); + }); +} diff --git a/app/test/widget_test.dart b/app/test/widget_test.dart index 70f7d317..dcca1120 100644 --- a/app/test/widget_test.dart +++ b/app/test/widget_test.dart @@ -1,9 +1,8 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:pipelines_app/main.dart'; -import 'package:pipelines_app/ui/adaptive/segmented_bar.dart'; +import 'package:pipelines_app/shell/adaptive_shell.dart'; +import 'package:pipelines_app/shell/destination.dart'; import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart'; void main() { @@ -36,52 +35,6 @@ void main() { ); } - testWidgets('Cupertino shell uses a tab bar on a narrow window', ( - tester, - ) async { - tester.view.physicalSize = const Size(390, 844); - tester.view.devicePixelRatio = 1; - addTearDown(tester.view.resetPhysicalSize); - addTearDown(tester.view.resetDevicePixelRatio); - await tester.pumpWidget(const MyApp(cupertino: true)); - expect(find.byType(SegmentedBar), findsOneWidget); - expect(find.byType(CupertinoNavigationBar), findsNothing); - expect(find.byType(FloatingDestinationBar), findsOneWidget); - expect(find.text('Pipelines — Not implemented'), findsOneWidget); - }); - - testWidgets('Cupertino shell floats its tab bar on a wide window', ( - tester, - ) async { - tester.view.physicalSize = const Size(1280, 900); - tester.view.devicePixelRatio = 1; - addTearDown(tester.view.resetPhysicalSize); - addTearDown(tester.view.resetDevicePixelRatio); - await tester.pumpWidget(const MyApp(cupertino: true)); - expect(find.byType(FloatingDestinationBar), findsOneWidget); - expect(find.byType(CupertinoListTile), findsNothing); - expect( - find.byKey(const ValueKey('shell.destination.pipelines')), - findsOneWidget, - ); - await tester.tap(find.byKey(const ValueKey('shell.destination.runs'))); - await tester.pumpAndSettle(); - expect(find.text('Runs — Not implemented'), findsOneWidget); - }); - - testWidgets('Cupertino content stays inside safe area', (tester) async { - tester.view.physicalSize = const Size(390, 844); - tester.view.devicePixelRatio = 1; - addTearDown(tester.view.resetPhysicalSize); - addTearDown(tester.view.resetDevicePixelRatio); - tester.view.padding = const FakeViewPadding(top: 36, bottom: 28); - addTearDown(tester.view.resetPadding); - await tester.pumpWidget(const MyApp(cupertino: true)); - final tabBar = tester.getRect(find.byType(FloatingDestinationBar)); - expect(tabBar.bottom, lessThanOrEqualTo(900 - 28)); - expect(tester.takeException(), isNull); - }); - testWidgets('destination state survives switching tabs', (tester) async { var builds = 0; await tester.pumpWidget(