Git Product home page Git Product logo

testsweets's Introduction

TestSweets Pub Version

This package is a utility and helper package to the TestSweets product. It is the package responsible for capturing your widget keys to the database which allows us to provide the auto complete functionality when you script your test cases.

Installation

To start using the package you have to add this package to your pubspec.yaml file.

dependencies:
  ...
  testsweets: [latest_version]

Setup

After the packages have been added we have to setup the code. TestSweets makes use of Flutter Driver to drive the test cases that we write. This means we have to enable Flutter driver for the version of the app that we build that goes through automation. Flutter driver disables certain things like the on screen keyboard. To disable completely TestSweets is as easy as passing enabled: false to setupTestSweets function.

...

void main() {
  // 1. Setup the TestSweets internal dependencies
  await setupTestSweets();
  ...
  runApp(MyApp());
}

in your MaterialApp

...
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {

    return MaterialApp(
      // 2. Inside MaterialApp add TestSweetsOverlayView to the builder
      //    with the projectId you get when you created a new project in Testsweets app
      builder: (context, child) => TestSweetsOverlayView(
        projectId: '3OezzTovG9xxxxxxxxx',
        child: child!,
      ),
      // 3. Finally add TestSweetsNavigatorObserver() 
      // to determine what view you are on right now
      navigatorObservers: [
        TestSweetsNavigatorObserver.instance,
      ],
    );

Capturing Interactions

To run the app in capture mode you just start the application and capture mode will be enabled. You can swap between capture mode and drive mode tapping on the screen with 3 fingers.

How to add an Interaction

Note: The view you are on is automatically captured

  1. Click the arrow to show the bottomsheet
  2. Select one of the three interaction types (default to Touchable)
  3. Drag the "T" icon onto the touchable widget e.g. a button
  4. Enter a widget name
  5. Tap the Save Widget button

Note: you can tap the arrow again to close the bottomsheet and move the widget freely and it will preserve the information

add.interaction.mp4

How to inspect a view

Inspecting view is the default state when you open the app.

However, if you’re Creating/Editing a widget and you want to go back to inspect mode you can tap the Clear button.

How to edit an interaction

Normal Edit

  1. To start editing first you have to be in inspecting mode
  2. Long press on the widget you want to edit
  3. Choose Edit from the menu that appeared
  4. That will pop up the bottom sheet with the old content of the interaction
  5. Change name, type, and position
  6. Tap update when done
  7. If you change your mind you can tap Clear to return to inspect mode without saving
normal.edit.mp4

Quick position edit

If you want to adjust the position only, there is a shortcut

  1. Long press and hold on the interaction you want to change size
  2. While holding drag to the preferred position
  3. Lift your finger to save the current position
quick.edit.mp4

How to remove an interaction

  1. To start editing first you have to be in inspecting mode
  2. Long press on the widget you want to edit
  3. Choose Remove from the menu that appeared and that’s it!
remove.interaction.mp4

Putting the app in Drive Mode

To ensure the app is built for TestSweets to be able to drive it you you should pass --dart-define=FORCE_CAPTURE_MODE=false when building or running the app for TestSweets.

Build the apk

flutter build apk --debug --dart-define=FORCE_CAPTURE_MODE=false

testsweets's People

Contributors

bats64mgutsi avatar eb-so avatar ebrahim-soliman avatar ferrarafer avatar filledstacks avatar isaacadariku avatar r0hit-gupta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

testsweets's Issues

Error: The argument type 'Overlay Function()' can't be assigned to the parameter type 'Widget Function(BuildContext, Widget?)?

Hi,

I've tried to use testsweets package ver. 1.5.2 (can't update it to the latest due to packages dependency issue).

Here is my App class:

   GetMaterialApp(
        title: 'MyAppName',
        themeMode: ThemeMode.light,
        theme: AppTheme.base,
        getPages: Routes.pages,
        locale: LocalizationService.locale,
        fallbackLocale: LocalizationService.fallbackLocale,
        translations: LocalizationService(),
        debugShowCheckedModeBanner: false,
        navigatorObservers: [
          TestSweetsNavigatorObserver(),
        ],
        builder: (context, child) => TestSweetsOverlayView(
          projectId: '>>myProjectId<<',
          child: child!,
        ),
      ),

