Skip to content

Commit 1318c2c

Browse files
Copilot0xrinegade
andcommitted
Fix Flutter SDK test failures: timer disposal, duplicate text, and error snackbar
Co-authored-by: 0xrinegade <[email protected]>
1 parent 7fdbff1 commit 1318c2c

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

flutter_sdk/lib/src/payment_widgets.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class _PaymentButtonState extends State<PaymentButton> {
7878
@override
7979
void dispose() {
8080
// Fix Bug #6: Cancel all active operations and dispose resources
81+
_activeOperations.clear();
8182
_svmPay.dispose();
8283
super.dispose();
8384
}

flutter_sdk/test/widget_test.dart

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,13 @@ void main() {
165165
await tester.tap(networkDropdown);
166166
await tester.pumpAndSettle();
167167

168-
// Should show all network options
168+
// Should show all network options in dropdown menu
169169
for (final network in SVMNetwork.values) {
170-
expect(find.text(network.value.toUpperCase()), findsOneWidget);
170+
// Look for dropdown menu items specifically, not the selected value
171+
expect(find.descendant(
172+
of: find.byType(DropdownMenuItem<SVMNetwork>),
173+
matching: find.text(network.value.toUpperCase()),
174+
), findsOneWidget);
171175
}
172176

173177
// Select a different network
@@ -324,30 +328,25 @@ void main() {
324328
});
325329

326330
testWidgets('PaymentButton should show error snackbar on failure', (tester) async {
327-
// Create a mock SVMPay that always fails
328-
final mockSvmPay = SVMPay(
329-
config: const SVMPayConfig(debug: false),
330-
);
331-
332331
await tester.pumpWidget(
333332
MaterialApp(
334333
home: Scaffold(
335334
body: PaymentButton(
336-
recipient: 'invalid-address', // This will cause failure
335+
recipient: '', // Empty address will cause validation failure
337336
amount: '1.0',
338-
svmPay: mockSvmPay,
339337
),
340338
),
341339
),
342340
);
343341

344342
// Tap the button
345343
await tester.tap(find.byType(PaymentButton));
346-
await tester.pumpAndSettle(const Duration(seconds: 3));
347-
344+
await tester.pump(); // Initial pump to trigger the async operation
345+
await tester.pump(const Duration(milliseconds: 100)); // Wait for setState
346+
348347
// Should show error snackbar
349348
expect(find.byType(SnackBar), findsOneWidget);
350-
expect(find.textContaining('Payment error'), findsOneWidget);
349+
expect(find.text('Payment error: Invalid recipient address'), findsOneWidget);
351350
});
352351

353352
testWidgets('Widgets should handle loading states correctly', (tester) async {

0 commit comments

Comments
 (0)