diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 559dae2..e06165e 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -22,10 +22,13 @@ jobs: # You can specify other versions if desired, see documentation here: # https://github.com/dart-lang/setup-dart/blob/main/README.md # - uses: dart-lang/setup-dart@v1 - - uses: dart-lang/setup-dart@9a04e6d73cca37bd455e0608d7e5092f881fd603 + - uses: subosito/flutter-action@v1 + with: + flutter-version: '3.13.0' + channel: 'stable' - name: Install dependencies - run: dart pub get + run: flutter pub get # Uncomment this step to verify the use of 'dart format' on each commit. # - name: Verify formatting @@ -33,10 +36,10 @@ jobs: # Consider passing '--fatal-infos' for slightly stricter analysis. - name: Analyze project source - run: dart analyze + run: flutter analyze --no-fatal-warnings # Your project will need to have tests in test/ and a dependency on # package:test for this step to succeed. Note that Flutter projects will # want to change this to 'flutter test'. - name: Run tests -# run: dart test + run: flutter test diff --git a/.vscode/settings.json b/.vscode/settings.json index ddca875..bd42e73 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -28,6 +28,7 @@ "Schyler", "shuttlemap", "sportscourt", + "Testeable", "Timesheet" ], "java.configuration.updateBuildConfiguration": "interactive", diff --git a/lib/main.dart b/lib/main.dart index 849de49..83a4427 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -129,7 +129,7 @@ class MyApp extends StatelessWidget { }, builder: FlutterI18n.rootAppBuilder(), home: counter == 0 - ? const OnboardingPage(title: "Welcome to GoKnights") + ? const OnboardingPage() : const CupertinoTabBarDemo(), )); } diff --git a/lib/onboarding.dart b/lib/onboarding.dart index 1eac646..59e4b7d 100644 --- a/lib/onboarding.dart +++ b/lib/onboarding.dart @@ -6,9 +6,7 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:back_button_interceptor/back_button_interceptor.dart'; class OnboardingPage extends StatefulWidget { - const OnboardingPage({super.key, required this.title}); - - final String title; + const OnboardingPage({super.key}); @override State createState() => _OnboardingPageState(); diff --git a/lib/options.dart b/lib/options.dart index dd9b60d..a5e3a6c 100644 --- a/lib/options.dart +++ b/lib/options.dart @@ -338,9 +338,8 @@ class _MyOptionsPageState extends State { // need to pop the current page (with nav) to go back to onboarding Navigator.of(context, rootNavigator: true).push( CupertinoPageRoute( - builder: (context) => OnboardingPage( - title: FlutterI18n.translate( - context, "onboarding.title")))), + builder: (context) => + const OnboardingPage())), }, ), CupertinoListTile.notched( diff --git a/test/widget_test.dart b/test/widget_test.dart index 009fe69..014b751 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -5,26 +5,70 @@ // 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/cupertino.dart'; +import 'package:flutter_i18n/flutter_i18n.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:goknights/main.dart'; +import 'package:goknights/onboarding.dart'; void main() { - testWidgets('Counter increments smoke test', (WidgetTester tester) async { - // Build our app and trigger a frame. - await tester.pumpWidget(const MyApp()); + group('UI TESTS', () { + Widget makeTesteableWidget({required Widget child}) { + return CupertinoApp( + title: 'GoKnights', + debugShowCheckedModeBanner: false, + localizationsDelegates: [ + FlutterI18nDelegate( + translationLoader: FileTranslationLoader( + useCountryCode: false, + fallbackFile: 'en', + basePath: 'assets/flutter_i18n'), + missingTranslationHandler: (key, locale) { + print( + "--- Missing Key: $key, languageCode: ${locale?.languageCode}"); + }, + ), + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, + ], + supportedLocales: const [ + Locale('en', 'US'), // English + Locale('es'), // Spanish + Locale('zh'), // Chinese + Locale('he'), // Hebrew + // Locale('it'), // Italian + // Locale('ru'), // Russian + ], + localeListResolutionCallback: (allLocales, supportedLocales) { + final locale = allLocales?.first.languageCode; + if (locale == 'en') { + return const Locale('en', 'US'); + } + if (locale == 'es') { + return const Locale('es', 'ES'); + } + if (locale == 'zh') { + return const Locale('zh', 'CN'); + } + if (locale == 'he') { + return const Locale('he', 'IL'); + } + // The default locale + return const Locale('en', 'US'); + }, + builder: FlutterI18n.rootAppBuilder(), + home: child); + } - // Verify that our counter starts at 0. - expect(find.text('0'), findsOneWidget); - expect(find.text('1'), findsNothing); + testWidgets('Onboarding page', (WidgetTester tester) async { + // Create the widget by telling the tester to build it. + final widget = makeTesteableWidget( + child: const OnboardingPage(), + ); - // 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); + await tester.pumpWidget(widget); + }); }); }