// An agent's notify call for captures of the web notification paths. Off by // default. // // `?agentNotice=` answers subscribe_notifications with no backlog, then // after it pushes one `chat_notify` notification // for the `ui-review` chat (add `ui-review=1` so the // chat has its title). `agentNoticePriority=2|3|4` // sets its priority (default 3). import 'dart:async'; import 'package:pipelines_app/core/api_gateway.dart'; Map _params = const {}; void configureAgentNoticeFixture(Map params) => _params = params; /// The subscribe reply for [request], or null when the fixture is off or the /// request is not a subscription. Schedules the push through [emit]. JsonMap? agentNoticeReply(JsonMap request, void Function(JsonMap) emit) { if (request['type'] != 'subscribe_notifications') return null; final delay = int.tryParse(_params['agentNotice'] ?? ''); if (delay != null) { final priority = int.tryParse(_params['agentNoticePriority'] ?? '') ?? 3; Timer(Duration(milliseconds: delay), () { emit({ 'type': 'notification', 'notification': { 'id': 'chat:ui-review:notify:shown_capture', 'kind': 'chat_notify', 'title': 'Build finished', 'message': 'All 412 tests pass. The release branch is ready to merge.', 'click': 'pipelines://chat/ui-review', 'priority': priority, 'tags': [], 'created_at': DateTime.now().toUtc().toIso8601String(), 'group': 'chat:ui-review', }, }); }); } return { 'id': request['id'], 'type': 'notifications_subscribed', 'notifications': [], 'ids': [], }; }