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 #165

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
73cf5c8
Prepare integration tests
Aug 12, 2021
9e411c3
Refactor callable main | remove duplicate code | add first navigation…
Aug 12, 2021
c6fcf85
Add first github action
Aug 12, 2021
917b519
fix action to use macos instead of web | enable desktop
Aug 12, 2021
03dc7fa
Rename e2e tests | enable macos
Aug 12, 2021
e49cf0b
add xcode to e2e
Aug 12, 2021
4745d94
update action
Aug 12, 2021
56a82be
Merge branch 'main' of https://github.com/leoafarias/sidekick into fe…
Aug 14, 2021
610a6a5
Merge remote-tracking branch 'origin' into feature/integration-tests
Ahmadre Aug 14, 2021
7010bfe
add fvm to setup for e2e
Aug 14, 2021
e88ad44
Merge branch 'feature/integration-tests' of https://github.com/Ahmadr…
Aug 14, 2021
a23f695
test record e2e test
Aug 14, 2021
f118251
Merge branch 'main' into pr/115
aguilaair Aug 15, 2021
16d2083
Use FVM to run e2e tests
aguilaair Aug 15, 2021
e74e0fa
tweak GH action to only install fvm
aguilaair Aug 15, 2021
1e13b30
Remove recording
aguilaair Aug 15, 2021
5cd4925
Add windows and linux environments
Ahmadre Aug 15, 2021
4a7b2e6
add chocolatey | fix linux and windows
Ahmadre Aug 15, 2021
24555a7
fix uses + run
Ahmadre Aug 15, 2021
cf73733
add args to ghaction-chocolatey
Ahmadre Aug 15, 2021
d21f862
install linux dependencies
Ahmadre Aug 15, 2021
d8ee534
Fix linux app start
Ahmadre Aug 15, 2021
65317c8
Add snap to linux channel
Ahmadre Aug 15, 2021
ece5d83
Add install snap | add sudo to snap install
Ahmadre Aug 15, 2021
fb956c8
Change linux dependency install flow
Aug 22, 2021
b32454e
Merge branch 'main' of https://github.com/leoafarias/sidekick into fe…
Aug 22, 2021
63c68ef
Remove Packages from tests
Aug 22, 2021
a2a3bba
Fix wrong mouse cursor due to null value in IconButton
Aug 22, 2021
10118d9
update i18next to pub version
rebarah Sep 2, 2021
c324292
Add checks to prefend hive errors
Ahmadre Sep 11, 2021
4a12dcf
Add LiveTest for general settings
Ahmadre Sep 11, 2021
4864b39
Merge branch 'main' into feature/integration-tests
Ahmadre Sep 11, 2021
1ab7d53
fix isCached nullable in VersionInstallButton
Ahmadre Sep 11, 2021
7fad0c1
disable linux until working
Ahmadre Sep 11, 2021
5ef4a0a
Add reset settings test
Ahmadre Sep 11, 2021
9390654
Add tooltip to settings icon | add translations | fix analyze
Ahmadre Sep 12, 2021
14fff88
Merge branch 'main' into feature/integration-tests
leoafarias Jan 1, 2022
7b70768
Update pubspec.lock
leoafarias Jan 1, 2022
146aa85
Squashed commit of the following:
leoafarias Jan 9, 2022
732b21b
Updated lock file
leoafarias Jan 9, 2022
c1e86bf
Update pubspec.lock
leoafarias Jan 9, 2022
a61376a
Squashed commit of the following:
leoafarias Jan 9, 2022
b2f74f5
wip
leoafarias Jan 9, 2022
188ac33
Squashed commit of the following:
leoafarias Jan 9, 2022
3931854
Merge branch 'main' into finish-integration-tests
leoafarias Jan 9, 2022
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
139 changes: 139 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# Name of your workflow.
name: Test (E2E)
# Trigger the workflow on push or pull request.
on: [push, pull_request]
# A workflow run is made up of one or more jobs.
jobs:
# id of job, a string that is unique to the "jobs" node above.
macos-e2e:
# Creates a build matrix for your jobs. You can define different
# variations of an environment to run each job in.
strategy:
# A set of different configurations of the virtual
# environment.
matrix:
device:
- "macOS (macos)"
# When set to true, GitHub cancels all in-progress jobs if any
# matrix job fails.
fail-fast: false
# The type of machine to run the job on.
runs-on: macos-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/[email protected]

- name: Install FVM & Flutter
run: |
brew tap leoafarias/fvm
brew install fvm
fvm install stable
fvm doctor

- name: Setup Flutter SDK
uses: subosito/flutter-action@master

- name: Set Up XCode
uses: devbotsxyz/[email protected]

- name: Enable desktop
run: flutter config --enable-macos-desktop

- name: Run integration tests
timeout-minutes: 30
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
flutter doctor -v
flutter pub get
flutter drive --driver=test_driver/integration_test.dart --target=integration_test/app_test.dart -d macos

