ba198d144a
Keep the audited runs filter, chat colour picker, and Needs you flows as Material bottom sheets on narrow or touch layouts while presenting bounded desktop dialogs on wide layouts. Remove obsolete Cupertino flags and add focused route regressions and notes.
170 lines
6.1 KiB
Dart
170 lines
6.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/features/attention/domain/attention_models.dart';
|
|
import 'package:pipelines_app/features/attention/ui/needs_you_keys.dart';
|
|
import 'package:pipelines_app/ui/status/run_status_icon.dart';
|
|
|
|
import 'needs_you_test_support.dart';
|
|
|
|
void main() {
|
|
testWidgets('Needs you uses a dialog wide and a bottom sheet narrow', (
|
|
tester,
|
|
) async {
|
|
final entry = attentionFixture(id: 1, title: 'Ship the release');
|
|
tester.view.physicalSize = const Size(800, 1400);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
await tester.pumpWidget(attentionApp(NeedsYouPage(entries: [entry])));
|
|
|
|
await tester.tap(find.byKey(attentionBellKey));
|
|
await tester.pumpAndSettle();
|
|
expect(find.byType(Dialog), findsOneWidget);
|
|
Navigator.of(tester.element(find.byKey(attentionSheetKey))).pop();
|
|
await tester.pumpAndSettle();
|
|
|
|
tester.view.physicalSize = const Size(500, 1400);
|
|
await tester.pump();
|
|
await tester.tap(find.byKey(attentionBellKey));
|
|
await tester.pumpAndSettle();
|
|
expect(find.byType(BottomSheet), findsOneWidget);
|
|
});
|
|
|
|
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])));
|
|
|
|
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(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('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(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);
|
|
});
|
|
}
|