diff --git a/.github/workflows/update_goldens.yml b/.github/workflows/update_goldens.yml new file mode 100644 index 000000000..2ffcc2eec --- /dev/null +++ b/.github/workflows/update_goldens.yml @@ -0,0 +1,46 @@ +name: update_goldens + +on: workflow_dispatch + +jobs: + update_goldens: + runs-on: ubuntu-latest + steps: + - name: 🚫 Ensure branch is not master + if: ${{ github.event.inputs.branch == 'master' || github.event.inputs.branch == 'origin/master'}} + run: | + echo "Updating goldens on 'master' branch is prohibited." + exit 1 + + - name: 📚 Checkout branch + uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.branch }} + + - name: 🐦 Install Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: "3.x" + channel: stable + cache: true + cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }} + + - name: 📦 Install Tools + run: flutter pub global activate melos + + - name: 🔧 Bootstrap Workspace + run: melos bootstrap --verbose + + - name: 🖼️ Update Goldens + working-directory: packages/stream_chat_flutter + continue-on-error: true + run: | + flutter test --tags golden --update-goldens + + - name: 📤 Commit Changes + id: commit_changes + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "chore: Update Goldens" + commit_user_name: github-actions[bot] + commit_user_email: 41898282+github-actions[bot]@users.noreply.github.com \ No newline at end of file diff --git a/.gitignore b/.gitignore index b0f5d50ec..5054df6c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,58 +1,118 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp .DS_Store .atom/ +.buildlog/ +.history +.svn/ +.project +.classpath +.settings + +# IntelliJ related +*.iml +*.ipr +*.iws .idea/ + +# VS Code related .vscode/ -**/lcov.info -coverage + +# Flutter/Dart/Pub related +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies .packages +.pub-cache/ .pub/ -.dart_tool/ +build/ +coverage/ +coverage_helper_test.dart +**/doc/api/ pubspec.lock pubspec_overrides.yaml flutter_export_environment.sh +generated_plugin_registrant.* +GeneratedPluginRegistrant.* -examples/all_plugins/pubspec.yaml +# Android related +**/android/**/gradle-wrapper.jar +**/android/.gradle +**/android/captures/ +**/android/gradlew +**/android/gradlew.bat +**/android/local.properties +**/android/**/GeneratedPluginRegistrant.java -Podfile +# iOS/XCode related +**/ios/**/*.mode1v3 +**/ios/**/*.mode2v3 +**/ios/**/*.moved-aside +**/ios/**/*.pbxuser +**/ios/**/*.perspectivev3 +**/ios/**/*sync/ +**/ios/**/.sconsign.dblite +**/ios/**/.tags* +**/ios/**/.vagrant/ +**/ios/**/DerivedData/ +**/ios/**/Icon? +**/ios/**/Pods/ +**/ios/**/.symlinks/ +**/ios/**/profile +**/ios/**/xcuserdata +**/ios/.generated/ +**/ios/Flutter/App.framework +**/ios/Flutter/Flutter.framework +**/ios/Flutter/Flutter.podspec +**/ios/Flutter/Generated.xcconfig +**/ios/Flutter/app.flx +**/ios/Flutter/app.zip +**/ios/Flutter/flutter_assets/ +**/ios/Flutter/flutter_export_environment.sh +**/ios/ServiceDefinitions.json +**/ios/Runner/GeneratedPluginRegistrant.* Podfile.lock -Pods/ -.symlinks/ -**/Flutter/App.framework/ -**/Flutter/ephemeral/ -**/Flutter/Flutter.framework/ -**/Flutter/Generated.xcconfig -**/Flutter/flutter_assets/ - -ServiceDefinitions.json -xcuserdata/ -**/DerivedData/ - -local.properties -keystore.properties + +# Exceptions to iOS rules +!**/ios/**/default.mode1v3 +!**/ios/**/default.mode2v3 +!**/ios/**/default.pbxuser +!**/ios/**/default.perspectivev3 + +# Generated files +*.dart.js +*.info.json +*.js +*.js_ +*.js.deps +*.js.map +**/lcov.info + +# Other ignored files +google-services.json +.melos_tool/ +.packages/flutter_widgets/example/ios/Flutter/.last_build_id +.packages/dart_client/example/ios/Flutter/.last_build_id +.packages/dart_client/example/ios/Runner.xcodeproj/project.pbxproj + +# Ignore FVM +**/.fvm + +# Gradle related .gradle/ gradlew gradlew.bat gradle-wrapper.jar -.flutter-plugins-dependencies -*.iml - -generated_plugin_registrant.dart -GeneratedPluginRegistrant.h -GeneratedPluginRegistrant.m -GeneratedPluginRegistrant.java -GeneratedPluginRegistrant.swift -build/ -.flutter-plugins - -.project -.classpath -.settings -**/.fvm -.melos_tool/ -/packages/flutter_widgets/example/ios/Flutter/.last_build_id -/packages/dart_client/example/ios/Flutter/.last_build_id -/packages/dart_client/example/ios/Runner.xcodeproj/project.pbxproj +# Non-CI golden files and failures +**/test/**/goldens/**/*.* +**/test/**/failures/**/*.* +!**/test/**/goldens/ci/*.* # Exceptions to the above rules !/pubspec.lock +!**/example/web/sql-wasm.js +!**/example/web/sql-wasm.wasm \ No newline at end of file diff --git a/melos.yaml b/melos.yaml index a3854f670..237ab3902 100644 --- a/melos.yaml +++ b/melos.yaml @@ -6,6 +6,10 @@ packages: command: bootstrap: + # It seems so that running "pub get" in parallel has some issues (like + # https://github.com/dart-lang/pub/issues/3404). Disabling this feature + # makes the CI much more stable. + runPubGetInParallel: false # Dart and Flutter environment used in the project. environment: sdk: ^3.5.4 @@ -72,12 +76,12 @@ command: # List of all the dev_dependencies used in the project. dev_dependencies: + alchemist: ^0.11.0 build_runner: ^2.4.9 drift_dev: ^2.22.1 fake_async: ^1.3.1 faker_dart: ^0.2.1 freezed: ^2.4.2 - golden_toolkit: ^0.15.0 json_serializable: ^6.7.1 mocktail: ^1.0.0 path: ^1.8.3 diff --git a/packages/stream_chat_flutter/.gitignore b/packages/stream_chat_flutter/.gitignore deleted file mode 100644 index 69e234515..000000000 --- a/packages/stream_chat_flutter/.gitignore +++ /dev/null @@ -1,68 +0,0 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# The .vscode folder contains launch configuration and tasks you configure in -# VS Code which you may wish to be included in version control, so this line -# is commented out by default. -#.vscode/ - -# Flutter/Dart/Pub related -**/doc/api/ -.dart_tool/ -.flutter-plugins -.flutter-plugins-dependencies -.packages -.pub-cache/ -.pub/ -/build/ -coverage/ -coverage_helper_test.dart - -# Web related -lib/generated_plugin_registrant.dart - -# Exceptions to above rules. -!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages -# See https://www.dartlang.org/guides/libraries/private-files - -# Files and directories created by pub -.dart_tool/ -.packages -build/ -# If you're building an application, you may want to check-in your pubspec.lock -pubspec.lock - -# Directory created by dartdoc -# If you don't generate documentation locally you can remove this line. -doc/api/ - -# Avoid committing generated JavaScript files: -*.dart.js -*.info.json # Produced by the --dump-info flag. -*.js # When generated by dart2js. Don't specify *.js if your - # project includes source files written in JavaScript. -*.js_ -*.js.deps -*.js.map - -fvm -google-services.json -example/ios/dist -.vscode/ - -# don't check in golden failure output -**/failures/*.png \ No newline at end of file diff --git a/packages/stream_chat_flutter/example/ios/Podfile b/packages/stream_chat_flutter/example/ios/Podfile new file mode 100644 index 000000000..b2e48e4a1 --- /dev/null +++ b/packages/stream_chat_flutter/example/ios/Podfile @@ -0,0 +1,44 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '12.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) +# target 'RunnerTests' do +# inherit! :search_paths +# end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/packages/stream_chat_flutter/example/lib/main.dart b/packages/stream_chat_flutter/example/lib/main.dart index 332d813bf..dd3231302 100644 --- a/packages/stream_chat_flutter/example/lib/main.dart +++ b/packages/stream_chat_flutter/example/lib/main.dart @@ -31,15 +31,8 @@ Future main() async { '''eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoic3VwZXItYmFuZC05In0.0L6lGoeLwkz0aZRUcpZKsvaXtNEDHBcezVTZ0oPq40A''', ); - final channel = client.channel('messaging', id: 'godevs'); - - await channel.watch(); - runApp( - MyApp( - client: client, - channel: channel, - ), + MyApp(client: client), ); } @@ -57,7 +50,6 @@ class MyApp extends StatelessWidget { const MyApp({ super.key, required this.client, - required this.channel, }); /// Instance of Stream Client. @@ -67,9 +59,6 @@ class MyApp extends StatelessWidget { /// trigger a websocket connection allowing for real-time updates. final StreamChatClient client; - /// Instance of the Channel - final Channel channel; - @override Widget build(BuildContext context) { return MaterialApp( @@ -89,10 +78,7 @@ class MyApp extends StatelessWidget { client: client, child: widget, ), - home: StreamChannel( - channel: channel, - child: const ResponsiveChat(), - ), + home: const ResponsiveChat(), ); } } @@ -106,38 +92,26 @@ class ResponsiveChat extends StatelessWidget { Widget build(BuildContext context) { return ResponsiveBuilder( builder: (context, sizingInformation) { - if (sizingInformation.isMobile) { - return ChannelListPage( - onTap: (c) { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) { - return StreamChannel( - channel: c, - child: ChannelPage( - onBackPressed: (context) { - Navigator.of( - context, - rootNavigator: true, - ).pop(); - }, - ), - ); - }, - ), - ); - }, - ); + if (sizingInformation.isDesktop || sizingInformation.isTablet) { + return const SplitView(); } - return const SplitView(); + return ChannelListPage( + onTap: (c) => Navigator.push( + context, + MaterialPageRoute( + builder: (context) => StreamChannel( + channel: c, + child: ChannelPage( + onBackPressed: (context) { + Navigator.of(context, rootNavigator: true).pop(); + }, + ), + ), + ), + ), + ); }, - breakpoints: const ScreenBreakpoints( - desktop: 550, - tablet: 550, - watch: 300, - ), ); } } @@ -279,11 +253,7 @@ class _ChannelPageState extends State { children: [ Expanded( child: StreamMessageListView( - threadBuilder: (context, parent) { - return ThreadPage( - parent: parent!, - ); - }, + threadBuilder: (_, parent) => ThreadPage(parent: parent!), messageBuilder: ( context, messageDetails, diff --git a/packages/stream_chat_flutter/example/linux/flutter/generated_plugin_registrant.cc b/packages/stream_chat_flutter/example/linux/flutter/generated_plugin_registrant.cc deleted file mode 100644 index f1848ef1f..000000000 --- a/packages/stream_chat_flutter/example/linux/flutter/generated_plugin_registrant.cc +++ /dev/null @@ -1,31 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#include "generated_plugin_registrant.h" - -#include -#include -#include -#include -#include - -void fl_register_plugins(FlPluginRegistry* registry) { - g_autoptr(FlPluginRegistrar) desktop_drop_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "DesktopDropPlugin"); - desktop_drop_plugin_register_with_registrar(desktop_drop_registrar); - g_autoptr(FlPluginRegistrar) file_selector_linux_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin"); - file_selector_plugin_register_with_registrar(file_selector_linux_registrar); - g_autoptr(FlPluginRegistrar) media_kit_video_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "MediaKitVideoPlugin"); - media_kit_video_plugin_register_with_registrar(media_kit_video_registrar); - g_autoptr(FlPluginRegistrar) sqlite3_flutter_libs_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "Sqlite3FlutterLibsPlugin"); - sqlite3_flutter_libs_plugin_register_with_registrar(sqlite3_flutter_libs_registrar); - g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); - url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); -} diff --git a/packages/stream_chat_flutter/example/linux/flutter/generated_plugin_registrant.h b/packages/stream_chat_flutter/example/linux/flutter/generated_plugin_registrant.h deleted file mode 100644 index e0f0a47bc..000000000 --- a/packages/stream_chat_flutter/example/linux/flutter/generated_plugin_registrant.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#ifndef GENERATED_PLUGIN_REGISTRANT_ -#define GENERATED_PLUGIN_REGISTRANT_ - -#include - -// Registers Flutter plugins. -void fl_register_plugins(FlPluginRegistry* registry); - -#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/packages/stream_chat_flutter/example/macos/Podfile b/packages/stream_chat_flutter/example/macos/Podfile new file mode 100644 index 000000000..1a7cd13c7 --- /dev/null +++ b/packages/stream_chat_flutter/example/macos/Podfile @@ -0,0 +1,43 @@ +platform :osx, '10.15' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) +# target 'RunnerTests' do +# inherit! :search_paths +# end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/packages/stream_chat_flutter/example/windows/flutter/generated_plugin_registrant.cc b/packages/stream_chat_flutter/example/windows/flutter/generated_plugin_registrant.cc deleted file mode 100644 index 314bf4231..000000000 --- a/packages/stream_chat_flutter/example/windows/flutter/generated_plugin_registrant.cc +++ /dev/null @@ -1,38 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#include "generated_plugin_registrant.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -void RegisterPlugins(flutter::PluginRegistry* registry) { - ConnectivityPlusWindowsPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin")); - DesktopDropPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("DesktopDropPlugin")); - FileSelectorWindowsRegisterWithRegistrar( - registry->GetRegistrarForPlugin("FileSelectorWindows")); - MediaKitVideoPluginCApiRegisterWithRegistrar( - registry->GetRegistrarForPlugin("MediaKitVideoPluginCApi")); - ScreenBrightnessWindowsPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("ScreenBrightnessWindowsPlugin")); - SharePlusWindowsPluginCApiRegisterWithRegistrar( - registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi")); - Sqlite3FlutterLibsPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("Sqlite3FlutterLibsPlugin")); - ThumblrWindowsPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("ThumblrWindowsPlugin")); - UrlLauncherWindowsRegisterWithRegistrar( - registry->GetRegistrarForPlugin("UrlLauncherWindows")); -} diff --git a/packages/stream_chat_flutter/example/windows/flutter/generated_plugin_registrant.h b/packages/stream_chat_flutter/example/windows/flutter/generated_plugin_registrant.h deleted file mode 100644 index dc139d85a..000000000 --- a/packages/stream_chat_flutter/example/windows/flutter/generated_plugin_registrant.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#ifndef GENERATED_PLUGIN_REGISTRANT_ -#define GENERATED_PLUGIN_REGISTRANT_ - -#include - -// Registers Flutter plugins. -void RegisterPlugins(flutter::PluginRegistry* registry); - -#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/packages/stream_chat_flutter/lib/src/message_input/dm_checkbox.dart b/packages/stream_chat_flutter/lib/src/message_input/dm_checkbox.dart index 13a77bb4d..ff2f570b6 100644 --- a/packages/stream_chat_flutter/lib/src/message_input/dm_checkbox.dart +++ b/packages/stream_chat_flutter/lib/src/message_input/dm_checkbox.dart @@ -30,6 +30,7 @@ class DmCheckbox extends StatelessWidget { Widget build(BuildContext context) { final _streamChatTheme = StreamChatTheme.of(context); return Row( + mainAxisSize: MainAxisSize.min, children: [ Container( height: 16, diff --git a/packages/stream_chat_flutter/lib/src/message_input/stream_message_input.dart b/packages/stream_chat_flutter/lib/src/message_input/stream_message_input.dart index f259d203f..879604a84 100644 --- a/packages/stream_chat_flutter/lib/src/message_input/stream_message_input.dart +++ b/packages/stream_chat_flutter/lib/src/message_input/stream_message_input.dart @@ -618,6 +618,7 @@ class StreamMessageInputState extends State }, child: Column( mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, children: [ if (_hasQuotedMessage && !_isEditing) // Ensure this doesn't show on web & desktop diff --git a/packages/stream_chat_flutter/pubspec.yaml b/packages/stream_chat_flutter/pubspec.yaml index 7efcf8e7f..3e9b0c6fc 100644 --- a/packages/stream_chat_flutter/pubspec.yaml +++ b/packages/stream_chat_flutter/pubspec.yaml @@ -61,10 +61,10 @@ dependencies: video_player: ^2.8.7 dev_dependencies: + alchemist: ^0.11.0 faker_dart: ^0.2.1 flutter_test: sdk: flutter - golden_toolkit: ^0.15.0 mocktail: ^1.0.0 path: ^1.8.3 diff --git a/packages/stream_chat_flutter/test/flutter_test_config.dart b/packages/stream_chat_flutter/test/flutter_test_config.dart index d5332f3af..7b00df938 100644 --- a/packages/stream_chat_flutter/test/flutter_test_config.dart +++ b/packages/stream_chat_flutter/test/flutter_test_config.dart @@ -1,30 +1,18 @@ import 'dart:async'; +import 'dart:io'; -import 'package:flutter/foundation.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; +import 'package:alchemist/alchemist.dart'; Future testExecutable(FutureOr Function() testMain) async { - await loadAppFonts(); - goldenFileComparator = - CustomGoldenFileComparator(Uri.parse('test/src/goldens')); - return testMain(); -} - -class CustomGoldenFileComparator extends LocalFileComparator { - CustomGoldenFileComparator(super.testFile); - - @override - Future compare(Uint8List imageBytes, Uri golden) async { - final result = await GoldenFileComparator.compareLists( - imageBytes, - await getGoldenBytes(golden), - ); + final isRunningInCi = Platform.environment.containsKey('CI') || + Platform.environment.containsKey('GITHUB_ACTIONS'); - if (!result.passed && result.diffPercent > 0.05) { - final error = await generateFailureOutput(result, golden, basedir); - throw FlutterError(error); - } - return true; - } + return AlchemistConfig.runWithConfig( + config: AlchemistConfig( + platformGoldensConfig: PlatformGoldensConfig( + enabled: !isRunningInCi, + ), + ), + run: testMain, + ); } diff --git a/packages/stream_chat_flutter/test/src/avatars/goldens/ci/gradient_avatar_0.png b/packages/stream_chat_flutter/test/src/avatars/goldens/ci/gradient_avatar_0.png new file mode 100644 index 000000000..dab41d6d7 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/avatars/goldens/ci/gradient_avatar_0.png differ diff --git a/packages/stream_chat_flutter/test/src/avatars/goldens/ci/gradient_avatar_1.png b/packages/stream_chat_flutter/test/src/avatars/goldens/ci/gradient_avatar_1.png new file mode 100644 index 000000000..b80de3c98 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/avatars/goldens/ci/gradient_avatar_1.png differ diff --git a/packages/stream_chat_flutter/test/src/avatars/goldens/ci/gradient_avatar_2.png b/packages/stream_chat_flutter/test/src/avatars/goldens/ci/gradient_avatar_2.png new file mode 100644 index 000000000..cd9808670 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/avatars/goldens/ci/gradient_avatar_2.png differ diff --git a/packages/stream_chat_flutter/test/src/avatars/goldens/ci/gradient_avatar_3.png b/packages/stream_chat_flutter/test/src/avatars/goldens/ci/gradient_avatar_3.png new file mode 100644 index 000000000..3aea9bc2d Binary files /dev/null and b/packages/stream_chat_flutter/test/src/avatars/goldens/ci/gradient_avatar_3.png differ diff --git a/packages/stream_chat_flutter/test/src/avatars/goldens/ci/group_avatar_0.png b/packages/stream_chat_flutter/test/src/avatars/goldens/ci/group_avatar_0.png new file mode 100644 index 000000000..447e0c39e Binary files /dev/null and b/packages/stream_chat_flutter/test/src/avatars/goldens/ci/group_avatar_0.png differ diff --git a/packages/stream_chat_flutter/test/src/avatars/goldens/ci/user_avatar_0.png b/packages/stream_chat_flutter/test/src/avatars/goldens/ci/user_avatar_0.png new file mode 100644 index 000000000..4e8db6160 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/avatars/goldens/ci/user_avatar_0.png differ diff --git a/packages/stream_chat_flutter/test/src/avatars/goldens/ci/user_avatar_1.png b/packages/stream_chat_flutter/test/src/avatars/goldens/ci/user_avatar_1.png new file mode 100644 index 000000000..5a43da106 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/avatars/goldens/ci/user_avatar_1.png differ diff --git a/packages/stream_chat_flutter/test/src/avatars/gradient_avatar_test.dart b/packages/stream_chat_flutter/test/src/avatars/gradient_avatar_test.dart index 8c4e0cf6f..c4d196163 100644 --- a/packages/stream_chat_flutter/test/src/avatars/gradient_avatar_test.dart +++ b/packages/stream_chat_flutter/test/src/avatars/gradient_avatar_test.dart @@ -1,6 +1,6 @@ +import 'package:alchemist/alchemist.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:mocktail/mocktail.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; @@ -39,92 +39,77 @@ void main() { }, ); - testGoldens( + goldenTest( 'golden test for the name "demo user"', - (WidgetTester tester) async { - await tester.pumpWidget( - MaterialAppWrapper( - home: const Scaffold( - body: Center( - child: SizedBox( - width: 100, - height: 100, - child: - StreamGradientAvatar(name: 'demo user', userId: 'demo123'), - ), - ), + fileName: 'gradient_avatar_0', + constraints: const BoxConstraints.tightFor(width: 300, height: 300), + builder: () => MaterialAppWrapper( + home: const Scaffold( + body: Center( + child: SizedBox( + width: 100, + height: 100, + child: StreamGradientAvatar(name: 'demo user', userId: 'demo123'), ), ), - ); - - await screenMatchesGolden(tester, 'gradient_avatar_0'); - }, + ), + ), ); - testGoldens( + goldenTest( 'golden test for the name "demo"', - (WidgetTester tester) async { - await tester.pumpWidget( - MaterialAppWrapper( - home: const Scaffold( - body: Center( - child: SizedBox( - width: 100, - height: 100, - child: StreamGradientAvatar(name: 'demo', userId: 'demo1'), - ), - ), + fileName: 'gradient_avatar_1', + constraints: const BoxConstraints.tightFor(width: 300, height: 300), + builder: () => MaterialAppWrapper( + home: const Scaffold( + body: Center( + child: SizedBox( + width: 100, + height: 100, + child: StreamGradientAvatar(name: 'demo', userId: 'demo1'), ), ), - ); - - await screenMatchesGolden(tester, 'gradient_avatar_1'); - }, + ), + ), ); - testGoldens( + goldenTest( 'control special character test', - (WidgetTester tester) async { - await tester.pumpWidget( - MaterialAppWrapper( - home: const Scaffold( - body: Center( - child: SizedBox( - width: 100, - height: 100, - child: StreamGradientAvatar( - name: r'd123@/d de:$as', - userId: 'demo123', - ), - ), + fileName: 'gradient_avatar_2', + constraints: const BoxConstraints.tightFor(width: 300, height: 300), + builder: () => MaterialAppWrapper( + home: const Scaffold( + body: Center( + child: SizedBox( + width: 100, + height: 100, + child: StreamGradientAvatar( + name: r'd123@/d de:$as', + userId: 'demo123', ), ), ), - ); - - await screenMatchesGolden(tester, 'gradient_avatar_2'); - }, + ), + ), ); - testGoldens( + goldenTest( 'control special character test 2', - (WidgetTester tester) async { - await tester.pumpWidget( - MaterialAppWrapper( - home: const Scaffold( - body: Center( - child: SizedBox( - width: 100, - height: 100, - child: StreamGradientAvatar( - name: r'123@/d $as', userId: 'demo123'), - ), + fileName: 'gradient_avatar_3', + constraints: const BoxConstraints.tightFor(width: 300, height: 300), + builder: () => MaterialAppWrapper( + home: const Scaffold( + body: Center( + child: SizedBox( + width: 100, + height: 100, + child: StreamGradientAvatar( + name: r'123@/d $as', + userId: 'demo123', ), ), ), - ); - - await screenMatchesGolden(tester, 'gradient_avatar_3'); - }, + ), + ), ); } diff --git a/packages/stream_chat_flutter/test/src/avatars/group_avatar_test.dart b/packages/stream_chat_flutter/test/src/avatars/group_avatar_test.dart index 5dae8417c..17f8341e6 100644 --- a/packages/stream_chat_flutter/test/src/avatars/group_avatar_test.dart +++ b/packages/stream_chat_flutter/test/src/avatars/group_avatar_test.dart @@ -1,7 +1,7 @@ +import 'package:alchemist/alchemist.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:mocktail/mocktail.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; @@ -63,6 +63,11 @@ void main() { ); }); + tearDown(() { + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler(methodChannel, null); + }); + testWidgets( 'control test', (WidgetTester tester) async { @@ -92,27 +97,27 @@ void main() { }, ); - testGoldens( + goldenTest( 'golden test for the group with "user123" and "user456"', - (WidgetTester tester) async { - await tester.pumpWidget( - MaterialAppWrapper( - home: StreamChat( - client: client, - streamChatThemeData: StreamChatThemeData.light(), - child: StreamChannel( - channel: channel, - child: Scaffold( - body: Center( - child: SizedBox( - width: 100, - height: 100, - child: StreamGroupAvatar( - members: [ - member, - member2, - ], - ), + fileName: 'group_avatar_0', + constraints: const BoxConstraints.tightFor(width: 300, height: 300), + builder: () { + return MaterialAppWrapper( + home: StreamChat( + client: client, + streamChatThemeData: StreamChatThemeData.light(), + child: StreamChannel( + channel: channel, + child: Scaffold( + body: Center( + child: SizedBox( + width: 100, + height: 100, + child: StreamGroupAvatar( + members: [ + member, + member2, + ], ), ), ), @@ -120,117 +125,6 @@ void main() { ), ), ); - - await screenMatchesGolden(tester, 'group_avatar_0'); - }, - ); - - tearDown(() { - TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger - .setMockMethodCallHandler(methodChannel, null); - }); - - /*testGoldens( - 'golden test for the name "demo user"', - (WidgetTester tester) async { - await tester.pumpWidget( - MaterialApp( - home: Scaffold( - body: Center( - child: SizedBox( - width: 100, - height: 100, - child: GroupAvatar( - members: [ - Member(userId: 'user123'), - Member(userId: 'user456'), - ], - ), - ), - ), - ), - ), - ); - - await screenMatchesGolden(tester, 'group_avatar_0'); - }, - ); - - testGoldens( - 'golden test for the name "demo"', - (WidgetTester tester) async { - await tester.pumpWidget( - MaterialApp( - home: Scaffold( - body: Center( - child: SizedBox( - width: 100, - height: 100, - child: GroupAvatar( - members: [ - Member(userId: 'user123'), - Member(userId: 'user456'), - ], - ), - ), - ), - ), - ), - ); - - await screenMatchesGolden(tester, 'group_avatar_1'); - }, - ); - - testGoldens( - 'control special character test', - (WidgetTester tester) async { - await tester.pumpWidget( - MaterialApp( - home: Scaffold( - body: Center( - child: SizedBox( - width: 100, - height: 100, - child: GroupAvatar( - members: [ - Member(userId: 'user123'), - Member(userId: 'user456'), - ], - ), - ), - ), - ), - ), - ); - - await screenMatchesGolden(tester, 'group_avatar_3'); }, ); - - testGoldens( - 'control special character test 2', - (WidgetTester tester) async { - await tester.pumpWidget( - MaterialApp( - home: Scaffold( - body: Center( - child: SizedBox( - width: 100, - height: 100, - child: GroupAvatar( - members: [ - Member(userId: 'user123'), - Member(userId: 'user456'), - ], - ), - ), - ), - ), - ), - ); - - await screenMatchesGolden(tester, 'group_avatar_3'); - }, - );*/ } diff --git a/packages/stream_chat_flutter/test/src/avatars/user_avatar_test.dart b/packages/stream_chat_flutter/test/src/avatars/user_avatar_test.dart index 026ae8fba..6a95d3637 100644 --- a/packages/stream_chat_flutter/test/src/avatars/user_avatar_test.dart +++ b/packages/stream_chat_flutter/test/src/avatars/user_avatar_test.dart @@ -1,6 +1,6 @@ +import 'package:alchemist/alchemist.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:mocktail/mocktail.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; @@ -45,69 +45,65 @@ void main() { }, ); - testGoldens( + goldenTest( 'golden test for online user "user123"', - (WidgetTester tester) async { + fileName: 'user_avatar_0', + constraints: const BoxConstraints.tightFor(width: 300, height: 300), + builder: () { when(() => user.online).thenReturn(true); - await tester.pumpWidget( - MaterialAppWrapper( - builder: (context, child) { - return StreamChatConfiguration( - data: StreamChatConfigurationData(), - child: child!, - ); - }, - home: StreamChatTheme( - data: StreamChatThemeData.light(), - child: Builder( - builder: (context) { - return Scaffold( - body: Center( - child: StreamUserAvatar( - user: user, - ), + return MaterialAppWrapper( + builder: (context, child) { + return StreamChatConfiguration( + data: StreamChatConfigurationData(), + child: child!, + ); + }, + home: StreamChatTheme( + data: StreamChatThemeData.light(), + child: Builder( + builder: (context) { + return Scaffold( + body: Center( + child: StreamUserAvatar( + user: user, ), - ); - }, - ), + ), + ); + }, ), ), ); - - await screenMatchesGolden(tester, 'user_avatar_0'); }, ); - testGoldens( + goldenTest( 'golden test for offline user "user123"', - (WidgetTester tester) async { + fileName: 'user_avatar_1', + constraints: const BoxConstraints.tightFor(width: 300, height: 300), + builder: () { when(() => user.online).thenReturn(false); - await tester.pumpWidget( - MaterialAppWrapper( - builder: (context, child) { - return StreamChatConfiguration( - data: StreamChatConfigurationData(), - child: child!, - ); - }, - home: StreamChatTheme( - data: StreamChatThemeData.light(), - child: Builder( - builder: (context) { - return Scaffold( - body: Center( - child: StreamUserAvatar( - user: user, - ), + return MaterialAppWrapper( + builder: (context, child) { + return StreamChatConfiguration( + data: StreamChatConfigurationData(), + child: child!, + ); + }, + home: StreamChatTheme( + data: StreamChatThemeData.light(), + child: Builder( + builder: (context) { + return Scaffold( + body: Center( + child: StreamUserAvatar( + user: user, ), - ); - }, - ), + ), + ); + }, ), ), ); - - await screenMatchesGolden(tester, 'user_avatar_1'); }, ); } diff --git a/packages/stream_chat_flutter/test/src/bottom_sheets/attachment_modal_sheet_test.dart b/packages/stream_chat_flutter/test/src/bottom_sheets/attachment_modal_sheet_test.dart index 8eb7b01b4..0779c67e8 100644 --- a/packages/stream_chat_flutter/test/src/bottom_sheets/attachment_modal_sheet_test.dart +++ b/packages/stream_chat_flutter/test/src/bottom_sheets/attachment_modal_sheet_test.dart @@ -1,6 +1,6 @@ +import 'package:alchemist/alchemist.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import '../material_app_wrapper.dart'; @@ -115,27 +115,23 @@ void main() { expect(called, 1); }); - testGoldens( + goldenTest( 'golden test for AttachmentModalSheet', - (WidgetTester tester) async { - await tester.pumpWidget( - MaterialAppWrapper( - home: Scaffold( - body: Builder(builder: (context) { - return Center( - child: AttachmentModalSheet( - onPhotoTap: () {}, - onVideoTap: () {}, - onFileTap: () {}, - ), - ); - }), - ), - ), - ); - - await screenMatchesGolden(tester, 'attachment_modal_sheet_0'); - }, + fileName: 'attachment_modal_sheet_0', + constraints: const BoxConstraints.tightFor(width: 300, height: 300), + builder: () => MaterialAppWrapper( + home: Scaffold( + body: Builder(builder: (context) { + return Center( + child: AttachmentModalSheet( + onPhotoTap: () {}, + onVideoTap: () {}, + onFileTap: () {}, + ), + ); + }), + ), + ), ); }); } diff --git a/packages/stream_chat_flutter/test/src/bottom_sheets/edit_message_sheet_test.dart b/packages/stream_chat_flutter/test/src/bottom_sheets/edit_message_sheet_test.dart index af455a4a4..571fe4c59 100644 --- a/packages/stream_chat_flutter/test/src/bottom_sheets/edit_message_sheet_test.dart +++ b/packages/stream_chat_flutter/test/src/bottom_sheets/edit_message_sheet_test.dart @@ -1,7 +1,7 @@ +import 'package:alchemist/alchemist.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import '../material_app_wrapper.dart'; @@ -68,27 +68,22 @@ void main() { expect(find.byType(StreamMessageInput), findsOneWidget); }); - testGoldens( + goldenTest( 'golden test for EditMessageSheet', - (WidgetTester tester) async { - await tester.pumpWidget( - MaterialAppWrapper( - builder: (context, child) => StreamChat( - client: MockClient(), - child: child, - ), - home: Scaffold( - body: Center( - child: EditMessageSheet( - channel: MockChannel(), - message: Message(id: 'msg123', text: 'Hello World!'), - ), - )), + fileName: 'edit_message_sheet_0', + constraints: const BoxConstraints.tightFor(width: 300, height: 300), + builder: () => MaterialAppWrapper( + builder: (context, child) => StreamChat( + client: MockClient(), + child: child, + ), + home: Scaffold( + bottomSheet: EditMessageSheet( + channel: MockChannel(), + message: Message(id: 'msg123', text: 'Hello World!'), ), - ); - - await screenMatchesGolden(tester, 'edit_message_sheet_0'); - }, + ), + ), ); tearDown(() { diff --git a/packages/stream_chat_flutter/test/src/bottom_sheets/error_alert_sheet_test.dart b/packages/stream_chat_flutter/test/src/bottom_sheets/error_alert_sheet_test.dart index 8ed886982..7dc89683b 100644 --- a/packages/stream_chat_flutter/test/src/bottom_sheets/error_alert_sheet_test.dart +++ b/packages/stream_chat_flutter/test/src/bottom_sheets/error_alert_sheet_test.dart @@ -1,7 +1,7 @@ +import 'package:alchemist/alchemist.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import '../material_app_wrapper.dart'; @@ -11,6 +11,7 @@ void main() { group('ErrorAlertSheet tests', () { const methodChannel = MethodChannel('dev.fluttercommunity.plus/connectivity_status'); + setUp(() { TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger .setMockMethodCallHandler(methodChannel, @@ -74,27 +75,21 @@ void main() { expect(find.text('Something went wrong'), findsOneWidget); }); - testGoldens( + goldenTest( 'golden test for ErrorAlertSheet', - (WidgetTester tester) async { - await tester.pumpWidget( - MaterialAppWrapper( - builder: (context, child) => StreamChat( - client: MockClient(), - child: child, - ), - home: const Scaffold( - body: Center( - child: ErrorAlertSheet( - errorDescription: 'Something went wrong.', - ), - ), - ), + fileName: 'error_alert_sheet_0', + constraints: const BoxConstraints.tightFor(width: 300, height: 300), + builder: () => MaterialAppWrapper( + builder: (context, child) => StreamChat( + client: MockClient(), + child: child, + ), + home: const Scaffold( + bottomSheet: ErrorAlertSheet( + errorDescription: 'Something went wrong.', ), - ); - - await screenMatchesGolden(tester, 'error_alert_sheet_0'); - }, + ), + ), ); tearDown(() { diff --git a/packages/stream_chat_flutter/test/src/bottom_sheets/goldens/ci/attachment_modal_sheet_0.png b/packages/stream_chat_flutter/test/src/bottom_sheets/goldens/ci/attachment_modal_sheet_0.png new file mode 100644 index 000000000..d08bde712 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/bottom_sheets/goldens/ci/attachment_modal_sheet_0.png differ diff --git a/packages/stream_chat_flutter/test/src/bottom_sheets/goldens/ci/edit_message_sheet_0.png b/packages/stream_chat_flutter/test/src/bottom_sheets/goldens/ci/edit_message_sheet_0.png new file mode 100644 index 000000000..68e394d70 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/bottom_sheets/goldens/ci/edit_message_sheet_0.png differ diff --git a/packages/stream_chat_flutter/test/src/bottom_sheets/goldens/ci/error_alert_sheet_0.png b/packages/stream_chat_flutter/test/src/bottom_sheets/goldens/ci/error_alert_sheet_0.png new file mode 100644 index 000000000..eecd46671 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/bottom_sheets/goldens/ci/error_alert_sheet_0.png differ diff --git a/packages/stream_chat_flutter/test/src/context_menu_items/download_menu_item_test.dart b/packages/stream_chat_flutter/test/src/context_menu_items/download_menu_item_test.dart index 1d63472ce..23b3a4c53 100644 --- a/packages/stream_chat_flutter/test/src/context_menu_items/download_menu_item_test.dart +++ b/packages/stream_chat_flutter/test/src/context_menu_items/download_menu_item_test.dart @@ -1,6 +1,6 @@ +import 'package:alchemist/alchemist.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:stream_chat_flutter/src/context_menu_items/download_menu_item.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; @@ -8,34 +8,13 @@ import '../material_app_wrapper.dart'; import '../mocks.dart'; void main() { - testWidgets('DownloadMenuItem test', (tester) async { - await tester.pumpWidget( - MaterialApp( - builder: (context, child) => StreamChat( - client: MockClient(), - child: child, - ), - home: Scaffold( - body: Center( - child: DownloadMenuItem( - attachment: MockAttachment(), - ), - ), - ), - ), - ); - - expect(find.byType(ListTile), findsOneWidget); - }); - - testGoldens( - 'golden test for DownloadMenuItem', - (WidgetTester tester) async { + group('DownloadMenuItem tests', () { + testWidgets('renders ListTile widget', (tester) async { await tester.pumpWidget( - MaterialAppWrapper( - builder: (context, child) => StreamChatTheme( - data: StreamChatThemeData.light(), - child: child!, + MaterialApp( + builder: (context, child) => StreamChat( + client: MockClient(), + child: child, ), home: Scaffold( body: Center( @@ -47,7 +26,26 @@ void main() { ), ); - await screenMatchesGolden(tester, 'download_menu_item_0'); - }, - ); + expect(find.byType(ListTile), findsOneWidget); + }); + + goldenTest( + 'golden test for DownloadMenuItem', + fileName: 'download_menu_item_0', + constraints: const BoxConstraints.tightFor(width: 300, height: 100), + builder: () => MaterialAppWrapper( + builder: (context, child) => StreamChatTheme( + data: StreamChatThemeData.light(), + child: child!, + ), + home: Scaffold( + body: Center( + child: DownloadMenuItem( + attachment: MockAttachment(), + ), + ), + ), + ), + ); + }); } diff --git a/packages/stream_chat_flutter/test/src/context_menu_items/goldens/ci/download_menu_item_0.png b/packages/stream_chat_flutter/test/src/context_menu_items/goldens/ci/download_menu_item_0.png new file mode 100644 index 000000000..b9ae155d4 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/context_menu_items/goldens/ci/download_menu_item_0.png differ diff --git a/packages/stream_chat_flutter/test/src/context_menu_items/goldens/ci/stream_chat_context_menu_item_0.png b/packages/stream_chat_flutter/test/src/context_menu_items/goldens/ci/stream_chat_context_menu_item_0.png new file mode 100644 index 000000000..1cfb96377 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/context_menu_items/goldens/ci/stream_chat_context_menu_item_0.png differ diff --git a/packages/stream_chat_flutter/test/src/context_menu_items/stream_chat_context_menu_item_test.dart b/packages/stream_chat_flutter/test/src/context_menu_items/stream_chat_context_menu_item_test.dart index d68295403..798e649cf 100644 --- a/packages/stream_chat_flutter/test/src/context_menu_items/stream_chat_context_menu_item_test.dart +++ b/packages/stream_chat_flutter/test/src/context_menu_items/stream_chat_context_menu_item_test.dart @@ -1,6 +1,6 @@ +import 'package:alchemist/alchemist.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:stream_chat_flutter/src/context_menu_items/stream_chat_context_menu_item.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; @@ -8,46 +8,44 @@ import '../material_app_wrapper.dart'; import '../mocks.dart'; void main() { - testWidgets('StreamChatContextMenuItem test', (tester) async { - await tester.pumpWidget( - MaterialApp( - builder: (context, child) => StreamChat( - client: MockClient(), - child: child, - ), - home: const Scaffold( - body: Center( - child: StreamChatContextMenuItem(), - ), - ), - ), - ); - - expect(find.byType(ListTile), findsOneWidget); - }); - - testGoldens( - 'golden test for StreamChatContextMenuItem', - (WidgetTester tester) async { + group('StreamChatContextMenuItem tests', () { + testWidgets('renders ListTile widget', (tester) async { await tester.pumpWidget( - MaterialAppWrapper( - builder: (context, child) => StreamChatTheme( - data: StreamChatThemeData.light(), - child: child!, + MaterialApp( + builder: (context, child) => StreamChat( + client: MockClient(), + child: child, ), - home: Scaffold( + home: const Scaffold( body: Center( - child: StreamChatContextMenuItem( - leading: const Icon(Icons.download), - title: const Text('Download'), - onClick: () {}, - ), + child: StreamChatContextMenuItem(), ), ), ), ); - await screenMatchesGolden(tester, 'stream_chat_context_menu_item_0'); - }, - ); + expect(find.byType(ListTile), findsOneWidget); + }); + + goldenTest( + 'golden test for StreamChatContextMenuItem', + fileName: 'stream_chat_context_menu_item_0', + constraints: const BoxConstraints.tightFor(width: 300, height: 80), + builder: () => MaterialAppWrapper( + builder: (context, child) => StreamChatTheme( + data: StreamChatThemeData.light(), + child: child!, + ), + home: Scaffold( + body: Center( + child: StreamChatContextMenuItem( + leading: const Icon(Icons.download), + title: const Text('Download'), + onClick: () {}, + ), + ), + ), + ), + ); + }); } diff --git a/packages/stream_chat_flutter/test/src/dialogs/confirmation_dialog_test.dart b/packages/stream_chat_flutter/test/src/dialogs/confirmation_dialog_test.dart index 58d876083..27e74c589 100644 --- a/packages/stream_chat_flutter/test/src/dialogs/confirmation_dialog_test.dart +++ b/packages/stream_chat_flutter/test/src/dialogs/confirmation_dialog_test.dart @@ -1,46 +1,51 @@ +import 'package:alchemist/alchemist.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:stream_chat_flutter/src/dialogs/confirmation_dialog.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import '../material_app_wrapper.dart'; void main() { - testWidgets('ChannelInfoDialog shows info and members', (tester) async { - await tester.pumpWidget( - MaterialApp( - home: Scaffold( - body: Builder(builder: (context) { - return Center( - child: StreamChatTheme( - data: StreamChatThemeData.light(), - child: ConfirmationDialog( - titleText: context.translations - .toggleMuteUnmuteUserText(isMuted: false), - promptText: context.translations - .toggleMuteUnmuteUserQuestion(isMuted: false), - affirmativeText: context.translations - .toggleMuteUnmuteAction(isMuted: false), - onConfirmation: () {}, - ), - ), - ); - }), + group('ConfirmationDialog tests', () { + testWidgets('renders with title, prompt, and action', (tester) async { + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: Builder( + builder: (context) { + return Center( + child: StreamChatTheme( + data: StreamChatThemeData.light(), + child: ConfirmationDialog( + titleText: context.translations + .toggleMuteUnmuteUserText(isMuted: false), + promptText: context.translations + .toggleMuteUnmuteUserQuestion(isMuted: false), + affirmativeText: context.translations + .toggleMuteUnmuteAction(isMuted: false), + onConfirmation: () {}, + ), + ), + ); + }, + ), + ), ), - ), - ); + ); - expect(find.byType(AlertDialog), findsOneWidget); - expect(find.text('Mute User'), findsOneWidget); - expect( - find.text('Are you sure you want to mute this user?'), findsOneWidget); - expect(find.text('MUTE'), findsOneWidget); - }); + expect(find.byType(AlertDialog), findsOneWidget); + expect(find.text('Mute User'), findsOneWidget); + expect(find.text('Are you sure you want to mute this user?'), + findsOneWidget); + expect(find.text('MUTE'), findsOneWidget); + }); - testGoldens('golden test for ConfirmationDialog', (tester) async { - await tester.pumpWidget( - MaterialAppWrapper( + goldenTest( + 'golden test for ConfirmationDialog', + fileName: 'confirmation_dialog_0', + constraints: const BoxConstraints.tightFor(width: 400, height: 300), + builder: () => MaterialAppWrapper( home: Scaffold( body: Builder( builder: (context) { @@ -63,7 +68,5 @@ void main() { ), ), ); - - await screenMatchesGolden(tester, 'confirmation_dialog_0'); }); } diff --git a/packages/stream_chat_flutter/test/src/dialogs/delete_message_dialog_test.dart b/packages/stream_chat_flutter/test/src/dialogs/delete_message_dialog_test.dart index faa351ceb..f1f154770 100644 --- a/packages/stream_chat_flutter/test/src/dialogs/delete_message_dialog_test.dart +++ b/packages/stream_chat_flutter/test/src/dialogs/delete_message_dialog_test.dart @@ -1,38 +1,41 @@ +import 'package:alchemist/alchemist.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:stream_chat_flutter/src/dialogs/delete_message_dialog.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import '../material_app_wrapper.dart'; void main() { - testWidgets('DeleteMessageDialog', (tester) async { - await tester.pumpWidget( - MaterialApp( - home: Scaffold( - body: Builder( - builder: (context) { - return Center( - child: StreamChatTheme( - data: StreamChatThemeData.light(), - child: const DeleteMessageDialog(), - ), - ); - }, + group('DeleteMessageDialog tests', () { + testWidgets('renders with correct title and actions', (tester) async { + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: Builder( + builder: (context) { + return Center( + child: StreamChatTheme( + data: StreamChatThemeData.light(), + child: const DeleteMessageDialog(), + ), + ); + }, + ), ), ), - ), - ); + ); - expect(find.byType(AlertDialog), findsOneWidget); - expect(find.text('Delete Message'), findsOneWidget); - expect(find.text('DELETE'), findsOneWidget); - }); + expect(find.byType(AlertDialog), findsOneWidget); + expect(find.text('Delete Message'), findsOneWidget); + expect(find.text('DELETE'), findsOneWidget); + }); - testGoldens('golden test for DeleteMessageDialog', (tester) async { - await tester.pumpWidget( - MaterialAppWrapper( + goldenTest( + 'golden test for DeleteMessageDialog', + fileName: 'delete_message_dialog_0', + constraints: const BoxConstraints.tightFor(width: 400, height: 300), + builder: () => MaterialAppWrapper( home: Scaffold( body: Builder( builder: (context) { @@ -47,7 +50,5 @@ void main() { ), ), ); - - await screenMatchesGolden(tester, 'delete_message_dialog_0'); }); } diff --git a/packages/stream_chat_flutter/test/src/dialogs/goldens/ci/confirmation_dialog_0.png b/packages/stream_chat_flutter/test/src/dialogs/goldens/ci/confirmation_dialog_0.png new file mode 100644 index 000000000..28fd09088 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/dialogs/goldens/ci/confirmation_dialog_0.png differ diff --git a/packages/stream_chat_flutter/test/src/dialogs/goldens/ci/delete_message_dialog_0.png b/packages/stream_chat_flutter/test/src/dialogs/goldens/ci/delete_message_dialog_0.png new file mode 100644 index 000000000..9314acdc8 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/dialogs/goldens/ci/delete_message_dialog_0.png differ diff --git a/packages/stream_chat_flutter/test/src/dialogs/goldens/ci/message_dialog_0.png b/packages/stream_chat_flutter/test/src/dialogs/goldens/ci/message_dialog_0.png new file mode 100644 index 000000000..e6bf309bc Binary files /dev/null and b/packages/stream_chat_flutter/test/src/dialogs/goldens/ci/message_dialog_0.png differ diff --git a/packages/stream_chat_flutter/test/src/dialogs/goldens/ci/message_dialog_1.png b/packages/stream_chat_flutter/test/src/dialogs/goldens/ci/message_dialog_1.png new file mode 100644 index 000000000..58f563434 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/dialogs/goldens/ci/message_dialog_1.png differ diff --git a/packages/stream_chat_flutter/test/src/dialogs/goldens/ci/message_dialog_2.png b/packages/stream_chat_flutter/test/src/dialogs/goldens/ci/message_dialog_2.png new file mode 100644 index 000000000..e6bf309bc Binary files /dev/null and b/packages/stream_chat_flutter/test/src/dialogs/goldens/ci/message_dialog_2.png differ diff --git a/packages/stream_chat_flutter/test/src/dialogs/message_dialog_test.dart b/packages/stream_chat_flutter/test/src/dialogs/message_dialog_test.dart index 62861f8c4..5a4483608 100644 --- a/packages/stream_chat_flutter/test/src/dialogs/message_dialog_test.dart +++ b/packages/stream_chat_flutter/test/src/dialogs/message_dialog_test.dart @@ -1,65 +1,68 @@ +import 'package:alchemist/alchemist.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:stream_chat_flutter/src/dialogs/message_dialog.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import '../material_app_wrapper.dart'; void main() { - testWidgets('MessageDialog shows default info', (tester) async { - await tester.pumpWidget( - MaterialApp( - home: Scaffold( - body: Builder( - builder: (context) { - return Center( - child: StreamChatTheme( - data: StreamChatThemeData.light(), - child: const MessageDialog(), - ), - ); - }, + group('MessageDialog tests', () { + testWidgets('shows default info', (tester) async { + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: Builder( + builder: (context) { + return Center( + child: StreamChatTheme( + data: StreamChatThemeData.light(), + child: const MessageDialog(), + ), + ); + }, + ), ), ), - ), - ); + ); - expect(find.byType(AlertDialog), findsOneWidget); - expect(find.text('Something went wrong'), findsOneWidget); - expect(find.text('OK'), findsOneWidget); - }); + expect(find.byType(AlertDialog), findsOneWidget); + expect(find.text('Something went wrong'), findsOneWidget); + expect(find.text('OK'), findsOneWidget); + }); - testWidgets('MessageDialog shows custom info', (tester) async { - await tester.pumpWidget( - MaterialApp( - home: Scaffold( - body: Builder( - builder: (context) { - return Center( - child: StreamChatTheme( - data: StreamChatThemeData.light(), - child: const MessageDialog( - titleText: 'Message', - messageText: 'Message body', + testWidgets('shows custom info', (tester) async { + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: Builder( + builder: (context) { + return Center( + child: StreamChatTheme( + data: StreamChatThemeData.light(), + child: const MessageDialog( + titleText: 'Message', + messageText: 'Message body', + ), ), - ), - ); - }, + ); + }, + ), ), ), - ), - ); + ); - expect(find.byType(AlertDialog), findsOneWidget); - expect(find.text('Message'), findsOneWidget); - expect(find.text('Message body'), findsOneWidget); - expect(find.text('OK'), findsOneWidget); - }); + expect(find.byType(AlertDialog), findsOneWidget); + expect(find.text('Message'), findsOneWidget); + expect(find.text('Message body'), findsOneWidget); + expect(find.text('OK'), findsOneWidget); + }); - testGoldens('golden test for default MessageDialog', (tester) async { - await tester.pumpWidget( - MaterialAppWrapper( + goldenTest( + 'golden test for default MessageDialog', + fileName: 'message_dialog_0', + constraints: const BoxConstraints.tightFor(width: 400, height: 300), + builder: () => MaterialAppWrapper( home: Scaffold( body: Builder( builder: (context) { @@ -75,12 +78,11 @@ void main() { ), ); - await screenMatchesGolden(tester, 'message_dialog_0'); - }); - - testGoldens('golden test for custom MessageDialog', (tester) async { - await tester.pumpWidget( - MaterialAppWrapper( + goldenTest( + 'golden test for custom MessageDialog', + fileName: 'message_dialog_1', + constraints: const BoxConstraints.tightFor(width: 400, height: 300), + builder: () => MaterialAppWrapper( home: Scaffold( body: Builder( builder: (context) { @@ -99,13 +101,11 @@ void main() { ), ); - await screenMatchesGolden(tester, 'message_dialog_1'); - }); - - testGoldens('golden test for custom MessageDialog with no body', - (tester) async { - await tester.pumpWidget( - MaterialAppWrapper( + goldenTest( + 'golden test for custom MessageDialog with no body', + fileName: 'message_dialog_2', + constraints: const BoxConstraints.tightFor(width: 400, height: 300), + builder: () => MaterialAppWrapper( home: Scaffold( body: Builder( builder: (context) { @@ -122,7 +122,5 @@ void main() { ), ), ); - - await screenMatchesGolden(tester, 'message_dialog_2'); }); } diff --git a/packages/stream_chat_flutter/test/src/gallery/gallery_footer_test.dart b/packages/stream_chat_flutter/test/src/gallery/gallery_footer_test.dart index 51991a19d..bd74265fb 100644 --- a/packages/stream_chat_flutter/test/src/gallery/gallery_footer_test.dart +++ b/packages/stream_chat_flutter/test/src/gallery/gallery_footer_test.dart @@ -1,7 +1,7 @@ +import 'package:alchemist/alchemist.dart'; // Changed from golden_toolkit import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:mocktail/mocktail.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; @@ -86,28 +86,27 @@ void main() { }, ); - testGoldens('golden test for GalleryFooter', (tester) async { - await tester.pumpWidget( - MaterialAppWrapper( - home: StreamChat( - client: client, - child: StreamChannel( - channel: channel, - child: PopScope( - onPopInvokedWithResult: (bool didPop, res) async => false, - child: const Scaffold( - body: StreamGalleryFooter( - mediaAttachmentPackages: [], - ), + goldenTest( + 'golden test for GalleryFooter', + fileName: 'gallery_footer_0', + constraints: const BoxConstraints.tightFor(width: 400, height: 300), + builder: () => MaterialAppWrapper( + home: StreamChat( + client: client, + child: StreamChannel( + channel: channel, + child: PopScope( + onPopInvokedWithResult: (bool didPop, res) async => false, + child: const Scaffold( + bottomNavigationBar: StreamGalleryFooter( + mediaAttachmentPackages: [], ), ), ), ), ), - ); - - await screenMatchesGolden(tester, 'gallery_footer_0'); - }); + ), + ); tearDown(() { TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger diff --git a/packages/stream_chat_flutter/test/src/gallery/gallery_header_test.dart b/packages/stream_chat_flutter/test/src/gallery/gallery_header_test.dart index 0321d4cd1..20fa9a881 100644 --- a/packages/stream_chat_flutter/test/src/gallery/gallery_header_test.dart +++ b/packages/stream_chat_flutter/test/src/gallery/gallery_header_test.dart @@ -1,7 +1,7 @@ +import 'package:alchemist/alchemist.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:mocktail/mocktail.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; @@ -87,9 +87,12 @@ void main() { }, ); - testGoldens('golden test for GalleryHeader', (tester) async { - await tester.pumpWidget( - MaterialAppWrapper( + goldenTest( + 'golden test for GalleryHeader', + fileName: 'gallery_header_0', + constraints: const BoxConstraints.tightFor(width: 300, height: 300), + builder: () { + return MaterialAppWrapper( home: StreamChat( client: client, child: StreamChannel( @@ -99,7 +102,7 @@ void main() { child: Scaffold( appBar: StreamGalleryHeader( userName: 'User', - sentAt: DateTime.now().toIso8601String(), + sentAt: '12:02 AM', message: Message(), attachment: MockAttachment(), ), @@ -107,11 +110,9 @@ void main() { ), ), ), - ), - ); - - await screenMatchesGolden(tester, 'gallery_header_0'); - }); + ); + }, + ); tearDown(() { TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger diff --git a/packages/stream_chat_flutter/test/src/gallery/goldens/ci/gallery_footer_0.png b/packages/stream_chat_flutter/test/src/gallery/goldens/ci/gallery_footer_0.png new file mode 100644 index 000000000..68ff5385f Binary files /dev/null and b/packages/stream_chat_flutter/test/src/gallery/goldens/ci/gallery_footer_0.png differ diff --git a/packages/stream_chat_flutter/test/src/gallery/goldens/ci/gallery_header_0.png b/packages/stream_chat_flutter/test/src/gallery/goldens/ci/gallery_header_0.png new file mode 100644 index 000000000..6b0e1397d Binary files /dev/null and b/packages/stream_chat_flutter/test/src/gallery/goldens/ci/gallery_header_0.png differ diff --git a/packages/stream_chat_flutter/test/src/goldens/attachment_button_0.png b/packages/stream_chat_flutter/test/src/goldens/attachment_button_0.png deleted file mode 100644 index 918525fa6..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/attachment_button_0.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/attachment_modal_sheet_0.png b/packages/stream_chat_flutter/test/src/goldens/attachment_modal_sheet_0.png deleted file mode 100644 index 5bd396394..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/attachment_modal_sheet_0.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/clear_input_item_0.png b/packages/stream_chat_flutter/test/src/goldens/clear_input_item_0.png deleted file mode 100644 index fca64b737..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/clear_input_item_0.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/command_button_0.png b/packages/stream_chat_flutter/test/src/goldens/command_button_0.png deleted file mode 100644 index a240087be..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/command_button_0.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/confirmation_dialog_0.png b/packages/stream_chat_flutter/test/src/goldens/confirmation_dialog_0.png deleted file mode 100644 index ca91c4724..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/confirmation_dialog_0.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/countdown_button_0.png b/packages/stream_chat_flutter/test/src/goldens/countdown_button_0.png deleted file mode 100644 index 9f60150c7..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/countdown_button_0.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/delete_message_dialog_0.png b/packages/stream_chat_flutter/test/src/goldens/delete_message_dialog_0.png deleted file mode 100644 index d5a7a6cc5..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/delete_message_dialog_0.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/deleted_message_custom.png b/packages/stream_chat_flutter/test/src/goldens/deleted_message_custom.png deleted file mode 100644 index 1da95a49b..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/deleted_message_custom.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/deleted_message_dark.png b/packages/stream_chat_flutter/test/src/goldens/deleted_message_dark.png deleted file mode 100644 index 42ce0b52a..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/deleted_message_dark.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/deleted_message_light.png b/packages/stream_chat_flutter/test/src/goldens/deleted_message_light.png deleted file mode 100644 index 5c3f2932a..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/deleted_message_light.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/dm_checkbox_0.png b/packages/stream_chat_flutter/test/src/goldens/dm_checkbox_0.png deleted file mode 100644 index ca8bce21d..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/dm_checkbox_0.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/dm_checkbox_1.png b/packages/stream_chat_flutter/test/src/goldens/dm_checkbox_1.png deleted file mode 100644 index 82291f7bd..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/dm_checkbox_1.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/dm_checkbox_2.png b/packages/stream_chat_flutter/test/src/goldens/dm_checkbox_2.png deleted file mode 100644 index ec92bb513..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/dm_checkbox_2.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/download_menu_item_0.png b/packages/stream_chat_flutter/test/src/goldens/download_menu_item_0.png deleted file mode 100644 index a301600d7..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/download_menu_item_0.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/edit_message_sheet_0.png b/packages/stream_chat_flutter/test/src/goldens/edit_message_sheet_0.png deleted file mode 100644 index c416907ec..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/edit_message_sheet_0.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/error_alert_sheet_0.png b/packages/stream_chat_flutter/test/src/goldens/error_alert_sheet_0.png deleted file mode 100644 index 831a1b4d7..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/error_alert_sheet_0.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/gallery_footer_0.png b/packages/stream_chat_flutter/test/src/goldens/gallery_footer_0.png deleted file mode 100644 index 5a803c904..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/gallery_footer_0.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/gallery_header_0.png b/packages/stream_chat_flutter/test/src/goldens/gallery_header_0.png deleted file mode 100644 index ad52eee94..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/gallery_header_0.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/gradient_avatar_0.png b/packages/stream_chat_flutter/test/src/goldens/gradient_avatar_0.png deleted file mode 100644 index 9425815da..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/gradient_avatar_0.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/gradient_avatar_1.png b/packages/stream_chat_flutter/test/src/goldens/gradient_avatar_1.png deleted file mode 100644 index 66176c4cd..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/gradient_avatar_1.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/gradient_avatar_2.png b/packages/stream_chat_flutter/test/src/goldens/gradient_avatar_2.png deleted file mode 100644 index ceb9226a5..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/gradient_avatar_2.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/gradient_avatar_3.png b/packages/stream_chat_flutter/test/src/goldens/gradient_avatar_3.png deleted file mode 100644 index 1de2bd40c..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/gradient_avatar_3.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/group_avatar_0.png b/packages/stream_chat_flutter/test/src/goldens/group_avatar_0.png deleted file mode 100644 index 6b184f3e5..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/group_avatar_0.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/message_dialog_0.png b/packages/stream_chat_flutter/test/src/goldens/message_dialog_0.png deleted file mode 100644 index 14cc95422..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/message_dialog_0.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/message_dialog_1.png b/packages/stream_chat_flutter/test/src/goldens/message_dialog_1.png deleted file mode 100644 index 45f34fbef..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/message_dialog_1.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/message_dialog_2.png b/packages/stream_chat_flutter/test/src/goldens/message_dialog_2.png deleted file mode 100644 index 64a0ae9d4..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/message_dialog_2.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/message_text.png b/packages/stream_chat_flutter/test/src/goldens/message_text.png deleted file mode 100644 index cc8c19662..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/message_text.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/poll_option_reorderable_list_view_dark.png b/packages/stream_chat_flutter/test/src/goldens/poll_option_reorderable_list_view_dark.png deleted file mode 100644 index 92e410589..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/poll_option_reorderable_list_view_dark.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/poll_option_reorderable_list_view_error.png b/packages/stream_chat_flutter/test/src/goldens/poll_option_reorderable_list_view_error.png deleted file mode 100644 index 78c610349..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/poll_option_reorderable_list_view_error.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/poll_option_reorderable_list_view_light.png b/packages/stream_chat_flutter/test/src/goldens/poll_option_reorderable_list_view_light.png deleted file mode 100644 index f52da6834..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/poll_option_reorderable_list_view_light.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/poll_question_text_field_dark.png b/packages/stream_chat_flutter/test/src/goldens/poll_question_text_field_dark.png deleted file mode 100644 index fff3f6c4d..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/poll_question_text_field_dark.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/poll_question_text_field_error.png b/packages/stream_chat_flutter/test/src/goldens/poll_question_text_field_error.png deleted file mode 100644 index 9c2825b7d..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/poll_question_text_field_error.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/poll_question_text_field_light.png b/packages/stream_chat_flutter/test/src/goldens/poll_question_text_field_light.png deleted file mode 100644 index 4cf9acaa3..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/poll_question_text_field_light.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/reaction_bubble_0.png b/packages/stream_chat_flutter/test/src/goldens/reaction_bubble_0.png deleted file mode 100644 index 18f898adb..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/reaction_bubble_0.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/reaction_bubble_2.png b/packages/stream_chat_flutter/test/src/goldens/reaction_bubble_2.png deleted file mode 100644 index f4ce18e8c..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/reaction_bubble_2.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/reaction_bubble_3_dark.png b/packages/stream_chat_flutter/test/src/goldens/reaction_bubble_3_dark.png deleted file mode 100644 index e358803dd..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/reaction_bubble_3_dark.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/reaction_bubble_3_light.png b/packages/stream_chat_flutter/test/src/goldens/reaction_bubble_3_light.png deleted file mode 100644 index 6d4b2dba8..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/reaction_bubble_3_light.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/reaction_bubble_like_dark.png b/packages/stream_chat_flutter/test/src/goldens/reaction_bubble_like_dark.png deleted file mode 100644 index 9103b1dd9..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/reaction_bubble_like_dark.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/reaction_bubble_like_light.png b/packages/stream_chat_flutter/test/src/goldens/reaction_bubble_like_light.png deleted file mode 100644 index ffceeb7d7..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/reaction_bubble_like_light.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/send_button_0.png b/packages/stream_chat_flutter/test/src/goldens/send_button_0.png deleted file mode 100644 index 087a0352a..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/send_button_0.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/sending_indicator_0.png b/packages/stream_chat_flutter/test/src/goldens/sending_indicator_0.png deleted file mode 100644 index 1c964c9a3..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/sending_indicator_0.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/sending_indicator_1.png b/packages/stream_chat_flutter/test/src/goldens/sending_indicator_1.png deleted file mode 100644 index b61584de0..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/sending_indicator_1.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/sending_indicator_2.png b/packages/stream_chat_flutter/test/src/goldens/sending_indicator_2.png deleted file mode 100644 index b61584de0..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/sending_indicator_2.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/stream_chat_context_menu_item_0.png b/packages/stream_chat_flutter/test/src/goldens/stream_chat_context_menu_item_0.png deleted file mode 100644 index e4b906ed3..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/stream_chat_context_menu_item_0.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/stream_poll_creator_dialog_dark.png b/packages/stream_chat_flutter/test/src/goldens/stream_poll_creator_dialog_dark.png deleted file mode 100644 index 716fd1bf0..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/stream_poll_creator_dialog_dark.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/stream_poll_creator_dialog_light.png b/packages/stream_chat_flutter/test/src/goldens/stream_poll_creator_dialog_light.png deleted file mode 100644 index 2aab6565f..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/stream_poll_creator_dialog_light.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/stream_poll_creator_full_screen_dialog_dark.png b/packages/stream_chat_flutter/test/src/goldens/stream_poll_creator_full_screen_dialog_dark.png deleted file mode 100644 index 81bfd22da..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/stream_poll_creator_full_screen_dialog_dark.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/stream_poll_creator_full_screen_dialog_light.png b/packages/stream_chat_flutter/test/src/goldens/stream_poll_creator_full_screen_dialog_light.png deleted file mode 100644 index a6c70b437..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/stream_poll_creator_full_screen_dialog_light.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/system_message_dark.png b/packages/stream_chat_flutter/test/src/goldens/system_message_dark.png deleted file mode 100644 index fd66b8962..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/system_message_dark.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/system_message_light.png b/packages/stream_chat_flutter/test/src/goldens/system_message_light.png deleted file mode 100644 index 2c46540e4..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/system_message_light.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/upload_progress_indicator_0.png b/packages/stream_chat_flutter/test/src/goldens/upload_progress_indicator_0.png deleted file mode 100644 index 35cd2acde..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/upload_progress_indicator_0.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/upload_progress_indicator_1.png b/packages/stream_chat_flutter/test/src/goldens/upload_progress_indicator_1.png deleted file mode 100644 index f667dd8e5..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/upload_progress_indicator_1.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/upload_progress_indicator_2.png b/packages/stream_chat_flutter/test/src/goldens/upload_progress_indicator_2.png deleted file mode 100644 index a748f229e..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/upload_progress_indicator_2.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/user_avatar_0.png b/packages/stream_chat_flutter/test/src/goldens/user_avatar_0.png deleted file mode 100644 index d5eed30d2..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/user_avatar_0.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/goldens/user_avatar_1.png b/packages/stream_chat_flutter/test/src/goldens/user_avatar_1.png deleted file mode 100644 index aa790d869..000000000 Binary files a/packages/stream_chat_flutter/test/src/goldens/user_avatar_1.png and /dev/null differ diff --git a/packages/stream_chat_flutter/test/src/indicators/goldens/ci/sending_indicator_0.png b/packages/stream_chat_flutter/test/src/indicators/goldens/ci/sending_indicator_0.png new file mode 100644 index 000000000..401991978 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/indicators/goldens/ci/sending_indicator_0.png differ diff --git a/packages/stream_chat_flutter/test/src/indicators/goldens/ci/sending_indicator_1.png b/packages/stream_chat_flutter/test/src/indicators/goldens/ci/sending_indicator_1.png new file mode 100644 index 000000000..ed5256803 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/indicators/goldens/ci/sending_indicator_1.png differ diff --git a/packages/stream_chat_flutter/test/src/indicators/goldens/ci/sending_indicator_2.png b/packages/stream_chat_flutter/test/src/indicators/goldens/ci/sending_indicator_2.png new file mode 100644 index 000000000..e81fe74e2 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/indicators/goldens/ci/sending_indicator_2.png differ diff --git a/packages/stream_chat_flutter/test/src/indicators/goldens/ci/upload_progress_indicator_0.png b/packages/stream_chat_flutter/test/src/indicators/goldens/ci/upload_progress_indicator_0.png new file mode 100644 index 000000000..388bedb5d Binary files /dev/null and b/packages/stream_chat_flutter/test/src/indicators/goldens/ci/upload_progress_indicator_0.png differ diff --git a/packages/stream_chat_flutter/test/src/indicators/goldens/ci/upload_progress_indicator_1.png b/packages/stream_chat_flutter/test/src/indicators/goldens/ci/upload_progress_indicator_1.png new file mode 100644 index 000000000..b408f1645 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/indicators/goldens/ci/upload_progress_indicator_1.png differ diff --git a/packages/stream_chat_flutter/test/src/indicators/goldens/ci/upload_progress_indicator_2.png b/packages/stream_chat_flutter/test/src/indicators/goldens/ci/upload_progress_indicator_2.png new file mode 100644 index 000000000..e20354870 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/indicators/goldens/ci/upload_progress_indicator_2.png differ diff --git a/packages/stream_chat_flutter/test/src/indicators/sending_indicator_test.dart b/packages/stream_chat_flutter/test/src/indicators/sending_indicator_test.dart index 369d850b5..2bea92457 100644 --- a/packages/stream_chat_flutter/test/src/indicators/sending_indicator_test.dart +++ b/packages/stream_chat_flutter/test/src/indicators/sending_indicator_test.dart @@ -1,13 +1,12 @@ +import 'package:alchemist/alchemist.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; - import '../material_app_wrapper.dart'; void main() { testWidgets( - 'StreamSendingIndicator shows sizedBox if messsage state is initial', + 'StreamSendingIndicator shows sizedBox if message state is initial', (tester) async { await tester.pumpWidget( MaterialApp( @@ -52,66 +51,62 @@ void main() { }, ); - testGoldens( - 'golden test for StreamSendingIndicator with StreamSvgIcon.checkAll', - (tester) async { - await tester.pumpWidget( - MaterialAppWrapper( - home: StreamChatTheme( - data: StreamChatThemeData.light(), - child: Scaffold( - body: Center( - child: StreamSendingIndicator( - isMessageRead: true, - message: Message(), - ), + goldenTest( + 'golden test for StreamSendingIndicator with StreamSvgIcon.checkAll', + fileName: 'sending_indicator_0', + constraints: const BoxConstraints.tightFor(width: 50, height: 50), + builder: () => MaterialAppWrapper( + home: StreamChatTheme( + data: StreamChatThemeData.light(), + child: Scaffold( + body: Center( + child: StreamSendingIndicator( + isMessageRead: true, + message: Message(), ), ), ), ), - ); - - await screenMatchesGolden(tester, 'sending_indicator_0'); - }); + ), + ); - testGoldens('golden test for StreamSendingIndicator with StreamSvgIcon.check', - (tester) async { - await tester.pumpWidget( - MaterialAppWrapper( - home: StreamChatTheme( - data: StreamChatThemeData.light(), - child: Scaffold( - body: Center( - child: StreamSendingIndicator( - message: Message(), + goldenTest( + 'golden test for StreamSendingIndicator with StreamSvgIcon.check', + fileName: 'sending_indicator_1', + constraints: const BoxConstraints.tightFor(width: 50, height: 50), + builder: () => MaterialAppWrapper( + home: StreamChatTheme( + data: StreamChatThemeData.light(), + child: Scaffold( + body: Center( + child: StreamSendingIndicator( + message: Message( + state: MessageState.sent, ), ), ), ), ), - ); - - await screenMatchesGolden(tester, 'sending_indicator_1'); - }); + ), + ); - testGoldens( - 'golden test for StreamSendingIndicator with Icon(Icons.access_time)', - (tester) async { - await tester.pumpWidget( - MaterialAppWrapper( - home: StreamChatTheme( - data: StreamChatThemeData.light(), - child: Scaffold( - body: Center( - child: StreamSendingIndicator( - message: Message(), + goldenTest( + 'golden test for StreamSendingIndicator with Icon(Icons.access_time)', + fileName: 'sending_indicator_2', + constraints: const BoxConstraints.tightFor(width: 50, height: 50), + builder: () => MaterialAppWrapper( + home: StreamChatTheme( + data: StreamChatThemeData.light(), + child: Scaffold( + body: Center( + child: StreamSendingIndicator( + message: Message( + state: MessageState.sending, ), ), ), ), ), - ); - - await screenMatchesGolden(tester, 'sending_indicator_2'); - }); + ), + ); } diff --git a/packages/stream_chat_flutter/test/src/indicators/upload_progress_indicator_test.dart b/packages/stream_chat_flutter/test/src/indicators/upload_progress_indicator_test.dart index 4376b1812..09a9237d8 100644 --- a/packages/stream_chat_flutter/test/src/indicators/upload_progress_indicator_test.dart +++ b/packages/stream_chat_flutter/test/src/indicators/upload_progress_indicator_test.dart @@ -1,6 +1,6 @@ +import 'package:alchemist/alchemist.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import '../material_app_wrapper.dart'; @@ -98,72 +98,63 @@ void main() { expect(const Color(0x99000000), backgroundColor); }); - testGoldens( - 'golden test for StreamUploadProgressIndicator at 0% with background', - (tester) async { - await tester.pumpWidget( - MaterialAppWrapper( - home: StreamChatTheme( - data: StreamChatThemeData.light(), - child: const Scaffold( - body: Center( - child: StreamUploadProgressIndicator( - total: 100, - uploaded: 0, - ), + goldenTest( + 'golden test for StreamUploadProgressIndicator at 0% with background', + fileName: 'upload_progress_indicator_0', + constraints: const BoxConstraints.tightFor(width: 300, height: 300), + pumpBeforeTest: pumpOnce, + builder: () => MaterialAppWrapper( + home: StreamChatTheme( + data: StreamChatThemeData.light(), + child: const Scaffold( + body: Center( + child: StreamUploadProgressIndicator( + total: 100, + uploaded: 0, ), ), ), ), - ); - - await screenMatchesGolden(tester, 'upload_progress_indicator_0', - customPump: (widget) => widget.pump(const Duration(seconds: 3))); - }); - - testGoldens( - 'golden test for StreamUploadProgressIndicator at 50% with background', - (tester) async { - await tester.pumpWidget( - MaterialAppWrapper( - home: StreamChatTheme( - data: StreamChatThemeData.light(), - child: const Scaffold( - body: Center( - child: StreamUploadProgressIndicator( - total: 100, - uploaded: 50, - ), + ), + ); + + goldenTest( + 'golden test for StreamUploadProgressIndicator at 50% with background', + fileName: 'upload_progress_indicator_1', + constraints: const BoxConstraints.tightFor(width: 300, height: 300), + pumpBeforeTest: pumpOnce, + builder: () => MaterialAppWrapper( + home: StreamChatTheme( + data: StreamChatThemeData.light(), + child: const Scaffold( + body: Center( + child: StreamUploadProgressIndicator( + total: 100, + uploaded: 50, ), ), ), ), - ); - - await screenMatchesGolden(tester, 'upload_progress_indicator_1', - customPump: (widget) => widget.pump(const Duration(seconds: 3))); - }); - - testGoldens( - 'golden test for StreamUploadProgressIndicator at 100% with background', - (tester) async { - await tester.pumpWidget( - MaterialAppWrapper( - home: StreamChatTheme( - data: StreamChatThemeData.light(), - child: const Scaffold( - body: Center( - child: StreamUploadProgressIndicator( - total: 100, - uploaded: 100, - ), + ), + ); + + goldenTest( + 'golden test for StreamUploadProgressIndicator at 100% with background', + fileName: 'upload_progress_indicator_2', + constraints: const BoxConstraints.tightFor(width: 300, height: 300), + pumpBeforeTest: pumpOnce, + builder: () => MaterialAppWrapper( + home: StreamChatTheme( + data: StreamChatThemeData.light(), + child: const Scaffold( + body: Center( + child: StreamUploadProgressIndicator( + total: 100, + uploaded: 100, ), ), ), ), - ); - - await screenMatchesGolden(tester, 'upload_progress_indicator_2', - customPump: (widget) => widget.pump(const Duration(seconds: 3))); - }); + ), + ); } diff --git a/packages/stream_chat_flutter/test/src/message_input/attachment_button_test.dart b/packages/stream_chat_flutter/test/src/message_input/attachment_button_test.dart index 9f7d9ef1c..e6290edeb 100644 --- a/packages/stream_chat_flutter/test/src/message_input/attachment_button_test.dart +++ b/packages/stream_chat_flutter/test/src/message_input/attachment_button_test.dart @@ -1,6 +1,6 @@ +import 'package:alchemist/alchemist.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:stream_chat_flutter/src/message_input/attachment_button.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; @@ -33,22 +33,21 @@ void main() { expect(count, 1); }); - testGoldens('golden test for AttachmentButton', (tester) async { - await tester.pumpWidget( - MaterialAppWrapper( - home: Scaffold( - body: Center( - child: AttachmentButton( - color: StreamChatThemeData.light() - .messageInputTheme - .actionButtonIdleColor, - onPressed: () {}, - ), + goldenTest( + 'golden test for AttachmentButton', + fileName: 'attachment_button_0', + constraints: const BoxConstraints.tightFor(width: 50, height: 50), + builder: () => MaterialAppWrapper( + home: Scaffold( + body: Center( + child: AttachmentButton( + color: StreamChatThemeData.light() + .messageInputTheme + .actionButtonIdleColor, + onPressed: () {}, ), ), ), - ); - - await screenMatchesGolden(tester, 'attachment_button_0'); - }); + ), + ); } diff --git a/packages/stream_chat_flutter/test/src/message_input/clear_input_item_test.dart b/packages/stream_chat_flutter/test/src/message_input/clear_input_item_test.dart index fa661d75f..68d1f430f 100644 --- a/packages/stream_chat_flutter/test/src/message_input/clear_input_item_test.dart +++ b/packages/stream_chat_flutter/test/src/message_input/clear_input_item_test.dart @@ -1,6 +1,6 @@ +import 'package:alchemist/alchemist.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:stream_chat_flutter/src/message_input/clear_input_item_button.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; @@ -33,22 +33,21 @@ void main() { expect(count, 1); }); - testGoldens('golden test for ClearInputItemButton', (tester) async { - await tester.pumpWidget( - MaterialAppWrapper( - home: StreamChatTheme( - data: StreamChatThemeData.light(), - child: Scaffold( - body: Center( - child: ClearInputItemButton( - onTap: () {}, - ), + goldenTest( + 'golden test for ClearInputItemButton', + fileName: 'clear_input_item_0', + constraints: const BoxConstraints.tightFor(width: 50, height: 50), + builder: () => MaterialAppWrapper( + home: StreamChatTheme( + data: StreamChatThemeData.light(), + child: Scaffold( + body: Center( + child: ClearInputItemButton( + onTap: () {}, ), ), ), ), - ); - - await screenMatchesGolden(tester, 'clear_input_item_0'); - }); + ), + ); } diff --git a/packages/stream_chat_flutter/test/src/message_input/command_button_test.dart b/packages/stream_chat_flutter/test/src/message_input/command_button_test.dart index 8a7365ab8..fc7dad0b5 100644 --- a/packages/stream_chat_flutter/test/src/message_input/command_button_test.dart +++ b/packages/stream_chat_flutter/test/src/message_input/command_button_test.dart @@ -1,6 +1,6 @@ +import 'package:alchemist/alchemist.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:stream_chat_flutter/src/message_input/command_button.dart'; import '../material_app_wrapper.dart'; @@ -72,20 +72,19 @@ void main() { ); }); - testGoldens('golden test for CommandButton', (tester) async { - await tester.pumpWidget( - MaterialAppWrapper( - home: Scaffold( - body: Center( - child: CommandButton( - color: Colors.red, - onPressed: () {}, - ), + goldenTest( + 'golden test for CommandButton', + fileName: 'command_button_0', + constraints: const BoxConstraints.tightFor(width: 50, height: 50), + builder: () => MaterialAppWrapper( + home: Scaffold( + body: Center( + child: CommandButton( + color: Colors.blueAccent, + onPressed: () {}, ), ), ), - ); - - await screenMatchesGolden(tester, 'command_button_0'); - }); + ), + ); } diff --git a/packages/stream_chat_flutter/test/src/message_input/countdown_button_test.dart b/packages/stream_chat_flutter/test/src/message_input/countdown_button_test.dart index e55a36ed4..025f7db80 100644 --- a/packages/stream_chat_flutter/test/src/message_input/countdown_button_test.dart +++ b/packages/stream_chat_flutter/test/src/message_input/countdown_button_test.dart @@ -1,6 +1,6 @@ +import 'package:alchemist/alchemist.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import '../material_app_wrapper.dart'; @@ -23,20 +23,19 @@ void main() { expect(find.text('5'), findsOneWidget); }); - testGoldens('golden test for CountdownButton', (tester) async { - await tester.pumpWidget( - MaterialAppWrapper( - home: StreamChatTheme( - data: StreamChatThemeData.light(), - child: const Scaffold( - body: Center( - child: StreamCountdownButton(count: 5), - ), + goldenTest( + 'golden test for CountdownButton', + fileName: 'countdown_button_0', + constraints: const BoxConstraints.tightFor(width: 50, height: 50), + builder: () => MaterialAppWrapper( + home: StreamChatTheme( + data: StreamChatThemeData.light(), + child: const Scaffold( + body: Center( + child: StreamCountdownButton(count: 5), ), ), ), - ); - - await screenMatchesGolden(tester, 'countdown_button_0'); - }); + ), + ); } diff --git a/packages/stream_chat_flutter/test/src/message_input/dm_checkbox_test.dart b/packages/stream_chat_flutter/test/src/message_input/dm_checkbox_test.dart index 6d559bf18..f462b4a7d 100644 --- a/packages/stream_chat_flutter/test/src/message_input/dm_checkbox_test.dart +++ b/packages/stream_chat_flutter/test/src/message_input/dm_checkbox_test.dart @@ -1,6 +1,6 @@ +import 'package:alchemist/alchemist.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:stream_chat_flutter/src/message_input/dm_checkbox.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; @@ -46,93 +46,88 @@ void main() { expect(count, 1); }); - testGoldens('golden test for checked DmCheckbox with border', (tester) async { - await tester.pumpWidget( - MaterialAppWrapper( - home: StreamChatTheme( - data: StreamChatThemeData.light(), - child: Scaffold( - body: Center( - child: DmCheckbox( - foregroundDecoration: BoxDecoration( - border: Border.all( - color: StreamChatThemeData.light() - .colorTheme - .textHighEmphasis - // ignore: deprecated_member_use - .withOpacity(0.5), - width: 2, - ), - borderRadius: BorderRadius.circular(3), + goldenTest( + 'golden test for checked DmCheckbox with border', + fileName: 'dm_checkbox_0', + constraints: const BoxConstraints.tightFor(width: 200, height: 50), + builder: () => MaterialAppWrapper( + home: StreamChatTheme( + data: StreamChatThemeData.light(), + child: Scaffold( + body: Center( + child: DmCheckbox( + foregroundDecoration: BoxDecoration( + border: Border.all( + color: StreamChatThemeData.light() + .colorTheme + .textHighEmphasis + // ignore: deprecated_member_use + .withOpacity(0.5), + width: 2, ), - color: StreamChatThemeData.light().colorTheme.accentPrimary, - onTap: () {}, - crossFadeState: CrossFadeState.showFirst, + borderRadius: BorderRadius.circular(3), ), + color: StreamChatThemeData.light().colorTheme.accentPrimary, + onTap: () {}, + crossFadeState: CrossFadeState.showFirst, ), ), ), ), - ); - - await screenMatchesGolden(tester, 'dm_checkbox_0'); - }); + ), + ); - testGoldens('golden test for checked DmCheckbox without border', - (tester) async { - await tester.pumpWidget( - MaterialAppWrapper( - home: StreamChatTheme( - data: StreamChatThemeData.light(), - child: Scaffold( - body: Center( - child: DmCheckbox( - foregroundDecoration: BoxDecoration( - borderRadius: BorderRadius.circular(3), - ), - color: StreamChatThemeData.light().colorTheme.accentPrimary, - onTap: () {}, - crossFadeState: CrossFadeState.showFirst, + goldenTest( + 'golden test for checked DmCheckbox without border', + fileName: 'dm_checkbox_1', + constraints: const BoxConstraints.tightFor(width: 200, height: 50), + builder: () => MaterialAppWrapper( + home: StreamChatTheme( + data: StreamChatThemeData.light(), + child: Scaffold( + body: Center( + child: DmCheckbox( + foregroundDecoration: BoxDecoration( + borderRadius: BorderRadius.circular(3), ), + color: StreamChatThemeData.light().colorTheme.accentPrimary, + onTap: () {}, + crossFadeState: CrossFadeState.showFirst, ), ), ), ), - ); - - await screenMatchesGolden(tester, 'dm_checkbox_1'); - }); + ), + ); - testGoldens('golden test for unchecked DmCheckbox with border', - (tester) async { - await tester.pumpWidget( - MaterialAppWrapper( - home: StreamChatTheme( - data: StreamChatThemeData.light(), - child: Scaffold( - body: Center( - child: DmCheckbox( - foregroundDecoration: BoxDecoration( - border: Border.all( - color: StreamChatThemeData.light() - .colorTheme - .textHighEmphasis - // ignore: deprecated_member_use - .withOpacity(0.5), - width: 2, - ), - borderRadius: BorderRadius.circular(3), + goldenTest( + 'golden test for unchecked DmCheckbox with border', + fileName: 'dm_checkbox_2', + constraints: const BoxConstraints.tightFor(width: 200, height: 50), + builder: () => MaterialAppWrapper( + home: StreamChatTheme( + data: StreamChatThemeData.light(), + child: Scaffold( + body: Center( + child: DmCheckbox( + foregroundDecoration: BoxDecoration( + border: Border.all( + color: StreamChatThemeData.light() + .colorTheme + .textHighEmphasis + // ignore: deprecated_member_use + .withOpacity(0.5), + width: 2, ), - color: StreamChatThemeData.light().colorTheme.barsBg, - onTap: () {}, - crossFadeState: CrossFadeState.showSecond, + borderRadius: BorderRadius.circular(3), ), + color: StreamChatThemeData.light().colorTheme.barsBg, + onTap: () {}, + crossFadeState: CrossFadeState.showSecond, ), ), ), ), - ); - - await screenMatchesGolden(tester, 'dm_checkbox_2'); - }); + ), + ); } diff --git a/packages/stream_chat_flutter/test/src/message_input/goldens/ci/attachment_button_0.png b/packages/stream_chat_flutter/test/src/message_input/goldens/ci/attachment_button_0.png new file mode 100644 index 000000000..e7db21355 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/message_input/goldens/ci/attachment_button_0.png differ diff --git a/packages/stream_chat_flutter/test/src/message_input/goldens/ci/clear_input_item_0.png b/packages/stream_chat_flutter/test/src/message_input/goldens/ci/clear_input_item_0.png new file mode 100644 index 000000000..989e925b4 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/message_input/goldens/ci/clear_input_item_0.png differ diff --git a/packages/stream_chat_flutter/test/src/message_input/goldens/ci/command_button_0.png b/packages/stream_chat_flutter/test/src/message_input/goldens/ci/command_button_0.png new file mode 100644 index 000000000..e3be49ff0 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/message_input/goldens/ci/command_button_0.png differ diff --git a/packages/stream_chat_flutter/test/src/message_input/goldens/ci/countdown_button_0.png b/packages/stream_chat_flutter/test/src/message_input/goldens/ci/countdown_button_0.png new file mode 100644 index 000000000..9d4da4d30 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/message_input/goldens/ci/countdown_button_0.png differ diff --git a/packages/stream_chat_flutter/test/src/message_input/goldens/ci/dm_checkbox_0.png b/packages/stream_chat_flutter/test/src/message_input/goldens/ci/dm_checkbox_0.png new file mode 100644 index 000000000..644c062bd Binary files /dev/null and b/packages/stream_chat_flutter/test/src/message_input/goldens/ci/dm_checkbox_0.png differ diff --git a/packages/stream_chat_flutter/test/src/message_input/goldens/ci/dm_checkbox_1.png b/packages/stream_chat_flutter/test/src/message_input/goldens/ci/dm_checkbox_1.png new file mode 100644 index 000000000..0626b48b9 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/message_input/goldens/ci/dm_checkbox_1.png differ diff --git a/packages/stream_chat_flutter/test/src/message_input/goldens/ci/dm_checkbox_2.png b/packages/stream_chat_flutter/test/src/message_input/goldens/ci/dm_checkbox_2.png new file mode 100644 index 000000000..340ddb3eb Binary files /dev/null and b/packages/stream_chat_flutter/test/src/message_input/goldens/ci/dm_checkbox_2.png differ diff --git a/packages/stream_chat_flutter/test/src/message_widget/deleted_message_test.dart b/packages/stream_chat_flutter/test/src/message_widget/deleted_message_test.dart index 9f18c56c6..1a33a4db2 100644 --- a/packages/stream_chat_flutter/test/src/message_widget/deleted_message_test.dart +++ b/packages/stream_chat_flutter/test/src/message_widget/deleted_message_test.dart @@ -1,48 +1,46 @@ +import 'package:alchemist/alchemist.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:mocktail/mocktail.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import '../material_app_wrapper.dart'; import '../mocks.dart'; -import '../widget_tester_extension.dart'; void main() { - testWidgets( - 'control test', - (WidgetTester tester) async { - final client = MockClient(); - final clientState = MockClientState(); + testWidgets('control test', (tester) async { + final client = MockClient(); + final clientState = MockClientState(); - when(() => client.state).thenReturn(clientState); - when(() => clientState.currentUser).thenReturn(OwnUser(id: 'user-id')); + when(() => client.state).thenReturn(clientState); + when(() => clientState.currentUser).thenReturn(OwnUser(id: 'user-id')); - await tester.pumpWidget( - MaterialApp( - home: StreamChat( - client: client, - child: const Scaffold( - body: StreamDeletedMessage( - messageTheme: StreamMessageThemeData( - createdAtStyle: TextStyle( - color: Colors.black, - ), - messageTextStyle: TextStyle(), + await tester.pumpWidget( + MaterialApp( + home: StreamChat( + client: client, + child: const Scaffold( + body: StreamDeletedMessage( + messageTheme: StreamMessageThemeData( + createdAtStyle: TextStyle( + color: Colors.black, ), + messageTextStyle: TextStyle(), ), ), ), ), - ); + ), + ); - expect(find.text('Message deleted'), findsOneWidget); - }, - ); + expect(find.text('Message deleted'), findsOneWidget); + }); - testGoldens( + goldenTest( 'control golden light', - (WidgetTester tester) async { + fileName: 'deleted_message_light', + constraints: const BoxConstraints.tightFor(width: 200, height: 200), + builder: () { final client = MockClient(); final clientState = MockClientState(); final channel = MockChannel(); @@ -71,8 +69,9 @@ void main() { useMaterial3: false, ); final theme = StreamChatThemeData.fromTheme(materialTheme); - await tester.pumpWidgetBuilder( - StreamChat( + return MaterialAppWrapper( + theme: materialTheme, + home: StreamChat( streamChatThemeData: theme, client: client, connectivityStream: Stream.value([ConnectivityResult.mobile]), @@ -88,20 +87,15 @@ void main() { ), ), ), - surfaceSize: const Size.square(200), - wrapper: (child) => MaterialAppWrapper( - theme: materialTheme, - home: child, - ), ); - - await screenMatchesGolden(tester, 'deleted_message_light'); }, ); - testGoldens( + goldenTest( 'control golden dark', - (WidgetTester tester) async { + fileName: 'deleted_message_dark', + constraints: const BoxConstraints.tightFor(width: 200, height: 200), + builder: () { final client = MockClient(); final clientState = MockClientState(); final channel = MockChannel(); @@ -130,36 +124,33 @@ void main() { useMaterial3: false, ); final theme = StreamChatThemeData.fromTheme(materialTheme); - await tester.pumpWidgetWithSize( - MaterialAppWrapper( - theme: materialTheme, - home: StreamChat( - streamChatThemeData: theme, - client: client, - connectivityStream: Stream.value([ConnectivityResult.mobile]), - child: StreamChannel( - showLoading: false, - channel: channel, - child: Scaffold( - body: Center( - child: StreamDeletedMessage( - messageTheme: theme.ownMessageTheme, - ), + return MaterialAppWrapper( + theme: materialTheme, + home: StreamChat( + streamChatThemeData: theme, + client: client, + connectivityStream: Stream.value([ConnectivityResult.mobile]), + child: StreamChannel( + showLoading: false, + channel: channel, + child: Scaffold( + body: Center( + child: StreamDeletedMessage( + messageTheme: theme.ownMessageTheme, ), ), ), ), ), - size: const Size.square(200), ); - - await screenMatchesGolden(tester, 'deleted_message_dark'); }, ); - testGoldens( + goldenTest( 'golden customization test', - (WidgetTester tester) async { + fileName: 'deleted_message_custom', + constraints: const BoxConstraints.tightFor(width: 200, height: 200), + builder: () { final client = MockClient(); final clientState = MockClientState(); final channel = MockChannel(); @@ -188,34 +179,29 @@ void main() { useMaterial3: false, ); final theme = StreamChatThemeData.fromTheme(materialTheme); - await tester.pumpWidgetWithSize( - MaterialAppWrapper( - theme: materialTheme, - home: StreamChat( - streamChatThemeData: theme, - client: client, - connectivityStream: Stream.value([ConnectivityResult.mobile]), - child: StreamChannel( - showLoading: false, - channel: channel, - child: Scaffold( - body: Center( - child: StreamDeletedMessage( - messageTheme: theme.ownMessageTheme, - reverse: true, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), - ), + return MaterialAppWrapper( + theme: materialTheme, + home: StreamChat( + streamChatThemeData: theme, + client: client, + connectivityStream: Stream.value([ConnectivityResult.mobile]), + child: StreamChannel( + showLoading: false, + channel: channel, + child: Scaffold( + body: Center( + child: StreamDeletedMessage( + messageTheme: theme.ownMessageTheme, + reverse: true, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), ), ), ), ), ), ), - size: const Size.square(200), ); - - await screenMatchesGolden(tester, 'deleted_message_custom'); }, ); } diff --git a/packages/stream_chat_flutter/test/src/message_widget/goldens/ci/deleted_message_custom.png b/packages/stream_chat_flutter/test/src/message_widget/goldens/ci/deleted_message_custom.png new file mode 100644 index 000000000..1a7c5174d Binary files /dev/null and b/packages/stream_chat_flutter/test/src/message_widget/goldens/ci/deleted_message_custom.png differ diff --git a/packages/stream_chat_flutter/test/src/message_widget/goldens/ci/deleted_message_dark.png b/packages/stream_chat_flutter/test/src/message_widget/goldens/ci/deleted_message_dark.png new file mode 100644 index 000000000..9b7f30f4b Binary files /dev/null and b/packages/stream_chat_flutter/test/src/message_widget/goldens/ci/deleted_message_dark.png differ diff --git a/packages/stream_chat_flutter/test/src/message_widget/goldens/ci/deleted_message_light.png b/packages/stream_chat_flutter/test/src/message_widget/goldens/ci/deleted_message_light.png new file mode 100644 index 000000000..6c46e0739 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/message_widget/goldens/ci/deleted_message_light.png differ diff --git a/packages/stream_chat_flutter/test/src/message_widget/goldens/ci/message_text.png b/packages/stream_chat_flutter/test/src/message_widget/goldens/ci/message_text.png new file mode 100644 index 000000000..656da4e1c Binary files /dev/null and b/packages/stream_chat_flutter/test/src/message_widget/goldens/ci/message_text.png differ diff --git a/packages/stream_chat_flutter/test/src/message_widget/message_text_test.dart b/packages/stream_chat_flutter/test/src/message_widget/message_text_test.dart index d33b24f70..e02b2b119 100644 --- a/packages/stream_chat_flutter/test/src/message_widget/message_text_test.dart +++ b/packages/stream_chat_flutter/test/src/message_widget/message_text_test.dart @@ -1,7 +1,7 @@ +import 'package:alchemist/alchemist.dart'; import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:mocktail/mocktail.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; @@ -177,9 +177,11 @@ void main() { ); }); - testGoldens( + goldenTest( 'control test', - (WidgetTester tester) async { + fileName: 'message_text', + constraints: const BoxConstraints.tightFor(width: 300, height: 200), + builder: () { final currentUser = OwnUser(id: 'user-id'); final client = MockClient(); final clientState = MockClientState(); @@ -216,9 +218,8 @@ and a list: cool.'''; - await tester.pumpWidgetBuilder( - MaterialAppWrapper( - home: SimpleFrame( + return MaterialAppWrapper( + home: SimpleFrame( child: StreamChat( client: client, connectivityStream: Stream.value([ConnectivityResult.wifi]), @@ -234,10 +235,8 @@ cool.'''; ), ), ), - )), - surfaceSize: const Size(500, 500), + ), ); - await screenMatchesGolden(tester, 'message_text'); }, ); } diff --git a/packages/stream_chat_flutter/test/src/misc/goldens/ci/reaction_bubble_2.png b/packages/stream_chat_flutter/test/src/misc/goldens/ci/reaction_bubble_2.png new file mode 100644 index 000000000..a7daaa305 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/misc/goldens/ci/reaction_bubble_2.png differ diff --git a/packages/stream_chat_flutter/test/src/misc/goldens/ci/reaction_bubble_3_dark.png b/packages/stream_chat_flutter/test/src/misc/goldens/ci/reaction_bubble_3_dark.png new file mode 100644 index 000000000..2a88d12d6 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/misc/goldens/ci/reaction_bubble_3_dark.png differ diff --git a/packages/stream_chat_flutter/test/src/misc/goldens/ci/reaction_bubble_3_light.png b/packages/stream_chat_flutter/test/src/misc/goldens/ci/reaction_bubble_3_light.png new file mode 100644 index 000000000..a2f9afc0b Binary files /dev/null and b/packages/stream_chat_flutter/test/src/misc/goldens/ci/reaction_bubble_3_light.png differ diff --git a/packages/stream_chat_flutter/test/src/misc/goldens/ci/reaction_bubble_like_dark.png b/packages/stream_chat_flutter/test/src/misc/goldens/ci/reaction_bubble_like_dark.png new file mode 100644 index 000000000..b9fdc003c Binary files /dev/null and b/packages/stream_chat_flutter/test/src/misc/goldens/ci/reaction_bubble_like_dark.png differ diff --git a/packages/stream_chat_flutter/test/src/misc/goldens/ci/reaction_bubble_like_light.png b/packages/stream_chat_flutter/test/src/misc/goldens/ci/reaction_bubble_like_light.png new file mode 100644 index 000000000..5d5d6e1ba Binary files /dev/null and b/packages/stream_chat_flutter/test/src/misc/goldens/ci/reaction_bubble_like_light.png differ diff --git a/packages/stream_chat_flutter/test/src/misc/goldens/ci/system_message_dark.png b/packages/stream_chat_flutter/test/src/misc/goldens/ci/system_message_dark.png new file mode 100644 index 000000000..c22da26c2 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/misc/goldens/ci/system_message_dark.png differ diff --git a/packages/stream_chat_flutter/test/src/misc/goldens/ci/system_message_light.png b/packages/stream_chat_flutter/test/src/misc/goldens/ci/system_message_light.png new file mode 100644 index 000000000..2eae25144 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/misc/goldens/ci/system_message_light.png differ diff --git a/packages/stream_chat_flutter/test/src/misc/reaction_bubble_test.dart b/packages/stream_chat_flutter/test/src/misc/reaction_bubble_test.dart index 55adbea44..2dd7ef0b1 100644 --- a/packages/stream_chat_flutter/test/src/misc/reaction_bubble_test.dart +++ b/packages/stream_chat_flutter/test/src/misc/reaction_bubble_test.dart @@ -1,6 +1,5 @@ +import 'package:alchemist/alchemist.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:mocktail/mocktail.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; @@ -8,9 +7,11 @@ import '../material_app_wrapper.dart'; import '../mocks.dart'; void main() { - testGoldens( + goldenTest( 'it should show a like - light theme', - (WidgetTester tester) async { + fileName: 'reaction_bubble_like_light', + constraints: const BoxConstraints.tightFor(width: 100, height: 100), + builder: () { final client = MockClient(); final clientState = MockClientState(); final themeData = ThemeData.light( @@ -21,8 +22,9 @@ void main() { when(() => clientState.currentUser).thenReturn(OwnUser(id: 'user-id')); final theme = StreamChatThemeData.fromTheme(themeData); - await tester.pumpWidgetBuilder( - StreamChat( + return MaterialAppWrapper( + theme: themeData, + home: StreamChat( client: client, streamChatThemeData: theme, connectivityStream: Stream.value([ConnectivityResult.mobile]), @@ -43,19 +45,15 @@ void main() { ), ), ), - surfaceSize: const Size(100, 100), - wrapper: (child) => MaterialAppWrapper( - theme: themeData, - home: child, - ), ); - await screenMatchesGolden(tester, 'reaction_bubble_like_light'); }, ); - testGoldens( + goldenTest( 'it should show a like - dark theme', - (WidgetTester tester) async { + fileName: 'reaction_bubble_like_dark', + constraints: const BoxConstraints.tightFor(width: 100, height: 100), + builder: () { final client = MockClient(); final clientState = MockClientState(); final themeData = ThemeData.dark(); @@ -64,35 +62,38 @@ void main() { when(() => client.state).thenReturn(clientState); when(() => clientState.currentUser).thenReturn(OwnUser(id: 'user-id')); - await tester.pumpWidgetBuilder( - StreamChat( + return MaterialAppWrapper( + theme: themeData, + home: StreamChat( client: client, streamChatThemeData: StreamChatThemeData.fromTheme(themeData), connectivityStream: Stream.value([ConnectivityResult.mobile]), - child: ColoredBox( - color: Colors.black, - child: StreamReactionBubble( - reactions: [ - Reaction( - type: 'like', - user: User(id: 'test'), - ), - ], - borderColor: theme.ownMessageTheme.reactionsBorderColor!, - backgroundColor: theme.ownMessageTheme.reactionsBackgroundColor!, - maskColor: theme.ownMessageTheme.reactionsMaskColor!, + child: Scaffold( + body: Center( + child: StreamReactionBubble( + reactions: [ + Reaction( + type: 'like', + user: User(id: 'test'), + ), + ], + borderColor: theme.ownMessageTheme.reactionsBorderColor!, + backgroundColor: + theme.ownMessageTheme.reactionsBackgroundColor!, + maskColor: theme.ownMessageTheme.reactionsMaskColor!, + ), ), ), ), - surfaceSize: const Size(100, 100), ); - await screenMatchesGolden(tester, 'reaction_bubble_like_dark'); }, ); - testGoldens( + goldenTest( 'it should show three reactions - light theme', - (WidgetTester tester) async { + fileName: 'reaction_bubble_3_light', + constraints: const BoxConstraints.tightFor(width: 140, height: 140), + builder: () { final client = MockClient(); final clientState = MockClientState(); final themeData = ThemeData.light(); @@ -101,43 +102,46 @@ void main() { when(() => client.state).thenReturn(clientState); when(() => clientState.currentUser).thenReturn(OwnUser(id: 'user-id')); - await tester.pumpWidgetBuilder( - StreamChat( + return MaterialAppWrapper( + theme: themeData, + home: StreamChat( client: client, streamChatThemeData: StreamChatThemeData.fromTheme(themeData), connectivityStream: Stream.value([ConnectivityResult.mobile]), - child: ColoredBox( - color: Colors.black, - child: StreamReactionBubble( - reactions: [ - Reaction( - type: 'like', - user: User(id: 'test'), - ), - Reaction( - type: 'like', - user: User(id: 'user-id'), - ), - Reaction( - type: 'like', - user: User(id: 'test'), - ), - ], - borderColor: theme.ownMessageTheme.reactionsBorderColor!, - backgroundColor: theme.ownMessageTheme.reactionsBackgroundColor!, - maskColor: theme.ownMessageTheme.reactionsMaskColor!, + child: Scaffold( + body: Center( + child: StreamReactionBubble( + reactions: [ + Reaction( + type: 'like', + user: User(id: 'test'), + ), + Reaction( + type: 'like', + user: User(id: 'user-id'), + ), + Reaction( + type: 'like', + user: User(id: 'test'), + ), + ], + borderColor: theme.ownMessageTheme.reactionsBorderColor!, + backgroundColor: + theme.ownMessageTheme.reactionsBackgroundColor!, + maskColor: theme.ownMessageTheme.reactionsMaskColor!, + ), ), ), ), - surfaceSize: const Size(140, 140), ); - await screenMatchesGolden(tester, 'reaction_bubble_3_light'); }, ); - testGoldens( + goldenTest( 'it should show three reactions - dark theme', - (WidgetTester tester) async { + fileName: 'reaction_bubble_3_dark', + constraints: const BoxConstraints.tightFor(width: 140, height: 140), + builder: () { final client = MockClient(); final clientState = MockClientState(); final themeData = ThemeData.dark(); @@ -146,43 +150,46 @@ void main() { when(() => client.state).thenReturn(clientState); when(() => clientState.currentUser).thenReturn(OwnUser(id: 'user-id')); - await tester.pumpWidgetBuilder( - StreamChat( + return MaterialAppWrapper( + theme: themeData, + home: StreamChat( client: client, streamChatThemeData: StreamChatThemeData.fromTheme(themeData), connectivityStream: Stream.value([ConnectivityResult.mobile]), - child: ColoredBox( - color: Colors.black, - child: StreamReactionBubble( - reactions: [ - Reaction( - type: 'like', - user: User(id: 'test'), - ), - Reaction( - type: 'like', - user: User(id: 'user-id'), - ), - Reaction( - type: 'like', - user: User(id: 'test'), - ), - ], - borderColor: theme.ownMessageTheme.reactionsBorderColor!, - backgroundColor: theme.ownMessageTheme.reactionsBackgroundColor!, - maskColor: theme.ownMessageTheme.reactionsMaskColor!, + child: Scaffold( + body: Center( + child: StreamReactionBubble( + reactions: [ + Reaction( + type: 'like', + user: User(id: 'test'), + ), + Reaction( + type: 'like', + user: User(id: 'user-id'), + ), + Reaction( + type: 'like', + user: User(id: 'test'), + ), + ], + borderColor: theme.ownMessageTheme.reactionsBorderColor!, + backgroundColor: + theme.ownMessageTheme.reactionsBackgroundColor!, + maskColor: theme.ownMessageTheme.reactionsMaskColor!, + ), ), ), ), - surfaceSize: const Size(140, 140), ); - await screenMatchesGolden(tester, 'reaction_bubble_3_dark'); }, ); - testGoldens( + goldenTest( 'it should show two reactions with customized ui', - (WidgetTester tester) async { + fileName: 'reaction_bubble_2', + constraints: const BoxConstraints.tightFor(width: 200, height: 200), + builder: () { final client = MockClient(); final clientState = MockClientState(); final themeData = ThemeData( @@ -192,8 +199,9 @@ void main() { when(() => client.state).thenReturn(clientState); when(() => clientState.currentUser).thenReturn(OwnUser(id: 'user-id')); - await tester.pumpWidgetBuilder( - StreamChat( + return MaterialAppWrapper( + theme: themeData, + home: StreamChat( client: client, connectivityStream: Stream.value([ConnectivityResult.mobile]), streamChatThemeData: StreamChatThemeData.fromTheme(themeData), @@ -224,14 +232,7 @@ void main() { ), ), ), - surfaceSize: const Size(200, 200), - wrapper: (child) => MaterialAppWrapper( - theme: themeData, - home: child, - ), ); - - await screenMatchesGolden(tester, 'reaction_bubble_2'); }, ); } diff --git a/packages/stream_chat_flutter/test/src/misc/system_message_test.dart b/packages/stream_chat_flutter/test/src/misc/system_message_test.dart index 73537c657..932e8cd74 100644 --- a/packages/stream_chat_flutter/test/src/misc/system_message_test.dart +++ b/packages/stream_chat_flutter/test/src/misc/system_message_test.dart @@ -1,6 +1,6 @@ +import 'package:alchemist/alchemist.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:mocktail/mocktail.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; @@ -61,9 +61,11 @@ void main() { }, ); - testGoldens( + goldenTest( 'control golden light', - (WidgetTester tester) async { + fileName: 'system_message_light', + constraints: const BoxConstraints.tightFor(width: 200, height: 200), + builder: () { final client = MockClient(); final clientState = MockClientState(); final channel = MockChannel(); @@ -88,8 +90,9 @@ void main() { when(() => clientState.totalUnreadCountStream) .thenAnswer((i) => Stream.value(10)); - await tester.pumpWidgetBuilder( - StreamChat( + return MaterialAppWrapper( + theme: ThemeData.light(), + home: StreamChat( client: client, connectivityStream: Stream.value([ConnectivityResult.mobile]), child: StreamChannel( @@ -106,19 +109,15 @@ void main() { ), ), ), - surfaceSize: const Size.square(200), - wrapper: (child) => MaterialAppWrapper( - home: child, - ), ); - - await screenMatchesGolden(tester, 'system_message_light'); }, ); - testGoldens( + goldenTest( 'control golden dark', - (WidgetTester tester) async { + fileName: 'system_message_dark', + constraints: const BoxConstraints.tightFor(width: 200, height: 200), + builder: () { final client = MockClient(); final clientState = MockClientState(); final channel = MockChannel(); @@ -143,8 +142,9 @@ void main() { when(() => clientState.totalUnreadCountStream) .thenAnswer((i) => Stream.value(10)); - await tester.pumpWidgetBuilder( - StreamChat( + return MaterialAppWrapper( + theme: ThemeData.dark(), + home: StreamChat( client: client, connectivityStream: Stream.value([ConnectivityResult.mobile]), child: StreamChannel( @@ -161,16 +161,7 @@ void main() { ), ), ), - surfaceSize: const Size.square(200), - wrapper: (child) => MaterialAppWrapper( - theme: ThemeData.dark( - useMaterial3: false, - ), - home: child, - ), ); - - await screenMatchesGolden(tester, 'system_message_dark'); }, ); } diff --git a/packages/stream_chat_flutter/test/src/poll/goldens/ci/poll_option_reorderable_list_view_dark.png b/packages/stream_chat_flutter/test/src/poll/goldens/ci/poll_option_reorderable_list_view_dark.png new file mode 100644 index 000000000..c868e9e93 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/poll/goldens/ci/poll_option_reorderable_list_view_dark.png differ diff --git a/packages/stream_chat_flutter/test/src/poll/goldens/ci/poll_option_reorderable_list_view_error.png b/packages/stream_chat_flutter/test/src/poll/goldens/ci/poll_option_reorderable_list_view_error.png new file mode 100644 index 000000000..00952a8c3 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/poll/goldens/ci/poll_option_reorderable_list_view_error.png differ diff --git a/packages/stream_chat_flutter/test/src/poll/goldens/ci/poll_option_reorderable_list_view_light.png b/packages/stream_chat_flutter/test/src/poll/goldens/ci/poll_option_reorderable_list_view_light.png new file mode 100644 index 000000000..0d90fd848 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/poll/goldens/ci/poll_option_reorderable_list_view_light.png differ diff --git a/packages/stream_chat_flutter/test/src/poll/goldens/ci/poll_question_text_field_dark.png b/packages/stream_chat_flutter/test/src/poll/goldens/ci/poll_question_text_field_dark.png new file mode 100644 index 000000000..a6dfc2bf4 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/poll/goldens/ci/poll_question_text_field_dark.png differ diff --git a/packages/stream_chat_flutter/test/src/poll/goldens/ci/poll_question_text_field_error.png b/packages/stream_chat_flutter/test/src/poll/goldens/ci/poll_question_text_field_error.png new file mode 100644 index 000000000..4b873c709 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/poll/goldens/ci/poll_question_text_field_error.png differ diff --git a/packages/stream_chat_flutter/test/src/poll/goldens/ci/poll_question_text_field_light.png b/packages/stream_chat_flutter/test/src/poll/goldens/ci/poll_question_text_field_light.png new file mode 100644 index 000000000..86a99f7cc Binary files /dev/null and b/packages/stream_chat_flutter/test/src/poll/goldens/ci/poll_question_text_field_light.png differ diff --git a/packages/stream_chat_flutter/test/src/poll/goldens/ci/stream_poll_creator_dialog_dark.png b/packages/stream_chat_flutter/test/src/poll/goldens/ci/stream_poll_creator_dialog_dark.png new file mode 100644 index 000000000..0ed7b6f37 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/poll/goldens/ci/stream_poll_creator_dialog_dark.png differ diff --git a/packages/stream_chat_flutter/test/src/poll/goldens/ci/stream_poll_creator_dialog_light.png b/packages/stream_chat_flutter/test/src/poll/goldens/ci/stream_poll_creator_dialog_light.png new file mode 100644 index 000000000..af940eb08 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/poll/goldens/ci/stream_poll_creator_dialog_light.png differ diff --git a/packages/stream_chat_flutter/test/src/poll/goldens/ci/stream_poll_creator_full_screen_dialog_dark.png b/packages/stream_chat_flutter/test/src/poll/goldens/ci/stream_poll_creator_full_screen_dialog_dark.png new file mode 100644 index 000000000..5c361040f Binary files /dev/null and b/packages/stream_chat_flutter/test/src/poll/goldens/ci/stream_poll_creator_full_screen_dialog_dark.png differ diff --git a/packages/stream_chat_flutter/test/src/poll/goldens/ci/stream_poll_creator_full_screen_dialog_light.png b/packages/stream_chat_flutter/test/src/poll/goldens/ci/stream_poll_creator_full_screen_dialog_light.png new file mode 100644 index 000000000..37da34d23 Binary files /dev/null and b/packages/stream_chat_flutter/test/src/poll/goldens/ci/stream_poll_creator_full_screen_dialog_light.png differ diff --git a/packages/stream_chat_flutter/test/src/poll/poll_option_reorderable_list_view_test.dart b/packages/stream_chat_flutter/test/src/poll/poll_option_reorderable_list_view_test.dart index 4c4904d3b..f7d082377 100644 --- a/packages/stream_chat_flutter/test/src/poll/poll_option_reorderable_list_view_test.dart +++ b/packages/stream_chat_flutter/test/src/poll/poll_option_reorderable_list_view_test.dart @@ -1,88 +1,63 @@ +import 'package:alchemist/alchemist.dart'; import 'package:flutter/material.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:stream_chat_flutter/src/poll/poll_option_reorderable_list_view.dart'; import 'package:stream_chat_flutter/src/theme/stream_chat_theme.dart'; void main() { - testGoldens( + goldenTest( '[Light] -> PollOptionReorderableListView should look fine', - (tester) async { - await tester.pumpWidgetBuilder( - PollOptionReorderableListView( - title: 'Options', - itemHintText: 'Add an option', - initialOptions: [ - PollOptionItem(text: 'Option 1'), - PollOptionItem(text: 'Option 2'), - PollOptionItem(text: 'Option 3'), - PollOptionItem(text: 'Option 4'), - ], - ), - surfaceSize: const Size(600, 500), - wrapper: (child) => _wrapWithMaterialApp( - child, - brightness: Brightness.light, - ), - ); - - await screenMatchesGolden( - tester, - 'poll_option_reorderable_list_view_light', - ); - }, + fileName: 'poll_option_reorderable_list_view_light', + constraints: const BoxConstraints.tightFor(width: 600, height: 500), + builder: () => _wrapWithMaterialApp( + brightness: Brightness.light, + PollOptionReorderableListView( + title: 'Options', + itemHintText: 'Add an option', + initialOptions: [ + PollOptionItem(text: 'Option 1'), + PollOptionItem(text: 'Option 2'), + PollOptionItem(text: 'Option 3'), + PollOptionItem(text: 'Option 4'), + ], + ), + ), ); - testGoldens( + goldenTest( '[Dark] -> PollOptionReorderableListView should look fine', - (tester) async { - await tester.pumpWidgetBuilder( - PollOptionReorderableListView( - title: 'Options', - itemHintText: 'Add an option', - initialOptions: [ - PollOptionItem(text: 'Option 1'), - PollOptionItem(text: 'Option 2'), - PollOptionItem(text: 'Option 3'), - PollOptionItem(text: 'Option 4'), - ], - ), - surfaceSize: const Size(600, 500), - wrapper: (child) => _wrapWithMaterialApp( - child, - brightness: Brightness.dark, - ), - ); - - await screenMatchesGolden( - tester, - 'poll_option_reorderable_list_view_dark', - ); - }, + fileName: 'poll_option_reorderable_list_view_dark', + constraints: const BoxConstraints.tightFor(width: 600, height: 500), + builder: () => _wrapWithMaterialApp( + brightness: Brightness.dark, + PollOptionReorderableListView( + title: 'Options', + itemHintText: 'Add an option', + initialOptions: [ + PollOptionItem(text: 'Option 1'), + PollOptionItem(text: 'Option 2'), + PollOptionItem(text: 'Option 3'), + PollOptionItem(text: 'Option 4'), + ], + ), + ), ); - testGoldens( + goldenTest( '[Error] -> PollOptionReorderableListView should look fine', - (tester) async { - await tester.pumpWidgetBuilder( - PollOptionReorderableListView( - title: 'Options', - itemHintText: 'Add an option', - initialOptions: [ - PollOptionItem(text: 'Option 1', error: 'Option already exists'), - PollOptionItem(text: 'Option 1', error: 'Option already exists'), - PollOptionItem(text: 'Option 3'), - PollOptionItem(text: 'Option 4'), - ], - ), - surfaceSize: const Size(600, 500), - wrapper: _wrapWithMaterialApp, - ); - - await screenMatchesGolden( - tester, - 'poll_option_reorderable_list_view_error', - ); - }, + fileName: 'poll_option_reorderable_list_view_error', + constraints: const BoxConstraints.tightFor(width: 600, height: 500), + builder: () => _wrapWithMaterialApp( + PollOptionReorderableListView( + title: 'Options', + itemHintText: 'Add an option', + initialOptions: [ + PollOptionItem(text: 'Option 1', error: 'Option already exists'), + PollOptionItem(text: 'Option 1', error: 'Option already exists'), + PollOptionItem(text: 'Option 3'), + PollOptionItem(text: 'Option 4'), + ], + ), + ), ); } diff --git a/packages/stream_chat_flutter/test/src/poll/poll_question_text_field_test.dart b/packages/stream_chat_flutter/test/src/poll/poll_question_text_field_test.dart index f352b16d3..1024ce535 100644 --- a/packages/stream_chat_flutter/test/src/poll/poll_question_text_field_test.dart +++ b/packages/stream_chat_flutter/test/src/poll/poll_question_text_field_test.dart @@ -1,66 +1,50 @@ +import 'package:alchemist/alchemist.dart'; import 'package:flutter/material.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:stream_chat_flutter/src/poll/poll_question_text_field.dart'; import 'package:stream_chat_flutter/src/theme/stream_chat_theme.dart'; void main() { - testGoldens( + goldenTest( '[Light] -> PollQuestionTextField should look fine', - (tester) async { - await tester.pumpWidgetBuilder( - PollQuestionTextField( - title: 'Question', - hintText: 'Ask a question', - initialQuestion: PollQuestion(), - ), - surfaceSize: const Size(600, 150), - wrapper: (child) => _wrapWithMaterialApp( - child, - brightness: Brightness.light, - ), - ); - - await screenMatchesGolden(tester, 'poll_question_text_field_light'); - }, - ); - - testGoldens( - '[Dark] -> PollQuestionTextField should look fine', - (tester) async { - await tester.pumpWidgetBuilder( - PollQuestionTextField( - title: 'Question', - initialQuestion: PollQuestion( - text: 'A very long question that should not be allowed', - error: 'Question should be at most 10 characters long', - ), - ), - surfaceSize: const Size(600, 150), - wrapper: _wrapWithMaterialApp, - ); - - await screenMatchesGolden(tester, 'poll_question_text_field_error'); - }, + fileName: 'poll_question_text_field_light', + constraints: const BoxConstraints.tightFor(width: 600, height: 150), + builder: () => _wrapWithMaterialApp( + brightness: Brightness.light, + PollQuestionTextField( + title: 'Question', + hintText: 'Ask a question', + initialQuestion: PollQuestion(), + ), + ), ); - testGoldens( + goldenTest( '[Error] -> PollQuestionTextField should look fine', - (tester) async { - await tester.pumpWidgetBuilder( - PollQuestionTextField( - title: 'Question', - hintText: 'Ask a question', - initialQuestion: PollQuestion(), + fileName: 'poll_question_text_field_error', + constraints: const BoxConstraints.tightFor(width: 600, height: 150), + builder: () => _wrapWithMaterialApp( + PollQuestionTextField( + title: 'Question', + initialQuestion: PollQuestion( + text: 'A very long question that should not be allowed', + error: 'Question should be at most 10 characters long', ), - surfaceSize: const Size(600, 150), - wrapper: (child) => _wrapWithMaterialApp( - child, - brightness: Brightness.dark, - ), - ); + ), + ), + ); - await screenMatchesGolden(tester, 'poll_question_text_field_dark'); - }, + goldenTest( + '[Dark] -> PollQuestionTextField should look fine', + fileName: 'poll_question_text_field_dark', + constraints: const BoxConstraints.tightFor(width: 600, height: 150), + builder: () => _wrapWithMaterialApp( + brightness: Brightness.dark, + PollQuestionTextField( + title: 'Question', + hintText: 'Ask a question', + initialQuestion: PollQuestion(), + ), + ), ); } diff --git a/packages/stream_chat_flutter/test/src/poll/stream_poll_creator_dialog_test.dart b/packages/stream_chat_flutter/test/src/poll/stream_poll_creator_dialog_test.dart index 0b7026f60..376b4064c 100644 --- a/packages/stream_chat_flutter/test/src/poll/stream_poll_creator_dialog_test.dart +++ b/packages/stream_chat_flutter/test/src/poll/stream_poll_creator_dialog_test.dart @@ -1,77 +1,47 @@ +import 'package:alchemist/alchemist.dart'; import 'package:flutter/material.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:stream_chat_flutter/src/poll/stream_poll_creator_dialog.dart'; import 'package:stream_chat_flutter/src/theme/stream_chat_theme.dart'; void main() { - testGoldens( + goldenTest( '[Light] -> StreamPollCreatorDialog should look fine', - (tester) async { - await tester.pumpWidgetBuilder( - const StreamPollCreatorDialog(), - surfaceSize: const Size(1280, 800), - wrapper: (child) => _wrapWithMaterialApp( - child, - brightness: Brightness.light, - ), - ); - - await screenMatchesGolden(tester, 'stream_poll_creator_dialog_light'); - }, + fileName: 'stream_poll_creator_dialog_light', + constraints: const BoxConstraints.tightFor(width: 1280, height: 800), + builder: () => _wrapWithMaterialApp( + brightness: Brightness.light, + const StreamPollCreatorDialog(), + ), ); - testGoldens( + goldenTest( '[Dark] -> StreamPollCreatorDialog should look fine', - (tester) async { - await tester.pumpWidgetBuilder( - const StreamPollCreatorDialog(), - surfaceSize: const Size(1280, 800), - wrapper: (child) => _wrapWithMaterialApp( - child, - brightness: Brightness.dark, - ), - ); - - await screenMatchesGolden(tester, 'stream_poll_creator_dialog_dark'); - }, + fileName: 'stream_poll_creator_dialog_dark', + constraints: const BoxConstraints.tightFor(width: 1280, height: 800), + builder: () => _wrapWithMaterialApp( + brightness: Brightness.dark, + const StreamPollCreatorDialog(), + ), ); - testGoldens( + goldenTest( '[Light] -> StreamPollCreatorFullScreenDialog should look fine', - (tester) async { - await tester.pumpWidgetBuilder( - const StreamPollCreatorFullScreenDialog(), - surfaceSize: const Size(412, 916), - wrapper: (child) => _wrapWithMaterialApp( - child, - brightness: Brightness.light, - ), - ); - - await screenMatchesGolden( - tester, - 'stream_poll_creator_full_screen_dialog_light', - ); - }, + fileName: 'stream_poll_creator_full_screen_dialog_light', + constraints: const BoxConstraints.tightFor(width: 412, height: 916), + builder: () => _wrapWithMaterialApp( + brightness: Brightness.light, + const StreamPollCreatorFullScreenDialog(), + ), ); - testGoldens( + goldenTest( '[Dark] -> StreamPollCreatorFullScreenDialog should look fine', - (tester) async { - await tester.pumpWidgetBuilder( - const StreamPollCreatorFullScreenDialog(), - surfaceSize: const Size(412, 916), - wrapper: (child) => _wrapWithMaterialApp( - child, - brightness: Brightness.dark, - ), - ); - - await screenMatchesGolden( - tester, - 'stream_poll_creator_full_screen_dialog_dark', - ); - }, + fileName: 'stream_poll_creator_full_screen_dialog_dark', + constraints: const BoxConstraints.tightFor(width: 412, height: 916), + builder: () => _wrapWithMaterialApp( + brightness: Brightness.dark, + const StreamPollCreatorFullScreenDialog(), + ), ); } diff --git a/packages/stream_chat_flutter/test/test_utils/golden.dart b/packages/stream_chat_flutter/test/test_utils/golden.dart deleted file mode 100644 index 7d7a45cc5..000000000 --- a/packages/stream_chat_flutter/test/test_utils/golden.dart +++ /dev/null @@ -1,54 +0,0 @@ -import 'package:flutter/foundation.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:golden_toolkit/golden_toolkit.dart'; -import 'package:golden_toolkit/src/testing_tools.dart'; -import 'package:path/path.dart' as path; - -const double _kGoldenDiffTolerance = 0.05; - -/// Wrapper function for golden tests. -Future customExpectGoldenMatches( - WidgetTester tester, - String name, { - bool? autoHeight, - Finder? finder, - CustomPump? customPump, - bool? skip, -}) { - final goldenPath = path.join('test/src/goldens'); - print('goldenPath: $goldenPath'); - goldenFileComparator = CustomGoldenFileComparator(Uri.parse(goldenPath)); - - return compareWithGolden( - tester, - name, - autoHeight: autoHeight, - finder: finder, - customPump: customPump, - skip: skip, - // This value is actually ignored. We are forced to pass it because the - // downstream API is structured poorly. This should be refactored. - device: Device.phone, - fileNameFactory: (String name, Device device) => - GoldenToolkit.configuration.fileNameFactory(name), - ); -} - -class CustomGoldenFileComparator extends LocalFileComparator { - CustomGoldenFileComparator(super.testFile); - - @override - Future compare(Uint8List imageBytes, Uri golden) async { - print('golden.toString(): ${golden.toString()}'); - final result = await GoldenFileComparator.compareLists( - imageBytes, - await getGoldenBytes(golden), - ); - - if (!result.passed && result.diffPercent > _kGoldenDiffTolerance) { - final error = await generateFailureOutput(result, golden, basedir); - throw FlutterError(error); - } - return result.passed; - } -} diff --git a/packages/stream_chat_flutter_core/.gitignore b/packages/stream_chat_flutter_core/.gitignore deleted file mode 100644 index 1985397a2..000000000 --- a/packages/stream_chat_flutter_core/.gitignore +++ /dev/null @@ -1,74 +0,0 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# The .vscode folder contains launch configuration and tasks you configure in -# VS Code which you may wish to be included in version control, so this line -# is commented out by default. -#.vscode/ - -# Flutter/Dart/Pub related -**/doc/api/ -.dart_tool/ -.flutter-plugins -.flutter-plugins-dependencies -.packages -.pub-cache/ -.pub/ -build/ - -# Android related -**/android/**/gradle-wrapper.jar -**/android/.gradle -**/android/captures/ -**/android/gradlew -**/android/gradlew.bat -**/android/local.properties -**/android/**/GeneratedPluginRegistrant.java - -# iOS/XCode related -**/ios/**/*.mode1v3 -**/ios/**/*.mode2v3 -**/ios/**/*.moved-aside -**/ios/**/*.pbxuser -**/ios/**/*.perspectivev3 -**/ios/**/*sync/ -**/ios/**/.sconsign.dblite -**/ios/**/.tags* -**/ios/**/.vagrant/ -**/ios/**/DerivedData/ -**/ios/**/Icon? -**/ios/**/Pods/ -**/ios/**/.symlinks/ -**/ios/**/profile -**/ios/**/xcuserdata -**/ios/.generated/ -**/ios/Flutter/App.framework -**/ios/Flutter/Flutter.framework -**/ios/Flutter/Flutter.podspec -**/ios/Flutter/Generated.xcconfig -**/ios/Flutter/app.flx -**/ios/Flutter/app.zip -**/ios/Flutter/flutter_assets/ -**/ios/Flutter/flutter_export_environment.sh -**/ios/ServiceDefinitions.json -**/ios/Runner/GeneratedPluginRegistrant.* - -# Exceptions to above rules. -!**/ios/**/default.mode1v3 -!**/ios/**/default.mode2v3 -!**/ios/**/default.pbxuser -!**/ios/**/default.perspectivev3 diff --git a/packages/stream_chat_flutter_core/example/ios/Podfile b/packages/stream_chat_flutter_core/example/ios/Podfile new file mode 100644 index 000000000..d97f17e22 --- /dev/null +++ b/packages/stream_chat_flutter_core/example/ios/Podfile @@ -0,0 +1,44 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '12.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/packages/stream_chat_flutter_core/example/windows/flutter/generated_plugin_registrant.cc b/packages/stream_chat_flutter_core/example/windows/flutter/generated_plugin_registrant.cc deleted file mode 100644 index 8777c93d9..000000000 --- a/packages/stream_chat_flutter_core/example/windows/flutter/generated_plugin_registrant.cc +++ /dev/null @@ -1,14 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#include "generated_plugin_registrant.h" - -#include - -void RegisterPlugins(flutter::PluginRegistry* registry) { - ConnectivityPlusWindowsPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin")); -} diff --git a/packages/stream_chat_flutter_core/example/windows/flutter/generated_plugin_registrant.h b/packages/stream_chat_flutter_core/example/windows/flutter/generated_plugin_registrant.h deleted file mode 100644 index dc139d85a..000000000 --- a/packages/stream_chat_flutter_core/example/windows/flutter/generated_plugin_registrant.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#ifndef GENERATED_PLUGIN_REGISTRANT_ -#define GENERATED_PLUGIN_REGISTRANT_ - -#include - -// Registers Flutter plugins. -void RegisterPlugins(flutter::PluginRegistry* registry); - -#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/packages/stream_chat_localizations/.gitignore b/packages/stream_chat_localizations/.gitignore deleted file mode 100644 index 1985397a2..000000000 --- a/packages/stream_chat_localizations/.gitignore +++ /dev/null @@ -1,74 +0,0 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# The .vscode folder contains launch configuration and tasks you configure in -# VS Code which you may wish to be included in version control, so this line -# is commented out by default. -#.vscode/ - -# Flutter/Dart/Pub related -**/doc/api/ -.dart_tool/ -.flutter-plugins -.flutter-plugins-dependencies -.packages -.pub-cache/ -.pub/ -build/ - -# Android related -**/android/**/gradle-wrapper.jar -**/android/.gradle -**/android/captures/ -**/android/gradlew -**/android/gradlew.bat -**/android/local.properties -**/android/**/GeneratedPluginRegistrant.java - -# iOS/XCode related -**/ios/**/*.mode1v3 -**/ios/**/*.mode2v3 -**/ios/**/*.moved-aside -**/ios/**/*.pbxuser -**/ios/**/*.perspectivev3 -**/ios/**/*sync/ -**/ios/**/.sconsign.dblite -**/ios/**/.tags* -**/ios/**/.vagrant/ -**/ios/**/DerivedData/ -**/ios/**/Icon? -**/ios/**/Pods/ -**/ios/**/.symlinks/ -**/ios/**/profile -**/ios/**/xcuserdata -**/ios/.generated/ -**/ios/Flutter/App.framework -**/ios/Flutter/Flutter.framework -**/ios/Flutter/Flutter.podspec -**/ios/Flutter/Generated.xcconfig -**/ios/Flutter/app.flx -**/ios/Flutter/app.zip -**/ios/Flutter/flutter_assets/ -**/ios/Flutter/flutter_export_environment.sh -**/ios/ServiceDefinitions.json -**/ios/Runner/GeneratedPluginRegistrant.* - -# Exceptions to above rules. -!**/ios/**/default.mode1v3 -!**/ios/**/default.mode2v3 -!**/ios/**/default.pbxuser -!**/ios/**/default.perspectivev3 diff --git a/packages/stream_chat_localizations/example/ios/Podfile b/packages/stream_chat_localizations/example/ios/Podfile new file mode 100644 index 000000000..d97f17e22 --- /dev/null +++ b/packages/stream_chat_localizations/example/ios/Podfile @@ -0,0 +1,44 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '12.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/packages/stream_chat_persistence/.gitignore b/packages/stream_chat_persistence/.gitignore deleted file mode 100644 index 1985397a2..000000000 --- a/packages/stream_chat_persistence/.gitignore +++ /dev/null @@ -1,74 +0,0 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# The .vscode folder contains launch configuration and tasks you configure in -# VS Code which you may wish to be included in version control, so this line -# is commented out by default. -#.vscode/ - -# Flutter/Dart/Pub related -**/doc/api/ -.dart_tool/ -.flutter-plugins -.flutter-plugins-dependencies -.packages -.pub-cache/ -.pub/ -build/ - -# Android related -**/android/**/gradle-wrapper.jar -**/android/.gradle -**/android/captures/ -**/android/gradlew -**/android/gradlew.bat -**/android/local.properties -**/android/**/GeneratedPluginRegistrant.java - -# iOS/XCode related -**/ios/**/*.mode1v3 -**/ios/**/*.mode2v3 -**/ios/**/*.moved-aside -**/ios/**/*.pbxuser -**/ios/**/*.perspectivev3 -**/ios/**/*sync/ -**/ios/**/.sconsign.dblite -**/ios/**/.tags* -**/ios/**/.vagrant/ -**/ios/**/DerivedData/ -**/ios/**/Icon? -**/ios/**/Pods/ -**/ios/**/.symlinks/ -**/ios/**/profile -**/ios/**/xcuserdata -**/ios/.generated/ -**/ios/Flutter/App.framework -**/ios/Flutter/Flutter.framework -**/ios/Flutter/Flutter.podspec -**/ios/Flutter/Generated.xcconfig -**/ios/Flutter/app.flx -**/ios/Flutter/app.zip -**/ios/Flutter/flutter_assets/ -**/ios/Flutter/flutter_export_environment.sh -**/ios/ServiceDefinitions.json -**/ios/Runner/GeneratedPluginRegistrant.* - -# Exceptions to above rules. -!**/ios/**/default.mode1v3 -!**/ios/**/default.mode2v3 -!**/ios/**/default.pbxuser -!**/ios/**/default.perspectivev3 diff --git a/packages/stream_chat_persistence/example/ios/Podfile b/packages/stream_chat_persistence/example/ios/Podfile new file mode 100644 index 000000000..d97f17e22 --- /dev/null +++ b/packages/stream_chat_persistence/example/ios/Podfile @@ -0,0 +1,44 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '12.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/packages/stream_chat_persistence/example/linux/flutter/generated_plugin_registrant.cc b/packages/stream_chat_persistence/example/linux/flutter/generated_plugin_registrant.cc deleted file mode 100644 index 2c1ec4fe4..000000000 --- a/packages/stream_chat_persistence/example/linux/flutter/generated_plugin_registrant.cc +++ /dev/null @@ -1,15 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#include "generated_plugin_registrant.h" - -#include - -void fl_register_plugins(FlPluginRegistry* registry) { - g_autoptr(FlPluginRegistrar) sqlite3_flutter_libs_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "Sqlite3FlutterLibsPlugin"); - sqlite3_flutter_libs_plugin_register_with_registrar(sqlite3_flutter_libs_registrar); -} diff --git a/packages/stream_chat_persistence/example/linux/flutter/generated_plugin_registrant.h b/packages/stream_chat_persistence/example/linux/flutter/generated_plugin_registrant.h deleted file mode 100644 index e0f0a47bc..000000000 --- a/packages/stream_chat_persistence/example/linux/flutter/generated_plugin_registrant.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#ifndef GENERATED_PLUGIN_REGISTRANT_ -#define GENERATED_PLUGIN_REGISTRANT_ - -#include - -// Registers Flutter plugins. -void fl_register_plugins(FlPluginRegistry* registry); - -#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/packages/stream_chat_persistence/example/macos/Podfile b/packages/stream_chat_persistence/example/macos/Podfile new file mode 100644 index 000000000..c795730db --- /dev/null +++ b/packages/stream_chat_persistence/example/macos/Podfile @@ -0,0 +1,43 @@ +platform :osx, '10.14' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/packages/stream_chat_persistence/example/windows/flutter/generated_plugin_registrant.cc b/packages/stream_chat_persistence/example/windows/flutter/generated_plugin_registrant.cc deleted file mode 100644 index 988f3c8f1..000000000 --- a/packages/stream_chat_persistence/example/windows/flutter/generated_plugin_registrant.cc +++ /dev/null @@ -1,14 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#include "generated_plugin_registrant.h" - -#include - -void RegisterPlugins(flutter::PluginRegistry* registry) { - Sqlite3FlutterLibsPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("Sqlite3FlutterLibsPlugin")); -} diff --git a/packages/stream_chat_persistence/example/windows/flutter/generated_plugin_registrant.h b/packages/stream_chat_persistence/example/windows/flutter/generated_plugin_registrant.h deleted file mode 100644 index dc139d85a..000000000 --- a/packages/stream_chat_persistence/example/windows/flutter/generated_plugin_registrant.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#ifndef GENERATED_PLUGIN_REGISTRANT_ -#define GENERATED_PLUGIN_REGISTRANT_ - -#include - -// Registers Flutter plugins. -void RegisterPlugins(flutter::PluginRegistry* registry); - -#endif // GENERATED_PLUGIN_REGISTRANT_