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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Widget unit testing with emoji_picker_flutter #156

Closed
LuchoTurtle opened this issue Sep 27, 2023 · 3 comments 路 Fixed by #183
Closed

Widget unit testing with emoji_picker_flutter #156

LuchoTurtle opened this issue Sep 27, 2023 · 3 comments 路 Fixed by #183
Labels
monitor Origin of this issue is unknown

Comments

@LuchoTurtle
Copy link

LuchoTurtle commented Sep 27, 2023

Hey there! 馃憢

Thanks for the package, it's mighty useful!

I'm having a bit of trouble widget-testing an application that includes this package. Since there aren't any testing utilities that I can go for, to test my code I'm doing something like this in my test:

	// Set size because it's needed to correctly tap on emoji picker
    await tester.binding.setSurfaceSize(const Size(380, 800));

 // .....

 // Tap on smile category
    await tester.tapAt(const Offset(61, 580));
    await tester.pumpAndSettle();

  // Tap on smile icon
  await tester.tapAt(const Offset(14, 632));
  await tester.pumpAndSettle();

I'm always setting the size of the unit test to always be the same one so it works every time. The thing is, I'm simulating this test on a physical device and everything works out - it clicks on an emoji and it is inserted as text. You can check it in the video below:

23-09-26-16-03-51.mp4

However, even though all the unit tests pass and the integration tests pass, it seems the callback of the inserted emoji is not covered.

image

Has this happened to y'all? Why is the onEmojiSelected callback not being invoked during unit tests and being covered?

If you're curious, you may see the offending file in https://github.com/dwyl/flutter-wysiwyg-editor-tutorial/pull/9/files#diff-64157eac151a0f2a28dff32d284fc4f62e2eaf53e0dd0a8c1cd31e77f56e700d.

Thank you!

@Fintasys
Copy link
Owner

Fintasys commented Oct 9, 2023

Hey @LuchoTurtle, thanks for reporting this issue. The onEmojiSelected callback seems to be invoked but only coverage seems not to be reported 馃 I don't know what could cause this. I need to setup some widget tests myself and check it. If you find the reason in the meantime please keep me updated 馃憤

@Fintasys Fintasys added bug Something isn't working monitor Origin of this issue is unknown and removed bug Something isn't working labels Oct 9, 2023
@LuchoTurtle
Copy link
Author

Thanks for the reply :)

I've found a way so onEmojiSelected is covered. You can see a simple widget test in https://github.com/dwyl/app/blob/6439db5d922ae5a4a368dfc2bba03040e58db2fc/test/widget/emoji_widget_test.dart.

However, the only way I got this to work is having to disable the "Recents" emojis tab.

Config(recentTabBehavior: RecentTabBehavior.NONE);

This was the only way I could find to find.byText() emojis to tap, thus invoking the onEmojiSelected. Otherwise, even though I scrolled and changed tabs, it wasn't working on tests.

So hopefully this helps people in the future :).

Though it'd be fun to have a neat utility function that would allow us to input emojis without having to go through these hoops. 馃憖

@Fintasys Fintasys mentioned this issue Jan 26, 2024
11 tasks
@Fintasys
Copy link
Owner

Version 2.0 will include some basic tests. Thanks again @LuchoTurtle for your help 馃檹 I will close this issue with the release of version 2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
monitor Origin of this issue is unknown
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants