Sheets, decision options, usage, settings and artifact errors: review r2 batches H and L
Shared AppSheetHeader (title + Done) for the Runs filter/sort and Needs you sheets; Runs filter single-choice groups as check rows and statuses in sentence case; Cupertino decision options as a check list; run action sheet titled with the run; usage page without the duplicate title and with honest empty states; Settings Reconnect wording, compact notifications row and a tinted Cupertino Save workspace; friendly artifact preview failures with Retry.
This commit is contained in:
@@ -3,6 +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/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);
|
||||
@@ -194,9 +195,33 @@ void main() {
|
||||
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);
|
||||
|
||||
await tester.tap(find.text(decisionConfirmLabel));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -81,10 +81,13 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
expect(
|
||||
find.text('Pipeline unavailable · 2m 5s · 3 steps'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Pipeline unavailable · 2m 5s · 3 steps'), findsOneWidget);
|
||||
});
|
||||
|
||||
test('the run action sheet is titled with the run', () {
|
||||
expect(runMoreMenuTitle(_finished), 'Ship the release notes');
|
||||
expect(runMoreMenuTitle({'id': 5, 'name': 'nightly'}), 'nightly');
|
||||
expect(runMoreMenuTitle({'id': 5}), 'Run 5');
|
||||
});
|
||||
|
||||
testWidgets('gives a list action menu a per-run key', (tester) async {
|
||||
|
||||
@@ -0,0 +1,188 @@
|
||||
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';
|
||||
import 'package:pipelines_app/features/runs/data/runs_repository.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/runs_controller.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/runs_filter_sheet.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/runs_filters.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/runs_list.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/runs_stats_page.dart';
|
||||
import 'package:pipelines_app/ui/layout/app_sheet_header.dart';
|
||||
|
||||
class _Gateway implements ApiGateway {
|
||||
final framesController = StreamController<JsonMap>.broadcast();
|
||||
JsonMap? reply;
|
||||
|
||||
@override
|
||||
Stream<JsonMap> get frames => framesController.stream;
|
||||
|
||||
@override
|
||||
Future<JsonMap> call(String type, [JsonMap fields = const {}]) async =>
|
||||
reply ?? {'runs': []};
|
||||
}
|
||||
|
||||
/// The Runs sheets share one header (title and Done), single-choice groups
|
||||
/// use check rows, statuses read in sentence case, and the usage page neither
|
||||
/// repeats its title nor draws a chart of zeros.
|
||||
void main() {
|
||||
late _Gateway gateway;
|
||||
late RunsController controller;
|
||||
|
||||
setUp(() {
|
||||
gateway = _Gateway();
|
||||
controller = RunsController(RunsRepository(gateway));
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
controller.dispose();
|
||||
await gateway.framesController.close();
|
||||
});
|
||||
|
||||
Future<void> mount(
|
||||
WidgetTester tester, {
|
||||
required bool cupertino,
|
||||
String? createdAt,
|
||||
}) async {
|
||||
tester.view.physicalSize = const Size(800, 1400);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
final at = createdAt ?? DateTime.now().toIso8601String();
|
||||
gateway.reply = {
|
||||
'runs': [
|
||||
{
|
||||
'id': 1,
|
||||
'pipeline_id': 9,
|
||||
'name': 'Alpha',
|
||||
'status': 'running',
|
||||
'created_at': at,
|
||||
'scheduled': true,
|
||||
},
|
||||
],
|
||||
};
|
||||
await controller.load();
|
||||
final list = AnimatedBuilder(
|
||||
animation: controller,
|
||||
builder: (context, _) =>
|
||||
RunsList(controller: controller, onSelected: (_) {}),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: list))
|
||||
: MaterialApp(home: Scaffold(body: list)),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
|
||||
testWidgets('$host filter sheet has a header whose Done closes it', (
|
||||
tester,
|
||||
) async {
|
||||
await mount(tester, cupertino: cupertino);
|
||||
await tester.tap(find.byKey(const ValueKey('runs.filter')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(AppSheetHeader), findsOneWidget);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byType(AppSheetHeader),
|
||||
matching: find.text(runsFilterTitle),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Queued'), findsOneWidget);
|
||||
expect(find.text('queued'), findsNothing);
|
||||
expect(find.byKey(runsFilterClearKey), findsNothing);
|
||||
|
||||
await tester.tap(find.text('Last 7 days'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.timeRange, 'last_7_days');
|
||||
// An active filter offers Clear in the header.
|
||||
expect(find.byKey(runsFilterClearKey), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(runsFilterDoneKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const ValueKey('runs.filter.sheet')), findsNothing);
|
||||
// The applied chip reads in sentence case too.
|
||||
expect(find.textContaining('Last 7 days'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets('Material single-choice groups are check rows, not checkboxes', (
|
||||
tester,
|
||||
) async {
|
||||
await mount(tester, cupertino: false);
|
||||
await tester.tap(find.byKey(const ValueKey('runs.filter')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Seven statuses may be combined: those keep their checkboxes.
|
||||
expect(find.byType(CheckboxListTile), findsNWidgets(7));
|
||||
final anyTime = find.widgetWithText(ListTile, 'Any time');
|
||||
expect(anyTime, findsOneWidget);
|
||||
expect(
|
||||
find.descendant(of: anyTime, matching: find.byIcon(Icons.check)),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.descendant(of: anyTime, matching: find.byType(Checkbox)),
|
||||
findsNothing,
|
||||
);
|
||||
final today = find.widgetWithText(ListTile, 'Today');
|
||||
expect(
|
||||
find.descendant(of: today, matching: find.byIcon(Icons.check)),
|
||||
findsNothing,
|
||||
);
|
||||
expect(tester.widget<ListTile>(anyTime).selected, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('Material sort sheet has the same header', (tester) async {
|
||||
await mount(tester, cupertino: false);
|
||||
await tester.tap(find.byKey(const ValueKey('runs.sort')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(runsSortTitle), findsOneWidget);
|
||||
await tester.tap(find.byKey(runsSortDoneKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(runsSortTitle), findsNothing);
|
||||
expect(controller.sort, 'newest_first');
|
||||
});
|
||||
|
||||
testWidgets('the usage page is honest when nothing was reported', (
|
||||
tester,
|
||||
) async {
|
||||
await mount(
|
||||
tester,
|
||||
cupertino: false,
|
||||
createdAt: DateTime(2020, 1, 1).toIso8601String(),
|
||||
);
|
||||
await tester.tap(find.byKey(const ValueKey('runs.stats')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// The bar says Usage; the body does not repeat it.
|
||||
expect(find.text('Usage'), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('runs.stats.usage.empty')), findsOne);
|
||||
expect(find.byKey(const ValueKey('runs.stats.days')), findsNothing);
|
||||
expect(find.byKey(const ValueKey('runs.stats.days.empty')), findsOne);
|
||||
expect(find.text('Running'), findsOneWidget);
|
||||
expect(find.text('0'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('the 7-day chart shows bars over an axis when runs started', (
|
||||
tester,
|
||||
) async {
|
||||
await mount(tester, cupertino: true);
|
||||
await tester.tap(find.byKey(const ValueKey('runs.stats')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const ValueKey('runs.stats.days')), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('runs.stats.days.empty')), findsNothing);
|
||||
// Only the day with a run is labelled with its count.
|
||||
final days = find.byKey(const ValueKey('runs.stats.days'));
|
||||
expect(find.descendant(of: days, matching: find.text('1')), findsOne);
|
||||
expect(find.text('0'), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
@@ -70,18 +70,22 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
Future<void> reveal(WidgetTester tester, Finder target) =>
|
||||
tester.scrollUntilVisible(
|
||||
target,
|
||||
80,
|
||||
// The sheet's own list, not the search field's inner scrollable.
|
||||
scrollable: find
|
||||
.descendant(
|
||||
of: find.byKey(const ValueKey('runs.filter.sheet')),
|
||||
matching: find.byType(Scrollable),
|
||||
)
|
||||
.first,
|
||||
);
|
||||
Future<void> reveal(WidgetTester tester, Finder target) async {
|
||||
await tester.scrollUntilVisible(
|
||||
target,
|
||||
80,
|
||||
// The sheet's own list, not the search field's inner scrollable.
|
||||
scrollable: find
|
||||
.descendant(
|
||||
of: find.byKey(const ValueKey('runs.filter.sheet')),
|
||||
matching: find.byType(Scrollable),
|
||||
)
|
||||
.first,
|
||||
);
|
||||
// Built is not on screen: bring the row fully inside the sheet.
|
||||
await tester.ensureVisible(target);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
Future<void> closeSheet(WidgetTester tester) async {
|
||||
await tester.tapAt(const Offset(4, 4));
|
||||
@@ -148,7 +152,7 @@ void main() {
|
||||
await tester.tap(find.byKey(const ValueKey('runs.filter')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(CupertinoSearchTextField), findsOneWidget);
|
||||
final failed = find.widgetWithText(CupertinoListTile, 'failed');
|
||||
final failed = find.widgetWithText(CupertinoListTile, 'Failed');
|
||||
await reveal(tester, failed);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(failed);
|
||||
@@ -156,7 +160,7 @@ void main() {
|
||||
expect(controller.statuses, {'failed'});
|
||||
await closeSheet(tester);
|
||||
|
||||
final failedChip = find.widgetWithText(CupertinoButton, 'failed');
|
||||
final failedChip = find.widgetWithText(CupertinoButton, 'Failed');
|
||||
expect(failedChip, findsOneWidget);
|
||||
expect(find.text('Alpha'), findsNothing);
|
||||
await tester.tap(failedChip);
|
||||
|
||||
Reference in New Issue
Block a user