windows-e2e:
# Creates a build matrix for your jobs. You can define different
# variations of an environment to run each job in.
strategy:
# A set of different configurations of the virtual
# environment.
matrix:
device:
- "Windows (windows)"
# When set to true, GitHub cancels all in-progress jobs if any
# matrix job fails.
fail-fast: false
# The type of machine to run the job on.
runs-on: windows-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/[email protected]

- uses: crazy-max/ghaction-chocolatey@v1
with:
args: -h

- name: Install FVM & Flutter
run: |
choco install fvm
fvm install stable
fvm doctor

- name: Setup Flutter SDK
uses: subosito/flutter-action@master

- name: Enable desktop
run: flutter config --enable-windows-desktop

- name: Run integration tests
timeout-minutes: 30
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
flutter doctor -v
flutter pub get
flutter drive --driver=test_driver/integration_test.dart --target=integration_test/app_test.dart -d windows

linux-e2e:
if: ${{ false }}
# Creates a build matrix for your jobs. You can define different
# variations of an environment to run each job in.
strategy:
# A set of different configurations of the virtual
# environment.
matrix:
device:
- "Linux (linux)"
# When set to true, GitHub cancels all in-progress jobs if any
# matrix job fails.
fail-fast: false
# The type of machine to run the job on.
runs-on: ubuntu-20.04
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/[email protected]

- name: Install FVM & Flutter
run: |
brew tap leoafarias/fvm
brew install fvm
fvm install master
fvm doctor

- uses: subosito/flutter-action@master
with:
channel: master

- name: Install Linux build tools
run: sudo apt-get update && sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev

- name: Enable desktop
run: flutter config --enable-linux-desktop

- name: Run integration tests
timeout-minutes: 30
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
flutter pub get
flutter drive --driver=test_driver/integration_test.dart --target=integration_test/app_test.dart -d linux
11 changes: 10 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,27 @@
{
"name": "Flutter: Attach to Device",
"type": "dart",
"program": "lib/main.dart",
"request": "attach"
},
{
"name": "Flutter",
"request": "launch",
"type": "dart"
"type": "dart",
"program": "lib/main.dart"
},
{
"name": "Flutter Profile",
"request": "launch",
"type": "dart",
"program": "lib/main.dart",
"flutterMode": "profile"
},
{
"name": "Integration Tests: Launch App",
"request": "launch",
"type": "dart",
"program": "integration_test/app_test.dart"
}
]
}
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ Sidekick is an app that provides a simple desktop interface to tools that enhanc
- Version sandboxing (playground)
- more...

## E2E Integration-Testing

To run your e2e Tests locally run:

```bash
flutter drive --driver=test_driver/integration_test.dart --target=integration_test/app_test.dart
```

## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Expand Down
26 changes: 26 additions & 0 deletions integration_test/app_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// @dart=2.9
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

import 'src/modules/common/app_shell_test.dart';
import 'src/modules/settings/settings_screen.dart';

import 'package:sidekick/main.dart' as app;

void main() async {
final IntegrationTestWidgetsFlutterBinding binding =
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;

setUpAll(() {});

tearDownAll(() {});

testWidgets('LiveTest', (WidgetTester tester) async {
await tester.pumpWidget(await app.main(isTestMode: true));

await AppShellTest.navigationTests(tester);
await SettingsScreenTest.changeSettingsTests(tester);
});
}
37 changes: 37 additions & 0 deletions integration_test/src/modules/common/app_shell_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import 'package:flutter_test/flutter_test.dart';

import 'package:flutter/material.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';

import 'package:sidekick/src/modules/fvm/fvm.screen.dart';
import 'package:sidekick/src/modules/projects/projects.screen.dart';
import 'package:sidekick/src/modules/releases/releases.screen.dart';

import '../settings/settings_screen.dart';

class AppShellTest {
static Future<void> navigationTests(WidgetTester tester) async {
await Future.delayed(const Duration(seconds: 2));

///---Navigation-Rail
/// Navigation Rail is visible and ready to test
expect(find.byType(NavigationRail), findsOneWidget);

await tester.tap(find.byIcon(Icons.category));
await tester.pumpAndSettle();
expect(find.byType(FVMScreen), findsOneWidget);

await tester.tap(find.byIcon(MdiIcons.folderMultiple));
await tester.pumpAndSettle();
expect(find.byType(ProjectsScreen), findsOneWidget);

await tester.tap(find.byIcon(Icons.explore));
await tester.pumpAndSettle();
expect(find.byType(ReleasesScreen), findsOneWidget);

///---Navigation-Rail

/// Settings Screen
await SettingsScreenTest.navigationTests(tester);
}
}
82 changes: 82 additions & 0 deletions integration_test/src/modules/settings/scenes/general_settings.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:sidekick/i18n/language_manager.dart';
import 'package:sidekick/src/modules/settings/settings.service.dart';

