87 lines
2.8 KiB
Dart
87 lines
2.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());
|
|
});
|
|
}
|