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

feat: fixing for Flutter 3.13.0 #51

Merged
merged 4 commits into from Aug 17, 2023
Merged

Conversation

erickzanardo
Copy link
Contributor

@erickzanardo erickzanardo commented Aug 17, 2023

Description

It seems that the navigator in Flutter 3.13.0 has changed a little bit how it works internally, those changes broke Mockinjay because how it "hooks" mocks in the navigation made that some internal fields were not populated, breaking the tests when the mocked navigator was disposed.

This PR adds an addition hack in order to trick those unpopulated internal fields so it can start working again.

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

Fixes #52

class _MockMaterialPageRoute extends MaterialPageRoute<void> {
_MockMaterialPageRoute({required super.builder});

void hackOverlays() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

I spent a good few minutes investigating what could have caused my test to fail after updating to Flutter 3.13.0.

I noticed that without using mockingjay, everything worked as expected (just like in version 3.10.0).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I create an issue about this, also: #52

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the issue @felipecastrosales !!!

lib/src/mock_navigator.dart Outdated Show resolved Hide resolved
_MockMaterialPageRoute({required super.builder});

void hackOverlays() {
for (var i = 0; i < overlayEntries.length; i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to test this method specifically? I feel it's now accidentally covered

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel we don't need any additional tests, since before the change, no test were passing in flutter 3.13

pubspec.yaml Outdated Show resolved Hide resolved
erickzanardo and others added 2 commits August 17, 2023 14:21
Co-authored-by: Jochum van der Ploeg <jochum@vdploeg.net>
@erickzanardo erickzanardo merged commit 46188b5 into main Aug 17, 2023
6 checks passed
@erickzanardo erickzanardo deleted the feat/hack-for-flutter-3.13.0 branch August 17, 2023 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

Problems with Flutter 3.13.0.
3 participants