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

Fix closing animation bug #314

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/src/core/widgets/backdrop/wiredash_backdrop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,9 @@ class _WiredashBackdropState extends State<WiredashBackdrop>
);
final wiredashModel = context.wiredashModel;
widget.controller._isAppInteractive = true;
_closeAnim = a2;
await Future.wait([a1, a2]);
_closeAnim = null;
_backdropStatus = WiredashBackdropStatus.closed;
await wiredashModel.hide();
},
Expand All @@ -892,7 +894,9 @@ class _WiredashBackdropState extends State<WiredashBackdrop>
curve: Curves.easeOutExpo,
duration: const Duration(milliseconds: 600),
);
_openAnim = a2;
await Future.wait([a1, a2]);
_openAnim = null;
_backdropStatus = WiredashBackdropStatus.open;
_swapAnimation();
},
Expand Down
42 changes: 42 additions & 0 deletions test/feedback_flow_test.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:spot/spot.dart';
import 'package:wiredash/src/_feedback.dart';
import 'package:wiredash/src/core/widgets/backdrop/wiredash_backdrop.dart';
import 'package:wiredash/src/core/widgets/larry_page_view.dart';
import 'package:wiredash/src/feedback/feedback_backdrop.dart';
import 'package:wiredash/wiredash.dart';

import 'util/robot.dart';
Expand Down Expand Up @@ -442,6 +444,46 @@ void main() {
expect(submittedFeedback!.labels, ['lbl-1', 'lbl-2']);
expect(submittedFeedback.message, 'feedback with labels');
});

testWidgets('spam tap during close animation', (tester) async {
Copy link
Contributor

Choose a reason for hiding this comment

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

lol I was wondering what our users had been doing

Copy link
Member Author

Choose a reason for hiding this comment

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

This was my first prediction. But the actual bug happened only after swiping first

final robot = await WiredashTestRobot(tester).launchApp();

await robot.openWiredash();
final bottomRight = tester.getBottomRight(find.byType(Wiredash));
final closeTapLocation = Offset(bottomRight.dx / 2, bottomRight.dy - 20);

int taps = 0;
while (find.byType(FeedbackBackdrop).evaluate().isNotEmpty) {
taps++;
await tester.tapAt(closeTapLocation);
await tester.pump(const Duration(milliseconds: 50));
}
expect(taps, greaterThan(10));
expect(taps, lessThan(20));
});

testWidgets('swipe up then tap to close', (tester) async {
// verifies issue https://github.com/wiredashio/wiredash-sdk/issues/311
final robot = await WiredashTestRobot(tester).launchApp();

await robot.openWiredash();
final topRight = tester.getTopRight(find.byType(MaterialApp));

// fling up
await tester.flingFrom(
Offset(topRight.dx / 2, topRight.dy + 20),
// only a bit up so that the close button is still visible
const Offset(0, -50),
500,
);
await tester.pump(const Duration(milliseconds: 10));

// Then tap to close while backdrop is still moving
await robot.closeWiredashWithButton(); // caused crash

await tester.pumpAndSettle();
spot<FeedbackBackdrop>().doesNotExist();
});
});
}

Expand Down
11 changes: 11 additions & 0 deletions test/util/robot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,17 @@ class WiredashTestRobot {
print('opened promoter score');
}

Future<void> closeWiredashWithButton() async {
_spotPageView.spotSingle<Step1FeedbackMessage>().existsOnce();
final spotCloseButton = _spotBackdrop.spotSingle<TronButton>(
children: [
spotSingleText('l10n.feedbackCloseButton'),
],
)..existsOnce();
await _tap(spotCloseButton);
print('closed Wiredash');
}

Future<void> closeWiredash() async {
// tap app which is located at the bottom of the screen
final bottomRight = tester.getBottomRight(find.byType(Wiredash));
Expand Down