yubioath-flutter/integration_test/android/beta_welcome_dialog_test.dart

43 lines
1.4 KiB
Dart
Raw Normal View History

import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:shared_preferences/shared_preferences.dart';
2022-09-12 13:58:17 +03:00
import 'package:yubico_authenticator/android/keys.dart' as keys;
import '../test_util.dart';
import 'constants.dart';
void main() {
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
group('Beta welcome dialog', () {
2022-09-13 13:32:13 +03:00
// this is here to make sure yubikey is connected before we test the dialog
testWidgets('startup', (WidgetTester tester) async {
await tester.startUp({
'dlg.beta.enabled': false,
});
});
testWidgets('shows welcome screen', (WidgetTester tester) async {
await tester.startUp({
'dlg.beta.enabled': true,
});
2022-09-13 13:32:13 +03:00
2022-09-12 13:58:17 +03:00
expect(find.byKey(keys.betaDialogView), findsOneWidget);
});
testWidgets('does not show welcome dialog', (WidgetTester tester) async {
await tester.startUp();
2022-09-12 13:58:17 +03:00
expect(find.byKey(keys.betaDialogView), findsNothing);
});
testWidgets('updates preferences', (WidgetTester tester) async {
await tester.startUp({'dlg.beta.enabled': true});
var prefs = await SharedPreferences.getInstance();
2022-09-12 13:58:17 +03:00
await tester.tap(find.byKey(keys.okButton));
await expectLater(prefs.getBool(betaDialogPrefName), equals(false));
});
});
}