import 'package:flutter_test/flutter_test.dart'; import 'package:marianum_mobile/push/push_message_handler.dart'; void main() { group('classifyPush', () { test('nextcloud push has subject + signature', () { expect( classifyPush({'subject': 'enc', 'signature': 'sig', 'type': 'chat'}), PushKind.nextcloud, ); }); test('connect push identified by source', () { expect( classifyPush({'source': 'connect', 'title': 'Hi', 'body': 'There'}), PushKind.connect, ); }); test('widget refresh push identified by source + type', () { expect( classifyPush({'source': 'connect', 'type': 'widget-refresh'}), PushKind.widgetRefresh, ); }); test('widget refresh push with reason still classifies', () { expect( classifyPush({ 'source': 'connect', 'type': 'widget-refresh', 'reason': 'morning', }), PushKind.widgetRefresh, ); }); test('connect push with unrelated type stays connect', () { expect( classifyPush({'source': 'connect', 'type': 'newsletter', 'title': 'Hi'}), PushKind.connect, ); }); test('nextcloud fields take precedence over widget-refresh type', () { expect( classifyPush({ 'subject': 'enc', 'signature': 'sig', 'source': 'connect', 'type': 'widget-refresh', }), PushKind.nextcloud, ); }); test('widget-refresh type without connect source is unknown', () { expect(classifyPush({'type': 'widget-refresh'}), PushKind.unknown); }); test('subject without signature is not a nextcloud push', () { expect(classifyPush({'subject': 'enc'}), PushKind.unknown); }); test('empty subject/signature is unknown', () { expect(classifyPush({'subject': '', 'signature': ''}), PushKind.unknown); }); test('unrelated payload is unknown', () { expect(classifyPush({'foo': 'bar'}), PushKind.unknown); }); }); }