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

Merge dev into main #206

Merged
merged 86 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from 69 commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
9494ac3
Added simple integration test for host scanner
git-elliot Nov 9, 2024
7a55394
run integration tests in ci
git-elliot Nov 9, 2024
a49971e
check api 29 first
git-elliot Nov 9, 2024
3d43a48
use only macos
git-elliot Nov 9, 2024
df31025
run test
git-elliot Nov 9, 2024
edd6d03
device added
git-elliot Nov 9, 2024
49b9930
test fixed
git-elliot Nov 9, 2024
09ca016
remove upgrade dep because lock file exists
git-elliot Nov 9, 2024
17a8698
remove upgrade dep because lock file exists
git-elliot Nov 9, 2024
9ba3a32
remove upgrade dep because lock file exists
git-elliot Nov 9, 2024
6875b31
rearrange
git-elliot Nov 9, 2024
4d96120
fixed tests
git-elliot Nov 9, 2024
f62158c
analyzer fixes
git-elliot Nov 9, 2024
c3e42a0
test fixes
git-elliot Nov 9, 2024
ffe8097
verificaiton
git-elliot Nov 9, 2024
aae7783
fix command
git-elliot Nov 9, 2024
c1d7d68
Merge pull request #203 from osociety/integration-tests
git-elliot Nov 9, 2024
9b225bb
Check integration tests are passing or not
git-elliot Nov 9, 2024
800459e
merge
git-elliot Nov 9, 2024
43223cc
added more tests
git-elliot Nov 9, 2024
e51e9e1
fix tests
git-elliot Nov 9, 2024
31916c7
check if test is culprit
git-elliot Nov 9, 2024
b5f80e5
check if test passes now
git-elliot Nov 9, 2024
4fb5383
check return code
git-elliot Nov 9, 2024
dfb4996
tests fucking sucks
git-elliot Nov 9, 2024
6bffd5e
check tests
git-elliot Nov 9, 2024
4d91972
fix
git-elliot Nov 9, 2024
2999382
fix
git-elliot Nov 9, 2024
9517f39
pump and settle
git-elliot Nov 9, 2024
c59f2c9
increased duration
git-elliot Nov 9, 2024
36ed0be
pumpAndSettle causes trouble
git-elliot Nov 9, 2024
8b72b01
pump
git-elliot Nov 9, 2024
cac7385
removed progrees bar
git-elliot Nov 9, 2024
826315d
icon not found
git-elliot Nov 9, 2024
a71673c
added indicator back
git-elliot Nov 9, 2024
6aa4cdd
delay
git-elliot Nov 9, 2024
55154d0
removed indicator
git-elliot Nov 9, 2024
b1be7b4
Merge pull request #204 from osociety/integration-tests
git-elliot Nov 9, 2024
5029e38
Host Scan to Port scan integration flow
git-elliot Nov 10, 2024
6defd64
finished flow
git-elliot Nov 10, 2024
fec932a
Merge branch 'dev' into integration-tests
git-elliot Nov 10, 2024
f102793
Update app_test.dart
git-elliot Nov 10, 2024
9eb1978
opened port
git-elliot Nov 10, 2024
b39f054
comment main branch
git-elliot Nov 10, 2024
97d6269
fix test
git-elliot Nov 10, 2024
80c8496
removed port test
git-elliot Nov 10, 2024
40b3ca3
port scan test
git-elliot Nov 10, 2024
eddb40a
remove circular progress indicator
git-elliot Nov 10, 2024
360bf3a
timeout increase
git-elliot Nov 10, 2024
b48be4c
findsany
git-elliot Nov 10, 2024
fefa93b
debug later
git-elliot Nov 10, 2024
00114bf
fix bloody damn test
git-elliot Nov 10, 2024
7390e20
chck int tests
git-elliot Nov 10, 2024
17a9b2e
add messages
git-elliot Nov 10, 2024
29f5c58
remove indiactor
git-elliot Nov 10, 2024
82be57d
fix tests
git-elliot Nov 10, 2024
5f2e2f2
fix pump
git-elliot Nov 10, 2024
f9311cc
some tests pass
git-elliot Nov 10, 2024
3186403
comment
git-elliot Nov 10, 2024
3575ded
duration added
git-elliot Nov 10, 2024
ff85ab4
fix
git-elliot Nov 10, 2024
019fa7f
fixed everything
git-elliot Nov 10, 2024
75fceb4
works in local
git-elliot Nov 10, 2024
04996c9
tests
git-elliot Nov 10, 2024
de75d74
work it man
git-elliot Nov 10, 2024
1c51097
only on main branch
git-elliot Nov 10, 2024
6625d38
let it settle
git-elliot Nov 10, 2024
960f9a7
Merge pull request #205 from osociety/integration-tests
git-elliot Nov 10, 2024
a74b540
Merge branch 'main' into dev
git-elliot Nov 10, 2024
a504319
changed keys to widgetkeys
git-elliot Nov 12, 2024
e5e9d13
fix tests
git-elliot Nov 12, 2024
ede13f5
fix analyzer warnings
git-elliot Nov 12, 2024
82c4e89
fix tests
git-elliot Nov 12, 2024
e823730
should fix it
git-elliot Nov 12, 2024
e23f6c2
fix test
git-elliot Nov 12, 2024
68bf02a
fix tests
git-elliot Nov 12, 2024
7217db0
fixed tests
git-elliot Nov 12, 2024
8003320
remove portscan test
git-elliot Nov 12, 2024
4ab7fa3
remove import
git-elliot Nov 12, 2024
36e7487
Fix for slowness of device scan
git-elliot Nov 16, 2024
fa12b7b
Prepare release v1.1.0+29
git-elliot Nov 16, 2024
413949e
Merge pull request #207 from osociety/fix-ui-slowness
git-elliot Nov 16, 2024
7fa041b
Added coverage action
git-elliot Nov 16, 2024
0b69b0c
added codecov badge
git-elliot Nov 16, 2024
8f05522
Merge branch 'dev' into fix-ui-slowness
git-elliot Nov 16, 2024
73f720a
Merge pull request #208 from osociety/fix-ui-slowness
git-elliot Nov 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .github/workflows/flutter_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ jobs:
- name: Download pub dependencies
run: flutter pub get

