Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration tests #204

Merged
merged 20 commits into from
Nov 9, 2024
18 changes: 9 additions & 9 deletions integration_test/app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ void main() {
configureDependencies(Env.test);

group('end-to-end test', () {
testWidgets('just test if app is able to launch', (tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp(true));
await tester.pumpAndSettle();
});

testWidgets('tap on the scan for devices button, verify device found',
(tester) async {
final appDocDirectory = await getApplicationDocumentsDirectory();
Expand All @@ -40,16 +46,10 @@ void main() {

// Emulate a tap on the button.
await tester.tap(devicesButton);

// Trigger a frame.
await tester.pumpAndSettle();

// Verify that the scan completes
// expect(
// find.byKey(const ValueKey(Keys.rescanIconButton)),
// findsOneWidget,
// );
await tester.pump();
expect(find.byType(AdaptiveListTile), findsAny);
await tester.pumpAndSettle();
expect(find.byType(AdaptiveListTile), findsAtLeast(2));
});
});
}
12 changes: 3 additions & 9 deletions lib/pages/host_scan_page/widgets/host_scan_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:vernet/pages/host_scan_page/host_scan_bloc/host_scan_bloc.dart';
import 'package:vernet/pages/network_troubleshoot/port_scan_page.dart';
import 'package:vernet/ui/adaptive/adaptive_list.dart';
import 'package:vernet/values/keys.dart';
import 'package:vernet/values/strings.dart';

//TODO: Device doesn't refresh when active scan going on
class HostScanWidget extends StatelessWidget {
Expand All @@ -30,7 +31,7 @@ class HostScanWidget extends StatelessWidget {
Text(
appSettings.gatewayIP.isNotEmpty
? 'Searching for devices in ${appSettings.gatewayIP} network'
: 'Searching for devices in your local network',
: StringValue.loadingDevicesMessage,
textAlign: TextAlign.center,
),
],
Expand Down Expand Up @@ -69,14 +70,7 @@ class HostScanWidget extends StatelessWidget {
textAlign: TextAlign.center,
),
trailing: loading
? const Padding(
padding: EdgeInsets.all(8.0),
child: SizedBox(
height: 25.0,
width: 25.0,
child: Center(child: CircularProgressIndicator.adaptive()),
),
)
? const SizedBox()
: IconButton(
key: const ValueKey(Keys.rescanIconButton),
onPressed: () {
Expand Down
3 changes: 2 additions & 1 deletion lib/values/strings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ class StringValue {
'Scan a custom subnet instead of local one.';
static const String customSubnetHint = 'e.g., 10.102.200.1';
static const String hostScanPageTitle = 'Scan for devices';

static const String loadingDevicesMessage =
'Searching for devices in your local network';
}
3 changes: 1 addition & 2 deletions test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import 'package:vernet/main.dart';

Future<void> main() async {
group('widget test', () {
testWidgets('tap on the scan for devices button, verify device found',
(tester) async {
testWidgets('my first widget test', (tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp(false));
});
Expand Down
Loading