import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/features/chat/domain/chat_automations.dart'; void main() { test( 'only supported integer counts from the selected chat are displayed', () { ChatAutomationStatus read(Map fields) => ChatAutomationStatus.fromReply({ 'chat_automations': {'session_id': 'chat', ...fields}, }, expectedSessionId: 'chat'); expect(read({'status': 'supported', 'active_count': 0}).count, 0); expect(read({'status': 'supported', 'active_count': 2}).count, 2); for (final fields in >[ {'status': 'unavailable', 'active_count': 2}, {'status': 'unknown', 'active_count': 2}, {'status': 'supported', 'active_count': 1.5}, {'status': 'supported', 'active_count': -1}, {'status': 'supported'}, {'session_id': 'foreign', 'status': 'supported', 'active_count': 2}, ]) { expect(read(fields).count, isNull, reason: '$fields'); } }, ); test('invalid report times remain unknown without losing a valid count', () { for (final stamp in [null, 'yesterday', -1, 1.5, 9223372036854775807]) { final result = ChatAutomationStatus.fromReply({ 'chat_automations': { 'session_id': 'chat', 'status': 'supported', 'active_count': 1, 'observed_at_ms': stamp, }, }, expectedSessionId: 'chat'); expect(result.count, 1); expect(result.observedAt, isNull); } }); }