- name: Upgrade pub dependencies
run: flutter pub upgrade

- name: Run build_runner
run: dart run build_runner build --delete-conflicting-outputs

Expand Down Expand Up @@ -150,9 +147,6 @@ jobs:
- name: Download pub dependencies
run: flutter pub get

- name: Upgrade pub dependencies
run: flutter pub upgrade

- name: Run build_runner
run: dart run build_runner build --delete-conflicting-outputs

Expand Down Expand Up @@ -204,9 +198,6 @@ jobs:
- name: Download pub dependencies
run: flutter pub get

- name: Upgrade pub dependencies
run: flutter pub upgrade

- name: Run build_runner
run: dart run build_runner build --delete-conflicting-outputs

Expand Down
17 changes: 8 additions & 9 deletions .github/workflows/flutter_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@ jobs:
name: 'Flutter Analyze + Test'
needs: changes
if: ${{ needs.changes.outputs.lib == 'true' || needs.changes.outputs.test == 'true' || needs.changes.outputs.yaml == 'true' || needs.changes.outputs.android == 'true' || needs.changes.outputs.linux == 'true' || needs.changes.outputs.macos == 'true' || needs.changes.outputs.windows == 'true' }}
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Setup Java JDK
uses: actions/[email protected]
with:
Expand Down Expand Up @@ -85,14 +89,15 @@ jobs:
build-runner-
- name: Download pub dependencies
run: flutter pub get
- name: Upgrade pub dependencies
run: flutter pub upgrade
- name: Run build_runner
run: flutter pub run build_runner build
- name: Run analyzer
run: flutter analyze
- name: Run tests
run: flutter test
- name: Run integration tests
if: ${{ steps.extract_branch.outputs.branch == 'main' }}
run: flutter test integration_test -d macos

android-linux-build:
name: 'Build Android + Linux'
Expand Down Expand Up @@ -130,8 +135,6 @@ jobs:
build-runner-
- name: Download pub dependencies
run: flutter pub get
- name: Upgrade pub dependencies
run: flutter pub upgrade
- name: Run build_runner
run: flutter pub run build_runner build
- name: Build Android
Expand Down Expand Up @@ -186,8 +189,6 @@ jobs:
${{ runner.os }}-pods-
- name: Download pub dependencies
run: flutter pub get
- name: Upgrade pub dependencies
run: flutter pub upgrade
- name: Run build_runner
run: flutter pub run build_runner build
- name: Build macos
Expand Down Expand Up @@ -224,8 +225,6 @@ jobs:
build-runner-
- name: Download pub dependencies
run: flutter pub get
- name: Upgrade pub dependencies
run: flutter pub upgrade
- name: Run build_runner
run: flutter pub run build_runner build
- name: Build windows
Expand Down
2 changes: 2 additions & 0 deletions generate_coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
genhtml coverage/lcov.info -o coverage/html
open coverage/html/index.html
112 changes: 112 additions & 0 deletions integration_test/app_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// This is a basic Flutter widget test.
git-elliot marked this conversation as resolved.
Show resolved Hide resolved
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
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/ui/adaptive/adaptive_list.dart';
import 'package:vernet/values/keys.dart';

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
setUpAll(() async {
configureDependencies(Env.test);
final appDocDirectory = await getApplicationDocumentsDirectory();
await configureNetworkToolsFlutter(appDocDirectory.path);
});

