App: agent notifications on the web (system notification, toast, tab title count)
The app subscribes to the notification stream on every connection and delivers chat_notify notices: a toast when the page is focused (none if that chat is in view), a browser notification titled '<chat>: <title>' plus a '(n)' tab title count when it is not, and on insecure http pages a toast, the title count and a short chime. Low priority posts only when hidden. Replays within an hour show once; ids persist in the ledger. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/attention/notify/agent_notices.dart';
|
||||
import 'package:pipelines_app/features/attention/notify/page_signals.dart';
|
||||
import 'package:pipelines_app/features/attention/ui/agent_notice_toast.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('the toast shows the headline and message; Open opens the chat', (
|
||||
tester,
|
||||
) async {
|
||||
final messenger = GlobalKey<ScaffoldMessengerState>();
|
||||
var opened = 0;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
scaffoldMessengerKey: messenger,
|
||||
home: const Scaffold(body: SizedBox.expand()),
|
||||
),
|
||||
);
|
||||
showAgentNoticeToast(
|
||||
messenger.currentState,
|
||||
AgentToast(
|
||||
headline: 'Release chat: Build done',
|
||||
message: 'All tests pass',
|
||||
open: () => opened++,
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(agentNoticeToastKey), findsOneWidget);
|
||||
expect(find.text('Release chat: Build done'), findsOneWidget);
|
||||
expect(find.text('All tests pass'), findsOneWidget);
|
||||
await tester.tap(find.text('Open'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(opened, 1);
|
||||
expect(find.byKey(agentNoticeToastKey), findsNothing);
|
||||
});
|
||||
|
||||
test('the tab title count is added, replaced and removed', () {
|
||||
expect(badgedTitle('Pipelines', 1), '(1) Pipelines');
|
||||
expect(badgedTitle('(1) Pipelines', 3), '(3) Pipelines');
|
||||
expect(badgedTitle('(3) Pipelines', 0), 'Pipelines');
|
||||
expect(unbadgedTitle('(12) Runs (2)'), 'Runs (2)');
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user