Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: multiScreenGoldens with autoHeight: true ignores device width #176

Open
1 task done
supposedlysam-bb opened this issue Jul 18, 2023 · 0 comments
Open
1 task done

Comments

@supposedlysam-bb
Copy link

supposedlysam-bb commented Jul 18, 2023

Is there an existing issue for this?

Steps to reproduce

  1. Create a new project with flutter create golden_toolkit_auto_height_bug
  2. Install latest golden_toolkit as a dev dependency (min version 0.15.0)
  golden_toolkit:
    dependency: "direct dev"
    description:
      name: golden_toolkit
      sha256: "8f74adab33154fe7b731395782797021f97d2edc52f7bfb85ff4f1b5c4a215f0"
      url: "https://pub.dev"
    source: hosted
    version: "0.15.0"
  1. Update test/widget_test.dart with provided group
  2. Run flutter test --update-goldens and compare the generated goldens

Expected results

Generated Goldens will be the same width as specified by the provided Device config

Actual results

Golden generated using autoHeight: true has a different width than the provided Device config

Code sample

widget_test.dart
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility in the flutter_test package. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:golden_toolkit/golden_toolkit.dart';

import 'package:golden_toolkit_auto_height_bug/main.dart';

void main() {
  testWidgets('Counter increments smoke test', (WidgetTester tester) async {
    // Build our app and trigger a frame.
    await tester.pumpWidget(const MyApp());

    // Verify that our counter starts at 0.
    expect(find.text('0'), findsOneWidget);
    expect(find.text('1'), findsNothing);

    // Tap the '+' icon and trigger a frame.
    await tester.tap(find.byIcon(Icons.add));
    await tester.pump();

    // Verify that our counter has incremented.
    expect(find.text('0'), findsNothing);
    expect(find.text('1'), findsOneWidget);
  });

  group('goldens', () {
    const iphone10 = Device(
      size: Size(375, 812),
      devicePixelRatio: 3.0,
      name: 'iPhone_X',
    );

    setUpAll(loadAppFonts);

    testGoldens('autoHeight: false', (tester) async {
      await tester.pumpWidgetBuilder(
        const MyApp(),
        wrapper: materialAppWrapper(),
        surfaceSize: const Size(3000, 3000),
      );

      await multiScreenGolden(
        tester,
        'counter.autoHeight_false',
        devices: [iphone10],
        autoHeight: false,
      );
    });

    testGoldens('autoHeight: true', (tester) async {
      await tester.pumpWidgetBuilder(
        const MyApp(),
        wrapper: materialAppWrapper(),
        surfaceSize: const Size(3000, 3000),
      );

      await multiScreenGolden(
        tester,
        'counter.autoHeight_true',
        devices: [iphone10],
        autoHeight: true,
      );
    });
  });
}

Screenshots

Screenshots
autoHeight: false autoHeight: true
counter autoHeight_false iPhone_X counter autoHeight_true iPhone_X

Flutter Doctor Verbose output

Doctor output
[✓] Flutter (Channel stable, 3.10.5, on macOS 13.4.1 22F82 darwin-x64, locale en-US)
    • Flutter version 3.10.5 on channel stable at /Users/supposedlysam/fvm/versions/3.10.5
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 796c8ef792 (5 weeks ago), 2023-06-13 15:51:02 -0700
    • Engine revision 45f6e00911
    • Dart version 3.0.5
    • DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc1)
    • Android SDK at /Users/supposedlysam/Library/Android/sdk
    • Platform android-34, build-tools 33.0.0-rc1
    • 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 14.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E300c
    • CocoaPods version 1.12.1

[✓] 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
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

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

[✓] VS Code (version 1.81.0-insider)
    • VS Code at /Users/supposedlysam/Applications/Visual Studio Code - Insiders.app/Contents
    • Flutter extension version 3.68.0

[✓] Connected device (3 available)
    • macOS (desktop)   • macos              • darwin-x64     • macOS 13.4.1 22F82 darwin-x64
    • Chrome (web)      • chrome             • web-javascript • Google Chrome 114.0.5735.198

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

• No issues found!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant