mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-23 00:57:26 +03:00
no accounts and conditional rename functionality
This commit is contained in:
parent
605e70c7c9
commit
b35b0d2fe3
@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:yubico_authenticator/app/views/message_page.dart';
|
||||
import 'package:yubico_authenticator/core/state.dart';
|
||||
import 'package:yubico_authenticator/oath/views/account_list.dart';
|
||||
import 'package:yubico_authenticator/oath/views/account_view.dart';
|
||||
@ -27,6 +28,9 @@ const deviceMenuAddAccountKey = Key('add oath account');
|
||||
const deviceMenuSetManagePasswordKey = Key('set or manage oath password');
|
||||
const deviceMenuResetOathKey = Key('reset oath app');
|
||||
|
||||
const noAccountsMessagePage = Key('oath.message_page.no_accounts');
|
||||
|
||||
|
||||
class Account {
|
||||
final String? issuer;
|
||||
final String name;
|
||||
@ -116,6 +120,13 @@ extension OathFunctions on WidgetTester {
|
||||
}
|
||||
|
||||
Future<AccountView?> findAccount(Account a, {bool quiet = true}) async {
|
||||
|
||||
if (find.byKey(noAccountsMessagePage).hitTestable().evaluate().isNotEmpty) {
|
||||
/// if there is no OATH account on the YubiKey, the app shows
|
||||
/// No accounts [MessagePage]
|
||||
return null;
|
||||
}
|
||||
|
||||
/// find an AccountView with issuer/name in the account list
|
||||
var matchingAccounts = find.descendant(
|
||||
of: findAccountList(),
|
||||
@ -198,6 +209,16 @@ extension OathFunctions on WidgetTester {
|
||||
|
||||
await openAccountDialog(a);
|
||||
var renameIconButton = find.byIcon(Icons.edit_outlined).hitTestable();
|
||||
|
||||
/// only newer FW supports renaming
|
||||
/// TODO verify this is correct for the FW of the YubiKey
|
||||
if (renameIconButton.evaluate().isEmpty) {
|
||||
/// close the dialog and return
|
||||
await tapAt(const Offset(10, 10));
|
||||
await shortWait();
|
||||
return;
|
||||
}
|
||||
|
||||
expect(renameIconButton, findsOneWidget);
|
||||
await tap(renameIconButton);
|
||||
await longWait();
|
||||
|
@ -121,6 +121,7 @@ class _UnlockedViewState extends ConsumerState<_UnlockedView> {
|
||||
if (credentials?.isEmpty == true) {
|
||||
return MessagePage(
|
||||
title: Text(AppLocalizations.of(context)!.oath_authenticator),
|
||||
key: const Key('oath.message_page.no_accounts'),
|
||||
graphic: noAccounts,
|
||||
header: AppLocalizations.of(context)!.oath_no_accounts,
|
||||
keyActions: _buildActions(
|
||||
|
Loading…
Reference in New Issue
Block a user