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

test: add basic integration test #979

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Changes from all commits
Commits
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
66 changes: 66 additions & 0 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
@@ -57,6 +57,72 @@ jobs:
files: ./coverage/lcov.info
flags: appainter

integration-test:
name: Integration test
runs-on: ${{ matrix.os }}

strategy:
matrix:
type: [macos, windows, linux]
include:
- type: macos
os: macos-latest

- type: windows
os: windows-latest

- type: linux
os: ubuntu-latest

steps:
- name: Checkout 🛎️
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- name: Get project Flutter version 🏷️
id: fvm-config
uses: kuhnroyal/flutter-fvm-config-action@v1.2.0

- name: Setup Flutter 💻
uses: subosito/flutter-action@v2.12.0
id: setup-flutter
with:
flutter-version: ${{ steps.fvm-config.outputs.FLUTTER_VERSION }}
cache: true
cache-key: ${{ runner.os }}-flutter-${{ steps.fvm-config.outputs.FLUTTER_VERSION }}-${{ hashFiles('**/pubspec.lock') }}

- name: Cache Pub 💾
uses: actions/cache@v3
with:
path: |
${{ env.PUB_CACHE }}
**/.dart_tool
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }}
restore-keys: |
${{ runner.os }}-pub-

- name: Patch for Linux build 🩹
if: ${{ matrix.type == 'linux' }}
run: |
sudo apt-get update -y
sudo apt-get install -y ninja-build libgtk-3-dev

- name: Write Google service info file for MacOS 📝
if: ${{ matrix.type == 'macos' }}
run: printf "${{ secrets.GOOGLE_SERVICE_INFO_MACOS }}" > macos/Runner/GoogleService-Info.plist

- name: Run tests 🧪
shell: bash
run: |
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
flutter build ${{ matrix.type }} --no-tree-shake-icons --target=integration_test/app_test.dart

if [ "${{ matrix.type }}" == "linux" ]; then
xvfb-run flutter test integration_test -d ${{ matrix.type }}
else
flutter test integration_test -d ${{ matrix.type }}
fi

lint:
name: Lint
runs-on: ubuntu-latest
19 changes: 19 additions & 0 deletions integration_test/app_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:appainter/basic_theme/basic_theme.dart';
import 'package:appainter/main.dart' as app;
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

group('end-to-end test', () {
testWidgets('render correctly', (tester) async {
await tester.binding.setSurfaceSize(const Size(2400, 850));
await app.main();
await tester.pumpAndSettle();

expect(find.byType(BasicThemeEditor), findsOneWidget);
});
});
}
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ import 'package:window_manager/window_manager.dart';
import 'app.dart';
import 'bloc_observer.dart';

void main() async {
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
Bloc.observer = MyBlocObserver();
EquatableConfig.stringify = kDebugMode;
43 changes: 37 additions & 6 deletions pubspec.lock
Original file line number Diff line number Diff line change
@@ -227,10 +227,10 @@ packages:
dependency: transitive
description:
name: coverage
sha256: ac86d3abab0f165e4b8f561280ff4e066bceaac83c424dd19f1ae2c2fcd12ca9
sha256: "595a29b55ce82d53398e1bcc2cba525d7bd7c59faeb2d2540e9d42c390cfeeeb"
url: "https://pub.dev"
source: hosted
version: "1.7.1"
version: "1.6.4"
crypto:
dependency: transitive
description:
@@ -468,6 +468,11 @@ packages:
url: "https://pub.dev"
source: hosted
version: "8.1.3"
flutter_driver:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
flutter_lints:
dependency: "direct dev"
description:
@@ -523,6 +528,11 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.2.0"
fuchsia_remote_debug_protocol:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
glob:
dependency: transitive
description:
@@ -603,6 +613,11 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.0.0"
integration_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
intl:
dependency: "direct main"
description:
@@ -847,10 +862,10 @@ packages:
dependency: transitive
description:
name: platform
sha256: "0a279f0707af40c890e80b1e9df8bb761694c074ba7e1d4ab1bc4b728e200b59"
sha256: ae68c7bfcd7383af3629daafb32fb4e8681c7154428da4febcff06200585f102
url: "https://pub.dev"
source: hosted
version: "3.1.3"
version: "3.1.2"
plugin_platform_interface:
dependency: transitive
description:
@@ -1136,6 +1151,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.2.0"
sync_http:
dependency: transitive
description:
name: sync_http
sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961"
url: "https://pub.dev"
source: hosted
version: "0.3.1"
system_info2:
dependency: transitive
description:
@@ -1308,10 +1331,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
sha256: c538be99af830f478718b51630ec1b6bee5e74e52c8a802d328d9e71d35d2583
url: "https://pub.dev"
source: hosted
version: "13.0.0"
version: "11.10.0"
watcher:
dependency: transitive
description:
@@ -1336,6 +1359,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.4.0"
webdriver:
dependency: transitive
description:
name: webdriver
sha256: "3c923e918918feeb90c4c9fdf1fe39220fa4c0e8e2c0fffaded174498ef86c49"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
webkit_inspection_protocol:
dependency: transitive
description:
2 changes: 2 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -57,6 +57,8 @@ dev_dependencies:
flutter_lints: 3.0.1
flutter_test:
sdk: flutter
integration_test:
sdk: flutter
mocktail: 1.0.1
path_provider_platform_interface: 2.1.1
remove_from_coverage: 2.0.0