Remove Cupertino attention branches
Keep the reviewed attention surfaces on their Material implementations while preserving public cupertino parameters for remaining callers. Remove the unreachable Cupertino sheet and narrow tests to the Material path.
This commit is contained in:
@@ -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';
|
||||
@@ -45,7 +44,6 @@ void main() {
|
||||
|
||||
Future<void> mount(
|
||||
WidgetTester tester, {
|
||||
required bool cupertino,
|
||||
ValueChanged<num>? onSelected,
|
||||
}) async {
|
||||
gateway.reply = {
|
||||
@@ -60,29 +58,23 @@ void main() {
|
||||
builder: (context, _) =>
|
||||
RunsList(controller: controller, onSelected: onSelected ?? (_) {}),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: list))
|
||||
: MaterialApp(home: Scaffold(body: list)),
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: list)));
|
||||
}
|
||||
|
||||
testWidgets(
|
||||
'uses native search and filters runs in CupertinoApp',
|
||||
'filters runs from the filter sheet',
|
||||
(tester) async {
|
||||
num? selectedRun;
|
||||
await mount(
|
||||
tester,
|
||||
cupertino: true,
|
||||
onSelected: (id) => selectedRun = id,
|
||||
);
|
||||
await mount(tester, onSelected: (id) => selectedRun = id);
|
||||
|
||||
// The text filter lives in the filter sheet.
|
||||
expect(find.byType(CupertinoSearchTextField), findsNothing);
|
||||
expect(find.text('Alpha'), findsOneWidget);
|
||||
await tester.tap(find.byKey(const ValueKey('runs.filter')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.enterText(find.byType(CupertinoSearchTextField), 'Beta');
|
||||
await tester.enterText(
|
||||
find.byKey(const ValueKey('runs.filter.query')),
|
||||
'Beta',
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tapAt(const Offset(4, 4));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -90,7 +82,7 @@ void main() {
|
||||
await tester.tap(find.byKey(const ValueKey('run-row-2')));
|
||||
expect(selectedRun, 2);
|
||||
},
|
||||
variant: TargetPlatformVariant.only(TargetPlatform.iOS),
|
||||
variant: TargetPlatformVariant.only(TargetPlatform.android),
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
@@ -147,9 +139,9 @@ void main() {
|
||||
gateway.gate = Completer<void>();
|
||||
final loading = controller.load();
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: CupertinoPageScaffold(
|
||||
child: AnimatedBuilder(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: AnimatedBuilder(
|
||||
animation: controller,
|
||||
builder: (_, child) =>
|
||||
RunsList(controller: controller, onSelected: (_) {}),
|
||||
@@ -158,7 +150,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
expect(find.byType(CupertinoActivityIndicator), findsOneWidget);
|
||||
expect(find.byType(CircularProgressIndicator), findsOneWidget);
|
||||
gateway.gate!.complete();
|
||||
await loading;
|
||||
await tester.pumpAndSettle();
|
||||
@@ -173,49 +165,45 @@ void main() {
|
||||
expect(find.textContaining('offline'), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
},
|
||||
variant: TargetPlatformVariant.only(TargetPlatform.iOS),
|
||||
variant: TargetPlatformVariant.only(TargetPlatform.android),
|
||||
);
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('the attention bell is one of the actions '
|
||||
'(${cupertino ? 'Cupertino' : 'Material'})', (tester) async {
|
||||
await mount(tester, cupertino: cupertino);
|
||||
await tester.pumpAndSettle();
|
||||
final bell = find.byType(NeedsYouRunsHeading);
|
||||
expect(bell, findsOneWidget);
|
||||
// Not in a row of its own: it shares the actions' line, before filter.
|
||||
final filter = find.byKey(const ValueKey('runs.filter'));
|
||||
expect(
|
||||
(tester.getCenter(bell).dy - tester.getCenter(filter).dy).abs(),
|
||||
lessThan(2),
|
||||
);
|
||||
expect(tester.getCenter(bell).dx, lessThan(tester.getCenter(filter).dx));
|
||||
expect(
|
||||
find.descendant(of: find.byType(RunsFilters), matching: bell),
|
||||
findsNothing,
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
testWidgets('the attention bell is one of the actions', (tester) async {
|
||||
await mount(tester);
|
||||
await tester.pumpAndSettle();
|
||||
final bell = find.byType(NeedsYouRunsHeading);
|
||||
expect(bell, findsOneWidget);
|
||||
// Not in a row of its own: it shares the actions' line, before filter.
|
||||
final filter = find.byKey(const ValueKey('runs.filter'));
|
||||
expect(
|
||||
(tester.getCenter(bell).dy - tester.getCenter(filter).dy).abs(),
|
||||
lessThan(2),
|
||||
);
|
||||
expect(tester.getCenter(bell).dx, lessThan(tester.getCenter(filter).dx));
|
||||
expect(
|
||||
find.descendant(of: find.byType(RunsFilters), matching: bell),
|
||||
findsNothing,
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('rows lead with the status glyph, not a status word '
|
||||
'(${cupertino ? 'Cupertino' : 'Material'})', (tester) async {
|
||||
await mount(tester, cupertino: cupertino);
|
||||
await tester.pumpAndSettle();
|
||||
final icons = tester
|
||||
.widgetList<RunStatusIcon>(find.byType(RunStatusIcon))
|
||||
.map((icon) => (icon.state, icon.label))
|
||||
.toList();
|
||||
expect(
|
||||
icons,
|
||||
unorderedEquals([('running', 'running'), ('failed', 'failed')]),
|
||||
);
|
||||
expect(find.text('failed'), findsNothing);
|
||||
expect(
|
||||
tester.getCenter(find.byType(RunStatusIcon).first).dx,
|
||||
lessThan(tester.getTopLeft(find.text('Alpha')).dx),
|
||||
);
|
||||
});
|
||||
}
|
||||
testWidgets('rows lead with the status glyph, not a status word', (
|
||||
tester,
|
||||
) async {
|
||||
await mount(tester);
|
||||
await tester.pumpAndSettle();
|
||||
final icons = tester
|
||||
.widgetList<RunStatusIcon>(find.byType(RunStatusIcon))
|
||||
.map((icon) => (icon.state, icon.label))
|
||||
.toList();
|
||||
expect(
|
||||
icons,
|
||||
unorderedEquals([('running', 'running'), ('failed', 'failed')]),
|
||||
);
|
||||
expect(find.text('failed'), findsNothing);
|
||||
expect(
|
||||
tester.getCenter(find.byType(RunStatusIcon).first).dx,
|
||||
lessThan(tester.getTopLeft(find.text('Alpha')).dx),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user