-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: u221711 <[email protected]>
- Loading branch information
Showing
29 changed files
with
742 additions
and
257 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 |
---|---|---|
|
@@ -16,7 +16,7 @@ on: | |
push: | ||
paths: | ||
- 'das_client/**' | ||
branches: [ "feature/das-client-durchstich" ] | ||
branches: [ "main" ] | ||
pull_request: | ||
paths: | ||
- 'das_client/**' | ||
|
@@ -34,16 +34,40 @@ jobs: | |
- uses: subosito/flutter-action@v2 | ||
with: | ||
flutter-version: '3.22.2' | ||
- run: flutter pub get | ||
- run: flutter pub run build_runner build --delete-conflicting-outputs | ||
- name: Prepare Flutter Build | ||
env: | ||
ANDROID_KEYSTORE_STRING: ${{ secrets.ANDROID_KEYSTORE }} | ||
ANDROID_KEYSTORE: ${{ github.workspace }}/das_client/android/das.keystore | ||
ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} | ||
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }} | ||
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }} | ||
run: | | ||
echo $ANDROID_KEYSTORE_STRING | base64 -d > $ANDROID_KEYSTORE | ||
echo "ANDROID_KEYSTORE=$ANDROID_KEYSTORE" >> "$GITHUB_ENV" | ||
echo "ANDROID_KEYSTORE_PASSWORD=$ANDROID_KEYSTORE_PASSWORD" >> "$GITHUB_ENV" | ||
echo "ANDROID_KEY_ALIAS=$ANDROID_KEY_ALIAS" >> "$GITHUB_ENV" | ||
echo "ANDROID_KEY_PASSWORD=$ANDROID_KEY_PASSWORD" >> "$GITHUB_ENV" | ||
flutter pub get | ||
flutter pub run build_runner build --delete-conflicting-outputs | ||
- shell: bash | ||
env: | ||
MQTT_USERNAME: ${{ secrets.MQTT_USERNAME }} | ||
MQTT_PASSWORD: ${{ secrets.MQTT_PASSWORD }} | ||
run: | | ||
flutter build apk --flavor dev -t integration_test/app_test.dart --no-tree-shake-icons --debug --dart-define=MQTT_USERNAME=$MQTT_USERNAME --dart-define=MQTT_PASSWORD=$MQTT_PASSWORD | ||
- name: browserstack | ||
uses: Grodien/[email protected] | ||
- name: Build Test Package | ||
run: | | ||
cd android | ||
./gradlew app:assembleAndroidTest | ||
cd .. | ||
- name: Upload and Run on Browserstack | ||
uses: Grodien/[email protected] | ||
with: | ||
browserstackUsername: "asdf" | ||
browserstackAccessKey: "asdf" | ||
browserstackUsername: ${{ secrets.BROWSERSTACK_USERNAME }} | ||
browserstackAccessKey: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} | ||
project: das_client | ||
customId: das_client_android | ||
buildTag: das_client_android | ||
appFilePath: ${{ github.workspace }}/das_client/build/app/outputs/flutter-apk/app-dev-debug.apk | ||
testFilePath: ${{ github.workspace }}/das_client/build/app/outputs/apk/androidTest/dev/debug/app-dev-debug-androidTest.apk | ||
devices: Samsung Galaxy Tab S9-13.0,Samsung Galaxy Tab S8-12.0 |
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
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
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
10 changes: 10 additions & 0 deletions
10
das_client/android/app/src/androidTest/java/ch/sbb/das/MainActivityTest.java
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,10 @@ | ||
package ch.sbb.das; | ||
import androidx.test.rule.ActivityTestRule; | ||
import dev.flutter.plugins.integration_test.FlutterTestRunner; | ||
import org.junit.Rule; | ||
import org.junit.runner.RunWith; | ||
@RunWith(FlutterTestRunner.class) | ||
public class MainActivityTest { | ||
@Rule | ||
public ActivityTestRule<MainActivity> rule = new ActivityTestRule<>(MainActivity.class, true, false); | ||
} |
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,50 @@ | ||
import 'package:das_client/flavor.dart'; | ||
import 'package:das_client/main.dart'; | ||
import 'package:design_system_flutter/design_system_flutter.dart'; | ||
import 'package:fimber/fimber.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:integration_test/integration_test.dart'; | ||
|
||
import 'di.dart'; | ||
|
||
void main() { | ||
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
Fimber.plantTree(DebugTree()); | ||
|
||
group('home screen test', () { | ||
testWidgets('load fahrbild company=1088, train=9232', (tester) async { | ||
|
||
// Load app widget. | ||
await prepareAndStartApp(tester); | ||
|
||
await tester.pump(const Duration(seconds: 1)); | ||
|
||
// Verify we have trainnumber with 9232. | ||
expect(find.text('9232'), findsOneWidget); | ||
|
||
// Verify we have company with 1088. | ||
expect(find.text('1088'), findsOneWidget); | ||
|
||
// check that the primary button is enabled | ||
var primaryButton = find.byWidgetPredicate((widget) => widget is SBBPrimaryButton).first; | ||
expect(tester.widget<SBBPrimaryButton>(primaryButton).onPressed, isNotNull); | ||
|
||
// press load Fahrordnung button | ||
await tester.tap(primaryButton); | ||
|
||
// wait for fahrbild to load | ||
await tester.pumpAndSettle(const Duration(seconds: 1)); | ||
|
||
// check if station is present | ||
expect(find.text('MEER-GRENS'), findsOneWidget); | ||
|
||
}); | ||
}); | ||
} | ||
|
||
Future<void> prepareAndStartApp(WidgetTester tester) async { | ||
await IntegrationTestDI.init(Flavor.dev); | ||
runDasApp(); | ||
await tester.pumpAndSettle(const Duration(milliseconds: 500)); | ||
} |
37 changes: 37 additions & 0 deletions
37
das_client/integration_test/auth/integrationtest_authenticator.dart
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,37 @@ | ||
import 'package:das_client/auth/authenticator.dart'; | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:sbb_oidc/sbb_oidc.dart'; | ||
|
||
class IntegrationtestAuthenticator implements Authenticator { | ||
@override | ||
Future<void> endSession() async {} | ||
|
||
@override | ||
Future<bool> get isAuthenticated async => true; | ||
|
||
@override | ||
Future<OidcToken> login({String? tokenId}) async { | ||
return _token(); | ||
} | ||
|
||
@override | ||
Future<void> logout() async {} | ||
|
||
@override | ||
Future<OidcToken> token({String? tokenId}) async { | ||
return _token(); | ||
} | ||
|
||
@override | ||
Future<String> userId({String? tokenId}) async { | ||
return "[email protected]"; | ||
} | ||
|
||
OidcToken _token() { | ||
return OidcToken( | ||
tokenType: '', | ||
accessToken: const AccessToken(''), | ||
idToken: JsonWebToken( | ||
header: const <String, dynamic>{}, payload: const <String, dynamic>{}, signature: Uint8List.fromList([]))); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
das_client/integration_test/auth/mqtt_client_user_connector.dart
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,34 @@ | ||
import 'package:das_client/service/mqtt/mqtt_client_connector.dart'; | ||
import 'package:fimber/fimber.dart'; | ||
import 'package:mqtt_client/mqtt_client.dart'; | ||
|
||
class MqttClientUserConnector implements MqttClientConnector { | ||
static const mqttUsername = "MQTT_USERNAME"; | ||
static const mqttPassword = "MQTT_PASSWORD"; | ||
|
||
@override | ||
Future<bool> connect(MqttClient client, String company, String train) async { | ||
Fimber.i("Connecting to mqtt using static login and password"); | ||
|
||
if (!const bool.hasEnvironment(mqttUsername) || !const bool.hasEnvironment(mqttPassword)) { | ||
Fimber.e("$mqttUsername or $mqttPassword not defined"); | ||
return false; | ||
} | ||
|
||
try { | ||
var mqttClientConnectionStatus = | ||
await client.connect(const String.fromEnvironment(mqttUsername), const String.fromEnvironment(mqttPassword)); | ||
Fimber.i("mqttClientConnectionStatus=$mqttClientConnectionStatus"); | ||
|
||
if (mqttClientConnectionStatus?.state == MqttConnectionState.connected) { | ||
Fimber.i("Successfully connected to MQTT broker"); | ||
return true; | ||
} | ||
} catch (e) { | ||
Fimber.e("Exception during connect", ex: e); | ||
} | ||
|
||
Fimber.w("Failed to connect to MQTT broker"); | ||
return false; | ||
} | ||
} |
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,33 @@ | ||
import 'package:das_client/auth/authenticator.dart'; | ||
import 'package:das_client/di.dart'; | ||
import 'package:das_client/flavor.dart'; | ||
import 'package:das_client/service/mqtt/mqtt_client_connector.dart'; | ||
import 'package:fimber/fimber.dart'; | ||
import 'package:get_it/get_it.dart'; | ||
|
||
import 'auth/integrationtest_authenticator.dart'; | ||
import 'auth/mqtt_client_user_connector.dart'; | ||
|
||
class IntegrationTestDI { | ||
const IntegrationTestDI._(); | ||
|
||
static Future<void> init(Flavor flavor) { | ||
Fimber.i('Initialize integration test dependency injection'); | ||
GetIt.I.registerFlavor(flavor); | ||
GetIt.I.registerTokenSpecProvider(); | ||
GetIt.I.registerOidcClient(); | ||
_registerIntegrationTestAuthenticator(); | ||
GetIt.I.registerBackendService(); | ||
_registerMqttClientConnector(); | ||
GetIt.I.registerMqttService(); | ||
return GetIt.I.allReady(); | ||
} | ||
|
||
static void _registerIntegrationTestAuthenticator() { | ||
GetIt.I.registerSingletonAsync<Authenticator>(() async => IntegrationtestAuthenticator()); | ||
} | ||
|
||
static void _registerMqttClientConnector() { | ||
GetIt.I.registerSingletonAsync<MqttClientConnector>(() async => MqttClientUserConnector()); | ||
} | ||
} |
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 @@ | ||
@import XCTest; | ||
@import integration_test; | ||
|
||
INTEGRATION_TEST_IOS_RUNNER(IntegrationTests) |
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
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
Oops, something went wrong.