When compiling, I'm getting an error as presented below (Android build):

 - 'Overlay' is from 'package:flutter/src/widgets/overlay.dart' ('../../flutter/packages/flutter/lib/src/widgets/overlay.dart').
 - 'Widget' is from 'package:flutter/src/widgets/framework.dart' ('../../flutter/packages/flutter/lib/src/widgets/framework.dart').
 - 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../../flutter/packages/flutter/lib/src/widgets/framework.dart').
          builder: () => Overlay(
                   ^
../../../.pub-cache/hosted/pub.dev/stacked-2.3.15+1/lib/src/state_management/skeleton_loader.dart:106:19: Error: No named parameter with the name 'vsync'.
                  vsync: this,
                  ^^^^^
../../flutter/packages/flutter/lib/src/widgets/animated_size.dart:28:9: Context: Found this candidate, but the arguments don't match.
  const AnimatedSize({
        ^^^^^^^^^^^^
../../../.pub-cache/hosted/pub.dev/stacked_core-1.2.4/lib/src/code_generation/locator/stacked_locator.dart:405:19: Error: The argument type 'Object?' can't be assigned to the parameter type 'T?'.
 - 'Object' is from 'dart:core'.
        instance: instance,
                  ^
Target kernel_snapshot failed: Exception

My configuration:

[!] Flutter (Channel [user-branch], 3.13.6, on macOS 14.2.1 23C71 darwin-arm64, locale en-PL)
    ! Flutter version 3.13.6 on channel [user-branch] at /Users/mat/Documents/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install.
    ! Upstream repository unknown source is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
    • Framework revision ead455963c (5 months ago), 2023-09-26 18:28:17 -0700
    • Engine revision a794cf2681
    • Dart version 3.1.3
    • DevTools version 2.25.0
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and
      upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/mat/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15C65
    • CocoaPods version 1.13.0

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • android-studio-dir = /Applications/Android Studio.app
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

[✓] VS Code (version 1.86.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.70.0

[✓] Connected device (3 available)
    • iPhone 15 Pro (mobile) • DAF45E4A-86E9-4F40-AEE1-C9CDD4BD9B7B • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)
    • macOS (desktop)        • macos                                • darwin-arm64   • macOS 14.2.1 23C71 darwin-arm64
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 121.0.6167.160

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

Error: Too many positional arguments: 1 allowed, but 2 found.

I just finished setting up TestSweet by following the guide

But it's not letting me run the app in capture mode.

I keep getting this error:

Error (Xcode): ../../../../.pub-cache/hosted/pub.dev/testsweets-1.16.1/lib/src/ui/widget_capture/widget_capture_viewmodel.dart:287:10: Error: Too many positional arguments: 1 allowed, but 2 found.

My pubspec:

name: app_stretch

# Prevent accidental publishing to pub.dev.
publish_to: "none"

version: 1.39.0+1210

environment:
  flutter: 3.13.9
  sdk: 3.1.5

dependencies:
  app_links: 3.4.5
  cached_network_image: 3.2.3
  carousel_slider: 4.2.1
  collection: 1.17.2
  core:
    path: ../core
  country_picker: 2.0.21
  data:
    path: ../data
  dio: 5.3.3
  domain:
    path: ../domain
  either_dart: 0.4.0
  features:
    path: ../features
  firebase_analytics: 10.4.2
  firebase_core: 2.13.1
  firebase_crashlytics: 3.3.2
  firebase_messaging: 14.6.2
  flex_color_scheme: 7.1.2
  flutter:
    sdk: flutter
  flutter_branch_sdk: 7.0.1
  flutter_dotenv: 5.1.0
  flutter_local_notifications: 16.3.2
  flutter_localizations:
    sdk: flutter
  flutter_pdfview: 1.3.1
  flutter_platform_alert: 0.5.1
  flutter_riverpod: 2.3.6
  flutter_stripe: 9.5.0+1
  flutter_svg: 2.0.7
  flutter_xlider: 3.5.0
  freezed_annotation: 2.4.1
  get_storage: 2.1.1
  go_router: 8.0.1
  google_fonts: 6.1.0
  image_cropper: 5.0.0
  image_picker: 1.0.2
  intl: 0.18.1
  isar: 3.1.0+1
  isar_flutter_libs: 3.1.0+1
  json_annotation: 4.8.1
  language_code: 0.3.0
  latlong2: 0.9.0
  localizations:
    path: ../localizations
  lottie: 2.4.0
  path: 1.8.3
  path_provider: 2.1.0
  permission_handler: 10.4.3
  pinput: 2.3.0
  pull_to_refresh_notification: 3.1.0
  rxdart: 0.27.7
  shared_preferences: ^2.2.2
  stack_trace: 1.11.0
  testsweets: 1.16.1
  timeago: 3.5.0
  uikit:
    path: ../uikit
  url_launcher: 6.1.14
  video_player: 2.7.1
  webview_flutter: 4.2.2

dev_dependencies:
  build_runner: 2.4.6
  custom_lint: 0.4.0
  flutter_gen: 5.3.2
  flutter_gen_runner: 5.3.2
  flutter_launcher_icons: 0.13.1
  flutter_native_splash: 2.3.1
  flutter_test:
    sdk: flutter
  freezed: 2.4.5
  isar_generator: 3.1.0+1
  json_serializable: 6.7.1

dependency_overrides:
  http: 1.1.0
  logger: 2.0.1

flutter_gen:
  line_length: 120
  integrations:
    flutter_svg: true

flutter:
  uses-material-design: true

  assets:
    - environment/
    - google_fonts/
    - assets/pngs/
    - assets/images/

flutter_launcher_icons:
  adaptive_icon_foreground: "assets/pngs/app_icon.png"
  adaptive_icon_background: "#E7DEFF"
  ios: true
  remove_alpha_ios: true
  image_path: "assets/pngs/app_icon.png"

flutter_native_splash:
  color: "#fffbff"
  image: "assets/pngs/launch_image.png"
  android_12:
    color: "#fffbff"
    image: "assets/pngs/launch_image.png"

My MaterialApp widget:

return StreamBuilder<AppThemeMode>(
      stream: themeRepository.observeThemeMode(),
      builder: (context, snapshot) {
        final themeMode = snapshot.data;
        final appTheme = themeMode?.toAppTheme(context) ?? AppTheme.of(context);

        return MaterialApp.router(
          restorationScopeId: 'app',
          localizationsDelegates: const [
            AppLocalizations.delegate,
            CountryLocalizations.delegate,
            GlobalMaterialLocalizations.delegate,
            GlobalWidgetsLocalizations.delegate,
            GlobalCupertinoLocalizations.delegate,
          ],
          supportedLocales: AppLocalizations.supportedLocales,
          onGenerateTitle: (context) => AppLocalizations.of(context).commonAppTitle,
          theme: appTheme.theme,
          routerConfig: router,
          builder: (context, child) => TestSweetsOverlayView(
            projectId: '{projectId}',
            child: _AppObserver(
              child: Builder(
                builder: (context) => MediaQuery(
                  data: MediaQuery.of(context).copyWith(
                    textScaleFactor: min(MediaQuery.of(context).textScaleFactor, 1.1),
                  ),
                  child: ThemeProvider(
                    appTheme: appTheme,
                    child: _legacyIntilized
                        ? Scaffold(
                            resizeToAvoidBottomInset: false,
                            key: _scaffoldKey,
                            body: child,
                          )
                        : const SizedBox(),
                  ),
                ),
              ),
            ),
          ),
        );
      },
    );

My main.dart:

final enableTestSweets = arguments.any((arg) => arg == 'enable_testsweets');
// Setup the TestSweets internal dependencies
await setupTestSweets(enabled: enableTestSweets);

I obviously ran flutter pub get

The flutter version for this project is: v3.13.3

No idea what to do to fix this...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.