2022-09-11 12:05:00 +03:00
|
|
|
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;
|
2022-09-11 12:05:00 +03:00
|
|
|
|
2022-09-14 13:03:36 +03:00
|
|
|
import '../android/util.dart' as android_test_util;
|
2022-09-11 12:05:00 +03:00
|
|
|
import 'constants.dart';
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
|
|
|
|
|
|
|
|
group('Beta welcome dialog', () {
|
|
|
|
testWidgets('shows welcome screen', (WidgetTester tester) async {
|
2022-09-14 13:03:36 +03:00
|
|
|
await android_test_util.startUp(tester, {
|
2022-09-11 12:05:00 +03:00
|
|
|
'dlg.beta.enabled': true,
|
2022-09-14 13:03:36 +03:00
|
|
|
'needs_yubikey': false,
|
2022-09-11 12:05:00 +03:00
|
|
|
});
|
2022-09-13 13:32:13 +03:00
|
|
|
|
2022-09-12 13:58:17 +03:00
|
|
|
expect(find.byKey(keys.betaDialogView), findsOneWidget);
|
2022-09-11 12:05:00 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
testWidgets('does not show welcome dialog', (WidgetTester tester) async {
|
2022-09-14 13:03:36 +03:00
|
|
|
await android_test_util.startUp(tester, {
|
|
|
|
'dlg.beta.enabled': false,
|
|
|
|
'needs_yubikey': false,
|
|
|
|
});
|
2022-09-12 13:58:17 +03:00
|
|
|
expect(find.byKey(keys.betaDialogView), findsNothing);
|
2022-09-11 12:05:00 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
testWidgets('updates preferences', (WidgetTester tester) async {
|
2022-09-14 13:03:36 +03:00
|
|
|
await android_test_util.startUp(tester, {
|
|
|
|
'dlg.beta.enabled': true,
|
|
|
|
'needs_yubikey': false,
|
|
|
|
});
|
2022-09-11 12:05:00 +03:00
|
|
|
var prefs = await SharedPreferences.getInstance();
|
2022-09-12 13:58:17 +03:00
|
|
|
await tester.tap(find.byKey(keys.okButton));
|
2022-09-11 12:05:00 +03:00
|
|
|
await expectLater(prefs.getBool(betaDialogPrefName), equals(false));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|