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

[FEATURE] Add key to submit button for integration testing #240

Open
jalakoo opened this issue Sep 2, 2021 · 2 comments
Open

[FEATURE] Add key to submit button for integration testing #240

jalakoo opened this issue Sep 2, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@jalakoo
Copy link

jalakoo commented Sep 2, 2021

Is your feature request related to a problem? Please describe.
Not a clear way to target the login/submit button to trigger in an integration test. There is a test util function for the packages own test, but as far as I can tell the animated_button widget is not accessible outside of the package.

Describe the solution you'd like
Would like to be able to something like tester.tap(find.byKey(Key("flutter_login_submit_button"); to trigger a tap on the submit button.

Additional context
image

@jalakoo jalakoo added the enhancement New feature or request label Sep 2, 2021
@danhunsaker
Copy link

Similar problem. Our app requires login to reach anything beyond the home screen, and I can't actually automate the login process without some way to find the relevant elements, so I can't write integration tests at the moment.

Unless I'm just missing something in the docs?

@danhunsaker
Copy link

Not in the docs, but digging through the package code leads to a workaround.

import 'package:flutter_login/src/widgets/animated_button.dart';
import 'package:flutter_login/src/widgets/animated_text_form_field.dart';

.
.
.

      final name = find.byType(AnimatedTextFormField).first;
      final pass = find.byType(AnimatedPasswordTextFormField).first;
      final btn = find.byType(AnimatedButton).first;

      await tester.enterText(name, '5');
      await tester.enterText(pass, '5');

      await tester.press(btn);

Definitely a bit fragile, as it depends on implementation details we shouldn't know or care about. Which is why it would be better to have keys on everything instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
2 participants