From 2e42813a3dd058a1430269d8f50af6304e83c2c3 Mon Sep 17 00:00:00 2001 From: seilylook Date: Mon, 25 Mar 2024 11:57:12 +0900 Subject: [PATCH] config: CIpipeline with Patrol & Gcloud & Firebase Test lab --- .github/workflows/android-release.yml | 128 ++++++++++++++++++++ .github/workflows/ios-release.yml | 141 +++++++++++++++++++++++ .github/workflows/send_slack_message.yml | 0 integration_test/app_test.dart | 28 +++++ integration_test/example_test.dart | 30 ----- integration_test/test_bundle.dart | 4 +- ios/Runner.xcodeproj/project.pbxproj | 24 +++- pubspec.lock | 2 +- pubspec.yaml | 1 + test/widget_test.dart | 42 ++++--- 10 files changed, 346 insertions(+), 54 deletions(-) create mode 100644 .github/workflows/android-release.yml create mode 100644 .github/workflows/ios-release.yml create mode 100644 .github/workflows/send_slack_message.yml delete mode 100644 integration_test/example_test.dart diff --git a/.github/workflows/android-release.yml b/.github/workflows/android-release.yml new file mode 100644 index 0000000..6baf0c2 --- /dev/null +++ b/.github/workflows/android-release.yml @@ -0,0 +1,128 @@ +name: Run Flutter E2E (android) test +on: + push: + branches: + - develop + pull_request: + branches: + - develop + +jobs: + e2e: + runs-on: ubuntu-latest + outputs: + SLACK_MESSAGE_TITLE: Flutter E2E Test on ${{ matrix.os }} ${{ matrix.os_version }} + TESTS_EXIT_CODE: ${{ steps.tests_step.outputs.TESTS_EXIT_CODE }} + URL_TO_DETAILS: ${{ steps.tests_step.outputs.URL_TO_DETAILS }} + + strategy: # 테스트를 하고자 하는 디바이스 설정 + matrix: + os: ["Android API"] + include: + - device_model: "oriole" + os_version: "33" + + steps: + # 1. 코드 체크아웃 + - name: Github Checkout + uses: actions/checkout@v3 + + # 2.1 Flutter 설치 + - uses: subosito/flutter-action@v2 + with: + channel: "stable" + + # 2.2. 의존성 설치 + - name: Install dependencies + run: flutter pub get + + # 2.3. Gradle wrapper 생성 + - name: Generate Gradle wrapper + run: flutter build apk --config-only + + # 3.1. Patrol CLI 설치 + - name: Set up Patrol CLI + run: dart pub global activate patrol_cli + + # 3.2. Patrol 빌드 + - name: patrol build android + run: patrol build android + + # 4.1. service-account.json 인증 + - name: Authenticate to Google Cloud + uses: google-github-actions/auth@v1 + with: + credentials_json: "${{secrets.GCP_STAGE_SERVICE_ACCOUNT_JSON}}" + + # 4.2. gcloud 설정 + - name: Set up Cloud SDK + uses: google-github-actions/setup-gcloud@v1 + + # 4.3 ENV 설정 + - name: Create .env File + uses: iamsauravsharma/create-dotenv@v1.2.2 + with: + env-prefix: "envkey_" + file-name: ".env" + directory: "/home/runner/work/tunefun_front/assets/config/" + env: + IS_SERVER: true + PUBLIC_BASE_URL: ${{secrets.PUBLIC_BASE_URL}} + PUBLIC_USER_REGISTER_URL: ${{secrets.PUBLIC_USER_REGISTER_URL}} + PUBLIC_USER_LOGIN_URL: ${{secrets.PUBLIC_USER_LOGIN_URL}} + PUBLIC_USER_LOGOUT_URL: ${{secrets.PUBLIC_USER_LOGOUT_URL}} + PUBLIC_USER_FIND_USERNAME: ${{secrets.PUBLIC_USER_FIND_USERNAME}} + PUBLIC_USER_ACCESS_TOKEN: ${{secrets.PUBLIC_USER_ACCESS_TOKEN}} + PUBLIC_USER_SET_NEW_PASSWORD: ${{secrets.PUBLIC_USER_SET_NEW_PASSWORD}} + PUBLIC_USER_UPDATE_NICKNAME: ${{secrets.PUBLIC_USER_UPDATE_NICKNAME}} + PUBLIC_USER_FORGOT_PASSWORD_SEND_OTP: ${{secrets.PUBLIC_USER_FORGOT_PASSWORD_SEND_OTP}} + PUBLIC_USER_OTP_RESEND: ${{secrets.PUBLIC_USER_OTP_RESEND}} + PUBLIC_USER_OTP_VERIFY: ${{secrets.PUBLIC_USER_OTP_VERIFY}} + PUBLIC_USER_CHECK_EMAIL_DUPLICATE: ${{secrets.PUBLIC_USER_CHECK_EMAIL_DUPLICATE}} + PUBLIC_USER_CHECK_EMAIL_VERIFIED: ${{secrets.PUBLIC_USER_CHECK_EMAIL_VERIFIED}} + PUBLIC_USER_CHECK_USERNAME_DUPLICATE: ${{secrets.PUBLIC_USER_CHECK_USERNAME_DUPLICATE}} + + # 5. Firebase Test Lab 에 APK 업로드 및 테스트 실행 + - name: Upload APKs to Firebase Test Lab and wait for tests to finish + id: tests_step + env: + ANDROID_DEVICE_MODEL: ${{ matrix.device_model }} + ANDROID_DEVICE_VERSION: ${{ matrix.os_version }} + run: | + set +e + set -euo pipefail + + # Firebase Test Lab 실행 및 결과 저장 + output=$(set -euo pipefail && \ + gcloud firebase test android run \ + --type instrumentation \ + --app build/app/outputs/apk/debug/app-debug.apk \ + --test build/app/outputs/apk/androidTest/debug/ap-debug-androidTest.apk \ + --device model="$ANDROID_DEVICE_MODEL",version="$ANDROID_DEVICE_VERSION",locale=en,orientation=portrait \ + --timeout 10m \ + --results-bucket="tunefun-6edf5.appspot.com" \ + --use-orchestrator \ + --environment-variables clearPackageData=true 2>&1) + + TESTS_EXIT_CODE=$? + set -e + + # Extract the last link using grep, tail, and sed, and write it to Github Summary + link="$(echo "$output" | grep -o 'https://[^ ]*' | tail -1 | sed 's/\[//;s/\]//')" + echo "[Test details on Firebase Test Lab]($link) (Firebase members only)" >> "$GITHUB_STEP_SUMMARY" + + echo "URL_TO_DETAILS=$link" >> "$GITHUB_OUTPUT" + echo "TESTS_EXIT_CODE=$TESTS_EXIT_CODE" >> "$GITHUB_OUTPUT" + exit $TESTS_EXIT_CODE + + # 6. Slack 메시지 전송 + # call_send_slack_message: + # name: Notify on Slack + # uses: ./.github/workflows/send_slack_message.yml + # needs: e2e + # if: always() + # with: + # TESTS_EXIT_CODE: ${{ needs.e2e.outputs.TESTS_EXIT_CODE }} + # SLACK_MESSAGE_TITLE: ${{ needs.e2e.outputs.SLACK_MESSAGE_TITLE }} + # URL_TO_DETAILS: ${{ needs.e2e.outputs.URL_TO_DETAILS }} + # secrets: inherit diff --git a/.github/workflows/ios-release.yml b/.github/workflows/ios-release.yml new file mode 100644 index 0000000..cc7d1c2 --- /dev/null +++ b/.github/workflows/ios-release.yml @@ -0,0 +1,141 @@ +name: Run Flutter E2E (ios) test +on: + push: + branches: + - develop + pull_request: + branches: + - develop +jobs: + e2e: + runs-on: macos-latest + outputs: + SLACK_MESSAGE_TITLE: Flutter E2E Test on ${{ matrix.os }} ${{ matrix.os_version }} + TESTS_EXIT_CODE: ${{ steps.tests_step.outputs.TESTS_EXIT_CODE }} + URL_TO_DETAILS: ${{ steps.tests_step.outputs.URL_TO_DETAILS }} + strategy: + # 테스트를 하고자 하는 디바이스 설정 + matrix: + device_model: ["iphone15pro"] + os_version: ["17.2"] + os: [iOS] + steps: + # 1. 코드 체크아웃 + - uses: actions/checkout@v3 + + # 2.1 Flutter 설치 + - uses: subosito/flutter-action@v2 + with: + channel: "stable" + + # 2.2. 의존성 설치 + - name: Install dependencies + run: flutter pub get + + # 3.1 Ruby 설치 (Fastlane 사용을 위해) + - name: Install Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.7.2 + bundler-cache: true + + # 3.2 bundle 설치 (Fastlane 사용을 위해) + - name: Install bundle + run: | + cd ios + bundle config path vendor/bundle + bundle install --jobs 4 --retry 3 + + # 4. Fastlane 사용하여 Certificate, Provisioning Profile 설치 + # 5. Fastlane 사용하여 Xcode Code Signing 변경 + - name: Sign iOS app + uses: maierj/fastlane-action@v3.0.0 + with: + lane: code_sign_developemnt + subdirectory: ios + + # 6.1 Patrol CLI 설치 + - name: Set up Patrol CLI + run: dart pub global activate patrol_cli + + # 6.2 Patrol 빌드 + - name: patrol build ios + run: patrol build ios + + # 7.1 service-account.json 인증 + - name: Authenticate to Google Cloud + uses: google-github-actions/auth@v1 + with: + credentials_json: "${{secrets.GCP_STAGE_SERVICE_ACCOUNT_JSON}}" + + # 7.2 gcloud 설정 + - name: Set up Cloud SDK + uses: google-github-actions/setup-gcloud@v1 + + # 7.3 ENV 설정 + - name: Create .env File + uses: iamsauravsharma/create-dotenv@v1.2.2 + with: + env-prefix: "envkey_" + file-name: ".env" + directory: "/home/runner/work/tunefun_front/assets/config/" + env: + IS_SERVER: true + PUBLIC_BASE_URL: ${{secrets.PUBLIC_BASE_URL}} + PUBLIC_USER_REGISTER_URL: ${{secrets.PUBLIC_USER_REGISTER_URL}} + PUBLIC_USER_LOGIN_URL: ${{secrets.PUBLIC_USER_LOGIN_URL}} + PUBLIC_USER_LOGOUT_URL: ${{secrets.PUBLIC_USER_LOGOUT_URL}} + PUBLIC_USER_FIND_USERNAME: ${{secrets.PUBLIC_USER_FIND_USERNAME}} + PUBLIC_USER_ACCESS_TOKEN: ${{secrets.PUBLIC_USER_ACCESS_TOKEN}} + PUBLIC_USER_SET_NEW_PASSWORD: ${{secrets.PUBLIC_USER_SET_NEW_PASSWORD}} + PUBLIC_USER_UPDATE_NICKNAME: ${{secrets.PUBLIC_USER_UPDATE_NICKNAME}} + PUBLIC_USER_FORGOT_PASSWORD_SEND_OTP: ${{secrets.PUBLIC_USER_FORGOT_PASSWORD_SEND_OTP}} + PUBLIC_USER_OTP_RESEND: ${{secrets.PUBLIC_USER_OTP_RESEND}} + PUBLIC_USER_OTP_VERIFY: ${{secrets.PUBLIC_USER_OTP_VERIFY}} + PUBLIC_USER_CHECK_EMAIL_DUPLICATE: ${{secrets.PUBLIC_USER_CHECK_EMAIL_DUPLICATE}} + PUBLIC_USER_CHECK_EMAIL_VERIFIED: ${{secrets.PUBLIC_USER_CHECK_EMAIL_VERIFIED}} + PUBLIC_USER_CHECK_USERNAME_DUPLICATE: ${{secrets.PUBLIC_USER_CHECK_USERNAME_DUPLICATE}} + + # 8. Firebase Test Lab 에 APK 업로드 및 테스트 실행 + - name: Upload iOS App to Firebase Test Lab and wait for tests to finish + id: tests_step + env: + IOS_DEVICE_MODEL: ${{ matrix.device_model }} + IOS_DEVICE_VERSION: ${{ matrix.os_version }} + run: | + set +e + + # iOS 테스트 준비 및 Firebase Test Lab 실행 + output=$(cd build/ios_integ/Build/Products && \ + rm -f ios_tests.zip && \ + zip -r ios_tests.zip Release-iphoneos/*.app *.xctestrun && \ + cd - && \ + gcloud firebase test ios run \ + --type xctest \ + --test "build/ios_integ/Build/Products/ios_tests.zip" \ + --device model="$IOS_DEVICE_MODEL",version="$IOS_DEVICE_VERSION",locale=en_US,orientation=portrait \ + --timeout 10m \ + --results-bucket="tunefun-6edf5.appspot.com" 2>&1) + + TESTS_EXIT_CODE=$? + set -e + + # 출력 및 링크 추출 + echo "$output" + link="$(echo "$output" | grep -o 'https://[^ ]*' | tail -1 | sed 's/\[//;s/\]//')" + echo "[Test details on Firebase Test Lab]($link) (Firebase members only)" >> "$GITHUB_STEP_SUMMARY" + echo "URL_TO_DETAILS=$link" >> "$GITHUB_OUTPUT" + echo "TESTS_EXIT_CODE=$TESTS_EXIT_CODE" >> "$GITHUB_OUTPUT" + exit $TESTS_EXIT_CODE + + # 9. Slack 메시지 전송 + # call_send_slack_message: + # name: Notify on Slack + # uses: ./.github/workflows/send_slack_message.yml + # needs: e2e + # if: always() + # with: + # TESTS_EXIT_CODE: ${{ needs.e2e.outputs.TESTS_EXIT_CODE }} + # SLACK_MESSAGE_TITLE: ${{ needs.e2e.outputs.SLACK_MESSAGE_TITLE }} + # URL_TO_DETAILS: ${{ needs.e2e.outputs.URL_TO_DETAILS }} + # secrets: inherit diff --git a/.github/workflows/send_slack_message.yml b/.github/workflows/send_slack_message.yml new file mode 100644 index 0000000..e69de29 diff --git a/integration_test/app_test.dart b/integration_test/app_test.dart index 8b13789..ca8d1d8 100644 --- a/integration_test/app_test.dart +++ b/integration_test/app_test.dart @@ -1 +1,29 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:patrol/patrol.dart'; +import 'package:tunefun_front/constants/dummy_data.dart'; +import 'package:tunefun_front/features/article/widgets/article_card.dart'; +import 'package:tunefun_front/features/article/widgets/article_list.dart'; +import 'package:tunefun_front/features/home/views/home_view.dart'; +import 'package:tunefun_front/main.dart'; +import 'package:patrol_finders/patrol_finders.dart'; +void main() { + testWidgets( + 'Main Screen test', + (WidgetTester tester) async { + PatrolTester $ = PatrolTester( + tester: tester, + config: const PatrolTesterConfig(), + ); + await $.pumpWidget( + const ProviderScope( + child: MyApp(), + ), + ); + expect($('TuneFun'), findsWidgets); + expect($(const HomeScreen()), findsOneWidget); + expect($(const ArticleList()), findsWidgets); + }, + ); +} diff --git a/integration_test/example_test.dart b/integration_test/example_test.dart deleted file mode 100644 index 2cc69fb..0000000 --- a/integration_test/example_test.dart +++ /dev/null @@ -1,30 +0,0 @@ -import 'dart:io'; - -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:integration_test/integration_test.dart'; -import 'package:patrol/patrol.dart'; - -void main() { - patrolTest( - 'counter state is the same after going to home and switching apps', - ($) async { - IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - - // Replace later with your app's main widget - await $.pumpWidgetAndSettle( - MaterialApp( - home: Scaffold( - appBar: AppBar(title: const Text('app')), - backgroundColor: Colors.blue, - ), - ), - ); - - expect($('app'), findsOneWidget); - if (!Platform.isMacOS) { - await $.native.pressHome(); - } - }, - ); -} diff --git a/integration_test/test_bundle.dart b/integration_test/test_bundle.dart index a6ae301..e2268b7 100644 --- a/integration_test/test_bundle.dart +++ b/integration_test/test_bundle.dart @@ -9,7 +9,7 @@ import 'package:patrol/src/native/contracts/contracts.dart'; import 'package:test_api/src/backend/invoker.dart'; // START: GENERATED TEST IMPORTS -import 'example_test.dart' as example_test; +import 'app_test.dart' as app_test; // END: GENERATED TEST IMPORTS Future main() async { @@ -66,7 +66,7 @@ Future main() async { }); // START: GENERATED TEST GROUPS - group('example_test', example_test.main); + group('app_test', app_test.main); // END: GENERATED TEST GROUPS final dartTestGroup = await testExplorationCompleter.future; diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index e36295f..af8ff41 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -633,8 +633,10 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 7Z5U7CM33F; + DEVELOPMENT_TEAM = ""; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; @@ -644,6 +646,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = com.example.tunefunFront; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; @@ -718,8 +721,10 @@ CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = ""; ENABLE_USER_SCRIPT_SANDBOXING = NO; GCC_C_LANGUAGE_STANDARD = gnu17; GENERATE_INFOPLIST_FILE = YES; @@ -730,6 +735,7 @@ MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.example.tunefunFront.RunnerUITests; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_EMIT_LOC_STRINGS = NO; TARGETED_DEVICE_FAMILY = "1,2"; TEST_TARGET_NAME = Runner; @@ -748,8 +754,10 @@ CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = ""; ENABLE_USER_SCRIPT_SANDBOXING = NO; GCC_C_LANGUAGE_STANDARD = gnu17; GENERATE_INFOPLIST_FILE = YES; @@ -759,6 +767,7 @@ MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.example.tunefunFront.RunnerUITests; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_EMIT_LOC_STRINGS = NO; TARGETED_DEVICE_FAMILY = "1,2"; TEST_TARGET_NAME = Runner; @@ -777,8 +786,10 @@ CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = ""; ENABLE_USER_SCRIPT_SANDBOXING = NO; GCC_C_LANGUAGE_STANDARD = gnu17; GENERATE_INFOPLIST_FILE = YES; @@ -788,6 +799,7 @@ MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.example.tunefunFront.RunnerUITests; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_EMIT_LOC_STRINGS = NO; TARGETED_DEVICE_FAMILY = "1,2"; TEST_TARGET_NAME = Runner; @@ -907,8 +919,10 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 7Z5U7CM33F; + DEVELOPMENT_TEAM = ""; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; @@ -918,6 +932,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = com.example.tunefunFront; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; @@ -931,8 +946,10 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 7Z5U7CM33F; + DEVELOPMENT_TEAM = ""; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; @@ -942,6 +959,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = com.example.tunefunFront; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; diff --git a/pubspec.lock b/pubspec.lock index e93a2d2..f39f066 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -608,7 +608,7 @@ packages: source: hosted version: "3.5.2" patrol_finders: - dependency: transitive + dependency: "direct dev" description: name: patrol_finders sha256: ac33527cc1b63e3aa131dbd7107cfda8ee2df0fb4a4a423c067174a2e60db77b diff --git a/pubspec.yaml b/pubspec.yaml index 1459934..c68c2ac 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -63,6 +63,7 @@ dev_dependencies: # package. See that file for information about deactivating specific lint # rules and activating additional ones. flutter_lints: ^2.0.0 + patrol_finders: ^2.0.2 patrol: app_name: tunefun_front diff --git a/test/widget_test.dart b/test/widget_test.dart index 2265e55..f8df25a 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -5,26 +5,32 @@ // 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_riverpod/flutter_riverpod.dart'; import 'package:flutter_test/flutter_test.dart'; - +import 'package:tunefun_front/constants/dummy_data.dart'; +import 'package:tunefun_front/features/article/widgets/article_card.dart'; +import 'package:tunefun_front/features/article/widgets/article_list.dart'; +import 'package:tunefun_front/features/home/views/home_view.dart'; import 'package:tunefun_front/main.dart'; +import 'package:patrol_finders/patrol_finders.dart'; void main() { - testWidgets('Counter increments smoke test', (WidgetTester tester) async { - // Build our app and trigger a frame. - await tester.pumpWidget(const MyApp()); - - // Verify that our counter starts at 0. - expect(find.text('0'), findsOneWidget); - expect(find.text('1'), findsNothing); - - // Tap the '+' icon and trigger a frame. - await tester.tap(find.byIcon(Icons.add)); - await tester.pump(); - - // Verify that our counter has incremented. - expect(find.text('0'), findsNothing); - expect(find.text('1'), findsOneWidget); - }); + testWidgets( + 'Main Screen test', + (WidgetTester tester) async { + PatrolTester $ = PatrolTester( + tester: tester, + config: const PatrolTesterConfig(), + ); + await $.pumpWidget( + const ProviderScope( + child: MyApp(), + ), + ); + expect($('TuneFun'), findsWidgets); + expect($(const HomeScreen()), findsOneWidget); + expect($(const ArticleList()), findsWidgets); + final articles = DummyData.articles; + }, + ); }