Remove Cupertino run action branches
Keep the Material-only run action behavior while preserving public Cupertino parameters for callers that will be cleaned up separately. Narrow the related tests to the supported Material path.
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'action_refusal.dart';
|
import 'action_refusal.dart';
|
||||||
@@ -21,16 +20,8 @@ Future<void> showCancelRunPrompt({
|
|||||||
}) {
|
}) {
|
||||||
final prompt = _CancelPrompt(
|
final prompt = _CancelPrompt(
|
||||||
runId: runId,
|
runId: runId,
|
||||||
cupertino: cupertino,
|
|
||||||
onSubmit: onSubmit,
|
onSubmit: onSubmit,
|
||||||
);
|
);
|
||||||
if (cupertino) {
|
|
||||||
return showCupertinoDialog<void>(
|
|
||||||
context: context,
|
|
||||||
barrierDismissible: false,
|
|
||||||
builder: (_) => prompt,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return showDialog<void>(
|
return showDialog<void>(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
@@ -39,14 +30,9 @@ Future<void> showCancelRunPrompt({
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _CancelPrompt extends StatefulWidget {
|
class _CancelPrompt extends StatefulWidget {
|
||||||
const _CancelPrompt({
|
const _CancelPrompt({required this.runId, required this.onSubmit});
|
||||||
required this.runId,
|
|
||||||
required this.cupertino,
|
|
||||||
required this.onSubmit,
|
|
||||||
});
|
|
||||||
|
|
||||||
final num runId;
|
final num runId;
|
||||||
final bool cupertino;
|
|
||||||
final CancelSubmit onSubmit;
|
final CancelSubmit onSubmit;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -97,8 +83,7 @@ class _CancelPromptState extends State<_CancelPrompt> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final dialog = widget.cupertino ? _cupertino(context) : _material(context);
|
return PopScope(canPop: !_sending, child: _material(context));
|
||||||
return PopScope(canPop: !_sending, child: dialog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get _confirmDisabled => _sending || _checking || _blocked;
|
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}) {
|
Widget _body({required TextStyle errorStyle}) {
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../core/api_gateway.dart';
|
import '../../../core/api_gateway.dart';
|
||||||
@@ -36,14 +35,6 @@ class _CancelRunActionState extends State<CancelRunAction> {
|
|||||||
bool _dialogOpen = false;
|
bool _dialogOpen = false;
|
||||||
Future<bool?>? _resync;
|
Future<bool?>? _resync;
|
||||||
|
|
||||||
bool _usesCupertino(BuildContext context) {
|
|
||||||
final material = Localizations.of<MaterialLocalizations>(
|
|
||||||
context,
|
|
||||||
MaterialLocalizations,
|
|
||||||
);
|
|
||||||
return material == null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _open() async {
|
Future<void> _open() async {
|
||||||
final id = cancelRunId(widget.run);
|
final id = cancelRunId(widget.run);
|
||||||
if (id == null || !canCancelRun(widget.run) || _dialogOpen) return;
|
if (id == null || !canCancelRun(widget.run) || _dialogOpen) return;
|
||||||
@@ -52,7 +43,7 @@ class _CancelRunActionState extends State<CancelRunAction> {
|
|||||||
await showCancelRunPrompt(
|
await showCancelRunPrompt(
|
||||||
context: context,
|
context: context,
|
||||||
runId: id,
|
runId: id,
|
||||||
cupertino: _usesCupertino(context),
|
cupertino: false,
|
||||||
onSubmit: () => _submit(id),
|
onSubmit: () => _submit(id),
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -103,16 +94,6 @@ class _CancelRunActionState extends State<CancelRunAction> {
|
|||||||
if (cancelRunId(widget.run) == null || !canCancelRun(widget.run)) {
|
if (cancelRunId(widget.run) == null || !canCancelRun(widget.run)) {
|
||||||
return const SizedBox.shrink();
|
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(
|
return OutlinedButton(
|
||||||
key: cancelActionKey,
|
key: cancelActionKey,
|
||||||
style: OutlinedButton.styleFrom(
|
style: OutlinedButton.styleFrom(
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../core/api_gateway.dart';
|
import '../../../core/api_gateway.dart';
|
||||||
@@ -30,7 +29,8 @@ class HumanDecisionAction extends StatefulWidget {
|
|||||||
final ApiGateway gateway;
|
final ApiGateway gateway;
|
||||||
final ValueChanged<JsonMap> onRunChanged;
|
final ValueChanged<JsonMap> 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;
|
final bool? cupertino;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -53,15 +53,6 @@ class _HumanDecisionActionState extends State<HumanDecisionAction> {
|
|||||||
_pending = pendingDecision(widget.run);
|
_pending = pendingDecision(widget.run);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _usesCupertino(BuildContext context) {
|
|
||||||
if (widget.cupertino != null) return widget.cupertino!;
|
|
||||||
final material = Localizations.of<MaterialLocalizations>(
|
|
||||||
context,
|
|
||||||
MaterialLocalizations,
|
|
||||||
);
|
|
||||||
return material == null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _open() async {
|
Future<void> _open() async {
|
||||||
final decision = _pending;
|
final decision = _pending;
|
||||||
if (decision == null || _dialogOpen) return;
|
if (decision == null || _dialogOpen) return;
|
||||||
@@ -71,7 +62,7 @@ class _HumanDecisionActionState extends State<HumanDecisionAction> {
|
|||||||
context: context,
|
context: context,
|
||||||
run: widget.run,
|
run: widget.run,
|
||||||
gateway: widget.gateway,
|
gateway: widget.gateway,
|
||||||
cupertino: _usesCupertino(context),
|
cupertino: widget.cupertino ?? false,
|
||||||
onRunChanged: _acceptRun,
|
onRunChanged: _acceptRun,
|
||||||
isCurrent: () => _owns(decision.runId),
|
isCurrent: () => _owns(decision.runId),
|
||||||
);
|
);
|
||||||
@@ -93,13 +84,6 @@ class _HumanDecisionActionState extends State<HumanDecisionAction> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final decision = _pending;
|
final decision = _pending;
|
||||||
if (decision == null) return const SizedBox.shrink();
|
if (decision == null) return const SizedBox.shrink();
|
||||||
if (_usesCupertino(context)) {
|
|
||||||
return CupertinoButton.filled(
|
|
||||||
key: decisionActionKey,
|
|
||||||
onPressed: _open,
|
|
||||||
child: const Text(decisionActionLabel),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return FilledButton(
|
return FilledButton(
|
||||||
key: decisionActionKey,
|
key: decisionActionKey,
|
||||||
onPressed: _open,
|
onPressed: _open,
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../domain/run_decisions.dart';
|
import '../domain/run_decisions.dart';
|
||||||
import '../domain/run_models.dart';
|
import '../domain/run_models.dart';
|
||||||
import 'action_refusal.dart';
|
import 'action_refusal.dart';
|
||||||
import 'decision_option_row.dart';
|
|
||||||
import 'decision_wording.dart';
|
import 'decision_wording.dart';
|
||||||
|
|
||||||
/// Sends the draft to the server. Returns null on success, or an
|
/// Sends the draft to the server. Returns null on success, or an
|
||||||
@@ -19,18 +17,7 @@ Future<void> showHumanDecisionPrompt({
|
|||||||
required bool cupertino,
|
required bool cupertino,
|
||||||
required DecisionSubmit onSubmit,
|
required DecisionSubmit onSubmit,
|
||||||
}) {
|
}) {
|
||||||
final prompt = _DecisionPrompt(
|
final prompt = _DecisionPrompt(decision: decision, onSubmit: onSubmit);
|
||||||
decision: decision,
|
|
||||||
cupertino: cupertino,
|
|
||||||
onSubmit: onSubmit,
|
|
||||||
);
|
|
||||||
if (cupertino) {
|
|
||||||
return showCupertinoDialog<void>(
|
|
||||||
context: context,
|
|
||||||
barrierDismissible: false,
|
|
||||||
builder: (_) => prompt,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return showDialog<void>(
|
return showDialog<void>(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
@@ -39,14 +26,9 @@ Future<void> showHumanDecisionPrompt({
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _DecisionPrompt extends StatefulWidget {
|
class _DecisionPrompt extends StatefulWidget {
|
||||||
const _DecisionPrompt({
|
const _DecisionPrompt({required this.decision, required this.onSubmit});
|
||||||
required this.decision,
|
|
||||||
required this.cupertino,
|
|
||||||
required this.onSubmit,
|
|
||||||
});
|
|
||||||
|
|
||||||
final PendingDecision decision;
|
final PendingDecision decision;
|
||||||
final bool cupertino;
|
|
||||||
final DecisionSubmit onSubmit;
|
final DecisionSubmit onSubmit;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -112,8 +94,7 @@ class _DecisionPromptState extends State<_DecisionPrompt> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final dialog = widget.cupertino ? _cupertino(context) : _material(context);
|
return PopScope(canPop: !_sending, child: _material(context));
|
||||||
return PopScope(canPop: !_sending, child: dialog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get _confirmDisabled => _sending || _checking || _blocked;
|
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({
|
Widget _body({
|
||||||
required TextStyle errorStyle,
|
required TextStyle errorStyle,
|
||||||
required Widget options,
|
required Widget options,
|
||||||
|
|||||||
@@ -1,109 +0,0 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
|
|
||||||
/// One option row in the Cupertino decision prompt, keyed by the option.
|
|
||||||
ValueKey<String> decisionOptionKey(String option) =>
|
|
||||||
ValueKey<String>('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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
import '../../../core/api_gateway.dart';
|
import '../../../core/api_gateway.dart';
|
||||||
import '../../../ui/adaptive/host.dart';
|
|
||||||
import '../data/runs_repository.dart';
|
import '../data/runs_repository.dart';
|
||||||
import '../domain/run_deletion.dart';
|
import '../domain/run_deletion.dart';
|
||||||
import 'delete_runs_dialog.dart';
|
import 'delete_runs_dialog.dart';
|
||||||
@@ -25,7 +24,7 @@ Future<bool> confirmDeleteRuns(
|
|||||||
context: context,
|
context: context,
|
||||||
count: ids.length,
|
count: ids.length,
|
||||||
size: runsSizeLabel(deletable),
|
size: runsSizeLabel(deletable),
|
||||||
cupertino: cupertino ?? usesCupertinoHost(context),
|
cupertino: cupertino ?? false,
|
||||||
onSubmit: () async {
|
onSubmit: () async {
|
||||||
try {
|
try {
|
||||||
onDeleted(await RunsRepository(gateway).deleteRuns(ids));
|
onDeleted(await RunsRepository(gateway).deleteRuns(ids));
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../domain/run_deletion.dart';
|
import '../domain/run_deletion.dart';
|
||||||
@@ -22,23 +21,12 @@ Future<bool> showDeleteRunsPrompt({
|
|||||||
required bool cupertino,
|
required bool cupertino,
|
||||||
required DeleteRunsSubmit onSubmit,
|
required DeleteRunsSubmit onSubmit,
|
||||||
}) async {
|
}) async {
|
||||||
final prompt = _DeleteRunsPrompt(
|
final prompt = _DeleteRunsPrompt(count: count, size: size, onSubmit: onSubmit);
|
||||||
count: count,
|
final result = await showDialog<bool>(
|
||||||
size: size,
|
context: context,
|
||||||
cupertino: cupertino,
|
barrierDismissible: false,
|
||||||
onSubmit: onSubmit,
|
builder: (_) => prompt,
|
||||||
);
|
);
|
||||||
final result = cupertino
|
|
||||||
? await showCupertinoDialog<bool>(
|
|
||||||
context: context,
|
|
||||||
barrierDismissible: false,
|
|
||||||
builder: (_) => prompt,
|
|
||||||
)
|
|
||||||
: await showDialog<bool>(
|
|
||||||
context: context,
|
|
||||||
barrierDismissible: false,
|
|
||||||
builder: (_) => prompt,
|
|
||||||
);
|
|
||||||
return result ?? false;
|
return result ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,13 +34,11 @@ class _DeleteRunsPrompt extends StatefulWidget {
|
|||||||
const _DeleteRunsPrompt({
|
const _DeleteRunsPrompt({
|
||||||
required this.count,
|
required this.count,
|
||||||
required this.size,
|
required this.size,
|
||||||
required this.cupertino,
|
|
||||||
required this.onSubmit,
|
required this.onSubmit,
|
||||||
});
|
});
|
||||||
|
|
||||||
final int count;
|
final int count;
|
||||||
final String? size;
|
final String? size;
|
||||||
final bool cupertino;
|
|
||||||
final DeleteRunsSubmit onSubmit;
|
final DeleteRunsSubmit onSubmit;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -88,7 +74,7 @@ class _DeleteRunsPromptState extends State<_DeleteRunsPrompt> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => PopScope(
|
Widget build(BuildContext context) => PopScope(
|
||||||
canPop: !_sending,
|
canPop: !_sending,
|
||||||
child: widget.cupertino ? _cupertinoDialog(context) : _material(context),
|
child: _material(context),
|
||||||
);
|
);
|
||||||
|
|
||||||
Widget _material(BuildContext 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(
|
Widget _body(TextStyle errorStyle) => Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../core/api_gateway.dart';
|
import '../../../core/api_gateway.dart';
|
||||||
@@ -42,8 +41,6 @@ class RetryRunAction extends StatefulWidget {
|
|||||||
class _RetryRunActionState extends State<RetryRunAction> {
|
class _RetryRunActionState extends State<RetryRunAction> {
|
||||||
bool _dialogOpen = false;
|
bool _dialogOpen = false;
|
||||||
|
|
||||||
bool _usesCupertino(BuildContext context) => _cupertinoLocale(context);
|
|
||||||
|
|
||||||
Future<void> _open() async {
|
Future<void> _open() async {
|
||||||
if (_dialogOpen) return;
|
if (_dialogOpen) return;
|
||||||
_dialogOpen = true;
|
_dialogOpen = true;
|
||||||
@@ -67,14 +64,6 @@ class _RetryRunActionState extends State<RetryRunAction> {
|
|||||||
if (retryRunId(widget.run) == null || !canRetryRun(widget.run)) {
|
if (retryRunId(widget.run) == null || !canRetryRun(widget.run)) {
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
}
|
}
|
||||||
if (_usesCupertino(context)) {
|
|
||||||
return CupertinoButton.tinted(
|
|
||||||
sizeStyle: CupertinoButtonSize.small,
|
|
||||||
key: retryActionKey,
|
|
||||||
onPressed: _open,
|
|
||||||
child: const Text(retryActionLabel),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return OutlinedButton(
|
return OutlinedButton(
|
||||||
key: retryActionKey,
|
key: retryActionKey,
|
||||||
onPressed: _open,
|
onPressed: _open,
|
||||||
@@ -83,10 +72,6 @@ class _RetryRunActionState extends State<RetryRunAction> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _cupertinoLocale(BuildContext context) =>
|
|
||||||
Localizations.of<MaterialLocalizations>(context, MaterialLocalizations) ==
|
|
||||||
null;
|
|
||||||
|
|
||||||
/// Opens the retry prompt for a failed [run]; only its confirm sends
|
/// Opens the retry prompt for a failed [run]; only its confirm sends
|
||||||
/// `retry_run`. An accepted reply reaches [onRunChanged] while [owns] still
|
/// `retry_run`. An accepted reply reaches [onRunChanged] while [owns] still
|
||||||
/// holds, and a new run id opens through [onRunOpened]. A refusal re-reads the
|
/// holds, and a new run id opens through [onRunOpened]. A refusal re-reads the
|
||||||
@@ -121,7 +106,7 @@ Future<void> openRetryRunPrompt(
|
|||||||
await showRetryRunPrompt(
|
await showRetryRunPrompt(
|
||||||
context: context,
|
context: context,
|
||||||
runId: id,
|
runId: id,
|
||||||
cupertino: _cupertinoLocale(context),
|
cupertino: false,
|
||||||
onSubmit: (intent) async {
|
onSubmit: (intent) async {
|
||||||
try {
|
try {
|
||||||
final updated = await repository.retryRun(
|
final updated = await repository.retryRun(
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'action_refusal.dart';
|
import 'action_refusal.dart';
|
||||||
@@ -24,16 +23,8 @@ Future<void> showRetryRunPrompt({
|
|||||||
}) {
|
}) {
|
||||||
final prompt = _RetryPrompt(
|
final prompt = _RetryPrompt(
|
||||||
runId: runId,
|
runId: runId,
|
||||||
cupertino: cupertino,
|
|
||||||
onSubmit: onSubmit,
|
onSubmit: onSubmit,
|
||||||
);
|
);
|
||||||
if (cupertino) {
|
|
||||||
return showCupertinoDialog<void>(
|
|
||||||
context: context,
|
|
||||||
barrierDismissible: false,
|
|
||||||
builder: (_) => prompt,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return showDialog<void>(
|
return showDialog<void>(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
@@ -42,14 +33,9 @@ Future<void> showRetryRunPrompt({
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _RetryPrompt extends StatefulWidget {
|
class _RetryPrompt extends StatefulWidget {
|
||||||
const _RetryPrompt({
|
const _RetryPrompt({required this.runId, required this.onSubmit});
|
||||||
required this.runId,
|
|
||||||
required this.cupertino,
|
|
||||||
required this.onSubmit,
|
|
||||||
});
|
|
||||||
|
|
||||||
final num runId;
|
final num runId;
|
||||||
final bool cupertino;
|
|
||||||
final RetrySubmit onSubmit;
|
final RetrySubmit onSubmit;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -116,8 +102,7 @@ class _RetryPromptState extends State<_RetryPrompt> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final dialog = widget.cupertino ? _cupertino(context) : _material(context);
|
return PopScope(canPop: !_sending, child: _material(context));
|
||||||
return PopScope(canPop: !_sending, child: dialog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get _confirmDisabled => _sending || _checking || _blocked;
|
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}) {
|
Widget _body({required TextStyle errorStyle}) {
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../core/api_gateway.dart';
|
import '../../../core/api_gateway.dart';
|
||||||
import '../../../core/error_reason.dart';
|
import '../../../core/error_reason.dart';
|
||||||
import '../../../ui/adaptive/host.dart';
|
|
||||||
import '../data/runs_repository.dart';
|
import '../data/runs_repository.dart';
|
||||||
|
|
||||||
/// The browser client's export-only repair wording, kept verbatim.
|
/// The browser client's export-only repair wording, kept verbatim.
|
||||||
@@ -131,22 +129,15 @@ class _SessionExportRepairActionState extends State<SessionExportRepairAction> {
|
|||||||
final label = _sending
|
final label = _sending
|
||||||
? sessionExportRepairBusyLabel
|
? sessionExportRepairBusyLabel
|
||||||
: sessionExportRepairLabel;
|
: sessionExportRepairLabel;
|
||||||
final cupertino = usesCupertinoHost(context);
|
final button = TextButton(
|
||||||
final button = cupertino
|
onPressed: enabled ? _send : null,
|
||||||
? CupertinoButton(
|
child: Text(label),
|
||||||
padding: EdgeInsets.zero,
|
);
|
||||||
onPressed: enabled ? _send : null,
|
|
||||||
child: Text(label),
|
|
||||||
)
|
|
||||||
: TextButton(onPressed: enabled ? _send : null, child: Text(label));
|
|
||||||
return Column(
|
return Column(
|
||||||
key: sessionExportRepairKey,
|
key: sessionExportRepairKey,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
if (cupertino)
|
Tooltip(message: sessionExportRepairHelp, child: button),
|
||||||
button
|
|
||||||
else
|
|
||||||
Tooltip(message: sessionExportRepairHelp, child: button),
|
|
||||||
if (_refusal != null)
|
if (_refusal != null)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: 8),
|
padding: const EdgeInsets.only(top: 8),
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../core/api_gateway.dart';
|
import '../../../core/api_gateway.dart';
|
||||||
@@ -33,8 +32,6 @@ class RunTitleAction extends StatefulWidget {
|
|||||||
class _RunTitleActionState extends State<RunTitleAction> {
|
class _RunTitleActionState extends State<RunTitleAction> {
|
||||||
bool _dialogOpen = false;
|
bool _dialogOpen = false;
|
||||||
|
|
||||||
bool _usesCupertino(BuildContext context) => _cupertinoLocale(context);
|
|
||||||
|
|
||||||
Future<void> _open() async {
|
Future<void> _open() async {
|
||||||
if (_dialogOpen) return;
|
if (_dialogOpen) return;
|
||||||
_dialogOpen = true;
|
_dialogOpen = true;
|
||||||
@@ -55,14 +52,6 @@ class _RunTitleActionState extends State<RunTitleAction> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (runTitleId(widget.run) == null) return const SizedBox.shrink();
|
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(
|
return OutlinedButton(
|
||||||
key: runTitleActionKey,
|
key: runTitleActionKey,
|
||||||
onPressed: _open,
|
onPressed: _open,
|
||||||
@@ -71,10 +60,6 @@ class _RunTitleActionState extends State<RunTitleAction> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _cupertinoLocale(BuildContext context) =>
|
|
||||||
Localizations.of<MaterialLocalizations>(context, MaterialLocalizations) ==
|
|
||||||
null;
|
|
||||||
|
|
||||||
/// Opens the rename prompt for [run]; only Save sends `set_run_title`, and the
|
/// Opens the rename prompt for [run]; only Save sends `set_run_title`, and the
|
||||||
/// server's returned detail reaches [onRunChanged] while [owns] still holds
|
/// 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.
|
/// for that run id. Shared by the button and the run detail's more menu.
|
||||||
@@ -92,7 +77,7 @@ Future<void> openRunTitleEditor(
|
|||||||
context: context,
|
context: context,
|
||||||
runId: id,
|
runId: id,
|
||||||
initialTitle: storedRunTitle(run),
|
initialTitle: storedRunTitle(run),
|
||||||
cupertino: _cupertinoLocale(context),
|
cupertino: false,
|
||||||
onSubmit: (title) async {
|
onSubmit: (title) async {
|
||||||
if (saving) return const ActionRefusal(actionAlreadySending);
|
if (saving) return const ActionRefusal(actionAlreadySending);
|
||||||
saving = true;
|
saving = true;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'action_refusal.dart';
|
import 'action_refusal.dart';
|
||||||
@@ -26,16 +25,8 @@ Future<void> showRunTitlePrompt({
|
|||||||
final prompt = _TitlePrompt(
|
final prompt = _TitlePrompt(
|
||||||
runId: runId,
|
runId: runId,
|
||||||
initialTitle: initialTitle,
|
initialTitle: initialTitle,
|
||||||
cupertino: cupertino,
|
|
||||||
onSubmit: onSubmit,
|
onSubmit: onSubmit,
|
||||||
);
|
);
|
||||||
if (cupertino) {
|
|
||||||
return showCupertinoDialog<void>(
|
|
||||||
context: context,
|
|
||||||
barrierDismissible: false,
|
|
||||||
builder: (_) => prompt,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return showDialog<void>(
|
return showDialog<void>(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
@@ -47,13 +38,11 @@ class _TitlePrompt extends StatefulWidget {
|
|||||||
const _TitlePrompt({
|
const _TitlePrompt({
|
||||||
required this.runId,
|
required this.runId,
|
||||||
required this.initialTitle,
|
required this.initialTitle,
|
||||||
required this.cupertino,
|
|
||||||
required this.onSubmit,
|
required this.onSubmit,
|
||||||
});
|
});
|
||||||
|
|
||||||
final num runId;
|
final num runId;
|
||||||
final String initialTitle;
|
final String initialTitle;
|
||||||
final bool cupertino;
|
|
||||||
final TitleSubmit onSubmit;
|
final TitleSubmit onSubmit;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -97,8 +86,7 @@ class _TitlePromptState extends State<_TitlePrompt> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final dialog = widget.cupertino ? _cupertino(context) : _material(context);
|
return PopScope(canPop: !_sending, child: _material(context));
|
||||||
return PopScope(canPop: !_sending, child: dialog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _material(BuildContext 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}) {
|
Widget _body({required Widget field, required TextStyle errorStyle}) {
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:pipelines_app/core/api_gateway.dart';
|
import 'package:pipelines_app/core/api_gateway.dart';
|
||||||
@@ -60,7 +59,6 @@ void main() {
|
|||||||
initial: executingRun(),
|
initial: executingRun(),
|
||||||
changed: changed,
|
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 = <JsonMap>[];
|
|
||||||
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', (
|
testWidgets('the action is absent for runs the web does not cancel', (
|
||||||
tester,
|
tester,
|
||||||
) async {
|
) async {
|
||||||
@@ -178,7 +127,6 @@ void main() {
|
|||||||
initial: run,
|
initial: run,
|
||||||
changed: changed,
|
changed: changed,
|
||||||
),
|
),
|
||||||
cupertino: false,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:pipelines_app/core/api_gateway.dart';
|
import 'package:pipelines_app/core/api_gateway.dart';
|
||||||
@@ -13,7 +12,6 @@ Future<void> _pump(
|
|||||||
WidgetTester tester,
|
WidgetTester tester,
|
||||||
FakeCancelGateway gateway,
|
FakeCancelGateway gateway,
|
||||||
List<JsonMap> changed, {
|
List<JsonMap> changed, {
|
||||||
bool cupertino = false,
|
|
||||||
double textScale = 1,
|
double textScale = 1,
|
||||||
JsonMap? run,
|
JsonMap? run,
|
||||||
}) async {
|
}) async {
|
||||||
@@ -24,7 +22,6 @@ Future<void> _pump(
|
|||||||
initial: run ?? executingRun(),
|
initial: run ?? executingRun(),
|
||||||
changed: changed,
|
changed: changed,
|
||||||
),
|
),
|
||||||
cupertino: cupertino,
|
|
||||||
textScale: textScale,
|
textScale: textScale,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -239,33 +236,20 @@ void main() {
|
|||||||
addTearDown(tester.view.resetPhysicalSize);
|
addTearDown(tester.view.resetPhysicalSize);
|
||||||
addTearDown(tester.view.resetDevicePixelRatio);
|
addTearDown(tester.view.resetDevicePixelRatio);
|
||||||
|
|
||||||
for (final cupertino in [false, true]) {
|
final gateway = FakeCancelGateway(
|
||||||
final gateway = FakeCancelGateway(
|
(type, fields) async => {'run_detail': acceptedCancelRun()},
|
||||||
(type, fields) async => {'run_detail': acceptedCancelRun()},
|
);
|
||||||
);
|
await _pump(tester, gateway, <JsonMap>[], textScale: 2);
|
||||||
await _pump(
|
await tester.tap(find.byKey(cancelActionKey));
|
||||||
tester,
|
await tester.pumpAndSettle();
|
||||||
gateway,
|
|
||||||
<JsonMap>[],
|
|
||||||
cupertino: cupertino,
|
|
||||||
textScale: 2,
|
|
||||||
);
|
|
||||||
await tester.tap(find.byKey(cancelActionKey));
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
|
|
||||||
expect(tester.takeException(), isNull, reason: 'cupertino=$cupertino');
|
expect(tester.takeException(), isNull);
|
||||||
expect(find.text(cancelDialogTitle(7)), findsOneWidget);
|
expect(find.text(cancelDialogTitle(7)), findsOneWidget);
|
||||||
expect(find.text(cancelDialogMessage), findsOneWidget);
|
expect(find.text(cancelDialogMessage), findsOneWidget);
|
||||||
expect(
|
expect(find.byType(AlertDialog), findsOneWidget);
|
||||||
cupertino
|
expect(gateway.calls, isEmpty);
|
||||||
? find.byType(CupertinoAlertDialog)
|
|
||||||
: find.byType(AlertDialog),
|
|
||||||
findsOneWidget,
|
|
||||||
);
|
|
||||||
expect(gateway.calls, isEmpty);
|
|
||||||
|
|
||||||
await tester.tap(find.byKey(cancelKeepKey));
|
await tester.tap(find.byKey(cancelKeepKey));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:pipelines_app/core/api_gateway.dart';
|
import 'package:pipelines_app/core/api_gateway.dart';
|
||||||
import 'package:pipelines_app/features/runs/actions/cancel_run_action.dart';
|
import 'package:pipelines_app/features/runs/actions/cancel_run_action.dart';
|
||||||
@@ -77,23 +76,13 @@ class _CancelHostState extends State<CancelHost> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget cancelApp(
|
Widget cancelApp(Widget child, {double textScale = 1}) {
|
||||||
Widget child, {
|
|
||||||
required bool cupertino,
|
|
||||||
double textScale = 1,
|
|
||||||
}) {
|
|
||||||
Widget media(BuildContext context, Widget? app) => MediaQuery(
|
Widget media(BuildContext context, Widget? app) => MediaQuery(
|
||||||
data: MediaQuery.of(
|
data: MediaQuery.of(
|
||||||
context,
|
context,
|
||||||
).copyWith(textScaler: TextScaler.linear(textScale)),
|
).copyWith(textScaler: TextScaler.linear(textScale)),
|
||||||
child: app!,
|
child: app!,
|
||||||
);
|
);
|
||||||
if (cupertino) {
|
|
||||||
return CupertinoApp(
|
|
||||||
builder: media,
|
|
||||||
home: CupertinoPageScaffold(child: Center(child: child)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
builder: media,
|
builder: media,
|
||||||
home: Scaffold(body: Center(child: child)),
|
home: Scaffold(body: Center(child: child)),
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:pipelines_app/core/api_gateway.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_action.dart';
|
||||||
import 'package:pipelines_app/features/runs/actions/decision_option_row.dart';
|
|
||||||
import 'package:pipelines_app/features/runs/actions/decision_wording.dart';
|
import 'package:pipelines_app/features/runs/actions/decision_wording.dart';
|
||||||
|
|
||||||
typedef _Handler = Future<JsonMap> Function(String type, JsonMap fields);
|
typedef _Handler = Future<JsonMap> Function(String type, JsonMap fields);
|
||||||
@@ -63,18 +61,7 @@ JsonMap _decided() => {
|
|||||||
'steps': const <JsonMap>[],
|
'steps': const <JsonMap>[],
|
||||||
};
|
};
|
||||||
|
|
||||||
Widget _app(Widget child, {required bool cupertino, double textScale = 1}) {
|
Widget _app(Widget child, {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)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
builder: (context, app) => MediaQuery(
|
builder: (context, app) => MediaQuery(
|
||||||
data: MediaQuery.of(
|
data: MediaQuery.of(
|
||||||
@@ -90,7 +77,6 @@ Future<void> _pump(
|
|||||||
WidgetTester tester,
|
WidgetTester tester,
|
||||||
_FakeGateway gateway,
|
_FakeGateway gateway,
|
||||||
JsonMap run, {
|
JsonMap run, {
|
||||||
required bool cupertino,
|
|
||||||
required List<JsonMap> changed,
|
required List<JsonMap> changed,
|
||||||
double textScale = 1,
|
double textScale = 1,
|
||||||
}) async {
|
}) async {
|
||||||
@@ -101,7 +87,6 @@ Future<void> _pump(
|
|||||||
gateway: gateway,
|
gateway: gateway,
|
||||||
onRunChanged: changed.add,
|
onRunChanged: changed.add,
|
||||||
),
|
),
|
||||||
cupertino: cupertino,
|
|
||||||
textScale: textScale,
|
textScale: textScale,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -126,7 +111,6 @@ void main() {
|
|||||||
tester,
|
tester,
|
||||||
gateway,
|
gateway,
|
||||||
_waitingRun(),
|
_waitingRun(),
|
||||||
cupertino: false,
|
|
||||||
changed: changed,
|
changed: changed,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -166,76 +150,41 @@ void main() {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
testWidgets(
|
testWidgets('a decision without feedback omits the field', (tester) async {
|
||||||
'cupertino decision uses a native dialog and omits empty feedback',
|
final gateway = _FakeGateway(
|
||||||
(tester) async {
|
(type, fields) async => {
|
||||||
final gateway = _FakeGateway(
|
'run_detail': type == 'decide_run' ? _decided() : _waitingRun(),
|
||||||
(type, fields) async => {
|
},
|
||||||
'run_detail': type == 'decide_run' ? _decided() : _waitingRun(),
|
);
|
||||||
},
|
final changed = <JsonMap>[];
|
||||||
);
|
await _pump(tester, gateway, _waitingRun(), changed: changed);
|
||||||
final changed = <JsonMap>[];
|
|
||||||
await _pump(
|
|
||||||
tester,
|
|
||||||
gateway,
|
|
||||||
_waitingRun(),
|
|
||||||
cupertino: true,
|
|
||||||
changed: changed,
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(find.byKey(decisionActionKey), findsOneWidget);
|
expect(find.byKey(decisionActionKey), findsOneWidget);
|
||||||
expect(find.byType(FilledButton), findsNothing);
|
expect(find.byType(FilledButton), findsOneWidget);
|
||||||
await _open(tester);
|
await _open(tester);
|
||||||
expect(find.byType(CupertinoAlertDialog), findsOneWidget);
|
expect(find.byType(AlertDialog), findsOneWidget);
|
||||||
expect(find.text(decisionWaitingTitle), findsOneWidget);
|
expect(find.text(decisionWaitingTitle), findsOneWidget);
|
||||||
expect(gateway.calls, isEmpty);
|
expect(gateway.calls, isEmpty);
|
||||||
|
|
||||||
final confirm = find.widgetWithText(
|
final confirm = find.widgetWithText(FilledButton, decisionConfirmLabel);
|
||||||
CupertinoDialogAction,
|
expect(tester.widget<FilledButton>(confirm).onPressed, isNull);
|
||||||
decisionConfirmLabel,
|
await tester.tap(find.text('skip'));
|
||||||
);
|
await tester.pump();
|
||||||
expect(tester.widget<CupertinoDialogAction>(confirm).onPressed, isNull);
|
expect(gateway.calls, isEmpty);
|
||||||
// Options are check-list rows, not blue link buttons: an empty circle
|
expect(tester.widget<FilledButton>(confirm).onPressed, isNotNull);
|
||||||
// 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);
|
|
||||||
|
|
||||||
await tester.tap(find.text(decisionConfirmLabel));
|
await tester.tap(find.text(decisionConfirmLabel));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
expect(gateway.calls.map((call) => call.type), ['decide_run']);
|
expect(gateway.calls.map((call) => call.type), ['decide_run']);
|
||||||
expect(gateway.calls.single.fields, {
|
expect(gateway.calls.single.fields, {
|
||||||
'run_id': 7,
|
'run_id': 7,
|
||||||
'stage': 'human',
|
'stage': 'human',
|
||||||
'option': 'skip',
|
'option': 'skip',
|
||||||
});
|
});
|
||||||
expect(changed.single['status'], 'succeeded');
|
expect(changed.single['status'], 'succeeded');
|
||||||
expect(find.byType(CupertinoAlertDialog), findsNothing);
|
expect(find.byType(AlertDialog), findsNothing);
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
testWidgets('Cancel dismisses the draft without sending anything', (
|
testWidgets('Cancel dismisses the draft without sending anything', (
|
||||||
tester,
|
tester,
|
||||||
@@ -248,7 +197,6 @@ void main() {
|
|||||||
tester,
|
tester,
|
||||||
gateway,
|
gateway,
|
||||||
_waitingRun(),
|
_waitingRun(),
|
||||||
cupertino: false,
|
|
||||||
changed: changed,
|
changed: changed,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -277,7 +225,7 @@ void main() {
|
|||||||
('export pending', _waitingRun(exportPending: 2)),
|
('export pending', _waitingRun(exportPending: 2)),
|
||||||
('model stage', _waitingRun(type: 'model')),
|
('model stage', _waitingRun(type: 'model')),
|
||||||
]) {
|
]) {
|
||||||
await _pump(tester, gateway, run, cupertino: false, changed: changed);
|
await _pump(tester, gateway, run, changed: changed);
|
||||||
expect(
|
expect(
|
||||||
find.byKey(decisionActionKey),
|
find.byKey(decisionActionKey),
|
||||||
findsNothing,
|
findsNothing,
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:pipelines_app/core/api_gateway.dart';
|
import 'package:pipelines_app/core/api_gateway.dart';
|
||||||
@@ -61,19 +60,13 @@ JsonMap _decided() => {
|
|||||||
'steps': const <JsonMap>[],
|
'steps': const <JsonMap>[],
|
||||||
};
|
};
|
||||||
|
|
||||||
Widget _app(Widget child, {required bool cupertino, double textScale = 1}) {
|
Widget _app(Widget child, {double textScale = 1}) {
|
||||||
Widget media(BuildContext context, Widget? app) => MediaQuery(
|
Widget media(BuildContext context, Widget? app) => MediaQuery(
|
||||||
data: MediaQuery.of(
|
data: MediaQuery.of(
|
||||||
context,
|
context,
|
||||||
).copyWith(textScaler: TextScaler.linear(textScale)),
|
).copyWith(textScaler: TextScaler.linear(textScale)),
|
||||||
child: app!,
|
child: app!,
|
||||||
);
|
);
|
||||||
if (cupertino) {
|
|
||||||
return CupertinoApp(
|
|
||||||
builder: media,
|
|
||||||
home: CupertinoPageScaffold(child: Center(child: child)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
builder: media,
|
builder: media,
|
||||||
home: Scaffold(body: Center(child: child)),
|
home: Scaffold(body: Center(child: child)),
|
||||||
@@ -84,7 +77,6 @@ Future<void> _pump(
|
|||||||
WidgetTester tester,
|
WidgetTester tester,
|
||||||
_FakeGateway gateway,
|
_FakeGateway gateway,
|
||||||
List<JsonMap> changed, {
|
List<JsonMap> changed, {
|
||||||
bool cupertino = false,
|
|
||||||
double textScale = 1,
|
double textScale = 1,
|
||||||
}) async {
|
}) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
@@ -94,7 +86,6 @@ Future<void> _pump(
|
|||||||
gateway: gateway,
|
gateway: gateway,
|
||||||
onRunChanged: changed.add,
|
onRunChanged: changed.add,
|
||||||
),
|
),
|
||||||
cupertino: cupertino,
|
|
||||||
textScale: textScale,
|
textScale: textScale,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -323,29 +314,16 @@ void main() {
|
|||||||
addTearDown(tester.view.resetPhysicalSize);
|
addTearDown(tester.view.resetPhysicalSize);
|
||||||
addTearDown(tester.view.resetDevicePixelRatio);
|
addTearDown(tester.view.resetDevicePixelRatio);
|
||||||
|
|
||||||
for (final cupertino in [false, true]) {
|
final gateway = _FakeGateway(
|
||||||
final gateway = _FakeGateway(
|
(type, fields) async => {'run_detail': _decided()},
|
||||||
(type, fields) async => {'run_detail': _decided()},
|
);
|
||||||
);
|
await _pump(tester, gateway, <JsonMap>[], textScale: 2);
|
||||||
await _pump(
|
await tester.tap(find.byKey(decisionActionKey));
|
||||||
tester,
|
await tester.pumpAndSettle();
|
||||||
gateway,
|
|
||||||
<JsonMap>[],
|
|
||||||
cupertino: cupertino,
|
|
||||||
textScale: 2,
|
|
||||||
);
|
|
||||||
await tester.tap(find.byKey(decisionActionKey));
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
|
|
||||||
expect(tester.takeException(), isNull, reason: 'cupertino=$cupertino');
|
expect(tester.takeException(), isNull);
|
||||||
expect(find.text(decisionWaitingTitle), findsOneWidget);
|
expect(find.text(decisionWaitingTitle), findsOneWidget);
|
||||||
expect(find.text('Ship it?'), findsOneWidget);
|
expect(find.text('Ship it?'), findsOneWidget);
|
||||||
expect(
|
expect(find.byType(AlertDialog), findsOneWidget);
|
||||||
cupertino
|
|
||||||
? find.byType(CupertinoAlertDialog)
|
|
||||||
: find.byType(AlertDialog),
|
|
||||||
findsOneWidget,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:pipelines_app/core/api_gateway.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 = <JsonMap>[];
|
|
||||||
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: <JsonMap>[],
|
|
||||||
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', (
|
testWidgets('the action is absent for runs the web does not retry', (
|
||||||
tester,
|
tester,
|
||||||
) async {
|
) async {
|
||||||
@@ -236,25 +160,22 @@ void main() {
|
|||||||
('succeeded', failedRun(status: 'succeeded'), false),
|
('succeeded', failedRun(status: 'succeeded'), false),
|
||||||
('canceled', failedRun(status: 'canceled'), false),
|
('canceled', failedRun(status: 'canceled'), false),
|
||||||
];
|
];
|
||||||
for (final cupertino in [false, true]) {
|
for (final (label, run, visible) in cases) {
|
||||||
for (final (label, run, visible) in cases) {
|
await tester.pumpWidget(
|
||||||
await tester.pumpWidget(
|
retryApp(
|
||||||
retryApp(
|
RetryHost(
|
||||||
RetryHost(
|
key: ValueKey(label),
|
||||||
key: ValueKey('$label-$cupertino'),
|
gateway: gateway,
|
||||||
gateway: gateway,
|
initial: run,
|
||||||
initial: run,
|
changed: changed,
|
||||||
changed: changed,
|
|
||||||
),
|
|
||||||
cupertino: cupertino,
|
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
expect(
|
);
|
||||||
find.byKey(retryActionKey),
|
expect(
|
||||||
visible ? findsOneWidget : findsNothing,
|
find.byKey(retryActionKey),
|
||||||
reason: '$label cupertino=$cupertino',
|
visible ? findsOneWidget : findsNothing,
|
||||||
);
|
reason: label,
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
expect(gateway.calls, isEmpty);
|
expect(gateway.calls, isEmpty);
|
||||||
expect(changed, isEmpty);
|
expect(changed, isEmpty);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:pipelines_app/core/api_gateway.dart';
|
import 'package:pipelines_app/core/api_gateway.dart';
|
||||||
@@ -95,39 +94,31 @@ void main() {
|
|||||||
addTearDown(tester.view.resetPhysicalSize);
|
addTearDown(tester.view.resetPhysicalSize);
|
||||||
addTearDown(tester.view.resetDevicePixelRatio);
|
addTearDown(tester.view.resetDevicePixelRatio);
|
||||||
|
|
||||||
for (final cupertino in [false, true]) {
|
final gateway = FakeRetryGateway(
|
||||||
final gateway = FakeRetryGateway(
|
(type, fields) async => {'run_detail': retriedRun()},
|
||||||
(type, fields) async => {'run_detail': retriedRun()},
|
);
|
||||||
);
|
await pumpRetry(
|
||||||
await pumpRetry(
|
tester,
|
||||||
tester,
|
gateway: gateway,
|
||||||
gateway: gateway,
|
changed: <JsonMap>[],
|
||||||
changed: <JsonMap>[],
|
textScale: 2,
|
||||||
cupertino: cupertino,
|
);
|
||||||
textScale: 2,
|
|
||||||
);
|
|
||||||
|
|
||||||
await tester.tap(find.byKey(retryActionKey));
|
await tester.tap(find.byKey(retryActionKey));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(tester.takeException(), isNull, reason: 'cupertino=$cupertino');
|
expect(tester.takeException(), isNull);
|
||||||
expect(find.text(retryDialogTitle(7)), findsOneWidget);
|
expect(find.text(retryDialogTitle(7)), findsOneWidget);
|
||||||
expect(find.text(retryDialogMessage), findsOneWidget);
|
expect(find.text(retryDialogMessage), findsOneWidget);
|
||||||
expect(
|
expect(find.byType(AlertDialog), findsOneWidget);
|
||||||
cupertino
|
|
||||||
? find.byType(CupertinoAlertDialog)
|
|
||||||
: find.byType(AlertDialog),
|
|
||||||
findsOneWidget,
|
|
||||||
);
|
|
||||||
|
|
||||||
await tester.tap(find.byKey(retryRestartKey));
|
await tester.tap(find.byKey(retryRestartKey));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(tester.takeException(), isNull, reason: 'restart=$cupertino');
|
expect(tester.takeException(), isNull);
|
||||||
expect(find.text(restartDialogTitle(7)), findsOneWidget);
|
expect(find.text(restartDialogTitle(7)), findsOneWidget);
|
||||||
expect(find.text(restartDialogMessage), findsOneWidget);
|
expect(find.text(restartDialogMessage), findsOneWidget);
|
||||||
|
|
||||||
await tester.tap(find.byKey(retryKeepKey));
|
await tester.tap(find.byKey(retryKeepKey));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(gateway.calls, isEmpty);
|
expect(gateway.calls, isEmpty);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:pipelines_app/core/api_gateway.dart';
|
import 'package:pipelines_app/core/api_gateway.dart';
|
||||||
@@ -71,19 +70,13 @@ class _RetryHostState extends State<RetryHost> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget retryApp(Widget child, {required bool cupertino, double textScale = 1}) {
|
Widget retryApp(Widget child, {double textScale = 1}) {
|
||||||
Widget media(BuildContext context, Widget? app) => MediaQuery(
|
Widget media(BuildContext context, Widget? app) => MediaQuery(
|
||||||
data: MediaQuery.of(
|
data: MediaQuery.of(
|
||||||
context,
|
context,
|
||||||
).copyWith(textScaler: TextScaler.linear(textScale)),
|
).copyWith(textScaler: TextScaler.linear(textScale)),
|
||||||
child: app!,
|
child: app!,
|
||||||
);
|
);
|
||||||
if (cupertino) {
|
|
||||||
return CupertinoApp(
|
|
||||||
builder: media,
|
|
||||||
home: CupertinoPageScaffold(child: Center(child: child)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
builder: media,
|
builder: media,
|
||||||
home: Scaffold(body: Center(child: child)),
|
home: Scaffold(body: Center(child: child)),
|
||||||
@@ -94,7 +87,6 @@ Future<void> pumpRetry(
|
|||||||
WidgetTester tester, {
|
WidgetTester tester, {
|
||||||
required FakeRetryGateway gateway,
|
required FakeRetryGateway gateway,
|
||||||
required List<JsonMap> changed,
|
required List<JsonMap> changed,
|
||||||
bool cupertino = false,
|
|
||||||
double textScale = 1,
|
double textScale = 1,
|
||||||
JsonMap? run,
|
JsonMap? run,
|
||||||
}) async {
|
}) async {
|
||||||
@@ -105,7 +97,6 @@ Future<void> pumpRetry(
|
|||||||
initial: run ?? failedRun(),
|
initial: run ?? failedRun(),
|
||||||
changed: changed,
|
changed: changed,
|
||||||
),
|
),
|
||||||
cupertino: cupertino,
|
|
||||||
textScale: textScale,
|
textScale: textScale,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:pipelines_app/core/api_gateway.dart';
|
import 'package:pipelines_app/core/api_gateway.dart';
|
||||||
@@ -11,11 +10,6 @@ import 'title_test_support.dart';
|
|||||||
String _materialFieldText(WidgetTester tester) =>
|
String _materialFieldText(WidgetTester tester) =>
|
||||||
tester.widget<TextField>(find.byKey(runTitleFieldKey)).controller!.text;
|
tester.widget<TextField>(find.byKey(runTitleFieldKey)).controller!.text;
|
||||||
|
|
||||||
String _cupertinoFieldText(WidgetTester tester) => tester
|
|
||||||
.widget<CupertinoTextField>(find.byKey(runTitleFieldKey))
|
|
||||||
.controller!
|
|
||||||
.text;
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets(
|
testWidgets(
|
||||||
'material rename starts from the stored title, typing sends nothing, '
|
'material rename starts from the stored title, typing sends nothing, '
|
||||||
@@ -29,7 +23,6 @@ void main() {
|
|||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
titleApp(
|
titleApp(
|
||||||
TitleHost(gateway: gateway, initial: titledRun(), changed: changed),
|
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 = <JsonMap>[];
|
|
||||||
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', (
|
testWidgets('a blank title is sent exactly and the server refusal is shown', (
|
||||||
tester,
|
tester,
|
||||||
) async {
|
) async {
|
||||||
@@ -145,7 +89,6 @@ void main() {
|
|||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
titleApp(
|
titleApp(
|
||||||
TitleHost(gateway: gateway, initial: titledRun(), changed: changed),
|
TitleHost(gateway: gateway, initial: titledRun(), changed: changed),
|
||||||
cupertino: false,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -189,7 +132,6 @@ void main() {
|
|||||||
),
|
),
|
||||||
changed: changed,
|
changed: changed,
|
||||||
),
|
),
|
||||||
cupertino: false,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
await tester.tap(find.byKey(runTitleActionKey));
|
await tester.tap(find.byKey(runTitleActionKey));
|
||||||
@@ -206,7 +148,6 @@ void main() {
|
|||||||
initial: titledRun(title: null, prompt: 'prompt is not a title'),
|
initial: titledRun(title: null, prompt: 'prompt is not a title'),
|
||||||
changed: changed,
|
changed: changed,
|
||||||
),
|
),
|
||||||
cupertino: false,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
await tester.tap(find.byKey(runTitleActionKey));
|
await tester.tap(find.byKey(runTitleActionKey));
|
||||||
@@ -231,7 +172,6 @@ void main() {
|
|||||||
initial: {'title': 'No id'},
|
initial: {'title': 'No id'},
|
||||||
changed: <JsonMap>[],
|
changed: <JsonMap>[],
|
||||||
),
|
),
|
||||||
cupertino: false,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:pipelines_app/core/api_gateway.dart';
|
import 'package:pipelines_app/core/api_gateway.dart';
|
||||||
@@ -13,7 +12,6 @@ Future<void> _pump(
|
|||||||
WidgetTester tester,
|
WidgetTester tester,
|
||||||
FakeTitleGateway gateway,
|
FakeTitleGateway gateway,
|
||||||
List<JsonMap> changed, {
|
List<JsonMap> changed, {
|
||||||
bool cupertino = false,
|
|
||||||
double textScale = 1,
|
double textScale = 1,
|
||||||
JsonMap? run,
|
JsonMap? run,
|
||||||
}) async {
|
}) async {
|
||||||
@@ -24,7 +22,6 @@ Future<void> _pump(
|
|||||||
initial: run ?? titledRun(),
|
initial: run ?? titledRun(),
|
||||||
changed: changed,
|
changed: changed,
|
||||||
),
|
),
|
||||||
cupertino: cupertino,
|
|
||||||
textScale: textScale,
|
textScale: textScale,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -35,18 +32,10 @@ Future<void> _open(WidgetTester tester) async {
|
|||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
}
|
}
|
||||||
|
|
||||||
String _fieldText(WidgetTester tester, {required bool cupertino}) {
|
String _fieldText(WidgetTester tester) => tester
|
||||||
if (cupertino) {
|
.widget<TextField>(find.byKey(runTitleFieldKey))
|
||||||
return tester
|
.controller!
|
||||||
.widget<CupertinoTextField>(find.byKey(runTitleFieldKey))
|
.text;
|
||||||
.controller!
|
|
||||||
.text;
|
|
||||||
}
|
|
||||||
return tester
|
|
||||||
.widget<TextField>(find.byKey(runTitleFieldKey))
|
|
||||||
.controller!
|
|
||||||
.text;
|
|
||||||
}
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('a failed save keeps the prompt open with the draft intact', (
|
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.text(refusal), findsOneWidget);
|
||||||
expect(find.byKey(runTitleErrorKey), findsOneWidget);
|
expect(find.byKey(runTitleErrorKey), findsOneWidget);
|
||||||
expect(_fieldText(tester, cupertino: false), ' Renamed draft ');
|
expect(_fieldText(tester), ' Renamed draft ');
|
||||||
expect(find.byType(AlertDialog), findsOneWidget);
|
expect(find.byType(AlertDialog), findsOneWidget);
|
||||||
expect(changed, isEmpty);
|
expect(changed, isEmpty);
|
||||||
expect(
|
expect(
|
||||||
@@ -87,7 +76,7 @@ void main() {
|
|||||||
(type, fields) async => throw const NotConnectedError(),
|
(type, fields) async => throw const NotConnectedError(),
|
||||||
);
|
);
|
||||||
final changed = <JsonMap>[];
|
final changed = <JsonMap>[];
|
||||||
await _pump(tester, gateway, changed, cupertino: true);
|
await _pump(tester, gateway, changed);
|
||||||
|
|
||||||
await _open(tester);
|
await _open(tester);
|
||||||
await tester.enterText(find.byKey(runTitleFieldKey), 'Unsent title');
|
await tester.enterText(find.byKey(runTitleFieldKey), 'Unsent title');
|
||||||
@@ -95,8 +84,8 @@ void main() {
|
|||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
expect(find.byKey(runTitleErrorKey), findsOneWidget);
|
expect(find.byKey(runTitleErrorKey), findsOneWidget);
|
||||||
expect(_fieldText(tester, cupertino: true), 'Unsent title');
|
expect(_fieldText(tester), 'Unsent title');
|
||||||
expect(find.byType(CupertinoAlertDialog), findsOneWidget);
|
expect(find.byType(AlertDialog), findsOneWidget);
|
||||||
expect(changed, isEmpty);
|
expect(changed, isEmpty);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -172,7 +161,6 @@ void main() {
|
|||||||
initial: titledRun(id: 8, title: 'Another run'),
|
initial: titledRun(id: 8, title: 'Another run'),
|
||||||
changed: changed,
|
changed: changed,
|
||||||
),
|
),
|
||||||
cupertino: false,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
@@ -198,46 +186,32 @@ void main() {
|
|||||||
addTearDown(tester.view.resetDevicePixelRatio);
|
addTearDown(tester.view.resetDevicePixelRatio);
|
||||||
|
|
||||||
const refusal = 'the title is too long for this run; shorten it';
|
const refusal = 'the title is too long for this run; shorten it';
|
||||||
for (final cupertino in [false, true]) {
|
final gateway = FakeTitleGateway(
|
||||||
final gateway = FakeTitleGateway(
|
(type, fields) async => throw const ProtocolError(refusal),
|
||||||
(type, fields) async => throw const ProtocolError(refusal),
|
);
|
||||||
);
|
await _pump(tester, gateway, <JsonMap>[], textScale: 2);
|
||||||
await _pump(
|
await _open(tester);
|
||||||
tester,
|
|
||||||
gateway,
|
|
||||||
<JsonMap>[],
|
|
||||||
cupertino: cupertino,
|
|
||||||
textScale: 2,
|
|
||||||
);
|
|
||||||
await _open(tester);
|
|
||||||
|
|
||||||
expect(tester.takeException(), isNull, reason: 'cupertino=$cupertino');
|
expect(tester.takeException(), isNull);
|
||||||
expect(
|
expect(find.byType(AlertDialog), findsOneWidget);
|
||||||
cupertino
|
expect(find.text(runTitleFieldLabel), findsOneWidget);
|
||||||
? find.byType(CupertinoAlertDialog)
|
expect(gateway.calls, isEmpty);
|
||||||
: find.byType(AlertDialog),
|
|
||||||
findsOneWidget,
|
|
||||||
);
|
|
||||||
expect(find.text(runTitleFieldLabel), findsOneWidget);
|
|
||||||
expect(gateway.calls, isEmpty);
|
|
||||||
|
|
||||||
await tester.enterText(
|
await tester.enterText(
|
||||||
find.byKey(runTitleFieldKey),
|
find.byKey(runTitleFieldKey),
|
||||||
'A deliberately long title that must scroll rather than overflow',
|
'A deliberately long title that must scroll rather than overflow',
|
||||||
);
|
);
|
||||||
await tester.tap(find.byKey(runTitleSaveKey));
|
await tester.tap(find.byKey(runTitleSaveKey));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(tester.takeException(), isNull, reason: 'cupertino=$cupertino');
|
expect(tester.takeException(), isNull);
|
||||||
expect(find.text(refusal), findsOneWidget);
|
expect(find.text(refusal), findsOneWidget);
|
||||||
expect(
|
expect(
|
||||||
_fieldText(tester, cupertino: cupertino),
|
_fieldText(tester),
|
||||||
'A deliberately long title that must scroll rather than overflow',
|
'A deliberately long title that must scroll rather than overflow',
|
||||||
);
|
);
|
||||||
|
|
||||||
await tester.tap(find.byKey(runTitleCancelKey));
|
await tester.tap(find.byKey(runTitleCancelKey));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(find.byType(AlertDialog), findsNothing);
|
expect(find.byType(AlertDialog), findsNothing);
|
||||||
expect(find.byType(CupertinoAlertDialog), findsNothing);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:pipelines_app/core/api_gateway.dart';
|
import 'package:pipelines_app/core/api_gateway.dart';
|
||||||
import 'package:pipelines_app/features/runs/actions/title_action.dart';
|
import 'package:pipelines_app/features/runs/actions/title_action.dart';
|
||||||
@@ -89,22 +88,15 @@ class _TitleHostState extends State<TitleHost> {
|
|||||||
|
|
||||||
const titleHostTitleKey = ValueKey<String>('rename-host-title');
|
const titleHostTitleKey = ValueKey<String>('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(
|
Widget media(BuildContext context, Widget? app) => MediaQuery(
|
||||||
data: MediaQuery.of(
|
data: MediaQuery.of(
|
||||||
context,
|
context,
|
||||||
).copyWith(textScaler: TextScaler.linear(textScale)),
|
).copyWith(textScaler: TextScaler.linear(textScale)),
|
||||||
child: app!,
|
child: app!,
|
||||||
);
|
);
|
||||||
final body = Center(child: child);
|
|
||||||
if (cupertino) {
|
|
||||||
return CupertinoApp(
|
|
||||||
builder: media,
|
|
||||||
home: CupertinoPageScaffold(child: body),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
builder: media,
|
builder: media,
|
||||||
home: Scaffold(body: body),
|
home: Scaffold(body: Center(child: child)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:pipelines_app/ui/status/run_status_icon.dart';
|
import 'package:pipelines_app/ui/status/run_status_icon.dart';
|
||||||
@@ -39,57 +38,49 @@ class _Gateway implements ApiGateway {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
for (final cupertino in [false, true]) {
|
testWidgets('actual detail confirms cancel and folds accepted state', (
|
||||||
testWidgets(
|
tester,
|
||||||
'actual detail confirms cancel and folds accepted state ($cupertino)',
|
) async {
|
||||||
(tester) async {
|
final gateway = _Gateway();
|
||||||
final gateway = _Gateway();
|
addTearDown(gateway.events.close);
|
||||||
addTearDown(gateway.events.close);
|
final screen = RunsScreen(gateway: gateway, initialRunId: 7);
|
||||||
final screen = RunsScreen(gateway: gateway, initialRunId: 7);
|
await tester.pumpWidget(MaterialApp(home: Scaffold(body: screen)));
|
||||||
await tester.pumpWidget(
|
await tester.pumpAndSettle();
|
||||||
cupertino
|
await tester.tap(find.byKey(cancelActionKey));
|
||||||
? CupertinoApp(home: CupertinoPageScaffold(child: screen))
|
await tester.pumpAndSettle();
|
||||||
: MaterialApp(home: Scaffold(body: screen)),
|
expect(find.text('Cancel run 7?'), findsOneWidget);
|
||||||
);
|
expect(gateway.requests.where((r) => r.type == 'cancel_run'), isEmpty);
|
||||||
await tester.pumpAndSettle();
|
await tester.tap(find.byKey(cancelKeepKey));
|
||||||
await tester.tap(find.byKey(cancelActionKey));
|
await tester.pumpAndSettle();
|
||||||
await tester.pumpAndSettle();
|
expect(gateway.requests.where((r) => r.type == 'cancel_run'), isEmpty);
|
||||||
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.tap(find.byKey(cancelActionKey));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await tester.tap(find.byKey(cancelConfirmKey));
|
await tester.tap(find.byKey(cancelConfirmKey));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(
|
expect(
|
||||||
gateway.requests.where((r) => r.type == 'cancel_run').single.fields,
|
gateway.requests.where((r) => r.type == 'cancel_run').single.fields,
|
||||||
{'run_id': 7},
|
{'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());
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
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());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'run_detail_finders.dart';
|
import 'run_detail_finders.dart';
|
||||||
@@ -90,41 +89,30 @@ Future<void> _pump(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
for (final cupertino in [false, true]) {
|
testWidgets('a decide route opens the waiting prompt', (tester) async {
|
||||||
testWidgets('a decide route opens the waiting prompt ($cupertino)', (
|
final gateway = _Gateway(_waitingRun());
|
||||||
tester,
|
addTearDown(gateway.close);
|
||||||
) async {
|
tester.view.physicalSize = const Size(900, 1000);
|
||||||
final gateway = _Gateway(_waitingRun());
|
tester.view.devicePixelRatio = 1;
|
||||||
addTearDown(gateway.close);
|
addTearDown(tester.view.reset);
|
||||||
tester.view.physicalSize = const Size(900, 1000);
|
final screen = RunsScreen(
|
||||||
tester.view.devicePixelRatio = 1;
|
gateway: gateway,
|
||||||
addTearDown(tester.view.reset);
|
initialRunId: 9,
|
||||||
final screen = RunsScreen(
|
initialDecide: true,
|
||||||
gateway: gateway,
|
);
|
||||||
initialRunId: 9,
|
await tester.pumpWidget(MaterialApp(home: Scaffold(body: screen)));
|
||||||
initialDecide: true,
|
await tester.pumpAndSettle();
|
||||||
);
|
|
||||||
await tester.pumpWidget(
|
|
||||||
cupertino
|
|
||||||
? CupertinoApp(home: CupertinoPageScaffold(child: screen))
|
|
||||||
: MaterialApp(home: Scaffold(body: screen)),
|
|
||||||
);
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
|
|
||||||
expect(find.byKey(decisionFeedbackKey), findsOneWidget);
|
expect(find.byKey(decisionFeedbackKey), findsOneWidget);
|
||||||
expect(
|
expect(find.text('Please review this recorded checkpoint.'), findsOneWidget);
|
||||||
find.text('Please review this recorded checkpoint.'),
|
|
||||||
findsOneWidget,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Closing the prompt leaves the loaded detail underneath.
|
// Closing the prompt leaves the loaded detail underneath.
|
||||||
await tester.tap(find.text(decisionCancelLabel));
|
await tester.tap(find.text(decisionCancelLabel));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(find.byKey(decisionFeedbackKey), findsNothing);
|
expect(find.byKey(decisionFeedbackKey), findsNothing);
|
||||||
expect(runDetailText('Human checkpoint'), findsOneWidget);
|
expect(runDetailText('Human checkpoint'), findsOneWidget);
|
||||||
expect(find.byKey(decisionActionKey), findsOneWidget);
|
expect(find.byKey(decisionActionKey), findsOneWidget);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
testWidgets('a decide route on a non-waiting run invents no prompt', (
|
testWidgets('a decide route on a non-waiting run invents no prompt', (
|
||||||
tester,
|
tester,
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:pipelines_app/core/api_gateway.dart';
|
import 'package:pipelines_app/core/api_gateway.dart';
|
||||||
@@ -60,74 +59,63 @@ class _DecisionGateway implements ApiGateway {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
for (final cupertino in [false, true]) {
|
testWidgets('actual detail exposes and confirms recorded decision', (
|
||||||
testWidgets(
|
tester,
|
||||||
'actual detail exposes and confirms recorded decision ($cupertino)',
|
) async {
|
||||||
(tester) async {
|
final gateway = _DecisionGateway();
|
||||||
final gateway = _DecisionGateway();
|
addTearDown(gateway.events.close);
|
||||||
addTearDown(gateway.events.close);
|
final screen = RunsScreen(gateway: gateway, initialRunId: 9);
|
||||||
final screen = RunsScreen(gateway: gateway, initialRunId: 9);
|
await tester.pumpWidget(MaterialApp(home: Scaffold(body: screen)));
|
||||||
await tester.pumpWidget(
|
await tester.pumpAndSettle();
|
||||||
cupertino
|
expect(find.text(decisionWaitingTitle), findsOneWidget);
|
||||||
? CupertinoApp(home: CupertinoPageScaffold(child: screen))
|
// The web's decision banner spans the header's glass strip (under
|
||||||
: MaterialApp(home: Scaffold(body: screen)),
|
// the top bar, 12 in from the pane) at the strip's 12px inset, with
|
||||||
);
|
// Decide trailing.
|
||||||
await tester.pumpAndSettle();
|
final banner = tester.getRect(find.byKey(const Key('run-decision-banner')));
|
||||||
expect(find.text(decisionWaitingTitle), findsOneWidget);
|
final strip = tester.getRect(
|
||||||
// The web's decision banner spans the header's glass strip (under
|
find.descendant(
|
||||||
// the top bar, 12 in from the pane) at the strip's 12px inset, with
|
of: find.byKey(const Key('run-detail-header')),
|
||||||
// Decide trailing.
|
matching: find.byType(GlassPill),
|
||||||
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());
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
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());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ void main() {
|
|||||||
await mountRetryScreen(
|
await mountRetryScreen(
|
||||||
tester,
|
tester,
|
||||||
gateway,
|
gateway,
|
||||||
cupertino: false,
|
|
||||||
onRunSelected: opened.add,
|
onRunSelected: opened.add,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -40,7 +39,6 @@ void main() {
|
|||||||
await mountRetryScreen(
|
await mountRetryScreen(
|
||||||
tester,
|
tester,
|
||||||
gateway,
|
gateway,
|
||||||
cupertino: false,
|
|
||||||
onRunSelected: opened.add,
|
onRunSelected: opened.add,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -65,7 +63,6 @@ void main() {
|
|||||||
await mountRetryScreen(
|
await mountRetryScreen(
|
||||||
tester,
|
tester,
|
||||||
gateway,
|
gateway,
|
||||||
cupertino: false,
|
|
||||||
onRunSelected: opened.add,
|
onRunSelected: opened.add,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -87,7 +84,6 @@ void main() {
|
|||||||
await mountRetryScreen(
|
await mountRetryScreen(
|
||||||
tester,
|
tester,
|
||||||
gateway,
|
gateway,
|
||||||
cupertino: false,
|
|
||||||
onRunSelected: opened.add,
|
onRunSelected: opened.add,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -107,7 +103,7 @@ void main() {
|
|||||||
) async {
|
) async {
|
||||||
final gateway = RetryWiringGateway(executing: true);
|
final gateway = RetryWiringGateway(executing: true);
|
||||||
addTearDown(gateway.framesController.close);
|
addTearDown(gateway.framesController.close);
|
||||||
await mountRetryScreen(tester, gateway, cupertino: false);
|
await mountRetryScreen(tester, gateway);
|
||||||
|
|
||||||
expect(find.byKey(runMoreMenuKey), findsOneWidget);
|
expect(find.byKey(runMoreMenuKey), findsOneWidget);
|
||||||
expect(await retryOffered(tester), isFalse);
|
expect(await retryOffered(tester), isFalse);
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:pipelines_app/features/runs/actions/cancel_wording.dart';
|
import 'package:pipelines_app/features/runs/actions/cancel_wording.dart';
|
||||||
@@ -36,57 +35,48 @@ void main() {
|
|||||||
expect(cancel.left, closeTo(16, 0.5));
|
expect(cancel.left, closeTo(16, 0.5));
|
||||||
});
|
});
|
||||||
|
|
||||||
for (final cupertino in [false, true]) {
|
testWidgets('320 px at 2x keeps Retry reachable', (tester) async {
|
||||||
testWidgets('320 px at 2x keeps Retry reachable ($cupertino)', (
|
tester.view.physicalSize = const Size(320, 480);
|
||||||
tester,
|
tester.view.devicePixelRatio = 1;
|
||||||
) async {
|
addTearDown(tester.view.resetPhysicalSize);
|
||||||
tester.view.physicalSize = const Size(320, 480);
|
addTearDown(tester.view.resetDevicePixelRatio);
|
||||||
tester.view.devicePixelRatio = 1;
|
|
||||||
addTearDown(tester.view.resetPhysicalSize);
|
|
||||||
addTearDown(tester.view.resetDevicePixelRatio);
|
|
||||||
|
|
||||||
final gateway = RetryWiringGateway();
|
final gateway = RetryWiringGateway();
|
||||||
addTearDown(gateway.framesController.close);
|
addTearDown(gateway.framesController.close);
|
||||||
Widget scale(BuildContext context, Widget? app) => MediaQuery(
|
Widget scale(BuildContext context, Widget? app) => MediaQuery(
|
||||||
data: MediaQuery.of(
|
data: MediaQuery.of(
|
||||||
context,
|
context,
|
||||||
).copyWith(textScaler: const TextScaler.linear(2)),
|
).copyWith(textScaler: const TextScaler.linear(2)),
|
||||||
child: app!,
|
child: app!,
|
||||||
);
|
);
|
||||||
// The action row itself, in the detail's 16 px inset, so the narrow
|
// The action row itself, in the detail's 16 px inset, so the narrow
|
||||||
// accessibility state is measured without unrelated header controls.
|
// accessibility state is measured without unrelated header controls.
|
||||||
final row = Padding(
|
final row = Padding(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
child: RunDetailActions(
|
child: RunDetailActions(
|
||||||
run: retryFailedDetail(),
|
run: retryFailedDetail(),
|
||||||
gateway: gateway,
|
gateway: gateway,
|
||||||
onRunChanged: (_) {},
|
onRunChanged: (_) {},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
cupertino
|
MaterialApp(
|
||||||
? CupertinoApp(
|
builder: scale,
|
||||||
builder: scale,
|
home: Scaffold(body: row),
|
||||||
home: CupertinoPageScaffold(child: SafeArea(child: row)),
|
),
|
||||||
)
|
);
|
||||||
: MaterialApp(
|
await tester.pumpAndSettle();
|
||||||
builder: scale,
|
|
||||||
home: Scaffold(body: row),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
|
|
||||||
expect(find.byKey(retryActionKey).hitTestable(), findsOneWidget);
|
expect(find.byKey(retryActionKey).hitTestable(), findsOneWidget);
|
||||||
final rect = tester.getRect(find.byKey(retryActionKey));
|
final rect = tester.getRect(find.byKey(retryActionKey));
|
||||||
expect(rect.left, greaterThanOrEqualTo(0));
|
expect(rect.left, greaterThanOrEqualTo(0));
|
||||||
expect(rect.right, lessThanOrEqualTo(320));
|
expect(rect.right, lessThanOrEqualTo(320));
|
||||||
|
|
||||||
await tester.tap(find.byKey(retryActionKey));
|
await tester.tap(find.byKey(retryActionKey));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(find.text(retryDialogTitle(7)), findsOneWidget);
|
expect(find.text(retryDialogTitle(7)), findsOneWidget);
|
||||||
await tester.tap(find.byKey(retryKeepKey));
|
await tester.tap(find.byKey(retryKeepKey));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(gateway.retryCalls, isEmpty);
|
expect(gateway.retryCalls, isEmpty);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:pipelines_app/features/runs/ui/run_more_menu.dart';
|
import 'package:pipelines_app/features/runs/ui/run_more_menu.dart';
|
||||||
@@ -88,7 +87,6 @@ class RetryWiringGateway implements ApiGateway {
|
|||||||
Future<void> mountRetryScreen(
|
Future<void> mountRetryScreen(
|
||||||
WidgetTester tester,
|
WidgetTester tester,
|
||||||
RetryWiringGateway gateway, {
|
RetryWiringGateway gateway, {
|
||||||
required bool cupertino,
|
|
||||||
ValueChanged<int>? onRunSelected,
|
ValueChanged<int>? onRunSelected,
|
||||||
}) async {
|
}) async {
|
||||||
final screen = RunsScreen(
|
final screen = RunsScreen(
|
||||||
@@ -96,13 +94,7 @@ Future<void> mountRetryScreen(
|
|||||||
initialRunId: 7,
|
initialRunId: 7,
|
||||||
onRunSelected: onRunSelected,
|
onRunSelected: onRunSelected,
|
||||||
);
|
);
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(MaterialApp(home: Scaffold(body: screen)));
|
||||||
cupertino
|
|
||||||
? CupertinoApp(
|
|
||||||
home: CupertinoPageScaffold(child: SafeArea(child: screen)),
|
|
||||||
)
|
|
||||||
: MaterialApp(home: Scaffold(body: screen)),
|
|
||||||
);
|
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,65 +7,55 @@ import 'run_retry_wiring_support.dart';
|
|||||||
import 'run_detail_finders.dart';
|
import 'run_detail_finders.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
for (final cupertino in [false, true]) {
|
testWidgets(
|
||||||
testWidgets(
|
'accepted retry reply opens the server-identified run',
|
||||||
'accepted retry reply opens the server-identified run ($cupertino)',
|
(tester) async {
|
||||||
(tester) async {
|
final gateway = RetryWiringGateway();
|
||||||
final gateway = RetryWiringGateway();
|
addTearDown(gateway.framesController.close);
|
||||||
addTearDown(gateway.framesController.close);
|
final opened = <int>[];
|
||||||
final opened = <int>[];
|
await mountRetryScreen(tester, gateway, onRunSelected: opened.add);
|
||||||
await mountRetryScreen(
|
|
||||||
tester,
|
|
||||||
gateway,
|
|
||||||
cupertino: cupertino,
|
|
||||||
onRunSelected: opened.add,
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(runDetailText(retryFailedTitle), findsOneWidget);
|
expect(runDetailText(retryFailedTitle), findsOneWidget);
|
||||||
expect(find.byKey(runMoreMenuKey), findsOneWidget);
|
expect(find.byKey(runMoreMenuKey), findsOneWidget);
|
||||||
expect(await retryOffered(tester), isTrue);
|
expect(await retryOffered(tester), isTrue);
|
||||||
expect(find.byKey(cancelActionKey), findsNothing);
|
expect(find.byKey(cancelActionKey), findsNothing);
|
||||||
expect(gateway.retryCalls, isEmpty);
|
expect(gateway.retryCalls, isEmpty);
|
||||||
|
|
||||||
await openRetry(tester);
|
await openRetry(tester);
|
||||||
expect(find.text(retryDialogTitle(7)), findsOneWidget);
|
expect(find.text(retryDialogTitle(7)), findsOneWidget);
|
||||||
expect(find.text(retryDialogMessage), findsOneWidget);
|
expect(find.text(retryDialogMessage), findsOneWidget);
|
||||||
expect(gateway.retryCalls, isEmpty);
|
expect(gateway.retryCalls, isEmpty);
|
||||||
|
|
||||||
await tester.tap(find.byKey(retryKeepKey));
|
await tester.tap(find.byKey(retryKeepKey));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(gateway.retryCalls, isEmpty);
|
expect(gateway.retryCalls, isEmpty);
|
||||||
expect(opened, isEmpty);
|
expect(opened, isEmpty);
|
||||||
expect(await retryOffered(tester), isTrue);
|
expect(await retryOffered(tester), isTrue);
|
||||||
|
|
||||||
await confirmRetry(tester);
|
await confirmRetry(tester);
|
||||||
expect(gateway.retryCalls, hasLength(1));
|
expect(gateway.retryCalls, hasLength(1));
|
||||||
final fields = gateway.retryCalls.single.fields;
|
final fields = gateway.retryCalls.single.fields;
|
||||||
expect(fields.keys.toSet(), {'run_id', 'request_key'});
|
expect(fields.keys.toSet(), {'run_id', 'request_key'});
|
||||||
expect(fields['run_id'], 7);
|
expect(fields['run_id'], 7);
|
||||||
expect(fields['request_key'], startsWith('app-retry-7-'));
|
expect(fields['request_key'], startsWith('app-retry-7-'));
|
||||||
expect(
|
expect((fields['request_key'] as String).length, lessThanOrEqualTo(128));
|
||||||
(fields['request_key'] as String).length,
|
// The prompt closes only from server truth; no navigation is guessed.
|
||||||
lessThanOrEqualTo(128),
|
expect(opened, isEmpty);
|
||||||
);
|
expect(runDetailText(retryFailedTitle), findsOneWidget);
|
||||||
// The prompt closes only from server truth; no navigation is guessed.
|
|
||||||
expect(opened, isEmpty);
|
|
||||||
expect(runDetailText(retryFailedTitle), findsOneWidget);
|
|
||||||
|
|
||||||
gateway.acceptRetry(retryCreatedDetail());
|
gateway.acceptRetry(retryCreatedDetail());
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
expect(opened, [8]);
|
expect(opened, [8]);
|
||||||
expect(runDetailText(retryCreatedTitle), findsOneWidget);
|
expect(runDetailText(retryCreatedTitle), findsOneWidget);
|
||||||
expect(runDetailText(retryFailedTitle), findsNothing);
|
expect(runDetailText(retryFailedTitle), findsNothing);
|
||||||
expect(await retryOffered(tester), isFalse);
|
expect(await retryOffered(tester), isFalse);
|
||||||
expect(
|
expect(
|
||||||
gateway.calls.where((call) => call.type == 'get_run').last.fields,
|
gateway.calls.where((call) => call.type == 'get_run').last.fields,
|
||||||
{'run_id': 8},
|
{'run_id': 8},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
testWidgets('restart sends its explicit mode through the real detail row', (
|
testWidgets('restart sends its explicit mode through the real detail row', (
|
||||||
tester,
|
tester,
|
||||||
@@ -73,12 +63,7 @@ void main() {
|
|||||||
final gateway = RetryWiringGateway();
|
final gateway = RetryWiringGateway();
|
||||||
addTearDown(gateway.framesController.close);
|
addTearDown(gateway.framesController.close);
|
||||||
final opened = <int>[];
|
final opened = <int>[];
|
||||||
await mountRetryScreen(
|
await mountRetryScreen(tester, gateway, onRunSelected: opened.add);
|
||||||
tester,
|
|
||||||
gateway,
|
|
||||||
cupertino: false,
|
|
||||||
onRunSelected: opened.add,
|
|
||||||
);
|
|
||||||
|
|
||||||
await openRetry(tester);
|
await openRetry(tester);
|
||||||
await tester.tap(find.byKey(retryRestartKey));
|
await tester.tap(find.byKey(retryRestartKey));
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:pipelines_app/core/api_gateway.dart';
|
import 'package:pipelines_app/core/api_gateway.dart';
|
||||||
@@ -100,16 +99,9 @@ Future<void> _pumpSession(
|
|||||||
WidgetTester tester,
|
WidgetTester tester,
|
||||||
_RepairGateway gateway, {
|
_RepairGateway gateway, {
|
||||||
JsonMap? run,
|
JsonMap? run,
|
||||||
bool cupertino = false,
|
|
||||||
}) {
|
}) {
|
||||||
final host = _SessionHost(run: run ?? partialRun(), gateway: gateway);
|
final host = _SessionHost(run: run ?? partialRun(), gateway: gateway);
|
||||||
return tester.pumpWidget(
|
return tester.pumpWidget(MaterialApp(home: Scaffold(body: host)));
|
||||||
cupertino
|
|
||||||
? CupertinoApp(
|
|
||||||
home: CupertinoPageScaffold(child: SafeArea(child: host)),
|
|
||||||
)
|
|
||||||
: MaterialApp(home: Scaffold(body: host)),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TextButton _materialButton(WidgetTester tester) => tester.widget<TextButton>(
|
TextButton _materialButton(WidgetTester tester) => tester.widget<TextButton>(
|
||||||
@@ -254,18 +246,15 @@ void main() {
|
|||||||
expect(find.text('partial'), findsOneWidget);
|
expect(find.text('partial'), findsOneWidget);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('the Cupertino host uses a native Cupertino button', (
|
testWidgets('the repair control is a Material text button', (tester) async {
|
||||||
tester,
|
|
||||||
) async {
|
|
||||||
final gateway = _RepairGateway(
|
final gateway = _RepairGateway(
|
||||||
(_, _) => Future<JsonMap>.error(StateError('unexpected')),
|
(_, _) => Future<JsonMap>.error(StateError('unexpected')),
|
||||||
);
|
);
|
||||||
await _pumpSession(tester, gateway, cupertino: true);
|
await _pumpSession(tester, gateway);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
find.widgetWithText(CupertinoButton, 'Retry export only'),
|
find.widgetWithText(TextButton, 'Retry export only'),
|
||||||
findsOneWidget,
|
findsOneWidget,
|
||||||
);
|
);
|
||||||
expect(find.widgetWithText(TextButton, 'Retry export only'), findsNothing);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'run_detail_finders.dart';
|
import 'run_detail_finders.dart';
|
||||||
@@ -65,28 +64,17 @@ class _Gateway implements ApiGateway {
|
|||||||
|
|
||||||
Future<_Gateway> _mount(
|
Future<_Gateway> _mount(
|
||||||
WidgetTester tester, {
|
WidgetTester tester, {
|
||||||
required bool cupertino,
|
|
||||||
int initialRunId = 1,
|
int initialRunId = 1,
|
||||||
}) async {
|
}) async {
|
||||||
final gateway = _Gateway();
|
final gateway = _Gateway();
|
||||||
final screen = RunsScreen(gateway: gateway, initialRunId: initialRunId);
|
final screen = RunsScreen(gateway: gateway, initialRunId: initialRunId);
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(MaterialApp(home: Scaffold(body: screen)));
|
||||||
cupertino
|
|
||||||
? CupertinoApp(
|
|
||||||
home: CupertinoPageScaffold(child: SafeArea(child: screen)),
|
|
||||||
)
|
|
||||||
: MaterialApp(home: Scaffold(body: screen)),
|
|
||||||
);
|
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
return gateway;
|
return gateway;
|
||||||
}
|
}
|
||||||
|
|
||||||
String _fieldText(WidgetTester tester, {required bool cupertino}) => cupertino
|
String _fieldText(WidgetTester tester) =>
|
||||||
? tester
|
tester.widget<TextField>(find.byKey(runTitleFieldKey)).controller!.text;
|
||||||
.widget<CupertinoTextField>(find.byKey(runTitleFieldKey))
|
|
||||||
.controller!
|
|
||||||
.text
|
|
||||||
: tester.widget<TextField>(find.byKey(runTitleFieldKey)).controller!.text;
|
|
||||||
|
|
||||||
/// Rename lives in the run detail's more menu.
|
/// Rename lives in the run detail's more menu.
|
||||||
Future<void> _openRename(WidgetTester tester) async {
|
Future<void> _openRename(WidgetTester tester) async {
|
||||||
@@ -99,7 +87,7 @@ Future<void> _openRename(WidgetTester tester) async {
|
|||||||
void main() {
|
void main() {
|
||||||
testWidgets('material detail renames through the shared gateway and folds '
|
testWidgets('material detail renames through the shared gateway and folds '
|
||||||
'only the server reply into the detail and list', (tester) async {
|
'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(runDetailText('Nightly build'), findsOneWidget);
|
||||||
expect(find.byKey(runMoreMenuKey), findsOneWidget);
|
expect(find.byKey(runMoreMenuKey), findsOneWidget);
|
||||||
@@ -107,7 +95,7 @@ void main() {
|
|||||||
|
|
||||||
await _openRename(tester);
|
await _openRename(tester);
|
||||||
expect(find.byType(AlertDialog), findsOneWidget);
|
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.enterText(find.byKey(runTitleFieldKey), 'Draft only');
|
||||||
await tester.pump();
|
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', (
|
testWidgets('a refused rename keeps the typed title and the stored detail', (
|
||||||
tester,
|
tester,
|
||||||
) async {
|
) async {
|
||||||
final gateway = await _mount(tester, cupertino: false);
|
final gateway = await _mount(tester);
|
||||||
|
|
||||||
await _openRename(tester);
|
await _openRename(tester);
|
||||||
await tester.enterText(find.byKey(runTitleFieldKey), ' locked ');
|
await tester.enterText(find.byKey(runTitleFieldKey), ' locked ');
|
||||||
@@ -184,7 +147,7 @@ void main() {
|
|||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
expect(find.text('rename refused by the server'), findsOneWidget);
|
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(find.byType(AlertDialog), findsOneWidget);
|
||||||
expect(runDetailText('Nightly build'), findsOneWidget);
|
expect(runDetailText('Nightly build'), findsOneWidget);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:pipelines_app/core/api_gateway.dart';
|
import 'package:pipelines_app/core/api_gateway.dart';
|
||||||
@@ -78,7 +77,6 @@ List<JsonMap> _fixture() {
|
|||||||
Future<void> _mount(
|
Future<void> _mount(
|
||||||
WidgetTester tester,
|
WidgetTester tester,
|
||||||
_Gateway gateway, {
|
_Gateway gateway, {
|
||||||
bool cupertino = false,
|
|
||||||
int? initialRunId,
|
int? initialRunId,
|
||||||
RunsSortStore? store,
|
RunsSortStore? store,
|
||||||
ValueChanged<int?>? onBack,
|
ValueChanged<int?>? onBack,
|
||||||
@@ -92,11 +90,7 @@ Future<void> _mount(
|
|||||||
onBack: onBack,
|
onBack: onBack,
|
||||||
sortStore: store ?? MemoryRunsSortStore(),
|
sortStore: store ?? MemoryRunsSortStore(),
|
||||||
);
|
);
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(MaterialApp(home: Scaffold(body: screen)));
|
||||||
cupertino
|
|
||||||
? CupertinoApp(home: CupertinoPageScaffold(child: screen))
|
|
||||||
: MaterialApp(home: Scaffold(body: screen)),
|
|
||||||
);
|
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,14 +194,14 @@ void main() {
|
|||||||
|
|
||||||
testWidgets('Cancel in the prompt sends nothing', (tester) async {
|
testWidgets('Cancel in the prompt sends nothing', (tester) async {
|
||||||
final gateway = _Gateway(_fixture());
|
final gateway = _Gateway(_fixture());
|
||||||
await _mount(tester, gateway, cupertino: true);
|
await _mount(tester, gateway);
|
||||||
await tester.tap(find.byKey(runsSelectKey));
|
await tester.tap(find.byKey(runsSelectKey));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await tester.tap(find.text('Yesterday done'));
|
await tester.tap(find.text('Yesterday done'));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await tester.tap(find.byKey(runsDeleteSelectedKey));
|
await tester.tap(find.byKey(runsDeleteSelectedKey));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(find.byType(CupertinoAlertDialog), findsOneWidget);
|
expect(find.byType(AlertDialog), findsOneWidget);
|
||||||
expect(find.text('Delete 1 run?'), findsOneWidget);
|
expect(find.text('Delete 1 run?'), findsOneWidget);
|
||||||
await tester.tap(find.byKey(deleteRunsKeepKey));
|
await tester.tap(find.byKey(deleteRunsKeepKey));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|||||||
Reference in New Issue
Block a user