merge(app): bring main into chat-cmd-session; /new /close /rename tests

This commit is contained in:
2026-10-22 22:29:33 +01:00
58 changed files with 4326 additions and 159 deletions
@@ -0,0 +1,118 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/transport/pipelines_client.dart';
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
import 'pipelines_app_test.dart' show pumpApp, replyList;
import 'pipelines_replies.dart';
/// The app lifts one attention controller above the destinations: the Runs
/// list seeds it when it loads and the app folds pushed `run_event` frames, so
/// the shell's Runs tab badge moves while another destination is shown.
void main() {
final needingAttention = RegExp('needing attention');
Finder badgeCount(String count) =>
find.descendant(of: find.byType(Badge), matching: find.text(count));
testWidgets(
'a run_event folded to waiting raises the Runs tab badge from Pipelines',
(tester) async {
final semantics = tester.ensureSemantics();
final channel = FakeChannel()..readyCompleter.complete();
final client = PipelinesClient(channelFactory: (_) => channel);
final provider = PlatformRouteInformationProvider(
initialRouteInformation: RouteInformation(uri: Uri.parse('/runs')),
);
addTearDown(provider.dispose);
await pumpApp(
tester,
channel: channel,
client: client,
provider: provider,
);
await replyList(
tester,
channel,
runs: [
{
'id': 1,
'pipeline_id': 4,
'name': 'nightly',
'title': 'Nightly build',
'status': 'running',
'created_at': DateTime.now().toIso8601String(),
},
],
);
expect(find.text('Nightly build'), findsWidgets);
expect(tester.widget<Badge>(find.byType(Badge)).isLabelVisible, isFalse);
expect(find.bySemanticsLabel(needingAttention), findsNothing);
await tester.tap(find.text('Pipelines').last);
await tester.pump();
expect(provider.value.uri.path, '/pipelines');
await waitForRequest(tester, channel, 'list_pipelines');
expect(find.text('Nightly build'), findsNothing);
channel.incoming.add(
jsonEncode({'type': 'run_event', 'run_id': 1, 'status': 'waiting'}),
);
await tester.pump();
await tester.pump();
expect(provider.value.uri.path, '/pipelines');
expect(tester.widget<Badge>(find.byType(Badge)).isLabelVisible, isTrue);
expect(badgeCount('1'), findsOneWidget);
expect(
find.bySemanticsLabel(RegExp('Notifications, 1 needing attention')),
findsOneWidget,
);
// The decision taken elsewhere clears the badge the same way.
channel.incoming.add(
jsonEncode({'type': 'run_event', 'run_id': 1, 'status': 'succeeded'}),
);
await tester.pump();
await tester.pump();
expect(tester.widget<Badge>(find.byType(Badge)).isLabelVisible, isFalse);
expect(badgeCount('1'), findsNothing);
expect(find.bySemanticsLabel(needingAttention), findsNothing);
semantics.dispose();
},
);
testWidgets('a new waiting run pushed before any list read is counted', (
tester,
) async {
final channel = FakeChannel()..readyCompleter.complete();
final client = PipelinesClient(channelFactory: (_) => channel);
final provider = PlatformRouteInformationProvider(
initialRouteInformation: RouteInformation(uri: Uri.parse('/settings')),
);
addTearDown(provider.dispose);
await pumpApp(tester, channel: channel, client: client, provider: provider);
expect(tester.widget<Badge>(find.byType(Badge)).isLabelVisible, isFalse);
channel.incoming.add(
jsonEncode({
'type': 'run_event',
'run_id': 9,
'pipeline_id': 4,
'name': 'nightly',
'title': 'Arrived while away',
'status': 'waiting',
'created_at': DateTime.now().toIso8601String(),
}),
);
await tester.pump();
await tester.pump();
expect(provider.value.uri.path, '/settings');
expect(badgeCount('1'), findsOneWidget);
});
}
@@ -97,6 +97,18 @@ void main() {
await tester.tap(find.byKey(runPipelineActionKey));
await tester.pumpAndSettle();
// The dialog asks for recent directories; answer it so the transport is
// free for the launch request this test asserts.
await waitForRequest(tester, channel, 'chat_directories');
final directories = pipelineRequest(channel, 'chat_directories')!;
channel.incoming.add(
jsonEncode({
'id': directories['id'],
'type': 'chat_directories',
'chat_directories': <dynamic>[],
}),
);
await tester.pump();
await tester.enterText(
find.byKey(runPipelinePromptKey),
'Review the change.',
@@ -21,7 +21,7 @@ Widget materialApp(
ServerEndpoint server, {
int? initialRunId,
ValueChanged<int>? onRunSelected,
VoidCallback? onBack,
ValueChanged<int?>? onBack,
}) => MaterialApp(
home: Scaffold(
body: RunsDestination(
@@ -0,0 +1,101 @@
import 'dart:async';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/application/app_route.dart';
import 'package:pipelines_app/features/attention/notify/chat_question_notices.dart';
import 'notification_test_support.dart';
class _Gateway implements ApiGateway {
final controller = StreamController<JsonMap>.broadcast();
@override
Stream<JsonMap> get frames => controller.stream;
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) async => {};
}
Map<String, dynamic> _event({
String id = 'form-1',
String session = 'session_1',
String kind = 'question',
bool resolved = false,
bool cancelled = false,
}) => {
'type': 'chat_event',
'chat_event': {
'session_id': session,
'kind': 'form',
'form': {
'id': id,
'kind': kind,
'title': 'Choose an option',
'resolved': resolved,
'cancelled': cancelled,
},
},
};
void main() {
late _Gateway gateway;
late FakeNotificationBridge bridge;
late bool allowed;
late String? active;
late List<AppRoute> opened;
late ChatQuestionNotices notices;
setUp(() {
gateway = _Gateway();
bridge = FakeNotificationBridge(permission: 'granted');
allowed = true;
active = null;
opened = [];
notices = ChatQuestionNotices(
gateway: gateway,
canNotify: () => allowed,
activeChatSessionId: () => active,
sessionTitle: (id) async => id == 'session_1' ? ' Design chat ' : null,
openChat: (id) => opened.add(AppRoute.chatSession(id)),
bridge: bridge,
);
});
tearDown(() async {
notices.dispose();
await gateway.controller.close();
});
test('notifies titled and unknown sessions; tap opens the chat route', () async {
gateway.controller.add(_event());
await Future<void>.delayed(Duration.zero);
gateway.controller.add(_event(id: 'form-2', session: 'unknown'));
await Future<void>.delayed(Duration.zero);
expect(bridge.shown.map((message) => message.title), [
'Design chat needs your answer',
'Chat needs your answer',
]);
expect(bridge.shown.first.body, 'Choose an option');
expect(bridge.shown.first.tag, 'chat-question:form-1');
bridge.taps.first?.call();
expect(opened, [AppRoute.chatSession('session_1')]);
});
test('suppresses active, unavailable, resolved, cancelled and non-question frames', () async {
active = 'session_1';
gateway.controller.add(_event());
await Future<void>.delayed(Duration.zero);
active = null;
allowed = false;
gateway.controller.add(_event(id: 'form-2'));
await Future<void>.delayed(Duration.zero);
allowed = true;
gateway.controller.add(_event(id: 'form-3', resolved: true));
await Future<void>.delayed(Duration.zero);
gateway.controller.add(_event(id: 'form-4', cancelled: true));
await Future<void>.delayed(Duration.zero);
gateway.controller.add(_event(id: 'form-5', kind: 'approval'));
await Future<void>.delayed(Duration.zero);
expect(bridge.shown, isEmpty);
});
}
@@ -152,7 +152,7 @@ void main() {
(tester) async {
final gateway = _ScreenGateway()
..sessions = [
{'id': 's', 'title': 'Wire chat', 'backend': 'claude'},
{'id': 's', 'title': 'Wire chat', 'backend': 'other'},
];
await _pumpScreen(tester, gateway, initialSessionId: 's');
@@ -195,41 +195,111 @@ void main() {
expect(palette(), findsNothing);
expect(gateway.promptBodies, isEmpty);
// A second Enter re-reports the command instead of sending it.
// A second Enter runs the command: its confirm, never a prompt.
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
expect(gateway.promptBodies, isEmpty);
expect(fieldText(tester), '/close');
expect(
find.text(
'“/close” is not available yet, so nothing was sent to the agent.',
),
findsOneWidget,
);
// The primary control and the explicit send shortcut take the same path.
await tester.tap(find.byKey(const Key('chat-composer-primary')));
expect(fieldText(tester), '');
expect(find.text('Close chat?'), findsOneWidget);
await tester.tap(find.text('Cancel'));
await tester.pumpAndSettle();
expect(gateway.promptBodies, isEmpty);
expect(fieldText(tester), '/close');
expect(gateway.calls.where((call) => call.type == 'chat_close'), isEmpty);
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
await tester.pumpAndSettle();
expect(gateway.promptBodies, isEmpty);
expect(fieldText(tester), '/close');
// An argument does not make the slash draft sendable either.
// An argument is validated locally, then consumed too.
await tester.enterText(field, '/close now');
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
expect(gateway.promptBodies, isEmpty);
expect(fieldText(tester), '/close now');
expect(fieldText(tester), '');
expect(find.text('/close does not take an argument.'), findsOneWidget);
});
testWidgets('/help consumes the draft and lists commands in recorded order', (
tester,
) async {
await pumpComposer(tester);
await tester.enterText(
find.byKey(const Key('chat-composer-field')),
'/help',
);
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
expect(fieldText(tester), '');
expect(gateway.promptBodies, isEmpty);
expect(
find.text(
'/new — Start a fresh session in this directory\n'
'/close — Finish this session for every client, keeping its history\n'
'/rename <title> — Rename this session on this device\n'
'/stop — Stop the turn that is running\n'
'/help — List every command',
),
findsOneWidget,
);
expect(find.text('Command'), findsOneWidget);
await tester.tap(find.byKey(const Key('chat-command-dismiss')));
await tester.pump();
expect(find.byKey(const Key('chat-composer-command-notice')), findsNothing);
});
testWidgets('/stop without a running turn and extra arguments fail locally', (
tester,
) async {
await pumpComposer(tester);
final field = find.byKey(const Key('chat-composer-field'));
await tester.enterText(field, '/stop');
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
expect(fieldText(tester), '');
expect(gateway.interruptBodies, isEmpty);
expect(find.text('Command failed'), findsOneWidget);
expect(find.text('No turn is running in this chat.'), findsOneWidget);
await tester.enterText(field, '/help x');
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
expect(fieldText(tester), '');
expect(find.text('/help does not take an argument.'), findsOneWidget);
expect(gateway.promptBodies, isEmpty);
});
testWidgets('/stop interrupts the current session through the composer', (
tester,
) async {
await pumpComposer(tester);
gateway.emitEvent({
'session_id': 's',
'kind': 'step',
'step': {'status': 'started', 'turn_id': 'turn', 'intermediate': false},
});
await tester.pumpAndSettle();
await tester.enterText(
find.byKey(const Key('chat-composer-field')),
'/stop',
);
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
expect(gateway.interruptBodies, [
<String, dynamic>{'session_id': 's'},
]);
expect(fieldText(tester), '');
expect(gateway.promptBodies, isEmpty);
});
testWidgets('a command picked from the palette is never sent either', (
@@ -244,17 +314,15 @@ void main() {
await tester.pumpAndSettle();
expect(fieldText(tester), '/help');
await tester.tap(find.byKey(const Key('chat-composer-primary')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('chat-composer-primary')));
await tester.pumpAndSettle();
expect(gateway.promptBodies, isEmpty);
expect(fieldText(tester), '/help');
expect(
find.text(
'“/help” is not available yet, so nothing was sent to the agent.',
),
findsOneWidget,
);
expect(fieldText(tester), '');
expect(find.text('Command'), findsOneWidget);
expect(find.textContaining('/help — List every command'), findsOneWidget);
});
testWidgets('a row completes the command and never prompts', (tester) async {
@@ -0,0 +1,164 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/core/transport/connection_state.dart';
import 'package:pipelines_app/features/chat/conversation/chat_draft_store.dart';
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
import 'chat_composer_bar_fixtures.dart';
/// Answers the session commands' create, close and rename requests.
class _SessionGateway extends ComposerBarGateway {
String? refuse;
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) async {
if (type == 'chat_create' ||
type == 'chat_close' ||
type == 'chat_rename') {
calls.add((type: type, fields: fields));
if (refuse != null) throw ProtocolError(refuse!);
if (type == 'chat_create') {
return {
'chat_session': {'id': 'n1', 'title': 'New chat', 'directory': '/w'},
};
}
return <String, dynamic>{};
}
return super.call(type, fields);
}
List<JsonMap> sent(String type) => [
for (final call in calls)
if (call.type == type) call.fields,
];
}
void main() {
late _SessionGateway gateway;
JsonMap? created;
String? createdNotice;
String? renamed;
var closed = 0;
setUp(() {
gateway = _SessionGateway();
created = null;
createdNotice = null;
renamed = null;
closed = 0;
});
Future<void> pump(WidgetTester tester, {String directory = '/w'}) async {
await tester.pumpWidget(
materialHost(
ChatThreadView(
gateway: gateway,
sessionId: 's',
title: 'Old',
session: {'id': 's', 'title': 'Old', 'directory': directory},
onBack: () {},
drafts: MemoryChatDraftStore(),
newOperationId: () => 'op-1',
onCreatedSession: (session, notice) {
created = session;
createdNotice = notice;
},
onSessionRenamed: (title) => renamed = title,
onSessionClosed: () => closed++,
),
),
);
await tester.pumpAndSettle();
}
Future<void> run(WidgetTester tester, String draft) async {
await tester.enterText(find.byKey(const Key('chat-composer-field')), draft);
await tester.pump();
// The first Enter may complete the palette row; the second runs it.
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
if (fieldText(tester).isNotEmpty) {
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
}
await tester.pumpAndSettle();
}
testWidgets('/new creates in this directory and hands the row over', (
tester,
) async {
await pump(tester);
await run(tester, '/new');
final body = gateway.sent('chat_create').single['chat_create'] as JsonMap;
expect(body['title'], 'New chat');
expect(body['directory'], '/w');
expect(body['operation_id'], 'op-1');
expect(created?['id'], 'n1');
expect(createdNotice, 'Started a new session “New chat” in /w.');
expect(gateway.promptBodies, isEmpty);
});
testWidgets('/new without a directory sends nothing and reports it', (
tester,
) async {
await pump(tester, directory: '');
await run(tester, '/new');
expect(gateway.sent('chat_create'), isEmpty);
expect(
find.text(
"Can't start a new session here: the server reported no directory "
'for this chat.',
),
findsOneWidget,
);
});
testWidgets('/rename sends the trimmed title and reports it', (tester) async {
await pump(tester);
await run(tester, '/rename Fresh title ');
final body = gateway.sent('chat_rename').single['chat_rename'] as JsonMap;
expect(body, {'session_id': 's', 'title': 'Fresh title'});
expect(renamed, 'Fresh title');
expect(find.text('Renamed this session to “Fresh title”.'), findsOneWidget);
});
testWidgets('/rename without a title reports usage and sends nothing', (
tester,
) async {
await pump(tester);
await run(tester, '/rename');
expect(gateway.sent('chat_rename'), isEmpty);
expect(
find.text(
'Usage: /rename <title> — renames this session on this device.',
),
findsOneWidget,
);
});
testWidgets('/close confirms, closes and a refusal keeps the reason', (
tester,
) async {
await pump(tester);
await run(tester, '/close');
await tester.tap(find.text('Close chat'));
await tester.pumpAndSettle();
expect(gateway.sent('chat_close').single['chat_query'], {
'session_id': 's',
});
expect(closed, 1);
gateway.refuse = 'chat is locked';
await run(tester, '/close');
await tester.tap(find.text('Close chat'));
await tester.pumpAndSettle();
expect(closed, 1);
expect(find.text('chat is locked'), findsOneWidget);
});
}
@@ -0,0 +1,340 @@
import 'dart:async';
import 'dart:convert';
import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/conversation/chat_composer_bar.dart';
import 'package:pipelines_app/features/chat/conversation/chat_composer_controller.dart';
import 'package:pipelines_app/features/chat/conversation/chat_draft_store.dart';
import 'package:pipelines_app/features/chat/domain/chat_attachment_draft.dart';
import 'package:pipelines_app/features/chat/domain/chat_attachment_picker.dart';
import 'package:pipelines_app/features/chat/domain/chat_clipboard_paste.dart';
import 'chat_composer_bar_fixtures.dart';
/// A host paste source driven by the test. [paste] mirrors the web listener:
/// it asks [canAccept] before it hands files to the composer.
class _FakePaste {
ChatPasteFiles? onFiles;
ChatPasteCanAccept? canAccept;
ChatPasteFailed? onError;
int listens = 0;
int stops = 0;
ChatClipboardPaste get source => ChatClipboardPaste(
subscribe: (onFiles, canAccept, onError) {
listens += 1;
this.onFiles = onFiles;
this.canAccept = canAccept;
this.onError = onError;
return () {
stops += 1;
this.onFiles = null;
this.canAccept = null;
this.onError = null;
};
},
);
void paste(List<ChatPickedFile> files) {
final handler = onFiles;
if (handler == null) return;
if (!(canAccept?.call() ?? false)) return;
handler(files);
}
}
ChatPickedFile _file(
String name,
List<int> bytes, {
String mime = 'text/plain',
}) => ChatPickedFile(name: name, mime: mime, bytes: Uint8List.fromList(bytes));
Finder get _field => find.byKey(const Key('chat-composer-field'));
Finder get _chips => find.byKey(const Key('chat-composer-attachments'));
void main() {
late ComposerBarGateway gateway;
late ChatComposerController composer;
late List<ChatComposerController> controllers;
setUp(() {
gateway = ComposerBarGateway();
controllers = [];
});
tearDown(() {
for (final controller in controllers) {
controller.dispose();
}
gateway.close();
});
/// Rebuilds the same composer with a different paste source, so a test can
/// tell a replaced listener from a disposed one.
Future<void> pumpWith(
WidgetTester tester, {
ChatClipboardPaste? paste,
}) async {
await tester.pumpWidget(
materialHost(
ChatComposerBar(composer: composer, running: false, paste: paste),
),
);
await tester.pump();
}
Future<void> pumpBar(
WidgetTester tester, {
ChatClipboardPaste? paste,
ChatDraftStore? drafts,
}) async {
composer = ChatComposerController(
gateway,
's',
drafts: drafts ?? MemoryChatDraftStore(),
newOperationId: () => 'op/1',
);
controllers.add(composer);
await pumpWith(tester, paste: paste);
}
Future<void> focusField(WidgetTester tester) async {
await tester.showKeyboard(_field);
await tester.pump();
}
testWidgets('a pasted file makes the same chip as a picked file', (
tester,
) async {
final fake = _FakePaste();
await pumpBar(tester, paste: fake.source);
await focusField(tester);
fake.paste([
_file('shot.png', [1, 2, 3], mime: 'image/png'),
]);
await tester.pump();
expect(_chips, findsOneWidget);
expect(find.text('shot.png'), findsOneWidget);
expect(fake.listens, 1);
expect(fake.stops, 0);
});
testWidgets('pasting several files keeps clipboard order', (tester) async {
final fake = _FakePaste();
await pumpBar(tester, paste: fake.source);
await focusField(tester);
fake.paste([
_file('first.png', [1], mime: 'image/png'),
_file('second.txt', [2]),
]);
await tester.pump();
expect(find.text('first.png'), findsOneWidget);
expect(find.text('second.txt'), findsOneWidget);
expect(
tester.getTopLeft(find.text('first.png')).dx,
lessThan(tester.getTopLeft(find.text('second.txt')).dx),
);
});
testWidgets('an over-limit paste shows the draft refusal and adds nothing', (
tester,
) async {
final fake = _FakePaste();
await pumpBar(tester, paste: fake.source);
await focusField(tester);
fake.paste([
_file(
'huge.bin',
List<int>.filled(ChatAttachmentDraft.maxTotalBytes + 1, 0),
mime: 'application/octet-stream',
),
]);
await tester.pump();
expect(
find.text(ChatAttachmentRefusal.totalTooLarge.message),
findsOneWidget,
);
expect(_chips, findsNothing);
expect(find.text('huge.bin'), findsNothing);
});
testWidgets('a refused paste keeps the files already in the draft', (
tester,
) async {
final fake = _FakePaste();
await pumpBar(tester, paste: fake.source);
await focusField(tester);
fake.paste([
_file('kept.txt', [1]),
_file(
'huge.bin',
List<int>.filled(ChatAttachmentDraft.maxTotalBytes, 0),
mime: 'application/octet-stream',
),
]);
await tester.pump();
expect(find.text('kept.txt'), findsOneWidget);
expect(find.text('huge.bin'), findsNothing);
expect(
find.text(ChatAttachmentRefusal.totalTooLarge.message),
findsOneWidget,
);
});
testWidgets('a pasted attachment sends its exact name, type and bytes', (
tester,
) async {
final fake = _FakePaste();
await pumpBar(tester, paste: fake.source);
await focusField(tester);
fake.paste([
_file('shot.png', [9, 8, 7], mime: 'image/png'),
]);
await tester.pump();
await tester.enterText(_field, 'look');
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('chat-composer-primary')));
await tester.pumpAndSettle();
expect(gateway.promptBodies.single['attachments'], [
{
'name': 'shot.png',
'mime': 'image/png',
'data': base64Encode([9, 8, 7]),
},
]);
expect(_chips, findsNothing);
});
testWidgets('pasted text keeps its caret, selection and draft', (
tester,
) async {
final drafts = MemoryChatDraftStore();
final fake = _FakePaste();
await pumpBar(tester, paste: fake.source, drafts: drafts);
await focusField(tester);
await tester.enterText(_field, 'hello world');
await tester.pumpAndSettle();
final editable = tester.widget<EditableText>(
find.descendant(of: _field, matching: find.byType(EditableText)),
);
editable.controller.selection = const TextSelection.collapsed(offset: 5);
// The platform's text update for a paste between "hello" and " world".
tester.testTextInput.updateEditingValue(
const TextEditingValue(
text: 'hello there world',
selection: TextSelection.collapsed(offset: 11),
),
);
await tester.pumpAndSettle();
expect(editable.controller.text, 'hello there world');
expect(
editable.controller.selection,
const TextSelection.collapsed(offset: 11),
);
expect(composer.draft, 'hello there world');
expect(drafts.entries, {'s': 'hello there world'});
});
testWidgets('paste is only taken while this composer owns the field', (
tester,
) async {
final fake = _FakePaste();
await pumpBar(tester, paste: fake.source);
expect(fake.canAccept!(), isFalse);
await focusField(tester);
expect(fake.canAccept!(), isTrue);
tester.binding.focusManager.primaryFocus?.unfocus();
await tester.pump();
expect(fake.canAccept!(), isFalse);
});
testWidgets('a paste during an in-flight prompt adds nothing', (
tester,
) async {
final reply = Completer<JsonMap>();
gateway.prompt = (_, _) => reply.future;
final fake = _FakePaste();
await pumpBar(tester, paste: fake.source);
await focusField(tester);
await tester.enterText(_field, 'hello');
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('chat-composer-primary')));
await tester.pump();
expect(fake.canAccept!(), isFalse);
fake.paste([
_file('late.png', [1], mime: 'image/png'),
]);
await tester.pump();
expect(_chips, findsNothing);
reply.complete(const {});
await tester.pumpAndSettle();
});
testWidgets('an unreadable clipboard file is reported', (tester) async {
final fake = _FakePaste();
await pumpBar(tester, paste: fake.source);
await focusField(tester);
fake.onError!(StateError('clipboard read failed'));
await tester.pump();
expect(find.textContaining('clipboard read failed'), findsOneWidget);
});
testWidgets('a partial clipboard read shows its files and the failure', (
tester,
) async {
final fake = _FakePaste();
await pumpBar(tester, paste: fake.source);
await focusField(tester);
// The web source delivers readable files before a partial read's failure.
fake.paste([
_file('readable.png', [1], mime: 'image/png'),
]);
fake.onError!(StateError('second file failed'));
await tester.pump();
expect(find.text('readable.png'), findsOneWidget);
expect(find.textContaining('second file failed'), findsOneWidget);
});
testWidgets(
'a replaced source stops listening and dispose stops the new one',
(tester) async {
final first = _FakePaste();
await pumpBar(tester, paste: first.source);
expect(first.listens, 1);
final second = _FakePaste();
await pumpWith(tester, paste: second.source);
expect(first.stops, 1);
expect(second.listens, 1);
await tester.pumpWidget(const SizedBox());
expect(second.stops, 1);
},
);
}
@@ -380,7 +380,7 @@ void main() {
await _openThread(
tester,
gateway,
session: _withSession({'backend': 'claude'}),
session: _withSession({'backend': 'other'}),
);
expect(find.byKey(const Key('chat-model')), findsNothing);
@@ -57,6 +57,7 @@ void main() {
'Dismiss connection notice',
'Dismiss live updates notice',
'Dismiss compaction notice',
'Dismiss command notice',
],
);
// A later compaction has its own recorded condition.
@@ -110,7 +110,7 @@ void main() {
gateway: gateway,
sessionId: 's',
title: _title,
session: {..._session, 'backend': 'claude'},
session: {..._session, 'backend': 'other'},
onBack: () {},
),
cupertino: false,
@@ -0,0 +1,47 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/domain/chat_clipboard_paste.dart';
void main() {
test('a nameless clipboard file takes the web client name for its type', () {
expect(chatPastedAttachmentName('image/png', 1), 'pasted-1.png');
expect(chatPastedAttachmentName('image/jpeg', 2), 'pasted-2.jpg');
expect(
chatPastedAttachmentName('application/octet-stream', 3),
'pasted-3.octetstream',
);
expect(chatPastedAttachmentName('', 4), 'pasted-4.bin');
});
test('the unsupported host keeps text paste and reports the gap', () {
const paste = ChatClipboardPaste.unsupported('no files here');
expect(paste.isSupported, isFalse);
expect(
() =>
paste.listen(onFiles: (_) {}, canAccept: () => true, onError: (_) {}),
throwsUnsupportedError,
);
});
test('a supported host subscribes once and returns its unsubscribe', () {
var listens = 0;
var stops = 0;
final paste = ChatClipboardPaste(
subscribe: (onFiles, canAccept, onError) {
listens += 1;
return () => stops += 1;
},
);
final stop = paste.listen(
onFiles: (_) {},
canAccept: () => true,
onError: (_) {},
);
expect(paste.isSupported, isTrue);
expect(listens, 1);
stop();
expect(stops, 1);
});
}
@@ -0,0 +1,87 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/ui/sessions/chat_sessions_screen.dart';
import 'chat_test_harness.dart';
import 'fake_chat_gateway.dart';
Future<void> _pump(
WidgetTester tester,
FakeChatGateway gateway, {
String? active,
}) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(platform: TargetPlatform.android),
home: ChatSessionsScreen(
gateway: gateway,
onOpen: (_) {},
localStore: _store,
activeSessionId: active,
),
),
);
await tester.pumpAndSettle();
}
late MemoryChatSessionLocalStore _store;
JsonMap _event(String id, {String kind = 'text'}) => {
'type': 'chat_event',
'chat_event': {'session_id': id, 'kind': kind},
};
void main() {
setUp(() => _store = MemoryChatSessionLocalStore());
FakeChatGateway gateway() => FakeChatGateway()
..sessionsReply = {
'chat_sessions': [
{'id': 's1', 'title': 'First', 'directory': '/w', 'updated_at': 1000},
],
};
testWidgets('a pushed event marks a background chat New without a refresh', (
tester,
) async {
final fake = gateway();
await _pump(tester, fake);
expect(find.text('New'), findsNothing);
fake.pushed.add(_event('s1'));
await tester.pumpAndSettle();
expect(find.text('New'), findsOneWidget);
expect(fake.count('chat_sessions'), 1);
await tester.tap(find.byKey(const Key('chat-row-s1')));
await tester.pumpAndSettle();
expect(find.text('New'), findsNothing);
});
testWidgets('usage frames and the open chat never raise New', (tester) async {
final fake = gateway();
await _pump(tester, fake, active: 's1');
fake.pushed.add(_event('s1'));
fake.pushed.add(_event('s1', kind: 'usage'));
await tester.pumpAndSettle();
expect(find.text('New'), findsNothing);
});
testWidgets('leaving the conversation lets later activity mark it New', (
tester,
) async {
final fake = gateway();
await _pump(tester, fake);
await tester.tap(find.byKey(const Key('chat-row-s1')));
await _pump(tester, fake, active: 's1');
await _pump(tester, fake);
fake.pushed.add({
'type': 'chat_permission',
'chat_permission': {'session_id': 's1'},
});
await tester.pumpAndSettle();
expect(find.text('New'), findsOneWidget);
});
}
@@ -19,8 +19,11 @@ class FakeChatGateway implements ApiGateway {
Future<JsonMap> Function()? directoriesHandler;
Future<JsonMap> Function()? backendsHandler;
/// Server-pushed frames; tests add `chat_event` or `chat_permission` here.
final pushed = StreamController<JsonMap>.broadcast();
@override
Stream<JsonMap> get frames => const Stream.empty();
Stream<JsonMap> get frames => pushed.stream;
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) {
@@ -86,6 +86,30 @@ void main() {
expect(find.text('Viewing v1 (latest v2).'), findsNothing);
});
testWidgets('detail Runs action names and opens that pipeline filter', (
tester,
) async {
final fixture = PipelineFixture();
final gateway = gatewayFor(fixture);
final opened = <int>[];
tester.view.physicalSize = const Size(1100, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
await tester.pumpWidget(
MaterialApp(
home: PipelinesScreen(gateway: gateway, onViewPipelineRuns: opened.add),
),
);
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('pipeline-row-1')));
await tester.pumpAndSettle();
expect(find.bySemanticsLabel('View runs of Alpha review'), findsOneWidget);
await tester.tap(find.byKey(const Key('pipeline-view-runs')));
expect(opened, [1]);
});
testWidgets('refresh keeps the selected row and its detail', (tester) async {
final fixture = PipelineFixture();
final gateway = gatewayFor(fixture);
@@ -3,6 +3,7 @@ import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/core/transport/connection_state.dart';
import 'package:pipelines_app/features/pipelines/screen.dart';
@@ -28,6 +29,10 @@ FakeGateway launchGateway(
)!,
),
'list_schedules' => {'type': 'schedules', 'schedules': <dynamic>[]},
'chat_directories' => {
'type': 'chat_directories',
'chat_directories': ['/work/recent', 'relative', '/work/other'],
},
'run_pipeline' => onLaunch(fields),
'get_run' when onLookup != null => onLookup(fields),
_ => errorReply('unexpected $type'),
@@ -74,6 +79,45 @@ Future<void> fillFields(
}
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
SharedPreferences.setMockInitialValues({});
testWidgets(
'workspace directory suggestions load on open and selection is local',
(tester) async {
final fixture = PipelineFixture();
final gateway = launchGateway(fixture, onLaunch: (_) => acceptedRun(76));
await pumpScreen(tester, gateway, <int>[]);
await openDetail(tester);
await tester.tap(find.byKey(runPipelineActionKey));
await tester.pumpAndSettle();
expect(gateway.callsOf('chat_directories'), hasLength(1));
expect(find.text(runPipelineDirectoriesLoading), findsNothing);
expect(
tester
.widget<TextField>(find.byKey(runPipelineWorkspaceKey))
.controller
?.text,
'/work/recent',
);
await tester.tap(find.byKey(runPipelineWorkspaceSuggestionsKey));
await tester.pumpAndSettle();
expect(find.text('/work/other'), findsOneWidget);
expect(find.text('relative'), findsNothing);
await tester.tap(find.text('/work/other'));
await tester.pumpAndSettle();
expect(
tester
.widget<TextField>(find.byKey(runPipelineWorkspaceKey))
.controller
?.text,
'/work/other',
);
expect(gateway.callsOf('run_pipeline'), isEmpty);
expect(gateway.callsOf('chat_directories'), hasLength(1));
},
);
testWidgets('the detail Run action sends the web request for the pinned '
'version and opens only the reply run', (tester) async {
final fixture = PipelineFixture();
@@ -93,6 +137,8 @@ void main() {
expect(find.text(runPipelinePromptLabel), findsOneWidget);
expect(find.text(runPipelineWorkspaceLabel), findsOneWidget);
expect(find.text(runPipelineNotifyLabel), findsOneWidget);
expect(find.text(runPipelineOutputFormatLabel), findsOneWidget);
expect(find.text(runPipelineOutputFormatHelper), findsOneWidget);
expect(find.text(runPipelineCancelLabel), findsOneWidget);
expect(
find.descendant(
@@ -104,14 +150,15 @@ void main() {
expect(gateway.callsOf('run_pipeline'), isEmpty);
await fillFields(tester, prompt: ' Review the change. ');
await tester.enterText(
find.byKey(runPipelineWorkspaceKey),
'/work/alpha ',
);
await tester.enterText(find.byKey(runPipelineWorkspaceKey), '/work/alpha ');
await tester.tap(find.byKey(runPipelineNotifyKey));
await tester.pumpAndSettle();
await tester.tap(find.text('Silent').last);
await tester.pumpAndSettle();
await tester.tap(find.byKey(runPipelineOutputFormatKey));
await tester.pumpAndSettle();
await tester.tap(find.text('HTML report').last);
await tester.pumpAndSettle();
await tester.tap(find.byKey(runPipelineConfirmKey));
await tester.pumpAndSettle();
@@ -123,6 +170,7 @@ void main() {
'workspace': '/work/alpha',
'input': {'prompt': 'Review the change.'},
'notify_mode': 'off',
'output_format': 'html',
});
expect(fields['request_key'], startsWith('app-run-1-2-'));
expect('${fields['request_key']}'.length, lessThanOrEqualTo(128));
@@ -317,6 +365,12 @@ void main() {
// The fields stay locked while admission is unknown.
final prompt = tester.widget<TextField>(find.byKey(runPipelinePromptKey));
expect(prompt.enabled, isFalse);
expect(
tester.widget<DropdownButtonFormField<dynamic>>(
find.byKey(runPipelineOutputFormatKey),
).onChanged,
isNull,
);
await tester.tap(find.byKey(runPipelineConfirmKey));
await tester.pumpAndSettle();
@@ -495,13 +549,7 @@ void main() {
final helper = tester
.widget<Text>(find.text(runPipelineWorkspaceHelper))
.style;
expect(
helper?.color,
CupertinoColors.secondaryLabel.resolveFrom(context),
);
expect(
helper?.fontSize,
theme.textTheme.tabLabelTextStyle.fontSize,
);
expect(helper?.color, CupertinoColors.secondaryLabel.resolveFrom(context));
expect(helper?.fontSize, theme.textTheme.tabLabelTextStyle.fontSize);
});
}
@@ -0,0 +1,38 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/runs/domain/run_models.dart';
void main() {
group('run day grouping', () {
final today = DateTime(2026, 10, 22, 12);
test('labels local days and invalid dates', () {
expect(runDayLabel('2026-10-22T08:00:00', today), 'Today');
expect(runDayLabel('2026-10-21T08:00:00', today), 'Yesterday');
expect(runDayLabel('2026-10-17T08:00:00', today), '17 Oct 2026');
expect(runDayLabel('', today), 'Unknown date');
expect(localDayKey(DateTime(2026, 1, 2)), '2026-01-02');
});
test('retains encounter order and groups adjacent equal labels', () {
final runs = [
{'id': 3, 'created_at': '2026-10-22T09:00:00'},
{'id': 2, 'created_at': '2026-10-21T09:00:00'},
{'id': 1, 'created_at': '2026-10-21T08:00:00'},
{'id': 0, 'created_at': ''},
];
final groups = groupRunsByDay(runs, today);
expect(groups.map((group) => group.label), [
'Today',
'Yesterday',
'Unknown date',
]);
expect(groups.expand((group) => group.runs).map((run) => run['id']), [
3,
2,
1,
0,
]);
});
});
}
@@ -46,17 +46,21 @@ const _runs = [
Widget _materialScreen(
_Gateway gateway, {
int? initialRunId,
int? initialPipelineId,
int syncToken = 0,
ValueChanged<int>? onRunSelected,
VoidCallback? onBack,
ValueChanged<int?>? onBack,
ValueChanged<int?>? onPipelineFilterChanged,
}) => MaterialApp(
home: Scaffold(
body: RunsScreen(
gateway: gateway,
initialRunId: initialRunId,
initialPipelineId: initialPipelineId,
syncToken: syncToken,
onRunSelected: onRunSelected,
onBack: onBack,
onPipelineFilterChanged: onPipelineFilterChanged,
),
),
);
@@ -149,12 +153,12 @@ void main() {
tester,
) async {
int? selected;
var backs = 0;
int? backedPipeline;
await tester.pumpWidget(
_materialScreen(
gateway,
onRunSelected: (id) => selected = id,
onBack: () => backs++,
onBack: (id) => backedPipeline = id,
),
);
await _mountList(tester, gateway);
@@ -167,10 +171,60 @@ void main() {
await tester.tap(find.text('Back to list'));
await tester.pump();
expect(backs, 1);
expect(backedPipeline, isNull);
expect(find.text('Alpha run'), findsOneWidget);
});
testWidgets(
'pipeline route shows its chip and clearing reports the URL change',
(tester) async {
int? changedPipeline = 3;
await tester.pumpWidget(
_materialScreen(
gateway,
initialPipelineId: 3,
onPipelineFilterChanged: (id) => changedPipeline = id,
),
);
await _mountList(tester, gateway);
expect(find.text('Pipeline 3'), findsOneWidget);
expect(changedPipeline, 3);
await tester.tap(find.byTooltip('Clear filter: Pipeline 3'));
await tester.pump();
expect(changedPipeline, isNull);
expect(find.text('Pipeline 3'), findsNothing);
},
);
testWidgets('run detail keeps the pipeline filter for Back routing', (
tester,
) async {
int? backPipeline;
await tester.pumpWidget(
_materialScreen(
gateway,
initialPipelineId: 3,
onBack: (id) => backPipeline = id,
),
);
await _mountList(tester, gateway);
await tester.pumpWidget(
_materialScreen(
gateway,
initialRunId: 2,
onBack: (id) => backPipeline = id,
),
);
await tester.pump();
gateway.replyDetail(2, 0, {'id': 2, 'title': 'Beta run'});
await tester.pump();
await tester.tap(find.text('Back to list'));
await tester.pump();
expect(backPipeline, 3);
});
testWidgets('a route change opens and closes the named run', (tester) async {
await tester.pumpWidget(_materialScreen(gateway, initialRunId: 2));
await _mountList(tester, gateway);
@@ -38,8 +38,21 @@ void main() {
Future<void> mount(WidgetTester tester, {required bool cupertino}) async {
gateway.reply = {
'runs': [
{'id': 1, 'name': 'Alpha', 'status': 'running', 'scheduled': true},
{'id': 2, 'name': 'Beta', 'status': 'failed', 'scheduled': false},
{
'id': 1,
'pipeline_id': 9,
'name': 'Alpha',
'status': 'running',
'created_at': DateTime.now().toIso8601String(),
'scheduled': true,
},
{
'id': 2,
'pipeline_id': 10,
'name': 'Beta',
'status': 'failed',
'created_at': DateTime.now().toIso8601String(),
},
],
};
await controller.load();
@@ -68,8 +81,42 @@ void main() {
await tester.tap(find.text('Filter'));
await tester.pumpAndSettle();
expect(find.text('queued'), findsOneWidget);
expect(find.text('Pipeline'), findsOneWidget);
expect(find.text('Any pipeline'), findsOneWidget);
expect(find.text('Time range'), findsOneWidget);
expect(find.text('Last 7 days'), findsOneWidget);
expect(find.text('Any trigger'), findsOneWidget);
expect(
find.text(
'Some records have no scheduling provenance; they stay unclassified.',
),
findsOneWidget,
);
final pipelineItem = find.ancestor(
of: find.text('Alpha'),
matching: find.byWidgetPredicate((widget) => widget is PopupMenuItem),
);
await tester.ensureVisible(pipelineItem);
await tester.tap(pipelineItem);
await tester.pumpAndSettle();
expect(controller.pipelineId, 9);
await tester.tap(find.text('Filter (1)'));
await tester.pumpAndSettle();
final timeItem = find.ancestor(
of: find.text('Last 7 days'),
matching: find.byWidgetPredicate((widget) => widget is PopupMenuItem),
);
await tester.ensureVisible(timeItem);
await tester.tap(timeItem);
await tester.pumpAndSettle();
expect(controller.timeRange, 'last_7_days');
expect(find.text('Filter (2)'), findsOneWidget);
expect(find.byTooltip('Clear filter: Last 7 days'), findsOneWidget);
await tester.tap(find.text('Filter (2)'));
await tester.pumpAndSettle();
final failedItem = find.ancestor(
of: find.text('failed'),
matching: find.byWidgetPredicate((widget) => widget is PopupMenuItem),
@@ -77,11 +124,10 @@ void main() {
await tester.tap(failedItem);
await tester.pumpAndSettle();
expect(controller.statuses, {'failed'});
expect(find.text('Filter (1)'), findsOneWidget);
expect(find.byType(InputChip), findsOneWidget);
expect(find.text('Filter (3)'), findsOneWidget);
expect(find.byType(InputChip), findsNWidgets(3));
expect(find.text('failed'), findsWidgets);
expect(find.text('Alpha'), findsNothing);
expect(find.text('Beta'), findsOneWidget);
expect(controller.visibleRuns, isEmpty);
await tester.tap(find.textContaining('Sort:'));
await tester.pumpAndSettle();
@@ -97,6 +143,8 @@ void main() {
await tester.tap(find.byTooltip('Clear filter: failed'));
await tester.pumpAndSettle();
expect(controller.statuses, isEmpty);
controller.clearFilters();
await tester.pumpAndSettle();
expect(find.byType(InputChip), findsNothing);
expect(find.text('Filter'), findsOneWidget);
expect(find.text('Alpha'), findsOneWidget);
@@ -122,6 +170,8 @@ void main() {
await tester.pumpAndSettle();
expect(controller.statuses, {'failed'});
expect(find.text('✓ failed'), findsOneWidget);
expect(find.text('Pipeline'), findsOneWidget);
expect(find.text('Last 7 days'), findsOneWidget);
expect(find.text('Filter (1)'), findsOneWidget);
await tester.tap(find.text('Done'));
+106
View File
@@ -0,0 +1,106 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
/// The Runs tab mirrors the attention count in every mount of both hosts:
/// Material rail and bottom bar, Cupertino sidebar and tab bar. Zero draws the
/// bare icon with no count and no attention semantics.
void main() {
final needingAttention = RegExp('Notifications, 3 needing attention');
final anyAttention = RegExp('needing attention');
Future<void> pumpShell(
WidgetTester tester, {
required double width,
required bool cupertino,
required int count,
}) async {
tester.view.physicalSize = Size(width, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final shell = AdaptiveShell(cupertino: cupertino, attentionCount: count);
await tester.pumpWidget(
cupertino ? CupertinoApp(home: shell) : MaterialApp(home: shell),
);
}
for (final width in [390.0, 1000.0]) {
final mount = width < 600 ? 'bottom bar' : 'rail';
testWidgets('Material $mount shows the count on the Runs tab', (
tester,
) async {
final semantics = tester.ensureSemantics();
await pumpShell(tester, width: width, cupertino: false, count: 3);
expect(
find.byType(width < 600 ? NavigationBar : NavigationRail),
findsOneWidget,
);
final badge = find.byType(Badge);
expect(badge, findsOneWidget);
expect(tester.widget<Badge>(badge).isLabelVisible, isTrue);
expect(
find.descendant(of: badge, matching: find.text('3')),
findsOneWidget,
);
expect(find.bySemanticsLabel(needingAttention), findsOneWidget);
semantics.dispose();
});
testWidgets('Material $mount hides the badge at zero', (tester) async {
final semantics = tester.ensureSemantics();
await pumpShell(tester, width: width, cupertino: false, count: 0);
final badge = find.byType(Badge);
expect(badge, findsOneWidget);
expect(tester.widget<Badge>(badge).isLabelVisible, isFalse);
expect(
find.descendant(of: badge, matching: find.byType(Text)),
findsNothing,
);
expect(find.bySemanticsLabel(anyAttention), findsNothing);
semantics.dispose();
});
}
for (final width in [390.0, 1280.0]) {
final mount = width < 600 ? 'tab bar' : 'sidebar';
testWidgets('Cupertino $mount shows the count on the Runs item', (
tester,
) async {
final semantics = tester.ensureSemantics();
await pumpShell(tester, width: width, cupertino: true, count: 3);
expect(
find.byType(CupertinoTabBar),
width < 600 ? findsOneWidget : findsNothing,
);
expect(find.byType(Badge), findsNothing, reason: 'no Material badge');
expect(find.text('3'), findsOneWidget);
expect(find.bySemanticsLabel(needingAttention), findsOneWidget);
semantics.dispose();
});
testWidgets('Cupertino $mount hides the count at zero', (tester) async {
final semantics = tester.ensureSemantics();
await pumpShell(tester, width: width, cupertino: true, count: 0);
expect(find.text('0'), findsNothing);
expect(find.bySemanticsLabel(anyAttention), findsNothing);
semantics.dispose();
});
}
testWidgets('the badge stays visible from every destination', (tester) async {
await pumpShell(tester, width: 1000, cupertino: false, count: 2);
for (final label in ['Runs', 'Chat', 'Settings']) {
await tester.tap(find.text(label).last);
await tester.pumpAndSettle();
expect(
find.descendant(of: find.byType(Badge), matching: find.text('2')),
findsOneWidget,
reason: 'badge missing on $label',
);
}
});
}