1+ // import 'package:flutter/material.dart';
2+ // import 'package:flutter_test/flutter_test.dart';
3+ // import 'package:provider/provider.dart';
4+
5+ // import 'package:vpn_client/main.dart';
6+ // import 'package:vpn_client/theme_provider.dart';
7+
8+ // void main() {
9+ // testWidgets('Counter increments smoke test', (WidgetTester tester) async {
10+ // await tester.pumpWidget(
11+ // MultiProvider(
12+ // providers: [
13+ // ChangeNotifierProvider<ThemeProvider>(create: (_) => ThemeProvider()),
14+ // ],
15+ // child: const MaterialApp(home: App()),
16+ // ),
17+ // );
18+ // <-- This test is designed for Flutter's default counter app, which are not using. So ours app doesn’t show '0' or '1', which leads to: error test
19+
20+
21+ // expect(find.text('0'), findsOneWidget);
22+ // expect(find.text('1'), findsNothing);
23+
24+ // await tester.tap(find.byIcon(Icons.add));
25+ // await tester.pump();
26+
27+ // expect(find.text('0'), findsNothing);
28+ // expect(find.text('1'), findsOneWidget);
29+ // });
30+ // }
31+
132import 'package:flutter/material.dart' ;
233import 'package:flutter_test/flutter_test.dart' ;
334import 'package:provider/provider.dart' ;
@@ -6,7 +37,7 @@ import 'package:vpn_client/main.dart';
637import 'package:vpn_client/theme_provider.dart' ;
738
839void main () {
9- testWidgets ('Counter increments smoke test ' , (WidgetTester tester) async {
40+ testWidgets ('App shows VPN status on launch ' , (WidgetTester tester) async {
1041 await tester.pumpWidget (
1142 MultiProvider (
1243 providers: [
@@ -16,13 +47,13 @@ void main() {
1647 ),
1748 );
1849
19- expect (find. text ( '0' ), findsOneWidget);
20- expect (find. text ( '1' ), findsNothing);
21-
22- await tester. tap (find. byIcon ( Icons .add));
23- await tester. pump ();
24-
25- expect (find. text ( '0' ), findsNothing);
26- expect (find. text ( '1' ), findsOneWidget );
50+ // Check that 'CONNECTED' or 'DISCONNECTED' appears on screen
51+ expect (
52+ find. byWidgetPredicate (
53+ (widget) => widget is Text &&
54+ (widget.data == 'CONNECTED' || widget.data == 'DISCONNECTED' ),
55+ ),
56+ findsOneWidget,
57+ );
2758 });
2859}
0 commit comments