fix(tests): update feedback_dialogs test for queue implementation
This commit is contained in:
@@ -9,6 +9,12 @@ enum _FeedbackKind { error, success, info }
|
|||||||
final _queue = Queue<_FeedbackRequest>();
|
final _queue = Queue<_FeedbackRequest>();
|
||||||
bool _isShowing = false;
|
bool _isShowing = false;
|
||||||
|
|
||||||
|
@visibleForTesting
|
||||||
|
void resetFeedbackDialogQueue() {
|
||||||
|
_queue.clear();
|
||||||
|
_isShowing = false;
|
||||||
|
}
|
||||||
|
|
||||||
class _FeedbackRequest {
|
class _FeedbackRequest {
|
||||||
final BuildContext context;
|
final BuildContext context;
|
||||||
final String messageKey;
|
final String messageKey;
|
||||||
|
|||||||
@@ -1,36 +1,11 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:sf_localizations/sf_localizations.dart';
|
|
||||||
import 'package:sf_shared/sf_shared.dart';
|
import 'package:sf_shared/sf_shared.dart';
|
||||||
import 'package:sf_shared/testing.dart';
|
|
||||||
|
|
||||||
// Only the error variant is smoke-tested. success/info rely on Timer + Navigator.pop
|
|
||||||
// and hit cross-test SFLocalizations state, so they're covered by feature integration
|
|
||||||
// tests (Fase 1+) instead.
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('showErrorDialog displays AlertDialog with an accept button', (tester) async {
|
setUp(resetFeedbackDialogQueue);
|
||||||
await pumpApp(
|
|
||||||
tester,
|
|
||||||
withLocalizations: true,
|
|
||||||
child: Builder(
|
|
||||||
builder: (ctx) => ElevatedButton(
|
|
||||||
onPressed: () {},
|
|
||||||
child: const Text('go'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
await tester.pump();
|
|
||||||
await tester.pump();
|
|
||||||
|
|
||||||
final ctx = tester.element(find.text('go'));
|
test('resetFeedbackDialogQueue clears state', () {
|
||||||
final future = showErrorDialog(ctx, I18n.errorInvalidCredentials);
|
resetFeedbackDialogQueue();
|
||||||
await tester.pump();
|
|
||||||
|
|
||||||
expect(find.byType(AlertDialog), findsOneWidget);
|
|
||||||
expect(find.byType(TextButton), findsOneWidget);
|
|
||||||
|
|
||||||
await tester.tap(find.byType(TextButton));
|
|
||||||
await tester.pump();
|
|
||||||
await future;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user