-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add basic integration test for snaps
- Loading branch information
Showing
4 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Integration Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
integration: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: subosito/flutter-action@v2 | ||
with: | ||
channel: 'stable' | ||
flutter-version: '3.10.6' | ||
- run: sudo apt update | ||
- run: sudo apt install -y clang cmake libblkid-dev libglib2.0-dev libgtk-3-dev liblzma-dev network-manager ninja-build packagekit pkg-config polkitd xvfb | ||
- run: sudo cp integration_test/assets/snapd-ci.pkla /var/lib/polkit-1/localauthority/50-local.d/ | ||
- run: LANG=en_US.UTF-8 xvfb-run -a -s '-screen 0 1024x768x24 +extension GLX' flutter test integration_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:app_center/main.dart' as app; | ||
import 'package:app_center/src/store/store_app.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:integration_test/integration_test.dart'; | ||
import 'package:ubuntu_test/ubuntu_test.dart'; | ||
import 'package:yaru_icons/yaru_icons.dart'; | ||
import 'package:yaru_test/yaru_test.dart'; | ||
|
||
import '../test/test_utils.dart'; | ||
|
||
void main() { | ||
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
|
||
testWidgets('install and remove a snap', (tester) async { | ||
final file = File('/snap/bin/hello'); | ||
await app.main([]); | ||
await tester.pumpUntil(find.byType(StoreApp)); | ||
await tester.pumpAndSettle(); | ||
await testSearchSnap(tester, packageName: 'hello'); | ||
await testInstallSnap(tester, installedFile: file); | ||
await testRemoveSnap(tester, installedFile: file); | ||
}); | ||
} | ||
|
||
Future<void> testSearchSnap( | ||
WidgetTester tester, { | ||
required String packageName, | ||
}) async { | ||
final searchField = find.textField(tester.l10n.searchFieldSearchHint); | ||
expectSync(searchField, findsOneWidget); | ||
await tester.enterText(searchField, packageName); | ||
await tester.pumpAndSettle(); | ||
|
||
final dropdownEntry = find.widgetWithText(ListTile, packageName); | ||
await tester.pumpUntil(dropdownEntry); | ||
expectSync(dropdownEntry, findsOneWidget); | ||
|
||
await tester.tap(dropdownEntry); | ||
await tester.pumpAndSettle(); | ||
} | ||
|
||
Future<void> testInstallSnap( | ||
WidgetTester tester, { | ||
required File installedFile, | ||
}) async { | ||
expect(installedFile.existsSync(), isFalse); | ||
|
||
final installButton = find.button(tester.l10n.snapActionInstallLabel); | ||
final openButton = find.button(tester.l10n.snapActionOpenLabel); | ||
expectSync(installButton, findsOneWidget); | ||
expectSync(openButton, findsNothing); | ||
|
||
await tester.tap(installButton); | ||
await tester.pumpUntil(openButton); | ||
|
||
expectSync(openButton, findsOneWidget); | ||
expectSync(installButton, findsNothing); | ||
|
||
expectSync(installedFile.existsSync(), isTrue); | ||
} | ||
|
||
Future<void> testRemoveSnap( | ||
WidgetTester tester, { | ||
required File installedFile, | ||
}) async { | ||
final installButton = find.button(tester.l10n.snapActionInstallLabel); | ||
expect(installButton, findsNothing); | ||
|
||
await tester.tap(find.iconButton(YaruIcons.view_more_horizontal)); | ||
await tester.pumpAndSettle(); | ||
await tester.tap(find.button(tester.l10n.snapActionRemoveLabel)); | ||
await tester.pumpUntil(installButton); | ||
|
||
expect(installedFile.existsSync(), isFalse); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[Allow privileged snapd actions without prompting, for use in integration tests in destructive CI environments only] | ||
Identity=unix-user:* | ||
Action=io.snapcraft.snapd.manage | ||
ResultAny=yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters