feat(app): Rename and Schedule this run move into the run detail's more menu
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_more_menu.dart';
|
||||
import 'package:pipelines_app/features/graph/widgets/run_graph_view.dart';
|
||||
import 'package:pipelines_app/features/runs/actions/title_wording.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_detail_tab.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_detail_tab_strip.dart';
|
||||
|
||||
@@ -36,7 +36,7 @@ void main() {
|
||||
expect(center.dx, greaterThan(previous));
|
||||
previous = center.dx;
|
||||
}
|
||||
expect(find.byKey(runTitleActionKey), findsOneWidget);
|
||||
expect(find.byKey(runMoreMenuKey), findsOneWidget);
|
||||
// The strip lines up with the header's 16px inset on both hosts: the
|
||||
// first label sits within its segment's own padding of that inset, not
|
||||
// behind a second 16px control inset (which put it at 48 on Cupertino).
|
||||
@@ -48,7 +48,7 @@ void main() {
|
||||
RunDetailTab.summary,
|
||||
]) {
|
||||
await openRunDetailTab(tester, tab);
|
||||
expect(find.byKey(runTitleActionKey), findsOneWidget);
|
||||
expect(find.byKey(runMoreMenuKey), findsOneWidget);
|
||||
expect(find.text('Graph run'), findsOneWidget);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_more_menu.dart';
|
||||
import 'package:pipelines_app/core/transport/connection_state.dart';
|
||||
import 'package:pipelines_app/features/runs/actions/retry_wording.dart';
|
||||
import 'package:pipelines_app/features/runs/actions/title_wording.dart';
|
||||
|
||||
import 'run_retry_wiring_support.dart';
|
||||
|
||||
@@ -108,7 +108,7 @@ void main() {
|
||||
addTearDown(gateway.framesController.close);
|
||||
await mountRetryScreen(tester, gateway, cupertino: false);
|
||||
|
||||
expect(find.byKey(runTitleActionKey), findsOneWidget);
|
||||
expect(find.byKey(runMoreMenuKey), findsOneWidget);
|
||||
expect(find.byKey(retryActionKey), findsNothing);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,13 +3,12 @@ import 'package:flutter/material.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/retry_wording.dart';
|
||||
import 'package:pipelines_app/features/runs/actions/title_wording.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_detail_actions.dart';
|
||||
|
||||
import 'run_retry_wiring_support.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('a hidden retry adds no extra gap for Rename and Cancel', (
|
||||
testWidgets('a hidden retry adds no leading gap before Cancel', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway = RetryWiringGateway();
|
||||
@@ -32,45 +31,13 @@ void main() {
|
||||
|
||||
// Retry is not eligible on the running run and must not consume spacing.
|
||||
expect(find.byKey(retryActionKey), findsNothing);
|
||||
final rename = tester.getRect(find.byKey(runTitleActionKey));
|
||||
// Rename lives in the more menu; Cancel now leads the row.
|
||||
final cancel = tester.getRect(find.byKey(cancelActionKey));
|
||||
expect(cancel.left - rename.right, closeTo(8, 0.5));
|
||||
expect(cancel.left, closeTo(16, 0.5));
|
||||
});
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('adjacent actions keep native spacing at 320 px ($cupertino)', (
|
||||
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);
|
||||
final row = Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: RunDetailActions(
|
||||
run: retryFailedDetail(),
|
||||
gateway: gateway,
|
||||
onRunChanged: (_) {},
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(
|
||||
home: CupertinoPageScaffold(child: SafeArea(child: row)),
|
||||
)
|
||||
: MaterialApp(home: Scaffold(body: row)),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expectNativeActionSpacing(tester);
|
||||
});
|
||||
}
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('320 px at 2x keeps Rename and Retry reachable ($cupertino)', (
|
||||
testWidgets('320 px at 2x keeps Retry reachable ($cupertino)', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(320, 480);
|
||||
@@ -109,12 +76,10 @@ void main() {
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(runTitleActionKey).hitTestable(), findsOneWidget);
|
||||
expect(find.byKey(retryActionKey).hitTestable(), findsOneWidget);
|
||||
final rect = tester.getRect(find.byKey(retryActionKey));
|
||||
expect(rect.left, greaterThanOrEqualTo(0));
|
||||
expect(rect.right, lessThanOrEqualTo(320));
|
||||
expectNativeActionSpacing(tester);
|
||||
|
||||
await tester.tap(find.byKey(retryActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -125,27 +90,3 @@ void main() {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// Asserts the action row uses the detail's native 8 dp / 4 dp spacing.
|
||||
///
|
||||
/// The row previously had no `spacing`, leaving the outlined Rename border
|
||||
/// touching the filled Retry button; browser measurement at 320 px reported a
|
||||
/// 0.008 px gap. A hidden action must not consume spacing either.
|
||||
void expectNativeActionSpacing(WidgetTester tester) {
|
||||
final rename = tester.getRect(find.byKey(runTitleActionKey));
|
||||
final retry = tester.getRect(find.byKey(retryActionKey));
|
||||
final sameRow = retry.top < rename.bottom && rename.top < retry.bottom;
|
||||
if (sameRow) {
|
||||
expect(
|
||||
retry.left - rename.right,
|
||||
greaterThanOrEqualTo(8 - 0.01),
|
||||
reason: 'side-by-side actions need the 8 dp Wrap spacing',
|
||||
);
|
||||
} else {
|
||||
expect(
|
||||
retry.top - rename.bottom,
|
||||
greaterThanOrEqualTo(4 - 0.01),
|
||||
reason: 'wrapped actions need the 4 dp Wrap run spacing',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_more_menu.dart';
|
||||
import 'package:pipelines_app/features/runs/actions/cancel_wording.dart';
|
||||
import 'package:pipelines_app/features/runs/actions/retry_wording.dart';
|
||||
import 'package:pipelines_app/features/runs/actions/title_wording.dart';
|
||||
|
||||
import 'run_retry_wiring_support.dart';
|
||||
|
||||
@@ -21,7 +21,7 @@ void main() {
|
||||
);
|
||||
|
||||
expect(find.text(retryFailedTitle), findsOneWidget);
|
||||
expect(find.byKey(runTitleActionKey), findsOneWidget);
|
||||
expect(find.byKey(runMoreMenuKey), findsOneWidget);
|
||||
expect(find.byKey(retryActionKey), findsOneWidget);
|
||||
expect(find.byKey(cancelActionKey), findsNothing);
|
||||
expect(gateway.retryCalls, isEmpty);
|
||||
|
||||
@@ -3,6 +3,7 @@ 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';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/core/transport/connection_state.dart';
|
||||
import 'package:pipelines_app/features/runs/actions/title_wording.dart';
|
||||
@@ -86,18 +87,24 @@ String _fieldText(WidgetTester tester, {required bool cupertino}) => cupertino
|
||||
.text
|
||||
: tester.widget<TextField>(find.byKey(runTitleFieldKey)).controller!.text;
|
||||
|
||||
/// Rename lives in the run detail's more menu.
|
||||
Future<void> _openRename(WidgetTester tester) async {
|
||||
await tester.tap(find.byKey(runMoreMenuKey));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text(runTitleActionLabel).last);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
expect(find.text('Nightly build'), findsOneWidget);
|
||||
expect(find.byKey(runTitleActionKey), findsOneWidget);
|
||||
expect(find.byType(OutlinedButton), findsOneWidget);
|
||||
expect(find.byKey(runMoreMenuKey), findsOneWidget);
|
||||
expect(gateway.saves, isEmpty);
|
||||
|
||||
await tester.tap(find.byKey(runTitleActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
await _openRename(tester);
|
||||
expect(find.byType(AlertDialog), findsOneWidget);
|
||||
expect(_fieldText(tester, cupertino: false), 'Nightly build');
|
||||
|
||||
@@ -109,8 +116,7 @@ void main() {
|
||||
expect(gateway.saves, isEmpty);
|
||||
expect(find.text('Nightly build'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(runTitleActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
await _openRename(tester);
|
||||
await tester.enterText(find.byKey(runTitleFieldKey), ' Release build ');
|
||||
await tester.tap(find.byKey(runTitleSaveKey));
|
||||
await tester.pump();
|
||||
@@ -139,11 +145,9 @@ void main() {
|
||||
) async {
|
||||
final gateway = await _mount(tester, cupertino: true);
|
||||
|
||||
expect(find.byKey(runTitleActionKey), findsOneWidget);
|
||||
expect(find.byType(OutlinedButton), findsNothing);
|
||||
expect(find.byKey(runMoreMenuKey), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(runTitleActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
await _openRename(tester);
|
||||
expect(find.byType(CupertinoAlertDialog), findsOneWidget);
|
||||
expect(find.byType(AlertDialog), findsNothing);
|
||||
|
||||
@@ -166,8 +170,7 @@ void main() {
|
||||
) async {
|
||||
final gateway = await _mount(tester, cupertino: false);
|
||||
|
||||
await tester.tap(find.byKey(runTitleActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
await _openRename(tester);
|
||||
await tester.enterText(find.byKey(runTitleFieldKey), ' locked ');
|
||||
await tester.tap(find.byKey(runTitleSaveKey));
|
||||
await tester.pump();
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/core/transport/connection_state.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_detail_actions.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_more_menu.dart';
|
||||
import 'package:pipelines_app/features/schedules/ui/editor/schedule_editor_wording.dart';
|
||||
import 'package:pipelines_app/features/schedules/ui/run/schedule_run_action.dart';
|
||||
|
||||
@@ -194,36 +194,36 @@ void main() {
|
||||
tester,
|
||||
) async {
|
||||
final gateway = SaveGateway();
|
||||
await pumpAction(
|
||||
tester,
|
||||
RunDetailActions(
|
||||
run: runFixture(),
|
||||
gateway: gateway,
|
||||
onRunChanged: (_) {},
|
||||
),
|
||||
);
|
||||
expect(find.byKey(scheduleRunActionKey), findsOneWidget);
|
||||
// The run detail offers it from its more menu, beside Rename.
|
||||
Future<void> openMenu(JsonMap run) async {
|
||||
await pumpAction(
|
||||
tester,
|
||||
RunMoreMenu(
|
||||
run: run,
|
||||
gateway: gateway,
|
||||
onRunChanged: (_) {},
|
||||
cupertino: false,
|
||||
),
|
||||
);
|
||||
// A run with nothing to offer shows no menu at all.
|
||||
if (find.byKey(runMoreMenuKey).evaluate().isEmpty) return;
|
||||
await tester.tap(find.byKey(runMoreMenuKey));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
await openMenu(runFixture());
|
||||
expect(find.text(scheduleRunActionLabel), findsOneWidget);
|
||||
await tester.tap(find.text(scheduleRunActionLabel));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(scheduleEditorSubmitKey), findsOneWidget);
|
||||
expect(gateway.calls, isEmpty);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
|
||||
await pumpAction(
|
||||
tester,
|
||||
RunDetailActions(
|
||||
run: runFixture(version: 0),
|
||||
gateway: gateway,
|
||||
onRunChanged: (_) {},
|
||||
),
|
||||
);
|
||||
expect(find.byKey(scheduleRunActionKey), findsNothing);
|
||||
await openMenu(runFixture(version: 0));
|
||||
expect(find.text(scheduleRunActionLabel), findsNothing);
|
||||
|
||||
await pumpAction(
|
||||
tester,
|
||||
RunDetailActions(
|
||||
run: runFixture(pipelineId: null),
|
||||
gateway: gateway,
|
||||
onRunChanged: (_) {},
|
||||
),
|
||||
);
|
||||
expect(find.byKey(scheduleRunActionKey), findsNothing);
|
||||
await openMenu(runFixture(pipelineId: null));
|
||||
expect(find.text(scheduleRunActionLabel), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('Cupertino uses the native action and fields', (tester) async {
|
||||
|
||||
Reference in New Issue
Block a user