Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Integration_test 2.5] tester.enterText is broken in release mode #89749

Open
@rxlabz

Description

@rxlabz

Since the Flutter 2.5 upgrade, tester.enterText() seems broken in my web integration tests in --release mode.
When I run flutter drive with --no-headless, I can see that no text is added in text fields.

Steps to Reproduce

You can reproduce it with this repo https://github.com/rxlabz/text_drive

sh drive_web.sh
sh drive_web_release.sh

You can also see the result of 3 GH actions workflows in the project :

  1. the first is running the integration_test without --release (https://github.com/rxlabz/text_drive/blob/master/.github/workflows/integration.yaml) => it works ( all tests passed ) https://github.com/rxlabz/text_drive/actions/runs/1217290271

  2. the other uses--release (https://github.com/rxlabz/text_drive/blob/master/.github/workflows/integration_release.yaml) and fails => https://github.com/rxlabz/text_drive/actions/runs/1217290268

  3. the last one is running with flutter 2.2.3 in --release https://github.com/rxlabz/text_drive/actions/runs/1217434660/workflow => it works https://github.com/rxlabz/text_drive/runs/3556551737

App
import 'package:flutter/material.dart';

void main() {
  runApp(const App());
}

class App extends StatelessWidget {
  const App({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) => const MaterialApp(home: MainScreen());
}

class MainScreen extends StatefulWidget {
  const MainScreen({Key? key}) : super(key: key);

  @override
  State<MainScreen> createState() => _MainScreenState();
}

class _MainScreenState extends State<MainScreen> {
  final TextEditingController controller = TextEditingController();

  String value = 'test';

  @override
  void initState() {
    super.initState();
    controller.addListener(() => setState(() => value = controller.text));
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            TextFormField(key: const Key('field'), controller: controller),
            Text(value)
          ],
        ),
      ),
    );
  }
}
integration test
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:text_drive/main.dart';

void main() {
  IntegrationTestWidgetsFlutterBinding.ensureInitialized();

  testWidgets("failing test example", (WidgetTester tester) async {
    await tester.pumpWidget(const App());

    final input = find.byKey(const Key('field'));
    expect(input, findsOneWidget);

    expect(find.text('test'), findsOneWidget);

    await tester.tap(input);
    await tester.enterText(input, 'Hello');

    // same result with `updateEditingValue`
    // (cf.https://flutter.dev/docs/release/breaking-changes/enterText-trailing-caret)
    // await tester.showKeyboard(input);
    // await tester.pumpAndSettle();
    //tester.testTextInput.updateEditingValue(
    //  const TextEditingValue(text: 'Hello'),
    //);

    await tester.pump();

    expect(find.text('Hello'), findsNWidgets(2));
  });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: releaseChallenges faced when attempting to productionize an appc: regressionIt was better in the past than it is nowcustomer: dentf: integration_testThe flutter/packages/integration_test pluginfound in release: 2.5Found to occur in 2.5frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions