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(); 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)'); }); }