Skip to content

Commit

Permalink
global var for testing added
Browse files Browse the repository at this point in the history
  • Loading branch information
git-elliot committed Jan 15, 2025
1 parent ba9c4d9 commit 60f02c9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions integration_test/app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ import 'package:network_tools_flutter/network_tools_flutter.dart';
import 'package:path_provider/path_provider.dart';
import 'package:vernet/injection.dart';
import 'package:vernet/main.dart';
import 'package:vernet/repository/notification_service.dart';
import 'package:vernet/ui/adaptive/adaptive_list.dart';
import 'package:vernet/values/globals.dart' as globals;
import 'package:vernet/values/keys.dart';

void main() {
globals.testingActive = true;
late ServerSocket server;
int port = 0;
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
setUpAll(() async {
configureDependencies(Env.test);
final appDocDirectory = await getApplicationDocumentsDirectory();
await configureNetworkToolsFlutter(appDocDirectory.path);
await NotificationService.initNotification();
//open a port in shared way because of portscanner using same,
//if passed false then two hosts come up in search and breaks test.
server =
Expand Down
11 changes: 10 additions & 1 deletion lib/pages/host_scan_page/host_scan_bloc/host_scan_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:vernet/models/isar/scan.dart';
import 'package:vernet/repository/notification_service.dart';
import 'package:vernet/repository/scan_repository.dart';
import 'package:vernet/services/impls/device_scanner_service.dart';
import 'package:vernet/values/globals.dart' as globals;

part 'host_scan_bloc.freezed.dart';
part 'host_scan_event.dart';
Expand Down Expand Up @@ -113,8 +114,16 @@ class HostScanBloc extends Bloc<HostScanEvent, HostScanState> {
emit(const HostScanState.loadInProgress());
emit(HostScanState.foundNewDevice(devicesSet));
}
debugPrint(
'Testing mode enabled ${globals.testingActive}',
);

if (!globals.testingActive) {
// Because notification is not working in test mode in github actions
await NotificationService.showNotificationWithActions();

Check warning on line 123 in lib/pages/host_scan_page/host_scan_bloc/host_scan_bloc.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/host_scan_page/host_scan_bloc/host_scan_bloc.dart#L123

Added line #L123 was not covered by tests
return;
}

await NotificationService.showNotificationWithActions();
emit(HostScanState.loadSuccess(devicesSet));
}

Expand Down
1 change: 1 addition & 0 deletions lib/values/globals.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bool testingActive = false;

0 comments on commit 60f02c9

Please sign in to comment.