Merge commit '98e2abd9af3a67c57ff42181aa1e5d1817dd3270' into pipelines/run-20261111-0410-cupertino-out-schedules-37d5
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/session_list_cupertino.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/session_list_material.dart';
|
||||
import 'package:pipelines_app/shell/adaptive_shell.dart';
|
||||
import 'package:pipelines_app/shell/destination.dart';
|
||||
@@ -9,114 +7,88 @@ import 'package:pipelines_app/shell/list_detail.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
for (final scale in [1.0, 2.0]) {
|
||||
testWidgets(
|
||||
'chat list stays above labeled navigation ($cupertino, $scale)',
|
||||
(tester) async {
|
||||
tester.view.physicalSize = const Size(1200, 900);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
tester.platformDispatcher.textScaleFactorTestValue = scale;
|
||||
addTearDown(tester.view.reset);
|
||||
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
|
||||
String? opened;
|
||||
final sessions = [
|
||||
for (var i = 0; i < 14; i++)
|
||||
{
|
||||
'id': 's$i',
|
||||
'title': 'Chat item $i',
|
||||
'model': 'model',
|
||||
'directory': '/work/project-$i',
|
||||
},
|
||||
];
|
||||
Widget list() => cupertino
|
||||
? CupertinoSessionList(
|
||||
sections: [(title: 'Chats', sessions: sessions)],
|
||||
emptyMessage: null,
|
||||
duplicateTitles: const {},
|
||||
onOpen: (row) => opened = row['id'] as String,
|
||||
onRename: (_) {},
|
||||
onClose: (_) {},
|
||||
onReopen: (_) {},
|
||||
onStar: (_) {},
|
||||
onHide: (_) {},
|
||||
onClearSearch: null,
|
||||
isUnseen: (_) => false,
|
||||
errorFor: (_) => null,
|
||||
)
|
||||
: MaterialSessionList(
|
||||
sections: [(title: 'Chats', sessions: sessions)],
|
||||
emptyMessage: null,
|
||||
duplicateTitles: const {},
|
||||
onOpen: (row) => opened = row['id'] as String,
|
||||
onRename: (_) {},
|
||||
onClose: (_) {},
|
||||
onReopen: (_) {},
|
||||
onStar: (_) {},
|
||||
onHide: (_) {},
|
||||
onClearSearch: null,
|
||||
isUnseen: (_) => false,
|
||||
errorFor: (_) => null,
|
||||
);
|
||||
final shell = AdaptiveShell(
|
||||
cupertino: cupertino,
|
||||
destination: AppDestination.chat,
|
||||
destinationBodies: {
|
||||
AppDestination.chat: (_) => ListDetailPanes(
|
||||
list: list(),
|
||||
detail: const SizedBox.expand(),
|
||||
),
|
||||
},
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino ? CupertinoApp(home: shell) : MaterialApp(home: shell),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
final navigation = tester.getRect(
|
||||
find.byKey(FloatingDestinationBar.rowKey),
|
||||
);
|
||||
final scrollView = find.byType(CustomScrollView);
|
||||
final viewport = tester.getRect(scrollView);
|
||||
expect(viewport.bottom, lessThanOrEqualTo(navigation.top + .5));
|
||||
expect(viewport.width, greaterThan(0));
|
||||
final scrollable = tester.state<ScrollableState>(
|
||||
find.descendant(of: scrollView, matching: find.byType(Scrollable)),
|
||||
);
|
||||
scrollable.position.jumpTo(scrollable.position.maxScrollExtent);
|
||||
await tester.pumpAndSettle();
|
||||
final last = find.byKey(const Key('chat-row-s13'));
|
||||
expect(
|
||||
tester.getRect(last).bottom,
|
||||
lessThanOrEqualTo(navigation.top + .5),
|
||||
);
|
||||
final metadata = find.descendant(
|
||||
of: last,
|
||||
matching: find.text('model · /work/project-13'),
|
||||
);
|
||||
expect(metadata, findsOneWidget);
|
||||
expect(
|
||||
tester.getRect(metadata).bottom,
|
||||
lessThanOrEqualTo(navigation.top + .5),
|
||||
);
|
||||
await tester.tap(find.text('Chat item 13'));
|
||||
await tester.pump();
|
||||
expect(opened, 's13');
|
||||
final retainedOffset = scrollable.position.pixels;
|
||||
tester.view.physicalSize = const Size(1440, 900);
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
tester.state<ScrollableState>(
|
||||
find.descendant(
|
||||
of: scrollView,
|
||||
matching: find.byType(Scrollable),
|
||||
),
|
||||
),
|
||||
same(scrollable),
|
||||
);
|
||||
expect(scrollable.position.pixels, closeTo(retainedOffset, .5));
|
||||
expect(tester.takeException(), isNull);
|
||||
for (final scale in [1.0, 2.0]) {
|
||||
testWidgets('chat list stays above labeled navigation ($scale)', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(1200, 900);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
tester.platformDispatcher.textScaleFactorTestValue = scale;
|
||||
addTearDown(tester.view.reset);
|
||||
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
|
||||
String? opened;
|
||||
final sessions = [
|
||||
for (var i = 0; i < 14; i++)
|
||||
{
|
||||
'id': 's$i',
|
||||
'title': 'Chat item $i',
|
||||
'model': 'model',
|
||||
'directory': '/work/project-$i',
|
||||
},
|
||||
];
|
||||
Widget list() => MaterialSessionList(
|
||||
sections: [(title: 'Chats', sessions: sessions)],
|
||||
emptyMessage: null,
|
||||
duplicateTitles: const {},
|
||||
onOpen: (row) => opened = row['id'] as String,
|
||||
onRename: (_) {},
|
||||
onClose: (_) {},
|
||||
onReopen: (_) {},
|
||||
onStar: (_) {},
|
||||
onHide: (_) {},
|
||||
onClearSearch: null,
|
||||
isUnseen: (_) => false,
|
||||
errorFor: (_) => null,
|
||||
);
|
||||
final shell = AdaptiveShell(
|
||||
destination: AppDestination.chat,
|
||||
destinationBodies: {
|
||||
AppDestination.chat: (_) =>
|
||||
ListDetailPanes(list: list(), detail: const SizedBox.expand()),
|
||||
},
|
||||
);
|
||||
}
|
||||
await tester.pumpWidget(MaterialApp(home: shell));
|
||||
await tester.pumpAndSettle();
|
||||
final navigation = tester.getRect(
|
||||
find.byKey(FloatingDestinationBar.rowKey),
|
||||
);
|
||||
final scrollView = find.byType(CustomScrollView);
|
||||
final viewport = tester.getRect(scrollView);
|
||||
expect(viewport.bottom, lessThanOrEqualTo(navigation.top + .5));
|
||||
expect(viewport.width, greaterThan(0));
|
||||
final scrollable = tester.state<ScrollableState>(
|
||||
find.descendant(of: scrollView, matching: find.byType(Scrollable)),
|
||||
);
|
||||
scrollable.position.jumpTo(scrollable.position.maxScrollExtent);
|
||||
await tester.pumpAndSettle();
|
||||
final last = find.byKey(const Key('chat-row-s13'));
|
||||
expect(
|
||||
tester.getRect(last).bottom,
|
||||
lessThanOrEqualTo(navigation.top + .5),
|
||||
);
|
||||
final metadata = find.descendant(
|
||||
of: last,
|
||||
matching: find.text('model · /work/project-13'),
|
||||
);
|
||||
expect(metadata, findsOneWidget);
|
||||
expect(
|
||||
tester.getRect(metadata).bottom,
|
||||
lessThanOrEqualTo(navigation.top + .5),
|
||||
);
|
||||
await tester.tap(find.text('Chat item 13'));
|
||||
await tester.pump();
|
||||
expect(opened, 's13');
|
||||
final retainedOffset = scrollable.position.pixels;
|
||||
tester.view.physicalSize = const Size(1440, 900);
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
tester.state<ScrollableState>(
|
||||
find.descendant(of: scrollView, matching: find.byType(Scrollable)),
|
||||
),
|
||||
same(scrollable),
|
||||
);
|
||||
expect(scrollable.position.pixels, closeTo(retainedOffset, .5));
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
@@ -60,7 +59,6 @@ void main() {
|
||||
initial: executingRun(),
|
||||
changed: changed,
|
||||
),
|
||||
cupertino: false,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -96,55 +94,6 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'cupertino cancel uses a native prompt and sends only on confirm',
|
||||
(tester) async {
|
||||
final accepted = acceptedCancelRun();
|
||||
final gateway = FakeCancelGateway(
|
||||
(type, fields) async => {'run_detail': accepted},
|
||||
);
|
||||
final changed = <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', (
|
||||
tester,
|
||||
) async {
|
||||
@@ -178,7 +127,6 @@ void main() {
|
||||
initial: run,
|
||||
changed: changed,
|
||||
),
|
||||
cupertino: false,
|
||||
),
|
||||
);
|
||||
expect(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
@@ -13,7 +12,6 @@ Future<void> _pump(
|
||||
WidgetTester tester,
|
||||
FakeCancelGateway gateway,
|
||||
List<JsonMap> changed, {
|
||||
bool cupertino = false,
|
||||
double textScale = 1,
|
||||
JsonMap? run,
|
||||
}) async {
|
||||
@@ -24,7 +22,6 @@ Future<void> _pump(
|
||||
initial: run ?? executingRun(),
|
||||
changed: changed,
|
||||
),
|
||||
cupertino: cupertino,
|
||||
textScale: textScale,
|
||||
),
|
||||
);
|
||||
@@ -239,33 +236,20 @@ void main() {
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
final gateway = FakeCancelGateway(
|
||||
(type, fields) async => {'run_detail': acceptedCancelRun()},
|
||||
);
|
||||
await _pump(
|
||||
tester,
|
||||
gateway,
|
||||
<JsonMap>[],
|
||||
cupertino: cupertino,
|
||||
textScale: 2,
|
||||
);
|
||||
await tester.tap(find.byKey(cancelActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
final gateway = FakeCancelGateway(
|
||||
(type, fields) async => {'run_detail': acceptedCancelRun()},
|
||||
);
|
||||
await _pump(tester, gateway, <JsonMap>[], textScale: 2);
|
||||
await tester.tap(find.byKey(cancelActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(tester.takeException(), isNull, reason: 'cupertino=$cupertino');
|
||||
expect(find.text(cancelDialogTitle(7)), findsOneWidget);
|
||||
expect(find.text(cancelDialogMessage), findsOneWidget);
|
||||
expect(
|
||||
cupertino
|
||||
? find.byType(CupertinoAlertDialog)
|
||||
: find.byType(AlertDialog),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(gateway.calls, isEmpty);
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(find.text(cancelDialogTitle(7)), findsOneWidget);
|
||||
expect(find.text(cancelDialogMessage), findsOneWidget);
|
||||
expect(find.byType(AlertDialog), findsOneWidget);
|
||||
expect(gateway.calls, isEmpty);
|
||||
|
||||
await tester.tap(find.byKey(cancelKeepKey));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
await tester.tap(find.byKey(cancelKeepKey));
|
||||
await tester.pumpAndSettle();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/runs/actions/cancel_run_action.dart';
|
||||
@@ -77,23 +76,13 @@ class _CancelHostState extends State<CancelHost> {
|
||||
}
|
||||
}
|
||||
|
||||
Widget cancelApp(
|
||||
Widget child, {
|
||||
required bool cupertino,
|
||||
double textScale = 1,
|
||||
}) {
|
||||
Widget cancelApp(Widget child, {double textScale = 1}) {
|
||||
Widget media(BuildContext context, Widget? app) => MediaQuery(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
).copyWith(textScaler: TextScaler.linear(textScale)),
|
||||
child: app!,
|
||||
);
|
||||
if (cupertino) {
|
||||
return CupertinoApp(
|
||||
builder: media,
|
||||
home: CupertinoPageScaffold(child: Center(child: child)),
|
||||
);
|
||||
}
|
||||
return MaterialApp(
|
||||
builder: media,
|
||||
home: Scaffold(body: Center(child: child)),
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/runs/actions/decision_action.dart';
|
||||
import 'package:pipelines_app/features/runs/actions/decision_option_row.dart';
|
||||
import 'package:pipelines_app/features/runs/actions/decision_wording.dart';
|
||||
|
||||
typedef _Handler = Future<JsonMap> Function(String type, JsonMap fields);
|
||||
@@ -63,18 +61,7 @@ JsonMap _decided() => {
|
||||
'steps': const <JsonMap>[],
|
||||
};
|
||||
|
||||
Widget _app(Widget child, {required bool cupertino, double textScale = 1}) {
|
||||
if (cupertino) {
|
||||
return CupertinoApp(
|
||||
builder: (context, app) => MediaQuery(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
).copyWith(textScaler: TextScaler.linear(textScale)),
|
||||
child: app!,
|
||||
),
|
||||
home: CupertinoPageScaffold(child: Center(child: child)),
|
||||
);
|
||||
}
|
||||
Widget _app(Widget child, {double textScale = 1}) {
|
||||
return MaterialApp(
|
||||
builder: (context, app) => MediaQuery(
|
||||
data: MediaQuery.of(
|
||||
@@ -90,7 +77,6 @@ Future<void> _pump(
|
||||
WidgetTester tester,
|
||||
_FakeGateway gateway,
|
||||
JsonMap run, {
|
||||
required bool cupertino,
|
||||
required List<JsonMap> changed,
|
||||
double textScale = 1,
|
||||
}) async {
|
||||
@@ -101,7 +87,6 @@ Future<void> _pump(
|
||||
gateway: gateway,
|
||||
onRunChanged: changed.add,
|
||||
),
|
||||
cupertino: cupertino,
|
||||
textScale: textScale,
|
||||
),
|
||||
);
|
||||
@@ -126,7 +111,6 @@ void main() {
|
||||
tester,
|
||||
gateway,
|
||||
_waitingRun(),
|
||||
cupertino: false,
|
||||
changed: changed,
|
||||
);
|
||||
|
||||
@@ -166,76 +150,41 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'cupertino decision uses a native dialog and omits empty feedback',
|
||||
(tester) async {
|
||||
final gateway = _FakeGateway(
|
||||
(type, fields) async => {
|
||||
'run_detail': type == 'decide_run' ? _decided() : _waitingRun(),
|
||||
},
|
||||
);
|
||||
final changed = <JsonMap>[];
|
||||
await _pump(
|
||||
tester,
|
||||
gateway,
|
||||
_waitingRun(),
|
||||
cupertino: true,
|
||||
changed: changed,
|
||||
);
|
||||
testWidgets('a decision without feedback omits the field', (tester) async {
|
||||
final gateway = _FakeGateway(
|
||||
(type, fields) async => {
|
||||
'run_detail': type == 'decide_run' ? _decided() : _waitingRun(),
|
||||
},
|
||||
);
|
||||
final changed = <JsonMap>[];
|
||||
await _pump(tester, gateway, _waitingRun(), changed: changed);
|
||||
|
||||
expect(find.byKey(decisionActionKey), findsOneWidget);
|
||||
expect(find.byType(FilledButton), findsNothing);
|
||||
await _open(tester);
|
||||
expect(find.byType(CupertinoAlertDialog), findsOneWidget);
|
||||
expect(find.text(decisionWaitingTitle), findsOneWidget);
|
||||
expect(gateway.calls, isEmpty);
|
||||
expect(find.byKey(decisionActionKey), findsOneWidget);
|
||||
expect(find.byType(FilledButton), findsOneWidget);
|
||||
await _open(tester);
|
||||
expect(find.byType(AlertDialog), findsOneWidget);
|
||||
expect(find.text(decisionWaitingTitle), findsOneWidget);
|
||||
expect(gateway.calls, isEmpty);
|
||||
|
||||
final confirm = find.widgetWithText(
|
||||
CupertinoDialogAction,
|
||||
decisionConfirmLabel,
|
||||
);
|
||||
expect(tester.widget<CupertinoDialogAction>(confirm).onPressed, isNull);
|
||||
// Options are check-list rows, not blue link buttons: an empty circle
|
||||
// until one is picked, then a filled check on that row only.
|
||||
final skip = find.byKey(decisionOptionKey('skip'));
|
||||
expect(skip, findsOneWidget);
|
||||
expect(
|
||||
find.ancestor(
|
||||
of: find.text('skip'),
|
||||
matching: find.byType(CupertinoButton),
|
||||
),
|
||||
findsNothing,
|
||||
);
|
||||
expect(find.byIcon(CupertinoIcons.checkmark_circle_fill), findsNothing);
|
||||
expect(
|
||||
find.descendant(of: skip, matching: find.byIcon(CupertinoIcons.circle)),
|
||||
findsOneWidget,
|
||||
);
|
||||
await tester.tap(find.text('skip'));
|
||||
await tester.pump();
|
||||
expect(gateway.calls, isEmpty);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: skip,
|
||||
matching: find.byIcon(CupertinoIcons.checkmark_circle_fill),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byIcon(CupertinoIcons.checkmark_circle_fill), findsOneWidget);
|
||||
final confirm = find.widgetWithText(FilledButton, decisionConfirmLabel);
|
||||
expect(tester.widget<FilledButton>(confirm).onPressed, isNull);
|
||||
await tester.tap(find.text('skip'));
|
||||
await tester.pump();
|
||||
expect(gateway.calls, isEmpty);
|
||||
expect(tester.widget<FilledButton>(confirm).onPressed, isNotNull);
|
||||
|
||||
await tester.tap(find.text(decisionConfirmLabel));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text(decisionConfirmLabel));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(gateway.calls.map((call) => call.type), ['decide_run']);
|
||||
expect(gateway.calls.single.fields, {
|
||||
'run_id': 7,
|
||||
'stage': 'human',
|
||||
'option': 'skip',
|
||||
});
|
||||
expect(changed.single['status'], 'succeeded');
|
||||
expect(find.byType(CupertinoAlertDialog), findsNothing);
|
||||
},
|
||||
);
|
||||
expect(gateway.calls.map((call) => call.type), ['decide_run']);
|
||||
expect(gateway.calls.single.fields, {
|
||||
'run_id': 7,
|
||||
'stage': 'human',
|
||||
'option': 'skip',
|
||||
});
|
||||
expect(changed.single['status'], 'succeeded');
|
||||
expect(find.byType(AlertDialog), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('Cancel dismisses the draft without sending anything', (
|
||||
tester,
|
||||
@@ -248,7 +197,6 @@ void main() {
|
||||
tester,
|
||||
gateway,
|
||||
_waitingRun(),
|
||||
cupertino: false,
|
||||
changed: changed,
|
||||
);
|
||||
|
||||
@@ -277,7 +225,7 @@ void main() {
|
||||
('export pending', _waitingRun(exportPending: 2)),
|
||||
('model stage', _waitingRun(type: 'model')),
|
||||
]) {
|
||||
await _pump(tester, gateway, run, cupertino: false, changed: changed);
|
||||
await _pump(tester, gateway, run, changed: changed);
|
||||
expect(
|
||||
find.byKey(decisionActionKey),
|
||||
findsNothing,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
@@ -61,19 +60,13 @@ JsonMap _decided() => {
|
||||
'steps': const <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(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
).copyWith(textScaler: TextScaler.linear(textScale)),
|
||||
child: app!,
|
||||
);
|
||||
if (cupertino) {
|
||||
return CupertinoApp(
|
||||
builder: media,
|
||||
home: CupertinoPageScaffold(child: Center(child: child)),
|
||||
);
|
||||
}
|
||||
return MaterialApp(
|
||||
builder: media,
|
||||
home: Scaffold(body: Center(child: child)),
|
||||
@@ -84,7 +77,6 @@ Future<void> _pump(
|
||||
WidgetTester tester,
|
||||
_FakeGateway gateway,
|
||||
List<JsonMap> changed, {
|
||||
bool cupertino = false,
|
||||
double textScale = 1,
|
||||
}) async {
|
||||
await tester.pumpWidget(
|
||||
@@ -94,7 +86,6 @@ Future<void> _pump(
|
||||
gateway: gateway,
|
||||
onRunChanged: changed.add,
|
||||
),
|
||||
cupertino: cupertino,
|
||||
textScale: textScale,
|
||||
),
|
||||
);
|
||||
@@ -323,29 +314,16 @@ void main() {
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
final gateway = _FakeGateway(
|
||||
(type, fields) async => {'run_detail': _decided()},
|
||||
);
|
||||
await _pump(
|
||||
tester,
|
||||
gateway,
|
||||
<JsonMap>[],
|
||||
cupertino: cupertino,
|
||||
textScale: 2,
|
||||
);
|
||||
await tester.tap(find.byKey(decisionActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
final gateway = _FakeGateway(
|
||||
(type, fields) async => {'run_detail': _decided()},
|
||||
);
|
||||
await _pump(tester, gateway, <JsonMap>[], textScale: 2);
|
||||
await tester.tap(find.byKey(decisionActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(tester.takeException(), isNull, reason: 'cupertino=$cupertino');
|
||||
expect(find.text(decisionWaitingTitle), findsOneWidget);
|
||||
expect(find.text('Ship it?'), findsOneWidget);
|
||||
expect(
|
||||
cupertino
|
||||
? find.byType(CupertinoAlertDialog)
|
||||
: find.byType(AlertDialog),
|
||||
findsOneWidget,
|
||||
);
|
||||
}
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(find.text(decisionWaitingTitle), findsOneWidget);
|
||||
expect(find.text('Ship it?'), findsOneWidget);
|
||||
expect(find.byType(AlertDialog), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
@@ -146,81 +145,6 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'cupertino retry uses a native prompt and sends only on confirm',
|
||||
(tester) async {
|
||||
final accepted = retriedRun();
|
||||
final gateway = FakeRetryGateway(
|
||||
(type, fields) async => {'run_detail': accepted},
|
||||
);
|
||||
final changed = <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', (
|
||||
tester,
|
||||
) async {
|
||||
@@ -236,25 +160,22 @@ void main() {
|
||||
('succeeded', failedRun(status: 'succeeded'), false),
|
||||
('canceled', failedRun(status: 'canceled'), false),
|
||||
];
|
||||
for (final cupertino in [false, true]) {
|
||||
for (final (label, run, visible) in cases) {
|
||||
await tester.pumpWidget(
|
||||
retryApp(
|
||||
RetryHost(
|
||||
key: ValueKey('$label-$cupertino'),
|
||||
gateway: gateway,
|
||||
initial: run,
|
||||
changed: changed,
|
||||
),
|
||||
cupertino: cupertino,
|
||||
for (final (label, run, visible) in cases) {
|
||||
await tester.pumpWidget(
|
||||
retryApp(
|
||||
RetryHost(
|
||||
key: ValueKey(label),
|
||||
gateway: gateway,
|
||||
initial: run,
|
||||
changed: changed,
|
||||
),
|
||||
);
|
||||
expect(
|
||||
find.byKey(retryActionKey),
|
||||
visible ? findsOneWidget : findsNothing,
|
||||
reason: '$label cupertino=$cupertino',
|
||||
);
|
||||
}
|
||||
),
|
||||
);
|
||||
expect(
|
||||
find.byKey(retryActionKey),
|
||||
visible ? findsOneWidget : findsNothing,
|
||||
reason: label,
|
||||
);
|
||||
}
|
||||
expect(gateway.calls, isEmpty);
|
||||
expect(changed, isEmpty);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
@@ -95,39 +94,31 @@ void main() {
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
final gateway = FakeRetryGateway(
|
||||
(type, fields) async => {'run_detail': retriedRun()},
|
||||
);
|
||||
await pumpRetry(
|
||||
tester,
|
||||
gateway: gateway,
|
||||
changed: <JsonMap>[],
|
||||
cupertino: cupertino,
|
||||
textScale: 2,
|
||||
);
|
||||
final gateway = FakeRetryGateway(
|
||||
(type, fields) async => {'run_detail': retriedRun()},
|
||||
);
|
||||
await pumpRetry(
|
||||
tester,
|
||||
gateway: gateway,
|
||||
changed: <JsonMap>[],
|
||||
textScale: 2,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(retryActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull, reason: 'cupertino=$cupertino');
|
||||
expect(find.text(retryDialogTitle(7)), findsOneWidget);
|
||||
expect(find.text(retryDialogMessage), findsOneWidget);
|
||||
expect(
|
||||
cupertino
|
||||
? find.byType(CupertinoAlertDialog)
|
||||
: find.byType(AlertDialog),
|
||||
findsOneWidget,
|
||||
);
|
||||
await tester.tap(find.byKey(retryActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(find.text(retryDialogTitle(7)), findsOneWidget);
|
||||
expect(find.text(retryDialogMessage), findsOneWidget);
|
||||
expect(find.byType(AlertDialog), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(retryRestartKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull, reason: 'restart=$cupertino');
|
||||
expect(find.text(restartDialogTitle(7)), findsOneWidget);
|
||||
expect(find.text(restartDialogMessage), findsOneWidget);
|
||||
await tester.tap(find.byKey(retryRestartKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(find.text(restartDialogTitle(7)), findsOneWidget);
|
||||
expect(find.text(restartDialogMessage), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(retryKeepKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(gateway.calls, isEmpty);
|
||||
}
|
||||
await tester.tap(find.byKey(retryKeepKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(gateway.calls, isEmpty);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
@@ -71,19 +70,13 @@ class _RetryHostState extends State<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(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
).copyWith(textScaler: TextScaler.linear(textScale)),
|
||||
child: app!,
|
||||
);
|
||||
if (cupertino) {
|
||||
return CupertinoApp(
|
||||
builder: media,
|
||||
home: CupertinoPageScaffold(child: Center(child: child)),
|
||||
);
|
||||
}
|
||||
return MaterialApp(
|
||||
builder: media,
|
||||
home: Scaffold(body: Center(child: child)),
|
||||
@@ -94,7 +87,6 @@ Future<void> pumpRetry(
|
||||
WidgetTester tester, {
|
||||
required FakeRetryGateway gateway,
|
||||
required List<JsonMap> changed,
|
||||
bool cupertino = false,
|
||||
double textScale = 1,
|
||||
JsonMap? run,
|
||||
}) async {
|
||||
@@ -105,7 +97,6 @@ Future<void> pumpRetry(
|
||||
initial: run ?? failedRun(),
|
||||
changed: changed,
|
||||
),
|
||||
cupertino: cupertino,
|
||||
textScale: textScale,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
@@ -11,11 +10,6 @@ import 'title_test_support.dart';
|
||||
String _materialFieldText(WidgetTester tester) =>
|
||||
tester.widget<TextField>(find.byKey(runTitleFieldKey)).controller!.text;
|
||||
|
||||
String _cupertinoFieldText(WidgetTester tester) => tester
|
||||
.widget<CupertinoTextField>(find.byKey(runTitleFieldKey))
|
||||
.controller!
|
||||
.text;
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
'material rename starts from the stored title, typing sends nothing, '
|
||||
@@ -29,7 +23,6 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
titleApp(
|
||||
TitleHost(gateway: gateway, initial: titledRun(), changed: changed),
|
||||
cupertino: false,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -85,55 +78,6 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('cupertino rename is native and sends only on Save', (
|
||||
tester,
|
||||
) async {
|
||||
final accepted = renamedRun(title: 'Release build');
|
||||
final gateway = FakeTitleGateway(
|
||||
(type, fields) async => {'run_detail': accepted},
|
||||
);
|
||||
final changed = <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', (
|
||||
tester,
|
||||
) async {
|
||||
@@ -145,7 +89,6 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
titleApp(
|
||||
TitleHost(gateway: gateway, initial: titledRun(), changed: changed),
|
||||
cupertino: false,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -189,7 +132,6 @@ void main() {
|
||||
),
|
||||
changed: changed,
|
||||
),
|
||||
cupertino: false,
|
||||
),
|
||||
);
|
||||
await tester.tap(find.byKey(runTitleActionKey));
|
||||
@@ -206,7 +148,6 @@ void main() {
|
||||
initial: titledRun(title: null, prompt: 'prompt is not a title'),
|
||||
changed: changed,
|
||||
),
|
||||
cupertino: false,
|
||||
),
|
||||
);
|
||||
await tester.tap(find.byKey(runTitleActionKey));
|
||||
@@ -231,7 +172,6 @@ void main() {
|
||||
initial: {'title': 'No id'},
|
||||
changed: <JsonMap>[],
|
||||
),
|
||||
cupertino: false,
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
@@ -13,7 +12,6 @@ Future<void> _pump(
|
||||
WidgetTester tester,
|
||||
FakeTitleGateway gateway,
|
||||
List<JsonMap> changed, {
|
||||
bool cupertino = false,
|
||||
double textScale = 1,
|
||||
JsonMap? run,
|
||||
}) async {
|
||||
@@ -24,7 +22,6 @@ Future<void> _pump(
|
||||
initial: run ?? titledRun(),
|
||||
changed: changed,
|
||||
),
|
||||
cupertino: cupertino,
|
||||
textScale: textScale,
|
||||
),
|
||||
);
|
||||
@@ -35,18 +32,10 @@ Future<void> _open(WidgetTester tester) async {
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
String _fieldText(WidgetTester tester, {required bool cupertino}) {
|
||||
if (cupertino) {
|
||||
return tester
|
||||
.widget<CupertinoTextField>(find.byKey(runTitleFieldKey))
|
||||
.controller!
|
||||
.text;
|
||||
}
|
||||
return tester
|
||||
.widget<TextField>(find.byKey(runTitleFieldKey))
|
||||
.controller!
|
||||
.text;
|
||||
}
|
||||
String _fieldText(WidgetTester tester) => tester
|
||||
.widget<TextField>(find.byKey(runTitleFieldKey))
|
||||
.controller!
|
||||
.text;
|
||||
|
||||
void main() {
|
||||
testWidgets('a failed save keeps the prompt open with the draft intact', (
|
||||
@@ -71,7 +60,7 @@ void main() {
|
||||
});
|
||||
expect(find.text(refusal), findsOneWidget);
|
||||
expect(find.byKey(runTitleErrorKey), findsOneWidget);
|
||||
expect(_fieldText(tester, cupertino: false), ' Renamed draft ');
|
||||
expect(_fieldText(tester), ' Renamed draft ');
|
||||
expect(find.byType(AlertDialog), findsOneWidget);
|
||||
expect(changed, isEmpty);
|
||||
expect(
|
||||
@@ -87,7 +76,7 @@ void main() {
|
||||
(type, fields) async => throw const NotConnectedError(),
|
||||
);
|
||||
final changed = <JsonMap>[];
|
||||
await _pump(tester, gateway, changed, cupertino: true);
|
||||
await _pump(tester, gateway, changed);
|
||||
|
||||
await _open(tester);
|
||||
await tester.enterText(find.byKey(runTitleFieldKey), 'Unsent title');
|
||||
@@ -95,8 +84,8 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(runTitleErrorKey), findsOneWidget);
|
||||
expect(_fieldText(tester, cupertino: true), 'Unsent title');
|
||||
expect(find.byType(CupertinoAlertDialog), findsOneWidget);
|
||||
expect(_fieldText(tester), 'Unsent title');
|
||||
expect(find.byType(AlertDialog), findsOneWidget);
|
||||
expect(changed, isEmpty);
|
||||
});
|
||||
|
||||
@@ -172,7 +161,6 @@ void main() {
|
||||
initial: titledRun(id: 8, title: 'Another run'),
|
||||
changed: changed,
|
||||
),
|
||||
cupertino: false,
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
@@ -198,46 +186,32 @@ void main() {
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
|
||||
const refusal = 'the title is too long for this run; shorten it';
|
||||
for (final cupertino in [false, true]) {
|
||||
final gateway = FakeTitleGateway(
|
||||
(type, fields) async => throw const ProtocolError(refusal),
|
||||
);
|
||||
await _pump(
|
||||
tester,
|
||||
gateway,
|
||||
<JsonMap>[],
|
||||
cupertino: cupertino,
|
||||
textScale: 2,
|
||||
);
|
||||
await _open(tester);
|
||||
final gateway = FakeTitleGateway(
|
||||
(type, fields) async => throw const ProtocolError(refusal),
|
||||
);
|
||||
await _pump(tester, gateway, <JsonMap>[], textScale: 2);
|
||||
await _open(tester);
|
||||
|
||||
expect(tester.takeException(), isNull, reason: 'cupertino=$cupertino');
|
||||
expect(
|
||||
cupertino
|
||||
? find.byType(CupertinoAlertDialog)
|
||||
: find.byType(AlertDialog),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text(runTitleFieldLabel), findsOneWidget);
|
||||
expect(gateway.calls, isEmpty);
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(find.byType(AlertDialog), findsOneWidget);
|
||||
expect(find.text(runTitleFieldLabel), findsOneWidget);
|
||||
expect(gateway.calls, isEmpty);
|
||||
|
||||
await tester.enterText(
|
||||
find.byKey(runTitleFieldKey),
|
||||
'A deliberately long title that must scroll rather than overflow',
|
||||
);
|
||||
await tester.tap(find.byKey(runTitleSaveKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull, reason: 'cupertino=$cupertino');
|
||||
expect(find.text(refusal), findsOneWidget);
|
||||
expect(
|
||||
_fieldText(tester, cupertino: cupertino),
|
||||
'A deliberately long title that must scroll rather than overflow',
|
||||
);
|
||||
await tester.enterText(
|
||||
find.byKey(runTitleFieldKey),
|
||||
'A deliberately long title that must scroll rather than overflow',
|
||||
);
|
||||
await tester.tap(find.byKey(runTitleSaveKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(find.text(refusal), findsOneWidget);
|
||||
expect(
|
||||
_fieldText(tester),
|
||||
'A deliberately long title that must scroll rather than overflow',
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(runTitleCancelKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(AlertDialog), findsNothing);
|
||||
expect(find.byType(CupertinoAlertDialog), findsNothing);
|
||||
}
|
||||
await tester.tap(find.byKey(runTitleCancelKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(AlertDialog), findsNothing);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/runs/actions/title_action.dart';
|
||||
@@ -89,22 +88,15 @@ class _TitleHostState extends State<TitleHost> {
|
||||
|
||||
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(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
).copyWith(textScaler: TextScaler.linear(textScale)),
|
||||
child: app!,
|
||||
);
|
||||
final body = Center(child: child);
|
||||
if (cupertino) {
|
||||
return CupertinoApp(
|
||||
builder: media,
|
||||
home: CupertinoPageScaffold(child: body),
|
||||
);
|
||||
}
|
||||
return MaterialApp(
|
||||
builder: media,
|
||||
home: Scaffold(body: body),
|
||||
home: Scaffold(body: Center(child: child)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/ui/status/run_status_icon.dart';
|
||||
@@ -39,57 +38,49 @@ class _Gateway implements ApiGateway {
|
||||
}
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets(
|
||||
'actual detail confirms cancel and folds accepted state ($cupertino)',
|
||||
(tester) async {
|
||||
final gateway = _Gateway();
|
||||
addTearDown(gateway.events.close);
|
||||
final screen = RunsScreen(gateway: gateway, initialRunId: 7);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: screen))
|
||||
: MaterialApp(home: Scaffold(body: screen)),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(cancelActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Cancel run 7?'), findsOneWidget);
|
||||
expect(gateway.requests.where((r) => r.type == 'cancel_run'), isEmpty);
|
||||
await tester.tap(find.byKey(cancelKeepKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(gateway.requests.where((r) => r.type == 'cancel_run'), isEmpty);
|
||||
testWidgets('actual detail confirms cancel and folds accepted state', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway = _Gateway();
|
||||
addTearDown(gateway.events.close);
|
||||
final screen = RunsScreen(gateway: gateway, initialRunId: 7);
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: screen)));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(cancelActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Cancel run 7?'), findsOneWidget);
|
||||
expect(gateway.requests.where((r) => r.type == 'cancel_run'), isEmpty);
|
||||
await tester.tap(find.byKey(cancelKeepKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(gateway.requests.where((r) => r.type == 'cancel_run'), isEmpty);
|
||||
|
||||
await tester.tap(find.byKey(cancelActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(cancelConfirmKey));
|
||||
await tester.pump();
|
||||
expect(
|
||||
gateway.requests.where((r) => r.type == 'cancel_run').single.fields,
|
||||
{'run_id': 7},
|
||||
);
|
||||
expect(find.text('canceled'), findsNothing);
|
||||
gateway.canceled.complete({
|
||||
'run_detail': {
|
||||
...gateway.run,
|
||||
'status': 'canceled',
|
||||
'executing': false,
|
||||
},
|
||||
});
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(cancelActionKey), findsNothing);
|
||||
expect(find.text('canceled'), findsOneWidget);
|
||||
// The held list is already visible beside the detail.
|
||||
expect(
|
||||
find.byWidgetPredicate(
|
||||
(widget) => widget is RunStatusIcon && widget.label == 'canceled',
|
||||
),
|
||||
findsWidgets,
|
||||
reason:
|
||||
'The accepted server state must also update the held list row',
|
||||
);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
},
|
||||
await tester.tap(find.byKey(cancelActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(cancelConfirmKey));
|
||||
await tester.pump();
|
||||
expect(
|
||||
gateway.requests.where((r) => r.type == 'cancel_run').single.fields,
|
||||
{'run_id': 7},
|
||||
);
|
||||
}
|
||||
expect(find.text('canceled'), findsNothing);
|
||||
gateway.canceled.complete({
|
||||
'run_detail': {
|
||||
...gateway.run,
|
||||
'status': 'canceled',
|
||||
'executing': false,
|
||||
},
|
||||
});
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(cancelActionKey), findsNothing);
|
||||
expect(find.text('canceled'), findsOneWidget);
|
||||
// The held list is already visible beside the detail.
|
||||
expect(
|
||||
find.byWidgetPredicate(
|
||||
(widget) => widget is RunStatusIcon && widget.label == 'canceled',
|
||||
),
|
||||
findsWidgets,
|
||||
reason: 'The accepted server state must also update the held list row',
|
||||
);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'run_detail_finders.dart';
|
||||
@@ -90,41 +89,30 @@ Future<void> _pump(
|
||||
}
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('a decide route opens the waiting prompt ($cupertino)', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway = _Gateway(_waitingRun());
|
||||
addTearDown(gateway.close);
|
||||
tester.view.physicalSize = const Size(900, 1000);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
final screen = RunsScreen(
|
||||
gateway: gateway,
|
||||
initialRunId: 9,
|
||||
initialDecide: true,
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: screen))
|
||||
: MaterialApp(home: Scaffold(body: screen)),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
testWidgets('a decide route opens the waiting prompt', (tester) async {
|
||||
final gateway = _Gateway(_waitingRun());
|
||||
addTearDown(gateway.close);
|
||||
tester.view.physicalSize = const Size(900, 1000);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
final screen = RunsScreen(
|
||||
gateway: gateway,
|
||||
initialRunId: 9,
|
||||
initialDecide: true,
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: screen)));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(decisionFeedbackKey), findsOneWidget);
|
||||
expect(
|
||||
find.text('Please review this recorded checkpoint.'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byKey(decisionFeedbackKey), findsOneWidget);
|
||||
expect(find.text('Please review this recorded checkpoint.'), findsOneWidget);
|
||||
|
||||
// Closing the prompt leaves the loaded detail underneath.
|
||||
await tester.tap(find.text(decisionCancelLabel));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(decisionFeedbackKey), findsNothing);
|
||||
expect(runDetailText('Human checkpoint'), findsOneWidget);
|
||||
expect(find.byKey(decisionActionKey), findsOneWidget);
|
||||
});
|
||||
}
|
||||
// Closing the prompt leaves the loaded detail underneath.
|
||||
await tester.tap(find.text(decisionCancelLabel));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(decisionFeedbackKey), findsNothing);
|
||||
expect(runDetailText('Human checkpoint'), findsOneWidget);
|
||||
expect(find.byKey(decisionActionKey), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('a decide route on a non-waiting run invents no prompt', (
|
||||
tester,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
@@ -60,74 +59,63 @@ class _DecisionGateway implements ApiGateway {
|
||||
}
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets(
|
||||
'actual detail exposes and confirms recorded decision ($cupertino)',
|
||||
(tester) async {
|
||||
final gateway = _DecisionGateway();
|
||||
addTearDown(gateway.events.close);
|
||||
final screen = RunsScreen(gateway: gateway, initialRunId: 9);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: screen))
|
||||
: MaterialApp(home: Scaffold(body: screen)),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(decisionWaitingTitle), findsOneWidget);
|
||||
// The web's decision banner spans the header's glass strip (under
|
||||
// the top bar, 12 in from the pane) at the strip's 12px inset, with
|
||||
// Decide trailing.
|
||||
final banner = tester.getRect(
|
||||
find.byKey(const Key('run-decision-banner')),
|
||||
);
|
||||
final strip = tester.getRect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('run-detail-header')),
|
||||
matching: find.byType(GlassPill),
|
||||
),
|
||||
);
|
||||
final pane = tester.getRect(
|
||||
find.byKey(const ValueKey('list-detail-body')),
|
||||
);
|
||||
expect(strip.left, pane.left + 12);
|
||||
expect(strip.right, pane.right - 12);
|
||||
expect(banner.left, strip.left + 12);
|
||||
expect(banner.right, strip.right - 12);
|
||||
expect(
|
||||
tester.getCenter(find.byKey(decisionActionKey)).dx,
|
||||
greaterThan(banner.center.dx),
|
||||
);
|
||||
await tester.tap(find.byKey(decisionActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.text('Please review this recorded checkpoint.'),
|
||||
findsOneWidget,
|
||||
);
|
||||
await tester.tap(find.text('approve'));
|
||||
await tester.enterText(find.byKey(decisionFeedbackKey), ' checked ');
|
||||
await tester.pump();
|
||||
expect(gateway.decisions, isEmpty);
|
||||
await tester.tap(find.text(decisionConfirmLabel));
|
||||
await tester.pump();
|
||||
expect(gateway.decisions.single, {
|
||||
'run_id': 9,
|
||||
'stage': 'gate',
|
||||
'option': 'approve',
|
||||
'feedback': 'checked',
|
||||
});
|
||||
gateway.reply.complete({
|
||||
'run_detail': {
|
||||
...gateway.run,
|
||||
'status': 'succeeded',
|
||||
'executing': false,
|
||||
},
|
||||
});
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(decisionActionKey), findsNothing);
|
||||
expect(find.text(decisionWaitingTitle), findsNothing);
|
||||
expect(find.text('succeeded'), findsOneWidget);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
},
|
||||
testWidgets('actual detail exposes and confirms recorded decision', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway = _DecisionGateway();
|
||||
addTearDown(gateway.events.close);
|
||||
final screen = RunsScreen(gateway: gateway, initialRunId: 9);
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: screen)));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(decisionWaitingTitle), findsOneWidget);
|
||||
// The web's decision banner spans the header's glass strip (under
|
||||
// the top bar, 12 in from the pane) at the strip's 12px inset, with
|
||||
// Decide trailing.
|
||||
final banner = tester.getRect(find.byKey(const Key('run-decision-banner')));
|
||||
final strip = tester.getRect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('run-detail-header')),
|
||||
matching: find.byType(GlassPill),
|
||||
),
|
||||
);
|
||||
}
|
||||
final pane = tester.getRect(find.byKey(const ValueKey('list-detail-body')));
|
||||
expect(strip.left, pane.left + 12);
|
||||
expect(strip.right, pane.right - 12);
|
||||
expect(banner.left, strip.left + 12);
|
||||
expect(banner.right, strip.right - 12);
|
||||
expect(
|
||||
tester.getCenter(find.byKey(decisionActionKey)).dx,
|
||||
greaterThan(banner.center.dx),
|
||||
);
|
||||
await tester.tap(find.byKey(decisionActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.text('Please review this recorded checkpoint.'),
|
||||
findsOneWidget,
|
||||
);
|
||||
await tester.tap(find.text('approve'));
|
||||
await tester.enterText(find.byKey(decisionFeedbackKey), ' checked ');
|
||||
await tester.pump();
|
||||
expect(gateway.decisions, isEmpty);
|
||||
await tester.tap(find.text(decisionConfirmLabel));
|
||||
await tester.pump();
|
||||
expect(gateway.decisions.single, {
|
||||
'run_id': 9,
|
||||
'stage': 'gate',
|
||||
'option': 'approve',
|
||||
'feedback': 'checked',
|
||||
});
|
||||
gateway.reply.complete({
|
||||
'run_detail': {
|
||||
...gateway.run,
|
||||
'status': 'succeeded',
|
||||
'executing': false,
|
||||
},
|
||||
});
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(decisionActionKey), findsNothing);
|
||||
expect(find.text(decisionWaitingTitle), findsNothing);
|
||||
expect(find.text('succeeded'), findsOneWidget);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ void main() {
|
||||
await mountRetryScreen(
|
||||
tester,
|
||||
gateway,
|
||||
cupertino: false,
|
||||
onRunSelected: opened.add,
|
||||
);
|
||||
|
||||
@@ -40,7 +39,6 @@ void main() {
|
||||
await mountRetryScreen(
|
||||
tester,
|
||||
gateway,
|
||||
cupertino: false,
|
||||
onRunSelected: opened.add,
|
||||
);
|
||||
|
||||
@@ -65,7 +63,6 @@ void main() {
|
||||
await mountRetryScreen(
|
||||
tester,
|
||||
gateway,
|
||||
cupertino: false,
|
||||
onRunSelected: opened.add,
|
||||
);
|
||||
|
||||
@@ -87,7 +84,6 @@ void main() {
|
||||
await mountRetryScreen(
|
||||
tester,
|
||||
gateway,
|
||||
cupertino: false,
|
||||
onRunSelected: opened.add,
|
||||
);
|
||||
|
||||
@@ -107,7 +103,7 @@ void main() {
|
||||
) async {
|
||||
final gateway = RetryWiringGateway(executing: true);
|
||||
addTearDown(gateway.framesController.close);
|
||||
await mountRetryScreen(tester, gateway, cupertino: false);
|
||||
await mountRetryScreen(tester, gateway);
|
||||
|
||||
expect(find.byKey(runMoreMenuKey), findsOneWidget);
|
||||
expect(await retryOffered(tester), isFalse);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/runs/actions/cancel_wording.dart';
|
||||
@@ -36,57 +35,48 @@ void main() {
|
||||
expect(cancel.left, closeTo(16, 0.5));
|
||||
});
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('320 px at 2x keeps Retry reachable ($cupertino)', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(320, 480);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
testWidgets('320 px at 2x keeps Retry reachable', (tester) async {
|
||||
tester.view.physicalSize = const Size(320, 480);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
|
||||
final gateway = RetryWiringGateway();
|
||||
addTearDown(gateway.framesController.close);
|
||||
Widget scale(BuildContext context, Widget? app) => MediaQuery(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
).copyWith(textScaler: const TextScaler.linear(2)),
|
||||
child: app!,
|
||||
);
|
||||
// The action row itself, in the detail's 16 px inset, so the narrow
|
||||
// accessibility state is measured without unrelated header controls.
|
||||
final row = Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: RunDetailActions(
|
||||
run: retryFailedDetail(),
|
||||
gateway: gateway,
|
||||
onRunChanged: (_) {},
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(
|
||||
builder: scale,
|
||||
home: CupertinoPageScaffold(child: SafeArea(child: row)),
|
||||
)
|
||||
: MaterialApp(
|
||||
builder: scale,
|
||||
home: Scaffold(body: row),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
final gateway = RetryWiringGateway();
|
||||
addTearDown(gateway.framesController.close);
|
||||
Widget scale(BuildContext context, Widget? app) => MediaQuery(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
).copyWith(textScaler: const TextScaler.linear(2)),
|
||||
child: app!,
|
||||
);
|
||||
// The action row itself, in the detail's 16 px inset, so the narrow
|
||||
// accessibility state is measured without unrelated header controls.
|
||||
final row = Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: RunDetailActions(
|
||||
run: retryFailedDetail(),
|
||||
gateway: gateway,
|
||||
onRunChanged: (_) {},
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: scale,
|
||||
home: Scaffold(body: row),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(retryActionKey).hitTestable(), findsOneWidget);
|
||||
final rect = tester.getRect(find.byKey(retryActionKey));
|
||||
expect(rect.left, greaterThanOrEqualTo(0));
|
||||
expect(rect.right, lessThanOrEqualTo(320));
|
||||
expect(find.byKey(retryActionKey).hitTestable(), findsOneWidget);
|
||||
final rect = tester.getRect(find.byKey(retryActionKey));
|
||||
expect(rect.left, greaterThanOrEqualTo(0));
|
||||
expect(rect.right, lessThanOrEqualTo(320));
|
||||
|
||||
await tester.tap(find.byKey(retryActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(retryDialogTitle(7)), findsOneWidget);
|
||||
await tester.tap(find.byKey(retryKeepKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(gateway.retryCalls, isEmpty);
|
||||
});
|
||||
}
|
||||
await tester.tap(find.byKey(retryActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(retryDialogTitle(7)), findsOneWidget);
|
||||
await tester.tap(find.byKey(retryKeepKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(gateway.retryCalls, isEmpty);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_more_menu.dart';
|
||||
@@ -88,7 +87,6 @@ class RetryWiringGateway implements ApiGateway {
|
||||
Future<void> mountRetryScreen(
|
||||
WidgetTester tester,
|
||||
RetryWiringGateway gateway, {
|
||||
required bool cupertino,
|
||||
ValueChanged<int>? onRunSelected,
|
||||
}) async {
|
||||
final screen = RunsScreen(
|
||||
@@ -96,13 +94,7 @@ Future<void> mountRetryScreen(
|
||||
initialRunId: 7,
|
||||
onRunSelected: onRunSelected,
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(
|
||||
home: CupertinoPageScaffold(child: SafeArea(child: screen)),
|
||||
)
|
||||
: MaterialApp(home: Scaffold(body: screen)),
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: screen)));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,65 +7,55 @@ import 'run_retry_wiring_support.dart';
|
||||
import 'run_detail_finders.dart';
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets(
|
||||
'accepted retry reply opens the server-identified run ($cupertino)',
|
||||
(tester) async {
|
||||
final gateway = RetryWiringGateway();
|
||||
addTearDown(gateway.framesController.close);
|
||||
final opened = <int>[];
|
||||
await mountRetryScreen(
|
||||
tester,
|
||||
gateway,
|
||||
cupertino: cupertino,
|
||||
onRunSelected: opened.add,
|
||||
);
|
||||
testWidgets(
|
||||
'accepted retry reply opens the server-identified run',
|
||||
(tester) async {
|
||||
final gateway = RetryWiringGateway();
|
||||
addTearDown(gateway.framesController.close);
|
||||
final opened = <int>[];
|
||||
await mountRetryScreen(tester, gateway, onRunSelected: opened.add);
|
||||
|
||||
expect(runDetailText(retryFailedTitle), findsOneWidget);
|
||||
expect(find.byKey(runMoreMenuKey), findsOneWidget);
|
||||
expect(await retryOffered(tester), isTrue);
|
||||
expect(find.byKey(cancelActionKey), findsNothing);
|
||||
expect(gateway.retryCalls, isEmpty);
|
||||
expect(runDetailText(retryFailedTitle), findsOneWidget);
|
||||
expect(find.byKey(runMoreMenuKey), findsOneWidget);
|
||||
expect(await retryOffered(tester), isTrue);
|
||||
expect(find.byKey(cancelActionKey), findsNothing);
|
||||
expect(gateway.retryCalls, isEmpty);
|
||||
|
||||
await openRetry(tester);
|
||||
expect(find.text(retryDialogTitle(7)), findsOneWidget);
|
||||
expect(find.text(retryDialogMessage), findsOneWidget);
|
||||
expect(gateway.retryCalls, isEmpty);
|
||||
await openRetry(tester);
|
||||
expect(find.text(retryDialogTitle(7)), findsOneWidget);
|
||||
expect(find.text(retryDialogMessage), findsOneWidget);
|
||||
expect(gateway.retryCalls, isEmpty);
|
||||
|
||||
await tester.tap(find.byKey(retryKeepKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(gateway.retryCalls, isEmpty);
|
||||
expect(opened, isEmpty);
|
||||
expect(await retryOffered(tester), isTrue);
|
||||
await tester.tap(find.byKey(retryKeepKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(gateway.retryCalls, isEmpty);
|
||||
expect(opened, isEmpty);
|
||||
expect(await retryOffered(tester), isTrue);
|
||||
|
||||
await confirmRetry(tester);
|
||||
expect(gateway.retryCalls, hasLength(1));
|
||||
final fields = gateway.retryCalls.single.fields;
|
||||
expect(fields.keys.toSet(), {'run_id', 'request_key'});
|
||||
expect(fields['run_id'], 7);
|
||||
expect(fields['request_key'], startsWith('app-retry-7-'));
|
||||
expect(
|
||||
(fields['request_key'] as String).length,
|
||||
lessThanOrEqualTo(128),
|
||||
);
|
||||
// The prompt closes only from server truth; no navigation is guessed.
|
||||
expect(opened, isEmpty);
|
||||
expect(runDetailText(retryFailedTitle), findsOneWidget);
|
||||
await confirmRetry(tester);
|
||||
expect(gateway.retryCalls, hasLength(1));
|
||||
final fields = gateway.retryCalls.single.fields;
|
||||
expect(fields.keys.toSet(), {'run_id', 'request_key'});
|
||||
expect(fields['run_id'], 7);
|
||||
expect(fields['request_key'], startsWith('app-retry-7-'));
|
||||
expect((fields['request_key'] as String).length, lessThanOrEqualTo(128));
|
||||
// The prompt closes only from server truth; no navigation is guessed.
|
||||
expect(opened, isEmpty);
|
||||
expect(runDetailText(retryFailedTitle), findsOneWidget);
|
||||
|
||||
gateway.acceptRetry(retryCreatedDetail());
|
||||
await tester.pumpAndSettle();
|
||||
gateway.acceptRetry(retryCreatedDetail());
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(opened, [8]);
|
||||
expect(runDetailText(retryCreatedTitle), findsOneWidget);
|
||||
expect(runDetailText(retryFailedTitle), findsNothing);
|
||||
expect(await retryOffered(tester), isFalse);
|
||||
expect(
|
||||
gateway.calls.where((call) => call.type == 'get_run').last.fields,
|
||||
{'run_id': 8},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
expect(opened, [8]);
|
||||
expect(runDetailText(retryCreatedTitle), findsOneWidget);
|
||||
expect(runDetailText(retryFailedTitle), findsNothing);
|
||||
expect(await retryOffered(tester), isFalse);
|
||||
expect(
|
||||
gateway.calls.where((call) => call.type == 'get_run').last.fields,
|
||||
{'run_id': 8},
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('restart sends its explicit mode through the real detail row', (
|
||||
tester,
|
||||
@@ -73,12 +63,7 @@ void main() {
|
||||
final gateway = RetryWiringGateway();
|
||||
addTearDown(gateway.framesController.close);
|
||||
final opened = <int>[];
|
||||
await mountRetryScreen(
|
||||
tester,
|
||||
gateway,
|
||||
cupertino: false,
|
||||
onRunSelected: opened.add,
|
||||
);
|
||||
await mountRetryScreen(tester, gateway, onRunSelected: opened.add);
|
||||
|
||||
await openRetry(tester);
|
||||
await tester.tap(find.byKey(retryRestartKey));
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
@@ -100,16 +99,9 @@ Future<void> _pumpSession(
|
||||
WidgetTester tester,
|
||||
_RepairGateway gateway, {
|
||||
JsonMap? run,
|
||||
bool cupertino = false,
|
||||
}) {
|
||||
final host = _SessionHost(run: run ?? partialRun(), gateway: gateway);
|
||||
return tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(
|
||||
home: CupertinoPageScaffold(child: SafeArea(child: host)),
|
||||
)
|
||||
: MaterialApp(home: Scaffold(body: host)),
|
||||
);
|
||||
return tester.pumpWidget(MaterialApp(home: Scaffold(body: host)));
|
||||
}
|
||||
|
||||
TextButton _materialButton(WidgetTester tester) => tester.widget<TextButton>(
|
||||
@@ -254,18 +246,15 @@ void main() {
|
||||
expect(find.text('partial'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('the Cupertino host uses a native Cupertino button', (
|
||||
tester,
|
||||
) async {
|
||||
testWidgets('the repair control is a Material text button', (tester) async {
|
||||
final gateway = _RepairGateway(
|
||||
(_, _) => Future<JsonMap>.error(StateError('unexpected')),
|
||||
);
|
||||
await _pumpSession(tester, gateway, cupertino: true);
|
||||
await _pumpSession(tester, gateway);
|
||||
|
||||
expect(
|
||||
find.widgetWithText(CupertinoButton, 'Retry export only'),
|
||||
find.widgetWithText(TextButton, 'Retry export only'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.widgetWithText(TextButton, 'Retry export only'), findsNothing);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'run_detail_finders.dart';
|
||||
@@ -65,28 +64,17 @@ class _Gateway implements ApiGateway {
|
||||
|
||||
Future<_Gateway> _mount(
|
||||
WidgetTester tester, {
|
||||
required bool cupertino,
|
||||
int initialRunId = 1,
|
||||
}) async {
|
||||
final gateway = _Gateway();
|
||||
final screen = RunsScreen(gateway: gateway, initialRunId: initialRunId);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(
|
||||
home: CupertinoPageScaffold(child: SafeArea(child: screen)),
|
||||
)
|
||||
: MaterialApp(home: Scaffold(body: screen)),
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: screen)));
|
||||
await tester.pumpAndSettle();
|
||||
return gateway;
|
||||
}
|
||||
|
||||
String _fieldText(WidgetTester tester, {required bool cupertino}) => cupertino
|
||||
? tester
|
||||
.widget<CupertinoTextField>(find.byKey(runTitleFieldKey))
|
||||
.controller!
|
||||
.text
|
||||
: tester.widget<TextField>(find.byKey(runTitleFieldKey)).controller!.text;
|
||||
String _fieldText(WidgetTester tester) =>
|
||||
tester.widget<TextField>(find.byKey(runTitleFieldKey)).controller!.text;
|
||||
|
||||
/// Rename lives in the run detail's more menu.
|
||||
Future<void> _openRename(WidgetTester tester) async {
|
||||
@@ -99,7 +87,7 @@ Future<void> _openRename(WidgetTester tester) async {
|
||||
void main() {
|
||||
testWidgets('material detail renames through the shared gateway and folds '
|
||||
'only the server reply into the detail and list', (tester) async {
|
||||
final gateway = await _mount(tester, cupertino: false);
|
||||
final gateway = await _mount(tester);
|
||||
|
||||
expect(runDetailText('Nightly build'), findsOneWidget);
|
||||
expect(find.byKey(runMoreMenuKey), findsOneWidget);
|
||||
@@ -107,7 +95,7 @@ void main() {
|
||||
|
||||
await _openRename(tester);
|
||||
expect(find.byType(AlertDialog), findsOneWidget);
|
||||
expect(_fieldText(tester, cupertino: false), 'Nightly build');
|
||||
expect(_fieldText(tester), 'Nightly build');
|
||||
|
||||
await tester.enterText(find.byKey(runTitleFieldKey), 'Draft only');
|
||||
await tester.pump();
|
||||
@@ -146,35 +134,10 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('cupertino detail shows the native rename entry point', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway = await _mount(tester, cupertino: true);
|
||||
|
||||
expect(find.byKey(runMoreMenuKey), findsOneWidget);
|
||||
|
||||
await _openRename(tester);
|
||||
expect(find.byType(CupertinoAlertDialog), findsOneWidget);
|
||||
expect(find.byType(AlertDialog), findsNothing);
|
||||
|
||||
await tester.enterText(find.byKey(runTitleFieldKey), 'Release build');
|
||||
await tester.tap(find.byKey(runTitleSaveKey));
|
||||
await tester.pump();
|
||||
expect(gateway.saves.single.fields, {
|
||||
'run_id': 1,
|
||||
'title': 'Release build',
|
||||
});
|
||||
gateway.accept('Release build');
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(CupertinoAlertDialog), findsNothing);
|
||||
expect(runDetailText('Release build'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('a refused rename keeps the typed title and the stored detail', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway = await _mount(tester, cupertino: false);
|
||||
final gateway = await _mount(tester);
|
||||
|
||||
await _openRename(tester);
|
||||
await tester.enterText(find.byKey(runTitleFieldKey), ' locked ');
|
||||
@@ -184,7 +147,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('rename refused by the server'), findsOneWidget);
|
||||
expect(_fieldText(tester, cupertino: false), ' locked ');
|
||||
expect(_fieldText(tester), ' locked ');
|
||||
expect(find.byType(AlertDialog), findsOneWidget);
|
||||
expect(runDetailText('Nightly build'), findsOneWidget);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
@@ -78,7 +77,6 @@ List<JsonMap> _fixture() {
|
||||
Future<void> _mount(
|
||||
WidgetTester tester,
|
||||
_Gateway gateway, {
|
||||
bool cupertino = false,
|
||||
int? initialRunId,
|
||||
RunsSortStore? store,
|
||||
ValueChanged<int?>? onBack,
|
||||
@@ -92,11 +90,7 @@ Future<void> _mount(
|
||||
onBack: onBack,
|
||||
sortStore: store ?? MemoryRunsSortStore(),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: screen))
|
||||
: MaterialApp(home: Scaffold(body: screen)),
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: screen)));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
@@ -200,14 +194,14 @@ void main() {
|
||||
|
||||
testWidgets('Cancel in the prompt sends nothing', (tester) async {
|
||||
final gateway = _Gateway(_fixture());
|
||||
await _mount(tester, gateway, cupertino: true);
|
||||
await _mount(tester, gateway);
|
||||
await tester.tap(find.byKey(runsSelectKey));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Yesterday done'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(runsDeleteSelectedKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(CupertinoAlertDialog), findsOneWidget);
|
||||
expect(find.byType(AlertDialog), findsOneWidget);
|
||||
expect(find.text('Delete 1 run?'), findsOneWidget);
|
||||
await tester.tap(find.byKey(deleteRunsKeepKey));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import '../../../native_back.dart';
|
||||
@@ -9,7 +8,6 @@ import 'package:pipelines_app/features/runs/screen.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_detail_view.dart';
|
||||
import 'run_detail_finders.dart';
|
||||
import 'package:pipelines_app/shell/empty_detail_pane.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||
|
||||
class _Gateway implements ApiGateway {
|
||||
final framesController = StreamController<JsonMap>.broadcast();
|
||||
@@ -345,32 +343,6 @@ void main() {
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets(
|
||||
'wide Cupertino host keeps list and detail bars while pending',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: CupertinoPageScaffold(
|
||||
navigationBar: const CupertinoNavigationBar(middle: Text('Runs')),
|
||||
child: SafeArea(
|
||||
child: RunsScreen(gateway: gateway, initialRunId: 1),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await _mountList(tester, gateway);
|
||||
|
||||
expect(find.byType(CupertinoPageScaffold), findsNWidgets(2));
|
||||
// The host's own bar and the detail pane's segmented bar.
|
||||
expect(find.byType(CupertinoNavigationBar), findsOneWidget);
|
||||
expect(find.byType(SegmentedBar), findsOneWidget);
|
||||
expect(find.text('Loading run details…'), findsOneWidget);
|
||||
expect(find.byType(CupertinoActivityIndicator), findsOneWidget);
|
||||
expect(find.text('Back to list'), findsOneWidget);
|
||||
},
|
||||
variant: TargetPlatformVariant.only(TargetPlatform.iOS),
|
||||
);
|
||||
|
||||
testWidgets('on a phone an open run is its own page and Back returns', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/transport/pipelines_client.dart'
|
||||
@@ -9,22 +8,18 @@ import 'package:pipelines_app/features/settings/settings_store.dart';
|
||||
import 'package:pipelines_app/shell/adaptive_shell.dart';
|
||||
import 'package:pipelines_app/shell/destination.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||
import 'package:pipelines_app/ui/theme/app_theme.dart';
|
||||
|
||||
import 'fake_channel.dart';
|
||||
|
||||
/// Settings as the shell's tab: the page runs behind the shell's bar, and on
|
||||
/// Cupertino the grouped background reaches the top edge with the bar's
|
||||
/// scrim in the same colour, so no white band or seam shows under the bar.
|
||||
/// Settings as the shell's tab: the page runs behind the shell's bar.
|
||||
void main() {
|
||||
Future<void> pump(WidgetTester tester, {required bool cupertino}) async {
|
||||
Future<void> pump(WidgetTester tester) async {
|
||||
await tester.binding.setSurfaceSize(const Size(560, 1000));
|
||||
addTearDown(() => tester.binding.setSurfaceSize(null));
|
||||
final factory = FakeChannelFactory();
|
||||
final client = transport.PipelinesClient(channelFactory: factory.call);
|
||||
addTearDown(client.dispose);
|
||||
final shell = AdaptiveShell(
|
||||
cupertino: cupertino,
|
||||
destination: AppDestination.settings,
|
||||
destinationBodies: {
|
||||
AppDestination.settings: (_) => SettingsScreen(
|
||||
@@ -34,9 +29,7 @@ void main() {
|
||||
),
|
||||
},
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino ? CupertinoApp(home: shell) : MaterialApp(home: shell),
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(home: shell));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
}
|
||||
@@ -52,34 +45,8 @@ void main() {
|
||||
)
|
||||
.color;
|
||||
|
||||
testWidgets('Cupertino: the grouped background runs under the bar', (
|
||||
tester,
|
||||
) async {
|
||||
await pump(tester, cupertino: true);
|
||||
|
||||
final grouped = AppColors.groupedBackground.color.toARGB32();
|
||||
expect(scrimOf(tester).toARGB32(), grouped);
|
||||
// The page's background starts at the top edge, behind the bar.
|
||||
final page = find.ancestor(
|
||||
of: find.byKey(const ValueKey<String>('settings.scroll')),
|
||||
matching: find.byWidgetPredicate(
|
||||
(widget) => widget is ColoredBox && widget.color.toARGB32() == grouped,
|
||||
),
|
||||
);
|
||||
expect(page, findsWidgets);
|
||||
expect(tester.getTopLeft(page.last).dy, 0);
|
||||
// The groups start below the bar and persistent category selector.
|
||||
final bar = tester.getRect(find.byType(SegmentedBar));
|
||||
expect(
|
||||
tester.getTopLeft(find.byType(SettingsGroup).first).dy,
|
||||
greaterThanOrEqualTo(bar.bottom - 8),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Material: the bar keeps the shell page background', (
|
||||
tester,
|
||||
) async {
|
||||
await pump(tester, cupertino: false);
|
||||
testWidgets('the bar keeps the shell page background', (tester) async {
|
||||
await pump(tester);
|
||||
|
||||
final context = tester.element(find.byType(SettingsGroup).first);
|
||||
expect(
|
||||
|
||||
Reference in New Issue
Block a user