1
1
import 'package:built_collection/built_collection.dart' ;
2
- import 'package:flutter/cupertino.dart' ;
3
2
import 'package:flutter_test/flutter_test.dart' ;
4
3
import 'package:mocktail/mocktail.dart' ;
5
- import 'package:neon_framework/blocs.dart' ;
6
4
import 'package:neon_framework/models.dart' ;
7
5
import 'package:neon_framework/testing.dart' ;
8
- import 'package:neon_framework/utils.dart' ;
9
6
import 'package:neon_framework/widgets.dart' ;
10
7
import 'package:neon_notifications/l10n/localizations.dart' ;
11
- import 'package:neon_notifications/l10n/localizations_en.dart' ;
12
8
import 'package:neon_notifications/src/widgets/action.dart' ;
13
9
import 'package:neon_notifications/src/widgets/notification.dart' ;
14
10
import 'package:nextcloud/nextcloud.dart' ;
@@ -45,14 +41,17 @@ void main() {
45
41
when (() => notification.datetime).thenReturn (tz.TZDateTime .now (tz.UTC ).toIso8601String ());
46
42
when (() => notification.actions).thenReturn (BuiltList ([primaryAction, secondaryAction]));
47
43
when (() => notification.icon).thenReturn ('' );
44
+ when (() => notification.link).thenReturn ('/link' );
48
45
49
46
callback = MockCallbackFunction <void >().call;
50
47
51
48
account = MockAccount ();
52
49
when (() => account.client).thenReturn (NextcloudClient (Uri .parse ('' )));
53
50
});
54
51
55
- testWidgets ('Without matching app' , (tester) async {
52
+ testWidgets ('Notification' , (tester) async {
53
+ final router = MockGoRouter ();
54
+
56
55
await tester.pumpWidgetWithAccessibility (
57
56
TestApp (
58
57
localizationsDelegates: NotificationsLocalizations .localizationsDelegates,
@@ -61,6 +60,7 @@ void main() {
61
60
Provider <BuiltSet <AppImplementation >>.value (value: BuiltSet ()),
62
61
Provider <Account >.value (value: account),
63
62
],
63
+ router: router,
64
64
child: NotificationsNotification (
65
65
notification: notification,
66
66
onDelete: callback,
@@ -73,58 +73,13 @@ void main() {
73
73
expect (find.text ('subject' ), findsOne);
74
74
expect (find.text ('now' ), findsOne);
75
75
expect (find.byType (NotificationsAction ), findsExactly (2 ));
76
- await expectLater (find.byType (TestApp ), matchesGoldenFile ('goldens/notification_without_matching_app.png' ));
77
-
78
- await tester.longPress (find.byType (NotificationsNotification ));
79
- verify (callback.call).called (1 );
80
-
81
- await tester.runAsync (() async {
82
- await tester.tap (find.byType (NotificationsNotification ));
83
- await tester.pumpAndSettle ();
84
-
85
- expect (find.byType (NeonDialog ), findsOne);
86
- expect (find.text (NotificationsLocalizationsEn ().notificationAppNotImplementedYet), findsOne);
87
- });
88
- });
89
-
90
- testWidgets ('With matching app' , (tester) async {
91
- final appsBloc = MockAppsBloc ();
92
-
93
- final app = MockAppImplementation ();
94
- when (() => app.id).thenReturn ('app' );
95
- when (() => app.buildIcon (size: any (named: 'size' ))).thenReturn (const SizedBox ());
96
-
97
- await tester.pumpWidgetWithAccessibility (
98
- TestApp (
99
- localizationsDelegates: NotificationsLocalizations .localizationsDelegates,
100
- supportedLocales: NotificationsLocalizations .supportedLocales,
101
- providers: [
102
- Provider <BuiltSet <AppImplementation >>.value (value: BuiltSet ({app})),
103
- Provider <Account >.value (value: account),
104
- NeonProvider <AppsBloc >.value (value: appsBloc),
105
- ],
106
- child: NotificationsNotification (
107
- notification: notification,
108
- onDelete: callback,
109
- ),
110
- ),
111
- );
112
-
113
- expect (find.byType (NeonUriImage ), findsNothing);
114
- expect (find.text ('message' ), findsOne);
115
- expect (find.text ('subject' ), findsOne);
116
- expect (find.text ('now' ), findsOne);
117
- expect (find.byType (NotificationsAction ), findsExactly (2 ));
118
- await expectLater (find.byType (TestApp ), matchesGoldenFile ('goldens/notification_with_matching_app.png' ));
76
+ await expectLater (find.byType (TestApp ), matchesGoldenFile ('goldens/notification.png' ));
119
77
120
78
await tester.longPress (find.byType (NotificationsNotification ));
121
79
verify (callback.call).called (1 );
122
80
123
- await tester.runAsync (() async {
124
- await tester.tap (find.byType (NotificationsNotification ));
125
- await tester.pumpAndSettle ();
81
+ await tester.tap (find.byType (NotificationsNotification ));
126
82
127
- verify (() => appsBloc.setActiveApp ('app' )).called (1 );
128
- });
83
+ verify (() => router.go ('/link' )).called (1 );
129
84
});
130
85
}
0 commit comments