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:
2026-11-11 01:31:14 +00:00
parent 37cf9472c2
commit 968e3e908a
16 changed files with 792 additions and 1157 deletions
@@ -6,10 +6,10 @@ import 'package:pipelines_app/features/attention/ui/needs_you_keys.dart';
import 'attention_runs_test_support.dart';
/// The hardest real-app case: a narrow phone at a doubled text scale. Both the
/// Runs list chrome and the native sheet must keep the bell and every action
/// inside the viewport.
/// Runs list chrome and the sheet must keep the bell and every action inside the
/// viewport.
void main() {
testWidgets('both hosts fit the bell and sheet at 320 logical px and 2x', (
testWidgets('Material fits the bell and sheet at 320 logical px and 2x', (
tester,
) async {
tester.view.devicePixelRatio = 2;
@@ -19,54 +19,49 @@ void main() {
final gateway = AttentionRunsGateway();
addTearDown(gateway.framesController.close);
for (final native in [false, true]) {
await mountAttentionRuns(
tester,
gateway,
cupertino: native,
store: MemoryAttentionStore(),
runs: [
attentionRun(
1,
'waiting',
title: 'Approve a release candidate at 320 px',
),
attentionRun(
2,
'failed',
title: 'A failed run with a label long enough to wrap',
diagnostic: 'Stage 3 stopped because the credential is missing.',
),
],
request: native ? 1 : 0,
textScale: 2,
key: ValueKey(native),
);
expect(find.byKey(attentionBellKey), findsOneWidget);
final listError = tester.takeException();
expect(
listError,
isNull,
reason: listError is FlutterError
? '${native ? 'Cupertino' : 'Material'} list: ${listError.toStringDeep()}'
: '${native ? 'Cupertino' : 'Material'} list: $listError',
);
await openAttentionSheet(tester);
final sheetError = tester.takeException();
expect(
sheetError,
isNull,
reason: sheetError is FlutterError
? '${native ? 'Cupertino' : 'Material'} sheet: ${sheetError.toStringDeep()}'
: '${native ? 'Cupertino' : 'Material'} sheet: $sheetError',
);
final sheet = tester.getRect(find.byKey(attentionSheetKey));
expect(sheet.left, greaterThanOrEqualTo(0));
expect(sheet.right, lessThanOrEqualTo(320));
expect(sheet.top, greaterThanOrEqualTo(0));
expect(sheet.bottom, lessThanOrEqualTo(640));
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
}
await mountAttentionRuns(
tester,
gateway,
store: MemoryAttentionStore(),
runs: [
attentionRun(
1,
'waiting',
title: 'Approve a release candidate at 320 px',
),
attentionRun(
2,
'failed',
title: 'A failed run with a label long enough to wrap',
diagnostic: 'Stage 3 stopped because the credential is missing.',
),
],
textScale: 2,
);
expect(find.byKey(attentionBellKey), findsOneWidget);
final listError = tester.takeException();
expect(
listError,
isNull,
reason: listError is FlutterError
? 'Material list: ${listError.toStringDeep()}'
: 'Material list: $listError',
);
await openAttentionSheet(tester);
final sheetError = tester.takeException();
expect(
sheetError,
isNull,
reason: sheetError is FlutterError
? 'Material sheet: ${sheetError.toStringDeep()}'
: 'Material sheet: $sheetError',
);
final sheet = tester.getRect(find.byKey(attentionSheetKey));
expect(sheet.left, greaterThanOrEqualTo(0));
expect(sheet.right, lessThanOrEqualTo(320));
expect(sheet.top, greaterThanOrEqualTo(0));
expect(sheet.bottom, lessThanOrEqualTo(640));
await tester.binding.handlePopRoute();
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 'package:pipelines_app/core/api_gateway.dart';
@@ -63,7 +62,6 @@ class AttentionRunsGateway implements ApiGateway {
Widget attentionRunsApp(
AttentionRunsGateway gateway, {
required bool cupertino,
required AttentionStore store,
double textScale = 1,
Key? key,
@@ -80,13 +78,6 @@ Widget attentionRunsApp(
attentionStore: store,
attentionNow: () => attentionTestNow,
);
if (cupertino) {
return CupertinoApp(
theme: const CupertinoThemeData(brightness: Brightness.dark),
builder: scaled,
home: CupertinoPageScaffold(child: screen),
);
}
return MaterialApp(
theme: ThemeData(platform: TargetPlatform.android),
builder: scaled,
@@ -97,7 +88,6 @@ Widget attentionRunsApp(
Future<void> mountAttentionRuns(
WidgetTester tester,
AttentionRunsGateway gateway, {
required bool cupertino,
required AttentionStore store,
required List<JsonMap> runs,
int request = 0,
@@ -107,7 +97,6 @@ Future<void> mountAttentionRuns(
await tester.pumpWidget(
attentionRunsApp(
gateway,
cupertino: cupertino,
store: store,
textScale: textScale,
key: key,
@@ -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/attention/domain/attention_models.dart';
@@ -14,183 +13,173 @@ void main() {
setUp(() => gateway = AttentionRunsGateway());
tearDown(() => gateway.framesController.close());
for (final native in [false, true]) {
final host = native ? 'Cupertino' : 'Material';
testWidgets(
'$host Runs list bell opens the native sheet and dismisses one',
(tester) async {
final semantics = tester.ensureSemantics();
final store = MemoryAttentionStore();
await mountAttentionRuns(
tester,
gateway,
cupertino: native,
store: store,
runs: [
attentionRun(1, 'waiting', title: 'Approve the release'),
attentionRun(
2,
'failed',
title: 'Ship the release',
diagnostic: 'Stage 2',
),
attentionRun(3, 'waiting', title: 'Machine export')
..['export_pending_sequence'] = 2,
attentionRun(4, 'running', title: 'Still running'),
],
);
expect(
find.bySemanticsLabel('Notifications, 2 needing attention'),
findsOneWidget,
);
await openAttentionSheet(tester);
expect(find.byKey(attentionSheetKey), findsOneWidget);
expect(find.byKey(attentionRowKey('3:Decision')), findsNothing);
expect(find.byKey(attentionRowKey('4:Failed')), findsNothing);
expect(find.byKey(attentionRowKey('2:Failed')), findsOneWidget);
await tester.tap(find.byKey(attentionDismissKey('2:Failed')));
await tester.pumpAndSettle();
expect(find.byKey(attentionSheetKey), findsOneWidget);
expect(find.byKey(attentionRowKey('2:Failed')), findsNothing);
expect(store.stored, encodeAttentionDismissals({'2:Failed'}));
// Closing and rebuilding from the same store keeps the dismissal.
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
await tester.pumpWidget(const SizedBox());
await mountAttentionRuns(
tester,
gateway,
cupertino: native,
store: store,
runs: [
attentionRun(1, 'waiting', title: 'Approve the release'),
attentionRun(
2,
'failed',
title: 'Ship the release',
diagnostic: 'Stage 2',
),
],
request: 1,
key: const ValueKey('rebuilt'),
);
expect(
find.bySemanticsLabel('Notifications, 1 needing attention'),
findsOneWidget,
);
semantics.dispose();
},
testWidgets('Material Runs list bell opens the sheet and dismisses one', (
tester,
) async {
final semantics = tester.ensureSemantics();
final store = MemoryAttentionStore();
await mountAttentionRuns(
tester,
gateway,
store: store,
runs: [
attentionRun(1, 'waiting', title: 'Approve the release'),
attentionRun(
2,
'failed',
title: 'Ship the release',
diagnostic: 'Stage 2',
),
attentionRun(3, 'waiting', title: 'Machine export')
..['export_pending_sequence'] = 2,
attentionRun(4, 'running', title: 'Still running'),
],
);
testWidgets('$host rows follow the browser open/dismiss rules', (
expect(
find.bySemanticsLabel('Notifications, 2 needing attention'),
findsOneWidget,
);
await openAttentionSheet(tester);
expect(find.byKey(attentionSheetKey), findsOneWidget);
expect(find.byKey(attentionRowKey('3:Decision')), findsNothing);
expect(find.byKey(attentionRowKey('4:Failed')), findsNothing);
expect(find.byKey(attentionRowKey('2:Failed')), findsOneWidget);
await tester.tap(find.byKey(attentionDismissKey('2:Failed')));
await tester.pumpAndSettle();
expect(find.byKey(attentionSheetKey), findsOneWidget);
expect(find.byKey(attentionRowKey('2:Failed')), findsNothing);
expect(store.stored, encodeAttentionDismissals({'2:Failed'}));
// Closing and rebuilding from the same store keeps the dismissal.
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
await tester.pumpWidget(const SizedBox());
await mountAttentionRuns(
tester,
) async {
final store = MemoryAttentionStore();
await mountAttentionRuns(
tester,
gateway,
cupertino: native,
store: store,
runs: [
attentionRun(1, 'waiting', title: 'Approve the release'),
attentionRun(2, 'failed', title: 'Ship the release'),
],
);
gateway,
store: store,
runs: [
attentionRun(1, 'waiting', title: 'Approve the release'),
attentionRun(
2,
'failed',
title: 'Ship the release',
diagnostic: 'Stage 2',
),
],
request: 1,
key: const ValueKey('rebuilt'),
);
expect(
find.bySemanticsLabel('Notifications, 1 needing attention'),
findsOneWidget,
);
semantics.dispose();
});
await openAttentionSheet(tester);
await tester.tap(find.byKey(attentionRowKey('1:Decision')));
await tester.pump();
await tester.pump(const Duration(milliseconds: 400));
expect(gateway.detailRequests[1], hasLength(1));
expect(
store.stored,
isNull,
reason: 'a Decision opens without dismissing',
);
gateway.replyDetail(1, {'id': 1, 'title': 'Approve the release'});
await tester.pump();
await tester.pumpAndSettle();
// The wide list and its bell stay available beside the open detail.
expect(find.byKey(const ValueKey('run-row-2')), findsOneWidget);
await openAttentionSheet(tester);
await tester.tap(find.byKey(attentionRowKey('2:Failed')));
await tester.pump();
await tester.pump(const Duration(milliseconds: 400));
expect(gateway.detailRequests[2], hasLength(1));
expect(store.stored, encodeAttentionDismissals({'2:Failed'}));
gateway.replyDetail(2, {'id': 2, 'title': 'Ship the release'});
await tester.pump();
});
testWidgets('$host live frame and Clear-all snapshot reach the bell', (
testWidgets('Material rows follow the browser open/dismiss rules', (
tester,
) async {
final store = MemoryAttentionStore();
await mountAttentionRuns(
tester,
) async {
final semantics = tester.ensureSemantics();
final store = MemoryAttentionStore();
await mountAttentionRuns(
tester,
gateway,
cupertino: native,
store: store,
runs: [attentionRun(1, 'failed', title: 'First failure')],
);
expect(
find.bySemanticsLabel('Notifications, 1 needing attention'),
findsOneWidget,
);
gateway,
store: store,
runs: [
attentionRun(1, 'waiting', title: 'Approve the release'),
attentionRun(2, 'failed', title: 'Ship the release'),
],
);
await openAttentionSheet(tester);
gateway.framesController.add({
'type': 'run_event',
'run_id': 9,
'pipeline_id': 4,
'name': 'nightly',
'title': 'Arrived while open',
'status': 'waiting',
'created_at': attentionTestNow
.subtract(const Duration(minutes: 5))
.toIso8601String(),
});
await tester.pump();
await tester.pumpAndSettle();
expect(find.byKey(attentionRowKey('9:Decision')), findsOneWidget);
await openAttentionSheet(tester);
await tester.tap(find.byKey(attentionRowKey('1:Decision')));
await tester.pump();
await tester.pump(const Duration(milliseconds: 400));
expect(gateway.detailRequests[1], hasLength(1));
expect(
store.stored,
isNull,
reason: 'a Decision opens without dismissing',
);
gateway.replyDetail(1, {'id': 1, 'title': 'Approve the release'});
await tester.pump();
await tester.pumpAndSettle();
await tester.tap(find.byKey(attentionClearAllKey));
await tester.pumpAndSettle();
expect(find.byKey(attentionRowKey('1:Failed')), findsNothing);
expect(
find.byKey(attentionRowKey('9:Decision')),
findsOneWidget,
reason: 'Clear all acts on the snapshot it opened with',
);
expect(store.stored, encodeAttentionDismissals({'1:Failed'}));
semantics.dispose();
});
// The wide list and its bell stay available beside the open detail.
expect(find.byKey(const ValueKey('run-row-2')), findsOneWidget);
await openAttentionSheet(tester);
await tester.tap(find.byKey(attentionRowKey('2:Failed')));
await tester.pump();
await tester.pump(const Duration(milliseconds: 400));
expect(gateway.detailRequests[2], hasLength(1));
expect(store.stored, encodeAttentionDismissals({'2:Failed'}));
gateway.replyDetail(2, {'id': 2, 'title': 'Ship the release'});
await tester.pump();
});
testWidgets('$host empty runs hide the badge but keep the bell', (
testWidgets('Material live frame and Clear-all snapshot reach the bell', (
tester,
) async {
final semantics = tester.ensureSemantics();
final store = MemoryAttentionStore();
await mountAttentionRuns(
tester,
) async {
final semantics = tester.ensureSemantics();
await mountAttentionRuns(
tester,
gateway,
cupertino: native,
store: MemoryAttentionStore(),
runs: const [],
);
gateway,
store: store,
runs: [attentionRun(1, 'failed', title: 'First failure')],
);
expect(
find.bySemanticsLabel('Notifications, 1 needing attention'),
findsOneWidget,
);
expect(find.byKey(attentionBellKey), findsOneWidget);
expect(find.byKey(attentionBadgeKey), findsNothing);
expect(find.bySemanticsLabel('Notifications'), findsOneWidget);
await openAttentionSheet(tester);
expect(find.text('Nothing needs you right now.'), findsOneWidget);
expect(find.byKey(attentionClearAllKey), findsNothing);
semantics.dispose();
await openAttentionSheet(tester);
gateway.framesController.add({
'type': 'run_event',
'run_id': 9,
'pipeline_id': 4,
'name': 'nightly',
'title': 'Arrived while open',
'status': 'waiting',
'created_at': attentionTestNow
.subtract(const Duration(minutes: 5))
.toIso8601String(),
});
}
await tester.pump();
await tester.pumpAndSettle();
expect(find.byKey(attentionRowKey('9:Decision')), findsOneWidget);
await tester.tap(find.byKey(attentionClearAllKey));
await tester.pumpAndSettle();
expect(find.byKey(attentionRowKey('1:Failed')), findsNothing);
expect(
find.byKey(attentionRowKey('9:Decision')),
findsOneWidget,
reason: 'Clear all acts on the snapshot it opened with',
);
expect(store.stored, encodeAttentionDismissals({'1:Failed'}));
semantics.dispose();
});
testWidgets('Material empty runs hide the badge but keep the bell', (
tester,
) async {
final semantics = tester.ensureSemantics();
await mountAttentionRuns(
tester,
gateway,
store: MemoryAttentionStore(),
runs: const [],
);
expect(find.byKey(attentionBellKey), findsOneWidget);
expect(find.byKey(attentionBadgeKey), findsNothing);
expect(find.bySemanticsLabel('Notifications'), findsOneWidget);
await openAttentionSheet(tester);
expect(find.text('Nothing needs you right now.'), findsOneWidget);
expect(find.byKey(attentionClearAllKey), findsNothing);
semantics.dispose();
});
}