class GeneralSettingsTest {
static final settings = SettingsService.read();

static Future changingThemeWorks(WidgetTester tester) async {
expect(find.byKey(Key('db_theme')), findsOneWidget);

for (var i = 0; i < 3; i++) {
await tester.tap(find.byKey(Key('db_theme')));
await tester.pumpAndSettle();

var system = find.byKey(Key('dmi_system'));
var light = find.byKey(Key('dmi_light'));
var dark = find.byKey(Key('dmi_dark'));

expect(system, findsWidgets);
expect(light, findsWidgets);
expect(dark, findsWidgets);

if (settings.themeMode == 'system') {
await tester.tap(find.byKey(Key('dmi_light')).last,
warnIfMissed: false);
await Future.delayed(const Duration(seconds: 1));
await tester.pumpAndSettle();

expect(find.byKey(Key('dmi_light')), findsWidgets);
} else if (settings.themeMode == 'light') {
await tester.tap(find.byKey(Key('dmi_dark')).last, warnIfMissed: false);
await Future.delayed(const Duration(seconds: 1));
await tester.pumpAndSettle();

expect(find.byKey(Key('dmi_dark')), findsWidgets);
} else if (settings.themeMode == 'dark') {
await tester.tap(find.byKey(Key('dmi_system')).last,
warnIfMissed: false);
await Future.delayed(const Duration(seconds: 1));
await tester.pumpAndSettle();

expect(find.byKey(Key('dmi_system')), findsWidgets);
}
}
}

static Future changingLocaleWorks(WidgetTester tester) async {
expect(find.byKey(Key('db_locale')), findsOneWidget);

for (var locale in languageManager.supportedLocales) {
await tester.tap(find.byKey(Key('db_locale')));
await tester.pumpAndSettle();

var localeButton = find.byKey(Key('dmi_${locale.toLanguageTag()}'));
expect(localeButton, findsWidgets);

await tester.tap(localeButton.last, warnIfMissed: false);
await Future.delayed(const Duration(seconds: 1));
await tester.pumpAndSettle();

expect(localeButton.last, findsWidgets);
}
}

static Future resetSettingsWorks(WidgetTester tester) async {
expect(find.byKey(Key('ob_reset')), findsOneWidget);

await tester.tap(find.byKey(Key('ob_reset')));
await Future.delayed(const Duration(seconds: 1));
await tester.pumpAndSettle();

expect(find.byKey(Key('tb_confirm')), findsOneWidget);

await tester.tap(find.byKey(Key('tb_confirm')));
await Future.delayed(const Duration(seconds: 2));
await tester.pumpAndSettle();

/// Detect reset if 'Reset' text for en-GB Locale exists
expect(find.text('Reset'), findsOneWidget);
}
}
56 changes: 56 additions & 0 deletions integration_test/src/modules/settings/settings_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';

import 'package:sidekick/src/components/molecules/top_app_bar.dart';
import 'package:sidekick/src/modules/settings/scenes/flutter_settings.scene.dart';
import 'package:sidekick/src/modules/settings/scenes/fvm_settings.scene.dart';
import 'package:sidekick/src/modules/settings/scenes/general_settings.scene.dart';
import 'package:sidekick/src/modules/settings/settings.screen.dart';

import 'scenes/general_settings.dart';

class SettingsScreenTest {
static Future navigationTests(WidgetTester tester) async {
expect(find.byType(SkAppBar), findsOneWidget);

await tester.tap(find.byIcon(Icons.settings));
await tester.pumpAndSettle();
expect(find.byType(SettingsScreen), findsOneWidget);
expect(find.byType(SettingsSectionGeneral), findsOneWidget);

await tester.tap(find.byIcon(MdiIcons.layers));
await tester.pumpAndSettle();
expect(find.byType(FvmSettingsScene), findsOneWidget);

await tester.tap(find.byIcon(MdiIcons.console));
await tester.pumpAndSettle();
expect(find.byType(SettingsSectionFlutter), findsOneWidget);

await tester.tap(find.byType(CloseButton));
await tester.pumpAndSettle();
expect(find.byType(SkAppBar), findsOneWidget);
}

static Future changeSettingsTests(WidgetTester tester) async {
expect(find.byType(SkAppBar), findsOneWidget);

await tester.tap(find.byIcon(Icons.settings));
await tester.pumpAndSettle();
expect(find.byType(SettingsScreen), findsOneWidget);
expect(find.byType(SettingsSectionGeneral), findsOneWidget);

/// Theme Tests
await GeneralSettingsTest.changingThemeWorks(tester);

/// Locale Tests
await GeneralSettingsTest.changingLocaleWorks(tester);

/// Reset Tests
await GeneralSettingsTest.resetSettingsWorks(tester);

await tester.tap(find.byType(CloseButton));
await tester.pumpAndSettle();
expect(find.byType(SkAppBar), findsOneWidget);
}
}
Loading