1
1
//import 'package:spot/spot.dart';
2
2
import 'package:apidash/providers/providers.dart' ;
3
3
import 'package:apidash/screens/common_widgets/common_widgets.dart' ;
4
- import 'package:apidash/screens/dashboard.dart' ;
5
4
import 'package:apidash/screens/envvar/environment_page.dart' ;
6
- import 'package:apidash/screens/home_page/collection_pane.dart' ;
7
5
import 'package:apidash/screens/home_page/editor_pane/details_card/response_pane.dart' ;
8
6
import 'package:apidash/screens/home_page/editor_pane/editor_default.dart' ;
9
7
import 'package:apidash/screens/home_page/editor_pane/editor_pane.dart' ;
10
8
import 'package:apidash/screens/home_page/editor_pane/url_card.dart' ;
11
9
import 'package:apidash/screens/home_page/home_page.dart' ;
10
+ import 'package:apidash/screens/screens.dart' ;
12
11
import 'package:apidash/screens/settings_page.dart' ;
13
12
import 'package:apidash/screens/history/history_page.dart' ;
14
13
import 'package:apidash/widgets/widgets.dart' ;
@@ -49,6 +48,7 @@ void main() {
49
48
expect (find.byType (HomePage ), findsOneWidget);
50
49
expect (find.byType (EnvironmentPage ), findsNothing);
51
50
expect (find.byType (HistoryPage ), findsNothing);
51
+ expect (find.byType (TerminalPage ), findsNothing);
52
52
expect (find.byType (SettingsPage ), findsNothing);
53
53
});
54
54
@@ -70,6 +70,7 @@ void main() {
70
70
expect (find.byType (HomePage ), findsNothing);
71
71
expect (find.byType (EnvironmentPage ), findsOneWidget);
72
72
expect (find.byType (HistoryPage ), findsNothing);
73
+ expect (find.byType (TerminalPage ), findsNothing);
73
74
expect (find.byType (SettingsPage ), findsNothing);
74
75
});
75
76
@@ -93,10 +94,11 @@ void main() {
93
94
expect (find.byType (HomePage ), findsNothing);
94
95
expect (find.byType (EnvironmentPage ), findsNothing);
95
96
expect (find.byType (HistoryPage ), findsOneWidget);
97
+ expect (find.byType (TerminalPage ), findsNothing);
96
98
expect (find.byType (SettingsPage ), findsNothing);
97
99
});
98
100
testWidgets (
99
- "Dashboard should display SettingsPage when navRailIndexStateProvider is 3" ,
101
+ "Dashboard should display TerminalPage when navRailIndexStateProvider is 3" ,
100
102
(WidgetTester tester) async {
101
103
await tester.pumpWidget (
102
104
ProviderScope (
@@ -115,6 +117,31 @@ void main() {
115
117
expect (find.byType (HomePage ), findsNothing);
116
118
expect (find.byType (EnvironmentPage ), findsNothing);
117
119
expect (find.byType (HistoryPage ), findsNothing);
120
+ expect (find.byType (TerminalPage ), findsOneWidget);
121
+ expect (find.byType (SettingsPage ), findsNothing);
122
+ });
123
+
124
+ testWidgets (
125
+ "Dashboard should display SettingsPage when navRailIndexStateProvider is 4" ,
126
+ (WidgetTester tester) async {
127
+ await tester.pumpWidget (
128
+ ProviderScope (
129
+ overrides: [
130
+ navRailIndexStateProvider.overrideWith ((ref) => 4 ),
131
+ ],
132
+ child: const Portal (
133
+ child: MaterialApp (
134
+ home: Dashboard (),
135
+ ),
136
+ ),
137
+ ),
138
+ );
139
+
140
+ // Verify that the SettingsPage is displayed
141
+ expect (find.byType (HomePage ), findsNothing);
142
+ expect (find.byType (EnvironmentPage ), findsNothing);
143
+ expect (find.byType (HistoryPage ), findsNothing);
144
+ expect (find.byType (TerminalPage ), findsNothing);
118
145
expect (find.byType (SettingsPage ), findsOneWidget);
119
146
});
120
147
@@ -138,7 +165,7 @@ void main() {
138
165
// Verify that the navRailIndexStateProvider is updated
139
166
final dashboard = tester.element (find.byType (Dashboard ));
140
167
final container = ProviderScope .containerOf (dashboard);
141
- expect (container.read (navRailIndexStateProvider), 3 );
168
+ expect (container.read (navRailIndexStateProvider), 4 );
142
169
});
143
170
144
171
testWidgets (
@@ -155,7 +182,7 @@ void main() {
155
182
),
156
183
);
157
184
158
- // Tap on the Settings icon to change the index to 3
185
+ // Tap on the Settings icon to change the index to 4
159
186
await tester.tap (find.byIcon (Icons .settings_outlined));
160
187
await tester.pump ();
161
188
@@ -173,12 +200,13 @@ void main() {
173
200
// Verify that the navRailIndexStateProvider still has the updated value
174
201
final dashboard = tester.element (find.byType (Dashboard ));
175
202
final container = ProviderScope .containerOf (dashboard);
176
- expect (container.read (navRailIndexStateProvider), 3 );
203
+ expect (container.read (navRailIndexStateProvider), 4 );
177
204
178
205
// Verify that the SettingsPage is still displayed after the rebuild
179
206
expect (find.byType (SettingsPage ), findsOneWidget);
180
207
expect (find.byType (HomePage ), findsNothing);
181
208
expect (find.byType (EnvironmentPage ), findsNothing);
209
+ expect (find.byType (TerminalPage ), findsNothing);
182
210
});
183
211
184
212
testWidgets (
@@ -216,10 +244,19 @@ void main() {
216
244
// Verify that the selected icon is the filled version (selectedIcon)
217
245
expect (find.byIcon (Icons .history_rounded), findsOneWidget);
218
246
219
- // Go to SettingsPage
247
+ // Go to TerminalPage
220
248
container.read (navRailIndexStateProvider.notifier).state = 3 ;
221
249
await tester.pump ();
222
250
251
+ // Verify that the TerminalPage is displayed
252
+ expect (find.byType (TerminalPage ), findsOneWidget);
253
+ // Verify that the selected icon is the filled version (selectedIcon)
254
+ expect (find.byIcon (Icons .terminal), findsOneWidget);
255
+
256
+ // Go to SettingsPage
257
+ container.read (navRailIndexStateProvider.notifier).state = 4 ;
258
+ await tester.pump ();
259
+
223
260
// Verify that the SettingsPage is displayed
224
261
expect (find.byType (SettingsPage ), findsOneWidget);
225
262
// Verify that the selected icon is the filled version (selectedIcon)
0 commit comments