group('host scanner end-to-end test', () {
testWidgets('just test if app is able to launch and display homepage',
(tester) async {
// Load app widget.
await tester.pumpWidget(const MyApp(true));
await tester.pumpAndSettle();

// Verify that there are 4 widgets at homepage
expect(find.bySubtype<AdaptiveListTile>(), findsAtLeastNWidgets(4));
});

testWidgets('tap on the scan for devices button, verify device found',
(tester) async {
// Load app widget.
await tester.pumpWidget(const MyApp(true));
await tester.pumpAndSettle();

// Verify that there are 4 widgets at homepage
expect(find.bySubtype<AdaptiveListTile>(), findsAtLeastNWidgets(4));

// Finds the scan for devices button to tap on.
final devicesButton = find.byKey(Keys.scanForDevicesButton);

// Emulate a tap on the button.
await tester.tap(devicesButton);
await tester.pump();
expect(find.byType(AdaptiveListTile), findsAny);
await tester.pumpAndSettle(const Duration(seconds: 20));
await tester.pump();
expect(find.byType(AdaptiveListTile), findsAtLeast(2));

final routerIconButton = find.byKey(Keys.routerOrGatewayTileIconButton);

await tester.tap(routerIconButton);
await tester.pumpAndSettle();
expect(find.byType(AppBar), findsOne);

final radioButton = find.byKey(Keys.rangePortScanRadioButton);
await tester.tap(radioButton);
await tester.pumpAndSettle();

final portChip = find.byKey(Keys.knownPortChip);

await tester.tap(portChip);
await tester.pumpAndSettle();

final portScanButton = find.byKey(Keys.portScanButton);
await tester.tap(portScanButton);
await tester.pumpAndSettle();
});

testWidgets('port scan returns open port for google.com', (tester) async {
// Load app widget.
await tester.pumpWidget(const MyApp(true));
await tester.pumpAndSettle();

// Verify that there are 4 widgets at homepage
expect(find.bySubtype<AdaptiveListTile>(), findsAtLeastNWidgets(4));

// Finds the open ports button to tap on.
final scanForOpenPortsButton = find.byKey(Keys.scanForOpenPortsButton);

await tester.tap(scanForOpenPortsButton);
await tester.pumpAndSettle();
expect(find.byType(AppBar), findsOne);

final googleChip = find.byKey(Keys.googleChip);
await tester.tap(googleChip);
await tester.pumpAndSettle();

final radioButton = find.byKey(Keys.rangePortScanRadioButton);
await tester.tap(radioButton);
await tester.pumpAndSettle();

final portChip = find.byKey(Keys.knownPortChip);
await tester.tap(portChip);
await tester.pumpAndSettle();

final portScanButton = find.byKey(Keys.portScanButton);
await tester.tap(portScanButton);
await tester.pumpAndSettle(const Duration(seconds: 20));
await tester.pump();
//TODO: not passing in github actions
expect(find.byType(AdaptiveListTile), findsAny);
});
});
}
4 changes: 4 additions & 0 deletions lib/helper/app_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,8 @@ class AppSettings {
_customSubnet;
debugPrint("Custom Subnet : $_customSubnet");
}

Future<bool> clearAll() async {
return (await SharedPreferences.getInstance()).clear();
}
}
5 changes: 4 additions & 1 deletion lib/pages/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import 'package:vernet/repository/notification_service.dart';
import 'package:vernet/services/impls/device_scanner_service.dart';
import 'package:vernet/ui/adaptive/adaptive_list.dart';
import 'package:vernet/ui/custom_tile.dart';
import 'package:vernet/values/keys.dart';
import 'package:vernet/values/strings.dart';

class HomePage extends StatefulWidget {
Expand Down Expand Up @@ -168,6 +169,7 @@ class _WifiDetailState extends State<HomePage> {
width: 4,
),
ElevatedButton(
key: Keys.scanForDevicesButton,
onPressed: () {
Navigator.push(
context,
Expand All @@ -192,7 +194,7 @@ class _WifiDetailState extends State<HomePage> {
} else if (snapshot.hasError) {
return const Text("Unable to fetch WiFi details");
} else {
return const CircularProgressIndicator.adaptive();
return const Text('Loading...');
}
},
),
Expand Down Expand Up @@ -221,6 +223,7 @@ class _WifiDetailState extends State<HomePage> {
),
const SizedBox(width: 10),
ElevatedButton.icon(
key: Keys.scanForOpenPortsButton,
onPressed: () {
Navigator.push(
context,
Expand Down
20 changes: 10 additions & 10 deletions lib/pages/host_scan_page/widgets/host_scan_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import 'package:vernet/models/isar/device.dart';
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';
import 'package:vernet/values/tooltip_messages.dart';

//TODO: Device doesn't refresh when active scan going on
class HostScanWidget extends StatelessWidget {
Expand All @@ -29,7 +32,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 @@ -68,15 +71,9 @@ 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: Keys.rescanIconButton,
onPressed: () {
context
.read<HostScanBloc>()
Expand All @@ -97,7 +94,10 @@ class HostScanWidget extends StatelessWidget {
'${host.internetAddress}, ${host.macAddress ?? ''}',
),
trailing: IconButton(
tooltip: 'Scan open ports for this target',
key: host.deviceMake == 'Router/Gateway'
? Keys.routerOrGatewayTileIconButton
: null,
tooltip: TooltipMessages.currentDevicePortScan,
icon: const Icon(Icons.radar),
onPressed: () {
Navigator.push(
Expand Down
Loading
Loading