nexo/apps/client/integration_test/plugin_integration_test.dart

71 lines
2.3 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:mattermost_push_plugin/mattermost_push_plugin.dart';
import 'package:nexo_client/main.dart';
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
testWidgets('singleton instance is accessible', (WidgetTester tester) async {
expect(MattermostPushPlugin.instance, isNotNull);
expect(
MattermostPushPlugin.notificationChannelName,
'com.tokilabs.mattermost/notifications',
);
});
testWidgets('native debug event reaches harness routing UI (channel)', (
WidgetTester tester,
) async {
await tester.pumpWidget(const MyApp());
MattermostPushPlugin.instance.listenNativeChannelForTesting();
await MattermostPushPlugin.instance.debugSendNativeEventForTesting(const {
'type': PushNotificationType.opened,
'server_url': 'https://mm.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 navigation: channel:https://mm.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());
MattermostPushPlugin.instance.listenNativeChannelForTesting();
await MattermostPushPlugin.instance.debugSendNativeEventForTesting(const {
'type': PushNotificationType.opened,
'server_url': 'https://mm.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 navigation: thread:https://mm.example.com/root-integration',
),
findsOneWidget,
);
await tester.pumpWidget(const SizedBox.shrink());
});
}