mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2025-01-08 20:08:45 +03:00
update integration tests
This commit is contained in:
parent
9f79cb7973
commit
03b9f2e69c
@ -26,12 +26,15 @@ void main() {
|
||||
var binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
|
||||
|
||||
group('UI tests', () {
|
||||
appTest('OATH Menu items exist', (WidgetTester tester) async {
|
||||
await tester.tapDeviceButton();
|
||||
group('OATH UI tests', () {
|
||||
appTest('Menu items exist', (WidgetTester tester) async {
|
||||
await tester.tapActionIconButton();
|
||||
expect(find.byKey(keys.addAccountAction), findsOneWidget);
|
||||
expect(find.byKey(keys.setOrManagePasswordAction), findsOneWidget);
|
||||
expect(find.byKey(keys.resetAction), findsOneWidget);
|
||||
|
||||
// close dialog
|
||||
await tester.tapTopLeftCorner();
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -42,14 +42,14 @@ class Account {
|
||||
extension OathFunctions on WidgetTester {
|
||||
/// Opens the device menu and taps the "Add account" menu item
|
||||
Future<void> tapAddAccount() async {
|
||||
await tapDeviceButton();
|
||||
await tapActionIconButton();
|
||||
await tap(find.byKey(keys.addAccountAction).hitTestable());
|
||||
await longWait();
|
||||
}
|
||||
|
||||
/// Opens the device menu and taps the "Set/Manage password" menu item
|
||||
Future<void> tapSetOrManagePassword() async {
|
||||
await tapDeviceButton();
|
||||
await tapActionIconButton();
|
||||
await tap(find.byKey(keys.setOrManagePasswordAction));
|
||||
await longWait();
|
||||
}
|
||||
|
@ -75,6 +75,20 @@ extension AppWidgetTester on WidgetTester {
|
||||
await pump(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
Finder findActionIconButton() {
|
||||
return find.byKey(actionsIconButtonKey).hitTestable();
|
||||
}
|
||||
|
||||
Future<void> tapActionIconButton() async {
|
||||
await tap(findActionIconButton());
|
||||
await pump(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
Future<void> tapTopLeftCorner() async {
|
||||
await tapAt(const Offset(0, 0));
|
||||
await longWait();
|
||||
}
|
||||
|
||||
/// Drawer helpers
|
||||
bool hasDrawer() => scaffoldGlobalKey.currentState!.hasDrawer;
|
||||
|
||||
@ -148,23 +162,22 @@ extension AppWidgetTester on WidgetTester {
|
||||
var subtitle = (lt.subtitle as Text?)?.data;
|
||||
|
||||
if (subtitle != null) {
|
||||
RegExpMatch? match = RegExp(r'S/N: (?<SN>\d.*) F/W: (?<FW>\d\.\d\.\d)')
|
||||
RegExpMatch? match = RegExp(r'S/N: (\d.*) F/W: (\d\.\d\.\d)')
|
||||
.firstMatch(subtitle);
|
||||
if (match != null) {
|
||||
yubiKeySerialNumber = match.namedGroup('SN');
|
||||
yubiKeyFirmware = match.namedGroup('FW');
|
||||
yubiKeySerialNumber = match.group(1);
|
||||
yubiKeyFirmware = match.group(2);
|
||||
} else {
|
||||
match = RegExp(r'F/W: (?<FW>\d\.\d\.\d)').firstMatch(subtitle);
|
||||
match = RegExp(r'F/W: (\d\.\d\.\d)').firstMatch(subtitle);
|
||||
if (match != null) {
|
||||
yubiKeyFirmware = match.namedGroup('FW');
|
||||
yubiKeyFirmware = match.group(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// close the opened menu
|
||||
await tapAt(const Offset(0, 0));
|
||||
await longWait();
|
||||
await tapTopLeftCorner();
|
||||
|
||||
testLog(false,
|
||||
'Connected YubiKey: $yubiKeySerialNumber/$yubiKeyFirmware - $yubiKeyName');
|
||||
|
@ -118,6 +118,7 @@ class AppPage extends StatelessWidget {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 4),
|
||||
child: IconButton(
|
||||
key: actionsIconButtonKey,
|
||||
onPressed: () {
|
||||
showBlurDialog(context: context, builder: keyActionsBuilder!);
|
||||
},
|
||||
|
@ -26,6 +26,7 @@ import '../../management/models.dart';
|
||||
import '../models.dart';
|
||||
import '../state.dart';
|
||||
import 'device_avatar.dart';
|
||||
import 'keys.dart';
|
||||
|
||||
final _hiddenDevicesProvider =
|
||||
StateNotifierProvider<_HiddenDevicesNotifier, List<String>>(
|
||||
@ -282,6 +283,7 @@ class _CurrentDeviceRow extends StatelessWidget {
|
||||
children: [
|
||||
_HeroAvatar(child: hero),
|
||||
ListTile(
|
||||
key: deviceInfoListTile,
|
||||
title: Text(messages.removeAt(0), textAlign: TextAlign.center),
|
||||
isThreeLine: messages.length > 1,
|
||||
subtitle: Text(messages.join('\n'), textAlign: TextAlign.center),
|
||||
|
@ -22,6 +22,7 @@ final scaffoldGlobalKey = GlobalKey<ScaffoldState>();
|
||||
const _prefix = 'app.keys';
|
||||
const deviceInfoListTile = Key('$_prefix.device_info_list_tile');
|
||||
const noDeviceAvatar = Key('$_prefix.no_device_avatar');
|
||||
const actionsIconButtonKey = Key('$_prefix.actions_icon_button');
|
||||
|
||||
// drawer items
|
||||
const managementAppDrawer = Key('$_prefix.drawer.management');
|
||||
|
@ -29,6 +29,7 @@ import '../../app/views/app_failure_page.dart';
|
||||
import '../../app/views/app_page.dart';
|
||||
import '../../app/views/graphics.dart';
|
||||
import '../../app/views/message_page.dart';
|
||||
import '../../exception/cancellation_exception.dart';
|
||||
import '../../widgets/list_title.dart';
|
||||
import '../keys.dart' as keys;
|
||||
import '../models.dart';
|
||||
@ -255,21 +256,28 @@ class _UnlockedViewState extends ConsumerState<_UnlockedView> {
|
||||
if (Platform.isAndroid) {
|
||||
final scanner = ref.read(qrScannerProvider);
|
||||
if (scanner != null) {
|
||||
final url = await scanner.scanQr();
|
||||
if (url != null) {
|
||||
otpauth = CredentialData.fromUri(Uri.parse(url));
|
||||
try {
|
||||
final url = await scanner.scanQr();
|
||||
if (url != null) {
|
||||
otpauth = CredentialData.fromUri(Uri.parse(url));
|
||||
}
|
||||
} on CancellationException catch (_) {
|
||||
// ignored - user cancelled
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
await showBlurDialog(
|
||||
context: context,
|
||||
builder: (context) => OathAddAccountPage(
|
||||
widget.devicePath,
|
||||
widget.oathState,
|
||||
credentials: ref.watch(credentialsProvider),
|
||||
credentialData: otpauth,
|
||||
),
|
||||
);
|
||||
await ref.read(withContextProvider)((context) async {
|
||||
await showBlurDialog(
|
||||
context: context,
|
||||
builder: (context) => OathAddAccountPage(
|
||||
widget.devicePath,
|
||||
widget.oathState,
|
||||
credentials: ref.watch(credentialsProvider),
|
||||
credentialData: otpauth,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
: null,
|
||||
),
|
||||
|
Loading…
Reference in New Issue
Block a user