nexo/apps/flutter-test/integration_test/plugin_integration_test.dart
toki 5e4089c629 feat: notification pipeline implementation
- Update messaging Flutter plugin with Firebase messaging service improvements
- Add notification helper and custom push notification helper enhancements
- Implement notification opened event handling
- Add Android unit tests for payload gate and notification helpers
- Update flutter-test app with integration and widget tests
- Update notification pipeline roadmap and task documentation
2026-05-31 06:34:44 +09:00

119 lines
3.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:nexo_messaging/nexo_messaging.dart';
import 'package:nexo_client/main.dart';
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
testWidgets('singleton instance is accessible', (WidgetTester tester) async {
expect(NexoMessagingPlugin.instance, isNotNull);
expect(
NexoMessagingPlugin.notificationChannelName,
'com.tokilabs.nexo.messaging/notifications',
);
expect(
NexoMessagingPlugin.actionChannelName,
'com.tokilabs.nexo.messaging/notification_actions',
);
});
testWidgets('native debug event reaches harness routing UI (channel)', (
WidgetTester tester,
) async {
await tester.pumpWidget(const MyApp(initializePlugin: false));
NexoMessagingPlugin.instance.listenNativeChannelForTesting();
await NexoMessagingPlugin.instance.debugSendNativeEventForTesting(const {
'type': PushNotificationType.opened,
'server_url': 'https://nexo.example.com',
'channel_id': 'channel-integration',
});
await tester.pumpAndSettle();
expect(find.textContaining('Last notification:'), findsOneWidget);
expect(find.textContaining('channel-integration'), findsWidgets);
expect(
find.text(
'Last opened: server_url: https://nexo.example.com, channel_id: channel-integration, root_id: null, is_crt_enabled: false',
),
findsOneWidget,
);
expect(
find.text(
'Last navigation: channel:https://nexo.example.com/channel-integration',
),
findsOneWidget,
);
await tester.pumpWidget(const SizedBox.shrink());
});
testWidgets('native debug event reaches harness routing UI (thread/CRT)', (
WidgetTester tester,
) async {
await tester.pumpWidget(const MyApp(initializePlugin: false));
NexoMessagingPlugin.instance.listenNativeChannelForTesting();
await NexoMessagingPlugin.instance.debugSendNativeEventForTesting(const {
'type': PushNotificationType.opened,
'server_url': 'https://nexo.example.com',
'channel_id': 'channel-integration',
'root_id': 'root-integration',
'is_crt_enabled': 'true',
});
await tester.pumpAndSettle();
expect(find.textContaining('Last notification:'), findsOneWidget);
expect(find.textContaining('root-integration'), findsWidgets);
expect(
find.text(
'Last opened: server_url: https://nexo.example.com, channel_id: channel-integration, root_id: root-integration, is_crt_enabled: true',
),
findsOneWidget,
);
expect(
find.text(
'Last navigation: thread:https://nexo.example.com/root-integration',
),
findsOneWidget,
);
await tester.pumpWidget(const SizedBox.shrink());
});
testWidgets('native debug event reaches harness routing UI (boolean CRT)', (
WidgetTester tester,
) async {
await tester.pumpWidget(const MyApp(initializePlugin: false));
NexoMessagingPlugin.instance.listenNativeChannelForTesting();
await NexoMessagingPlugin.instance.debugSendNativeEventForTesting(const {
'type': PushNotificationType.opened,
'server_url': 'https://nexo.example.com',
'channel_id': 'channel-integration',
'root_id': 'root-integration',
'is_crt_enabled': true,
});
await tester.pumpAndSettle();
expect(
find.text(
'Last opened: server_url: https://nexo.example.com, channel_id: channel-integration, root_id: root-integration, is_crt_enabled: true',
),
findsOneWidget,
);
expect(
find.text(
'Last navigation: thread:https://nexo.example.com/root-integration',
),
findsOneWidget,
);
await tester.pumpWidget(const SizedBox.shrink());
});
}