Merge commit 'b29bd5830cba1485f365cd6f06a29d0e0f0468b4' into pipelines/run-20261111-0115-cupertino-out-servers-and-settings-secur-c6ad
This commit is contained in:
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,126 +1,137 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/attention/ui/needs_you_bell.dart';
|
||||
import 'package:pipelines_app/features/attention/ui/needs_you_keys.dart';
|
||||
|
||||
import 'needs_you_test_support.dart';
|
||||
|
||||
void main() {
|
||||
for (final native in [false, true]) {
|
||||
final host = native ? 'Cupertino' : 'Material';
|
||||
testWidgets('Material bell is plain and announced when nothing needs you', (
|
||||
tester,
|
||||
) async {
|
||||
final semantics = tester.ensureSemantics();
|
||||
await tester.pumpWidget(attentionApp(NeedsYouPage(entries: const [])));
|
||||
|
||||
testWidgets('$host bell is plain and announced when nothing needs you', (
|
||||
tester,
|
||||
) async {
|
||||
final semantics = tester.ensureSemantics();
|
||||
await tester.pumpWidget(
|
||||
attentionApp(NeedsYouPage(entries: const [], cupertino: native)),
|
||||
);
|
||||
expect(find.bySemanticsLabel('Notifications'), findsOneWidget);
|
||||
expect(find.byKey(attentionBadgeKey), findsNothing);
|
||||
expect(find.text('0'), findsNothing);
|
||||
semantics.dispose();
|
||||
});
|
||||
|
||||
expect(find.bySemanticsLabel('Notifications'), findsOneWidget);
|
||||
expect(find.byKey(attentionBadgeKey), findsNothing);
|
||||
expect(find.text('0'), findsNothing);
|
||||
semantics.dispose();
|
||||
});
|
||||
testWidgets('Material bell announces the count and shows one badge', (
|
||||
tester,
|
||||
) async {
|
||||
final semantics = tester.ensureSemantics();
|
||||
final entries = [
|
||||
attentionFixture(id: 1),
|
||||
attentionFixture(id: 2, status: 'waiting', title: 'Approve release'),
|
||||
attentionFixture(id: 3, diagnostic: 'Stage 2 failed'),
|
||||
];
|
||||
await tester.pumpWidget(attentionApp(NeedsYouPage(entries: entries)));
|
||||
|
||||
testWidgets('$host bell announces the count and shows one badge', (
|
||||
tester,
|
||||
) async {
|
||||
final semantics = tester.ensureSemantics();
|
||||
final entries = [
|
||||
attentionFixture(id: 1),
|
||||
attentionFixture(id: 2, status: 'waiting', title: 'Approve release'),
|
||||
attentionFixture(id: 3, diagnostic: 'Stage 2 failed'),
|
||||
];
|
||||
await tester.pumpWidget(
|
||||
attentionApp(
|
||||
NeedsYouPage(entries: entries, cupertino: native),
|
||||
cupertino: native,
|
||||
expect(
|
||||
find.bySemanticsLabel('Notifications, 3 needing attention'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byKey(attentionBadgeKey), findsOneWidget);
|
||||
expect(find.text('3'), findsOneWidget);
|
||||
semantics.dispose();
|
||||
});
|
||||
|
||||
testWidgets('Material bell opens the honest empty sheet and back closes it', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(attentionApp(NeedsYouPage(entries: const [])));
|
||||
|
||||
await tester.tap(find.byKey(attentionBellKey));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(attentionSheetKey), findsOneWidget);
|
||||
expect(find.text('Needs you'), findsOneWidget);
|
||||
expect(find.text('Nothing needs you right now.'), findsOneWidget);
|
||||
expect(find.byKey(attentionEmptyKey), findsOneWidget);
|
||||
expect(find.byKey(attentionClearAllKey), findsNothing);
|
||||
expect(find.text('Dismiss'), findsNothing);
|
||||
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(attentionSheetKey), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('Material sheet is a named heading and Escape closes it', (
|
||||
tester,
|
||||
) async {
|
||||
final semantics = tester.ensureSemantics();
|
||||
await tester.pumpWidget(attentionApp(NeedsYouPage(entries: const [])));
|
||||
|
||||
await tester.tap(find.byKey(attentionBellKey));
|
||||
await tester.pumpAndSettle();
|
||||
final title = tester.getSemantics(find.text('Needs you'));
|
||||
expect(
|
||||
title.getSemanticsData().flagsCollection.isHeader,
|
||||
isTrue,
|
||||
reason: 'the sheet title must reach assistive tech as a heading',
|
||||
);
|
||||
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(attentionSheetKey), findsNothing);
|
||||
semantics.dispose();
|
||||
});
|
||||
|
||||
testWidgets('Material sheet closes on a barrier tap', (tester) async {
|
||||
await tester.pumpWidget(attentionApp(NeedsYouPage(entries: const [])));
|
||||
|
||||
await tester.tap(find.byKey(attentionBellKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(attentionSheetKey), findsOneWidget);
|
||||
|
||||
// Above the sheet body: only the native modal barrier is there.
|
||||
await tester.tapAt(const Offset(20, 20));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(attentionSheetKey), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('Material closing the sheet returns focus to the bell', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(attentionApp(NeedsYouPage(entries: const [])));
|
||||
|
||||
await tester.tap(find.byKey(attentionBellKey));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(attentionSheetKey), findsNothing);
|
||||
expect(bellHasFocus(tester), isTrue);
|
||||
});
|
||||
|
||||
testWidgets('a stale cupertino flag still draws the Material bell and sheet', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
attentionApp(
|
||||
Scaffold(
|
||||
body: Center(
|
||||
child: NeedsYouBell(
|
||||
entries: [attentionFixture()],
|
||||
cupertino: true,
|
||||
onOpen: (_) {},
|
||||
onDismiss: (_) {},
|
||||
onClearAll: (_) {},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
),
|
||||
);
|
||||
|
||||
expect(
|
||||
find.bySemanticsLabel('Notifications, 3 needing attention'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byKey(attentionBadgeKey), findsOneWidget);
|
||||
expect(find.text('3'), findsOneWidget);
|
||||
semantics.dispose();
|
||||
});
|
||||
expect(tester.widget(find.byKey(attentionBellKey)), isA<IconButton>());
|
||||
expect(find.byIcon(Icons.notifications_outlined), findsOneWidget);
|
||||
|
||||
testWidgets('$host bell opens the honest empty sheet and back closes it', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
attentionApp(NeedsYouPage(entries: const [], cupertino: native)),
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(attentionBellKey));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(attentionSheetKey), findsOneWidget);
|
||||
expect(find.text('Needs you'), findsOneWidget);
|
||||
expect(find.text('Nothing needs you right now.'), findsOneWidget);
|
||||
expect(find.byKey(attentionEmptyKey), findsOneWidget);
|
||||
expect(find.byKey(attentionClearAllKey), findsNothing);
|
||||
expect(find.text('Dismiss'), findsNothing);
|
||||
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(attentionSheetKey), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('$host sheet is a named heading and Escape closes it', (
|
||||
tester,
|
||||
) async {
|
||||
final semantics = tester.ensureSemantics();
|
||||
await tester.pumpWidget(
|
||||
attentionApp(NeedsYouPage(entries: const [], cupertino: native)),
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(attentionBellKey));
|
||||
await tester.pumpAndSettle();
|
||||
final title = tester.getSemantics(find.text('Needs you'));
|
||||
expect(
|
||||
title.getSemanticsData().flagsCollection.isHeader,
|
||||
isTrue,
|
||||
reason: 'the sheet title must reach assistive tech as a heading',
|
||||
);
|
||||
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(attentionSheetKey), findsNothing);
|
||||
semantics.dispose();
|
||||
});
|
||||
|
||||
testWidgets('$host sheet closes on a barrier tap', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
attentionApp(NeedsYouPage(entries: const [], cupertino: native)),
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(attentionBellKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(attentionSheetKey), findsOneWidget);
|
||||
|
||||
// Above the sheet body: only the native modal barrier is there.
|
||||
await tester.tapAt(const Offset(20, 20));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(attentionSheetKey), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('$host closing the sheet returns focus to the bell', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
attentionApp(NeedsYouPage(entries: const [], cupertino: native)),
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(attentionBellKey));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(attentionSheetKey), findsNothing);
|
||||
expect(bellHasFocus(tester), isTrue);
|
||||
});
|
||||
}
|
||||
await tester.tap(find.byKey(attentionBellKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(BottomSheet), findsOneWidget);
|
||||
expect(find.byKey(attentionSheetKey), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -6,65 +6,60 @@ import 'needs_you_test_support.dart';
|
||||
|
||||
/// Layout evidence for the hardest case: a narrow phone at a doubled text scale.
|
||||
void main() {
|
||||
for (final native in [false, true]) {
|
||||
final host = native ? 'Cupertino' : 'Material';
|
||||
testWidgets('Material sheet wraps at 320 logical px and 2x in dark', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.devicePixelRatio = 2;
|
||||
tester.view.physicalSize = const Size(640, 1280);
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
const longTitle =
|
||||
'Implementer-with-an-unshortened-stage-label that the operator sees';
|
||||
const longDetail =
|
||||
'Stage 3 stopped at the export archive step because the credential '
|
||||
'it needs is no longer configured on this server.';
|
||||
final entry = attentionFixture(
|
||||
id: 1,
|
||||
name: 'Release',
|
||||
title: longTitle,
|
||||
diagnostic: longDetail,
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
attentionApp(
|
||||
NeedsYouPage(entries: [entry]),
|
||||
dark: true,
|
||||
textScale: 2,
|
||||
),
|
||||
);
|
||||
|
||||
testWidgets('$host sheet wraps at 320 logical px and 2x in dark', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.devicePixelRatio = 2;
|
||||
tester.view.physicalSize = const Size(640, 1280);
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
const longTitle =
|
||||
'Implementer-with-an-unshortened-stage-label that the operator sees';
|
||||
const longDetail =
|
||||
'Stage 3 stopped at the export archive step because the credential '
|
||||
'it needs is no longer configured on this server.';
|
||||
final entry = attentionFixture(
|
||||
id: 1,
|
||||
name: 'Release',
|
||||
title: longTitle,
|
||||
diagnostic: longDetail,
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
attentionApp(
|
||||
NeedsYouPage(entries: [entry], cupertino: native),
|
||||
cupertino: native,
|
||||
dark: true,
|
||||
textScale: 2,
|
||||
),
|
||||
);
|
||||
await tester.tap(find.byKey(attentionBellKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull);
|
||||
|
||||
await tester.tap(find.byKey(attentionBellKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull);
|
||||
final label = find.text(longTitle);
|
||||
final description = find.text('Release · $longDetail');
|
||||
expect(label, findsOneWidget);
|
||||
expect(description, findsOneWidget);
|
||||
await tester.ensureVisible(label);
|
||||
final paragraph = tester.renderObject<RenderParagraph>(label);
|
||||
expect(paragraph.didExceedMaxLines, isFalse);
|
||||
final unscaled = TextPainter(
|
||||
text: paragraph.text,
|
||||
textDirection: paragraph.textDirection,
|
||||
textScaler: TextScaler.noScaling,
|
||||
)..layout();
|
||||
expect(
|
||||
unscaled.width,
|
||||
greaterThan(paragraph.size.width),
|
||||
reason: 'the long label wraps instead of shrinking to one line',
|
||||
);
|
||||
unscaled.dispose();
|
||||
|
||||
final label = find.text(longTitle);
|
||||
final description = find.text('Release · $longDetail');
|
||||
expect(label, findsOneWidget);
|
||||
expect(description, findsOneWidget);
|
||||
await tester.ensureVisible(label);
|
||||
final paragraph = tester.renderObject<RenderParagraph>(label);
|
||||
expect(paragraph.didExceedMaxLines, isFalse);
|
||||
final unscaled = TextPainter(
|
||||
text: paragraph.text,
|
||||
textDirection: paragraph.textDirection,
|
||||
textScaler: TextScaler.noScaling,
|
||||
)..layout();
|
||||
expect(
|
||||
unscaled.width,
|
||||
greaterThan(paragraph.size.width),
|
||||
reason: 'the long label wraps instead of shrinking to one line',
|
||||
);
|
||||
unscaled.dispose();
|
||||
|
||||
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));
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
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));
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -9,109 +9,97 @@ import 'needs_you_test_support.dart';
|
||||
/// arrive, disappear or change text must redraw, while Clear all stays limited
|
||||
/// to the snapshot the route opened with.
|
||||
void main() {
|
||||
for (final native in [false, true]) {
|
||||
final host = native ? 'Cupertino' : 'Material';
|
||||
|
||||
testWidgets(
|
||||
'$host same-identity content change reaches the open and reopened sheet',
|
||||
(tester) async {
|
||||
final before = attentionFixture(id: 1, title: 'Old title');
|
||||
final changed = attentionFixture(
|
||||
id: 1,
|
||||
title: 'New title',
|
||||
diagnostic: 'Stage 3 failed',
|
||||
);
|
||||
final reopened = attentionFixture(id: 1, title: 'Newest title');
|
||||
expect(changed.key, before.key);
|
||||
final source = ValueNotifier<List<AttentionEntry>>([before]);
|
||||
addTearDown(source.dispose);
|
||||
await tester.pumpWidget(
|
||||
attentionApp(
|
||||
AttentionHarness(
|
||||
source: source,
|
||||
opened: <AttentionEntry>[],
|
||||
dismissed: <AttentionEntry>[],
|
||||
cleared: <List<AttentionEntry>>[],
|
||||
cupertino: native,
|
||||
),
|
||||
cupertino: native,
|
||||
),
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(attentionBellKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Old title'), findsOneWidget);
|
||||
|
||||
// Same run and kind, new title and diagnostic: the open sheet must
|
||||
// redraw from the caller's list, as the browser does.
|
||||
source.value = [changed];
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('New title'), findsOneWidget);
|
||||
expect(find.text('Old title'), findsNothing);
|
||||
expect(find.text('Release · Stage 3 failed'), findsOneWidget);
|
||||
expect(
|
||||
attentionDismissName(tester, changed),
|
||||
'Dismiss New title',
|
||||
reason: 'the row action is named from the row it now shows',
|
||||
);
|
||||
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(attentionSheetKey), findsNothing);
|
||||
|
||||
// A closed sheet must not keep the list it was last opened with either.
|
||||
source.value = [reopened];
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(attentionBellKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Newest title'), findsOneWidget);
|
||||
expect(find.text('New title'), findsNothing);
|
||||
expect(attentionDismissName(tester, reopened), 'Dismiss Newest title');
|
||||
},
|
||||
testWidgets('Material same-identity content change reaches the open and '
|
||||
'reopened sheet', (tester) async {
|
||||
final before = attentionFixture(id: 1, title: 'Old title');
|
||||
final changed = attentionFixture(
|
||||
id: 1,
|
||||
title: 'New title',
|
||||
diagnostic: 'Stage 3 failed',
|
||||
);
|
||||
final reopened = attentionFixture(id: 1, title: 'Newest title');
|
||||
expect(changed.key, before.key);
|
||||
final source = ValueNotifier<List<AttentionEntry>>([before]);
|
||||
addTearDown(source.dispose);
|
||||
await tester.pumpWidget(
|
||||
attentionApp(
|
||||
AttentionHarness(
|
||||
source: source,
|
||||
opened: <AttentionEntry>[],
|
||||
dismissed: <AttentionEntry>[],
|
||||
cleared: <List<AttentionEntry>>[],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'$host Clear all uses the open snapshot and leaves later arrivals',
|
||||
(tester) async {
|
||||
final a = attentionFixture(id: 1, title: 'Ship the release');
|
||||
final b = attentionFixture(id: 2, title: 'Arrived while open');
|
||||
final source = ValueNotifier<List<AttentionEntry>>([a]);
|
||||
addTearDown(source.dispose);
|
||||
final cleared = <List<AttentionEntry>>[];
|
||||
await tester.pumpWidget(
|
||||
attentionApp(
|
||||
AttentionHarness(
|
||||
source: source,
|
||||
opened: <AttentionEntry>[],
|
||||
dismissed: <AttentionEntry>[],
|
||||
cleared: cleared,
|
||||
cupertino: native,
|
||||
),
|
||||
cupertino: native,
|
||||
),
|
||||
);
|
||||
await tester.tap(find.byKey(attentionBellKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Old title'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(attentionBellKey));
|
||||
await tester.pumpAndSettle();
|
||||
source.value = [a, b];
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.byKey(attentionRowKey(b.key)),
|
||||
findsOneWidget,
|
||||
reason: 'the open sheet shows the live list, as the browser does',
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(attentionClearAllKey));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(cleared, hasLength(1));
|
||||
expect(cleared.single.map((entry) => entry.key), [a.key]);
|
||||
expect(source.value.map((entry) => entry.key), [b.key]);
|
||||
// Clearing keeps the sheet open; only the snapshot it opened with is gone.
|
||||
expect(find.byKey(attentionSheetKey), findsOneWidget);
|
||||
expect(find.byKey(attentionRowKey(b.key)), findsOneWidget);
|
||||
expect(find.byKey(attentionRowKey(a.key)), findsNothing);
|
||||
},
|
||||
// Same run and kind, new title and diagnostic: the open sheet must
|
||||
// redraw from the caller's list, as the browser does.
|
||||
source.value = [changed];
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('New title'), findsOneWidget);
|
||||
expect(find.text('Old title'), findsNothing);
|
||||
expect(find.text('Release · Stage 3 failed'), findsOneWidget);
|
||||
expect(
|
||||
attentionDismissName(tester, changed),
|
||||
'Dismiss New title',
|
||||
reason: 'the row action is named from the row it now shows',
|
||||
);
|
||||
}
|
||||
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(attentionSheetKey), findsNothing);
|
||||
|
||||
// A closed sheet must not keep the list it was last opened with either.
|
||||
source.value = [reopened];
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(attentionBellKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Newest title'), findsOneWidget);
|
||||
expect(find.text('New title'), findsNothing);
|
||||
expect(attentionDismissName(tester, reopened), 'Dismiss Newest title');
|
||||
});
|
||||
|
||||
testWidgets('Material Clear all uses the open snapshot and leaves later '
|
||||
'arrivals', (tester) async {
|
||||
final a = attentionFixture(id: 1, title: 'Ship the release');
|
||||
final b = attentionFixture(id: 2, title: 'Arrived while open');
|
||||
final source = ValueNotifier<List<AttentionEntry>>([a]);
|
||||
addTearDown(source.dispose);
|
||||
final cleared = <List<AttentionEntry>>[];
|
||||
await tester.pumpWidget(
|
||||
attentionApp(
|
||||
AttentionHarness(
|
||||
source: source,
|
||||
opened: <AttentionEntry>[],
|
||||
dismissed: <AttentionEntry>[],
|
||||
cleared: cleared,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(attentionBellKey));
|
||||
await tester.pumpAndSettle();
|
||||
source.value = [a, b];
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.byKey(attentionRowKey(b.key)),
|
||||
findsOneWidget,
|
||||
reason: 'the open sheet shows the live list, as the browser does',
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(attentionClearAllKey));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(cleared, hasLength(1));
|
||||
expect(cleared.single.map((entry) => entry.key), [a.key]);
|
||||
expect(source.value.map((entry) => entry.key), [b.key]);
|
||||
// Clearing keeps the sheet open; only the snapshot it opened with is gone.
|
||||
expect(find.byKey(attentionSheetKey), findsOneWidget);
|
||||
expect(find.byKey(attentionRowKey(b.key)), findsOneWidget);
|
||||
expect(find.byKey(attentionRowKey(a.key)), findsNothing);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -7,166 +7,140 @@ import 'package:pipelines_app/ui/status/run_status_icon.dart';
|
||||
import 'needs_you_test_support.dart';
|
||||
|
||||
void main() {
|
||||
for (final native in [false, true]) {
|
||||
final host = native ? 'Cupertino' : 'Material';
|
||||
testWidgets('Material sheet names every row and every dismiss action', (
|
||||
tester,
|
||||
) async {
|
||||
final a = attentionFixture(id: 1, title: 'Ship the release');
|
||||
final b = attentionFixture(id: 2, name: 'Nightly audit', status: 'waiting');
|
||||
await tester.pumpWidget(attentionApp(NeedsYouPage(entries: [a, b])));
|
||||
|
||||
testWidgets('$host sheet names every row and every dismiss action', (
|
||||
tester,
|
||||
) async {
|
||||
final a = attentionFixture(id: 1, title: 'Ship the release');
|
||||
final b = attentionFixture(
|
||||
id: 2,
|
||||
name: 'Nightly audit',
|
||||
status: 'waiting',
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
attentionApp(
|
||||
NeedsYouPage(entries: [a, b], cupertino: native),
|
||||
cupertino: native,
|
||||
await tester.tap(find.byKey(attentionBellKey));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(attentionSheetKey), findsOneWidget);
|
||||
expect(find.text('Needs you'), findsOneWidget);
|
||||
expect(find.byKey(attentionRowKey(a.key)), findsOneWidget);
|
||||
expect(find.byKey(attentionRowKey(b.key)), findsOneWidget);
|
||||
expect(find.text('Ship the release'), findsOneWidget);
|
||||
expect(find.text('Release · Run failed'), findsOneWidget);
|
||||
expect(find.text('Nightly audit'), findsOneWidget);
|
||||
expect(find.text('Nightly audit · Waiting for your decision'), findsOneWidget);
|
||||
expect(find.byKey(attentionClearAllKey), findsOneWidget);
|
||||
// Each row leads with the shared run status glyph, as the web's rows.
|
||||
expect(
|
||||
tester
|
||||
.widgetList<RunStatusIcon>(find.byType(RunStatusIcon))
|
||||
.map((icon) => icon.state),
|
||||
unorderedEquals(['failed', 'waiting']),
|
||||
);
|
||||
|
||||
// The browser names each destructive control after the row it removes.
|
||||
expect(attentionDismissName(tester, a), 'Dismiss Ship the release');
|
||||
expect(attentionDismissName(tester, b), 'Dismiss Nightly audit');
|
||||
expect(find.text('Dismiss'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('Material repeated labels add the run id to the dismiss name', (
|
||||
tester,
|
||||
) async {
|
||||
final first = attentionFixture(id: 11, title: 'Nightly audit');
|
||||
final second = attentionFixture(id: 12, title: 'Nightly audit');
|
||||
await tester.pumpWidget(
|
||||
attentionApp(NeedsYouPage(entries: [first, second])),
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(attentionBellKey));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(attentionDismissName(tester, first), 'Dismiss Nightly audit (run 11)');
|
||||
expect(
|
||||
attentionDismissName(tester, second),
|
||||
'Dismiss Nightly audit (run 12)',
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Material row Dismiss names its identity and stays open', (
|
||||
tester,
|
||||
) async {
|
||||
final a = attentionFixture(id: 1, title: 'Ship the release');
|
||||
final b = attentionFixture(id: 2, title: 'Fix the export');
|
||||
final source = ValueNotifier<List<AttentionEntry>>([a, b]);
|
||||
addTearDown(source.dispose);
|
||||
final opened = <AttentionEntry>[];
|
||||
final dismissed = <AttentionEntry>[];
|
||||
await tester.pumpWidget(
|
||||
attentionApp(
|
||||
AttentionHarness(
|
||||
source: source,
|
||||
opened: opened,
|
||||
dismissed: dismissed,
|
||||
cleared: <List<AttentionEntry>>[],
|
||||
),
|
||||
);
|
||||
),
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(attentionBellKey));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(attentionBellKey));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(attentionDismissKey(b.key)));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(attentionSheetKey), findsOneWidget);
|
||||
expect(find.text('Needs you'), findsOneWidget);
|
||||
expect(find.byKey(attentionRowKey(a.key)), findsOneWidget);
|
||||
expect(find.byKey(attentionRowKey(b.key)), findsOneWidget);
|
||||
expect(find.text('Ship the release'), findsOneWidget);
|
||||
expect(find.text('Release · Run failed'), findsOneWidget);
|
||||
expect(find.text('Nightly audit'), findsOneWidget);
|
||||
expect(
|
||||
find.text('Nightly audit · Waiting for your decision'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byKey(attentionClearAllKey), findsOneWidget);
|
||||
// Each row leads with the shared run status glyph, as the web's rows.
|
||||
expect(
|
||||
tester
|
||||
.widgetList<RunStatusIcon>(find.byType(RunStatusIcon))
|
||||
.map((icon) => icon.state),
|
||||
unorderedEquals(['failed', 'waiting']),
|
||||
);
|
||||
expect(dismissed.map((entry) => entry.key), [b.key]);
|
||||
expect(opened, isEmpty);
|
||||
// The browser keeps the sheet open and redraws it; the caller removed the
|
||||
// dismissed identity, so the remaining row is still there for a second one.
|
||||
expect(find.byKey(attentionSheetKey), findsOneWidget);
|
||||
expect(find.byKey(attentionRowKey(b.key)), findsNothing);
|
||||
expect(find.byKey(attentionRowKey(a.key)), findsOneWidget);
|
||||
});
|
||||
|
||||
// The browser names each destructive control after the row it removes.
|
||||
expect(attentionDismissName(tester, a), 'Dismiss Ship the release');
|
||||
expect(attentionDismissName(tester, b), 'Dismiss Nightly audit');
|
||||
expect(find.text('Dismiss'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('$host repeated labels add the run id to the dismiss name', (
|
||||
tester,
|
||||
) async {
|
||||
final first = attentionFixture(id: 11, title: 'Nightly audit');
|
||||
final second = attentionFixture(id: 12, title: 'Nightly audit');
|
||||
await tester.pumpWidget(
|
||||
attentionApp(
|
||||
NeedsYouPage(entries: [first, second], cupertino: native),
|
||||
cupertino: native,
|
||||
testWidgets('Material row opens its run and only a Failed row is dismissed', (
|
||||
tester,
|
||||
) async {
|
||||
final failed = attentionFixture(id: 1, title: 'Ship the release');
|
||||
final decision = attentionFixture(
|
||||
id: 2,
|
||||
title: 'Approve the release',
|
||||
status: 'waiting',
|
||||
);
|
||||
final source = ValueNotifier<List<AttentionEntry>>([failed, decision]);
|
||||
addTearDown(source.dispose);
|
||||
final opened = <AttentionEntry>[];
|
||||
final dismissed = <AttentionEntry>[];
|
||||
await tester.pumpWidget(
|
||||
attentionApp(
|
||||
AttentionHarness(
|
||||
source: source,
|
||||
opened: opened,
|
||||
dismissed: dismissed,
|
||||
cleared: <List<AttentionEntry>>[],
|
||||
),
|
||||
);
|
||||
),
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(attentionBellKey));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(attentionBellKey));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(attentionRowKey(failed.key)));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(
|
||||
attentionDismissName(tester, first),
|
||||
'Dismiss Nightly audit (run 11)',
|
||||
);
|
||||
expect(
|
||||
attentionDismissName(tester, second),
|
||||
'Dismiss Nightly audit (run 12)',
|
||||
);
|
||||
});
|
||||
expect(opened.map((entry) => entry.key), [failed.key]);
|
||||
expect(
|
||||
dismissed.map((entry) => entry.key),
|
||||
[failed.key],
|
||||
reason: 'opening a failed run is the operator dealing with it',
|
||||
);
|
||||
expect(find.byKey(attentionSheetKey), findsNothing);
|
||||
|
||||
testWidgets('$host row Dismiss names its identity and stays open', (
|
||||
tester,
|
||||
) async {
|
||||
final a = attentionFixture(id: 1, title: 'Ship the release');
|
||||
final b = attentionFixture(id: 2, title: 'Fix the export');
|
||||
final source = ValueNotifier<List<AttentionEntry>>([a, b]);
|
||||
addTearDown(source.dispose);
|
||||
final opened = <AttentionEntry>[];
|
||||
final dismissed = <AttentionEntry>[];
|
||||
await tester.pumpWidget(
|
||||
attentionApp(
|
||||
AttentionHarness(
|
||||
source: source,
|
||||
opened: opened,
|
||||
dismissed: dismissed,
|
||||
cleared: <List<AttentionEntry>>[],
|
||||
cupertino: native,
|
||||
),
|
||||
cupertino: native,
|
||||
),
|
||||
);
|
||||
await tester.tap(find.byKey(attentionBellKey));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(attentionRowKey(decision.key)));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.byKey(attentionBellKey));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(attentionDismissKey(b.key)));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(dismissed.map((entry) => entry.key), [b.key]);
|
||||
expect(opened, isEmpty);
|
||||
// The browser keeps the sheet open and redraws it; the caller removed the
|
||||
// dismissed identity, so the remaining row is still there for a second one.
|
||||
expect(find.byKey(attentionSheetKey), findsOneWidget);
|
||||
expect(find.byKey(attentionRowKey(b.key)), findsNothing);
|
||||
expect(find.byKey(attentionRowKey(a.key)), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('$host row opens its run and only a Failed row is dismissed', (
|
||||
tester,
|
||||
) async {
|
||||
final failed = attentionFixture(id: 1, title: 'Ship the release');
|
||||
final decision = attentionFixture(
|
||||
id: 2,
|
||||
title: 'Approve the release',
|
||||
status: 'waiting',
|
||||
);
|
||||
final source = ValueNotifier<List<AttentionEntry>>([failed, decision]);
|
||||
addTearDown(source.dispose);
|
||||
final opened = <AttentionEntry>[];
|
||||
final dismissed = <AttentionEntry>[];
|
||||
await tester.pumpWidget(
|
||||
attentionApp(
|
||||
AttentionHarness(
|
||||
source: source,
|
||||
opened: opened,
|
||||
dismissed: dismissed,
|
||||
cleared: <List<AttentionEntry>>[],
|
||||
cupertino: native,
|
||||
),
|
||||
cupertino: native,
|
||||
),
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(attentionBellKey));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(attentionRowKey(failed.key)));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(opened.map((entry) => entry.key), [failed.key]);
|
||||
expect(
|
||||
dismissed.map((entry) => entry.key),
|
||||
[failed.key],
|
||||
reason: 'opening a failed run is the operator dealing with it',
|
||||
);
|
||||
expect(find.byKey(attentionSheetKey), findsNothing);
|
||||
|
||||
await tester.tap(find.byKey(attentionBellKey));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(attentionRowKey(decision.key)));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(opened.map((entry) => entry.key), [failed.key, decision.key]);
|
||||
expect(
|
||||
dismissed.map((entry) => entry.key),
|
||||
[failed.key],
|
||||
reason: 'a decision stays until the operator answers it',
|
||||
);
|
||||
expect(find.byKey(attentionSheetKey), findsNothing);
|
||||
});
|
||||
}
|
||||
expect(opened.map((entry) => entry.key), [failed.key, decision.key]);
|
||||
expect(
|
||||
dismissed.map((entry) => entry.key),
|
||||
[failed.key],
|
||||
reason: 'a decision stays until the operator answers it',
|
||||
);
|
||||
expect(find.byKey(attentionSheetKey), findsNothing);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
@@ -27,27 +26,13 @@ AttentionEntry attentionFixture({
|
||||
})!;
|
||||
}
|
||||
|
||||
Widget attentionApp(
|
||||
Widget home, {
|
||||
bool cupertino = false,
|
||||
bool dark = false,
|
||||
double textScale = 1,
|
||||
}) {
|
||||
Widget attentionApp(Widget home, {bool dark = false, double textScale = 1}) {
|
||||
Widget scaled(BuildContext context, Widget? app) => MediaQuery(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
).copyWith(textScaler: TextScaler.linear(textScale)),
|
||||
child: app!,
|
||||
);
|
||||
if (cupertino) {
|
||||
return CupertinoApp(
|
||||
theme: CupertinoThemeData(
|
||||
brightness: dark ? Brightness.dark : Brightness.light,
|
||||
),
|
||||
builder: scaled,
|
||||
home: home,
|
||||
);
|
||||
}
|
||||
return MaterialApp(
|
||||
theme: ThemeData(
|
||||
platform: TargetPlatform.android,
|
||||
@@ -63,14 +48,12 @@ class NeedsYouPage extends StatelessWidget {
|
||||
const NeedsYouPage({
|
||||
super.key,
|
||||
required this.entries,
|
||||
this.cupertino = false,
|
||||
this.onOpen,
|
||||
this.onDismiss,
|
||||
this.onClearAll,
|
||||
});
|
||||
|
||||
final List<AttentionEntry> entries;
|
||||
final bool cupertino;
|
||||
final ValueChanged<AttentionEntry>? onOpen;
|
||||
final ValueChanged<AttentionEntry>? onDismiss;
|
||||
final ValueChanged<List<AttentionEntry>>? onClearAll;
|
||||
@@ -79,15 +62,11 @@ class NeedsYouPage extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final bell = NeedsYouBell(
|
||||
entries: entries,
|
||||
cupertino: cupertino,
|
||||
onOpen: onOpen ?? (_) {},
|
||||
onDismiss: onDismiss ?? (_) {},
|
||||
onClearAll: onClearAll ?? (_) {},
|
||||
);
|
||||
final body = Center(child: bell);
|
||||
return cupertino
|
||||
? CupertinoPageScaffold(child: SafeArea(child: body))
|
||||
: Scaffold(body: SafeArea(child: body));
|
||||
return Scaffold(body: SafeArea(child: Center(child: bell)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,14 +80,12 @@ class AttentionHarness extends StatelessWidget {
|
||||
required this.opened,
|
||||
required this.dismissed,
|
||||
required this.cleared,
|
||||
this.cupertino = false,
|
||||
});
|
||||
|
||||
final ValueNotifier<List<AttentionEntry>> source;
|
||||
final List<AttentionEntry> opened;
|
||||
final List<AttentionEntry> dismissed;
|
||||
final List<List<AttentionEntry>> cleared;
|
||||
final bool cupertino;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -116,7 +93,6 @@ class AttentionHarness extends StatelessWidget {
|
||||
valueListenable: source,
|
||||
builder: (context, entries, _) => NeedsYouPage(
|
||||
entries: entries,
|
||||
cupertino: cupertino,
|
||||
onOpen: opened.add,
|
||||
onDismiss: (entry) {
|
||||
dismissed.add(entry);
|
||||
@@ -143,24 +119,16 @@ bool bellHasFocus(WidgetTester tester) {
|
||||
final widget = tester.widget(find.byKey(attentionBellKey));
|
||||
final node = switch (widget) {
|
||||
IconButton() => widget.focusNode,
|
||||
CupertinoButton() => widget.focusNode,
|
||||
_ => null,
|
||||
};
|
||||
return node?.hasPrimaryFocus ?? false;
|
||||
}
|
||||
|
||||
/// The accessible name of one row's Dismiss action, whichever host drew it.
|
||||
/// The accessible name of one row's Dismiss action.
|
||||
///
|
||||
/// Material exposes it as the button tooltip, Cupertino as the xmark icon's
|
||||
/// semantic label; both must name the row they remove.
|
||||
/// The Material control exposes it as the button tooltip; it must name the row
|
||||
/// it removes.
|
||||
String attentionDismissName(WidgetTester tester, AttentionEntry entry) {
|
||||
final key = attentionDismissKey(entry.key);
|
||||
final xmark = find.descendant(
|
||||
of: find.byKey(key),
|
||||
matching: find.byIcon(CupertinoIcons.xmark),
|
||||
);
|
||||
if (xmark.evaluate().isNotEmpty) {
|
||||
return tester.widget<Icon>(xmark).semanticLabel ?? '';
|
||||
}
|
||||
return tester.widget<IconButton>(find.byKey(key)).tooltip ?? '';
|
||||
}
|
||||
|
||||
@@ -6,12 +6,11 @@ import 'package:pipelines_app/features/attention/ui/notification_permission_tile
|
||||
|
||||
import 'needs_you_test_support.dart';
|
||||
|
||||
/// The tile inside a normal page, so both native hosts can draw it. The page
|
||||
/// scrolls like the Settings list does, so the tile is never given a fixed
|
||||
/// The tile inside a normal page, so it is drawn the way Settings draws it. The
|
||||
/// page scrolls like the Settings list does, so the tile is never given a fixed
|
||||
/// height to overflow.
|
||||
Widget _page({
|
||||
required NotificationPermissionState state,
|
||||
bool cupertino = false,
|
||||
bool asked = false,
|
||||
VoidCallback? onRequest,
|
||||
}) => attentionApp(
|
||||
@@ -24,124 +23,130 @@ Widget _page({
|
||||
),
|
||||
),
|
||||
),
|
||||
cupertino: cupertino,
|
||||
);
|
||||
|
||||
void _noop() {}
|
||||
|
||||
void main() {
|
||||
for (final native in [false, true]) {
|
||||
final host = native ? 'Cupertino' : 'Material';
|
||||
|
||||
testWidgets('$host shows a compact row for each state', (tester) async {
|
||||
final cases = <NotificationPermissionState, String>{
|
||||
NotificationPermissionState.unsupported: notificationUnsupportedCopy,
|
||||
NotificationPermissionState.needsSecureContext:
|
||||
notificationInsecureCopy,
|
||||
NotificationPermissionState.granted: notificationGrantedCopy,
|
||||
NotificationPermissionState.denied: notificationDeniedCopy,
|
||||
NotificationPermissionState.notRequested: notificationDefaultCopy,
|
||||
};
|
||||
for (final entry in cases.entries) {
|
||||
await tester.pumpWidget(
|
||||
_page(state: entry.key, cupertino: native, onRequest: _noop),
|
||||
);
|
||||
final view = notificationPermissionView(entry.key);
|
||||
// The Settings section owns the heading; the tile is one short row.
|
||||
expect(find.text(notificationSectionTitle), findsNothing);
|
||||
expect(find.text(notificationRationale), findsNothing);
|
||||
expect(find.text(view.headline), findsOneWidget);
|
||||
expect(find.text(view.helper), findsOneWidget);
|
||||
// The full honest sentence is what assistive technology reads.
|
||||
expect(view.body, entry.value);
|
||||
expect(find.bySemanticsLabel(entry.value), findsOneWidget);
|
||||
expect(
|
||||
find.byKey(notificationEnableKey),
|
||||
entry.key == NotificationPermissionState.notRequested
|
||||
? findsOneWidget
|
||||
: findsNothing,
|
||||
reason: '${entry.key}',
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('$host shows the asked wording without an action', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
_page(
|
||||
state: NotificationPermissionState.notRequested,
|
||||
asked: true,
|
||||
cupertino: native,
|
||||
),
|
||||
testWidgets('Material shows a compact row for each state', (tester) async {
|
||||
final cases = <NotificationPermissionState, String>{
|
||||
NotificationPermissionState.unsupported: notificationUnsupportedCopy,
|
||||
NotificationPermissionState.needsSecureContext: notificationInsecureCopy,
|
||||
NotificationPermissionState.granted: notificationGrantedCopy,
|
||||
NotificationPermissionState.denied: notificationDeniedCopy,
|
||||
NotificationPermissionState.notRequested: notificationDefaultCopy,
|
||||
};
|
||||
for (final entry in cases.entries) {
|
||||
await tester.pumpWidget(_page(state: entry.key, onRequest: _noop));
|
||||
final view = notificationPermissionView(entry.key);
|
||||
// The Settings section owns the heading; the tile is one short row.
|
||||
expect(find.text(notificationSectionTitle), findsNothing);
|
||||
expect(find.text(notificationRationale), findsNothing);
|
||||
expect(find.text(view.headline), findsOneWidget);
|
||||
expect(find.text(view.helper), findsOneWidget);
|
||||
// The full honest sentence is what assistive technology reads.
|
||||
expect(view.body, entry.value);
|
||||
expect(find.bySemanticsLabel(entry.value), findsOneWidget);
|
||||
expect(
|
||||
find.byKey(notificationEnableKey),
|
||||
entry.key == NotificationPermissionState.notRequested
|
||||
? findsOneWidget
|
||||
: findsNothing,
|
||||
reason: '${entry.key}',
|
||||
);
|
||||
expect(find.text('Alerts are still off'), findsOneWidget);
|
||||
expect(find.bySemanticsLabel(notificationDefaultAskedCopy), findsOne);
|
||||
expect(find.bySemanticsLabel(notificationDefaultCopy), findsNothing);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('$host Enable runs the explicit request', (tester) async {
|
||||
var requested = 0;
|
||||
await tester.pumpWidget(
|
||||
_page(
|
||||
state: NotificationPermissionState.notRequested,
|
||||
cupertino: native,
|
||||
onRequest: () => requested++,
|
||||
),
|
||||
);
|
||||
await tester.tap(find.byKey(notificationEnableKey));
|
||||
await tester.pump();
|
||||
expect(requested, 1);
|
||||
});
|
||||
testWidgets('Material shows the asked wording without an action', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
_page(state: NotificationPermissionState.notRequested, asked: true),
|
||||
);
|
||||
expect(find.text('Alerts are still off'), findsOneWidget);
|
||||
expect(find.bySemanticsLabel(notificationDefaultAskedCopy), findsOne);
|
||||
expect(find.bySemanticsLabel(notificationDefaultCopy), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('$host tile wraps at 320 logical px and 2x in dark', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.devicePixelRatio = 2;
|
||||
tester.view.physicalSize = const Size(640, 1280);
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
testWidgets('Material Enable runs the explicit request', (tester) async {
|
||||
var requested = 0;
|
||||
await tester.pumpWidget(
|
||||
_page(
|
||||
state: NotificationPermissionState.notRequested,
|
||||
onRequest: () => requested++,
|
||||
),
|
||||
);
|
||||
await tester.tap(find.byKey(notificationEnableKey));
|
||||
await tester.pump();
|
||||
expect(requested, 1);
|
||||
});
|
||||
|
||||
// The undecided state is the hardest: it carries the Enable action as well
|
||||
// as the longest copy, so the section title must still have room to read.
|
||||
await tester.pumpWidget(
|
||||
attentionApp(
|
||||
Scaffold(
|
||||
body: SingleChildScrollView(
|
||||
child: NotificationPermissionTile(
|
||||
state: NotificationPermissionState.notRequested,
|
||||
onRequest: _noop,
|
||||
),
|
||||
testWidgets('a stale cupertino flag still draws the Material row', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
attentionApp(
|
||||
Scaffold(
|
||||
body: SingleChildScrollView(
|
||||
child: NotificationPermissionTile(
|
||||
state: NotificationPermissionState.notRequested,
|
||||
cupertino: true,
|
||||
onRequest: _noop,
|
||||
),
|
||||
),
|
||||
cupertino: native,
|
||||
dark: true,
|
||||
textScale: 2,
|
||||
),
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
),
|
||||
);
|
||||
|
||||
final view = notificationPermissionView(
|
||||
NotificationPermissionState.notRequested,
|
||||
);
|
||||
final helper = tester.renderObject<RenderParagraph>(
|
||||
find.text(view.helper),
|
||||
);
|
||||
expect(
|
||||
helper.size.width,
|
||||
greaterThan(100),
|
||||
reason: 'the action must not squeeze the row copy',
|
||||
);
|
||||
final body = tester.renderObject<RenderParagraph>(
|
||||
find.text(view.headline),
|
||||
);
|
||||
expect(body.didExceedMaxLines, isFalse);
|
||||
expect(find.byKey(notificationEnableKey), findsOneWidget);
|
||||
expect(
|
||||
tester.widget(find.byKey(notificationEnableKey)),
|
||||
isA<FilledButton>(),
|
||||
);
|
||||
expect(find.text(notificationEnableShortLabel), findsOneWidget);
|
||||
});
|
||||
|
||||
final rect = tester.getRect(find.byKey(notificationStateKey));
|
||||
expect(rect.left, greaterThanOrEqualTo(0));
|
||||
expect(rect.right, lessThanOrEqualTo(320));
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
testWidgets('Material tile wraps at 320 logical px and 2x in dark', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.devicePixelRatio = 2;
|
||||
tester.view.physicalSize = const Size(640, 1280);
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
|
||||
// The undecided state is the hardest: it carries the Enable action as well
|
||||
// as the longest copy, so the section title must still have room to read.
|
||||
await tester.pumpWidget(
|
||||
attentionApp(
|
||||
Scaffold(
|
||||
body: SingleChildScrollView(
|
||||
child: NotificationPermissionTile(
|
||||
state: NotificationPermissionState.notRequested,
|
||||
onRequest: _noop,
|
||||
),
|
||||
),
|
||||
),
|
||||
dark: true,
|
||||
textScale: 2,
|
||||
),
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
|
||||
final view = notificationPermissionView(
|
||||
NotificationPermissionState.notRequested,
|
||||
);
|
||||
final helper = tester.renderObject<RenderParagraph>(find.text(view.helper));
|
||||
expect(
|
||||
helper.size.width,
|
||||
greaterThan(100),
|
||||
reason: 'the action must not squeeze the row copy',
|
||||
);
|
||||
final body = tester.renderObject<RenderParagraph>(find.text(view.headline));
|
||||
expect(body.didExceedMaxLines, isFalse);
|
||||
expect(find.byKey(notificationEnableKey), findsOneWidget);
|
||||
|
||||
final rect = tester.getRect(find.byKey(notificationStateKey));
|
||||
expect(rect.left, greaterThanOrEqualTo(0));
|
||||
expect(rect.right, lessThanOrEqualTo(320));
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -75,6 +75,24 @@ void main() {
|
||||
return controller;
|
||||
}
|
||||
|
||||
testWidgets('the panel filters entries through its Material field', (
|
||||
tester,
|
||||
) async {
|
||||
await pump(tester);
|
||||
final field = find.byType(TextField);
|
||||
expect(field, findsOneWidget);
|
||||
expect(
|
||||
tester.widget<TextField>(field).decoration?.hintText,
|
||||
'Filter files',
|
||||
);
|
||||
await tester.enterText(field, 'notes');
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('notes.txt'), findsOneWidget);
|
||||
expect(find.text('picture.png'), findsNothing);
|
||||
expect(find.widgetWithText(TextButton, '~'), findsOneWidget);
|
||||
expect(find.widgetWithText(TextButton, 'demo'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('text tap opens shared viewer and fetches inline URL', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
@@ -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