diff --git a/integration_test/copy_to_clipboard_test.dart b/integration_test/copy_to_clipboard_test.dart index b343400f9..f46885398 100644 --- a/integration_test/copy_to_clipboard_test.dart +++ b/integration_test/copy_to_clipboard_test.dart @@ -33,7 +33,7 @@ void main() { when(mockTokenFolderRepository.loadFolders()).thenAnswer((_) async => []); when(mockTokenFolderRepository.saveOrReplaceFolders(any)).thenAnswer((_) async => []); }); - testWidgets('AppTest', (tester) async { + testWidgets('Copy to Clipboard Test', (tester) async { await tester.pumpWidget(TestsAppWrapper( overrides: [ settingsProvider.overrideWith((ref) => SettingsNotifier(repository: mockSettingsRepository)), diff --git a/integration_test/rename_and_delete_test.dart b/integration_test/rename_and_delete_test.dart index 552d7bac5..1010f0467 100644 --- a/integration_test/rename_and_delete_test.dart +++ b/integration_test/rename_and_delete_test.dart @@ -37,7 +37,7 @@ void main() { when(mockTokenFolderRepository.loadFolders()).thenAnswer((_) async => []); when(mockTokenFolderRepository.saveOrReplaceFolders(any)).thenAnswer((_) async => []); }); - testWidgets('Rename Token', (tester) async { + testWidgets('Rename and Delete Token', (tester) async { await tester.pumpWidget(TestsAppWrapper( overrides: [ settingsProvider.overrideWith((ref) => SettingsNotifier(repository: mockSettingsRepository)), @@ -46,67 +46,59 @@ void main() { ], child: PrivacyIDEAAuthenticator(customization: ApplicationCustomization.defaultCustomization), )); - await tester.pumpAndSettle(); - await pumpUntilFindNWidgets(tester, find.byType(HOTPTokenWidget), 1, const Duration(seconds: 10)); - expect(find.byType(HOTPTokenWidget), findsOneWidget); - await tester.drag(find.byType(HOTPTokenWidget), const Offset(-300, 0)); - await tester.pumpAndSettle(); - await pumpUntilFindNWidgets(tester, find.byType(EditHOTPTokenAction), 1, const Duration(seconds: 2)); - await tester.tap(find.byType(EditHOTPTokenAction)); - await tester.pumpAndSettle(); - expect(find.text('Edit Token'), findsOneWidget); - expect(find.byType(TextFormField), findsNWidgets(3)); - await tester.enterText(find.byType(TextFormField).first, 'Renamed Token'); - await tester.tap(find.text('Save')); - await tester.pumpAndSettle(); - expect(find.text('Renamed Token'), findsOneWidget); - }); - testWidgets('Rename Token again', (tester) async { - await tester.pumpWidget(TestsAppWrapper( - overrides: [ - settingsProvider.overrideWith((ref) => SettingsNotifier(repository: mockSettingsRepository)), - tokenProvider.overrideWith((ref) => TokenNotifier(repository: mockTokenRepository)), - tokenFolderProvider.overrideWith((ref) => TokenFolderNotifier(repository: mockTokenFolderRepository)), - ], - child: PrivacyIDEAAuthenticator(customization: ApplicationCustomization.defaultCustomization), - )); - await tester.pumpAndSettle(); - await pumpUntilFindNWidgets(tester, find.byType(HOTPTokenWidget), 1, const Duration(seconds: 10)); - expect(find.byType(HOTPTokenWidget), findsOneWidget); - await tester.drag(find.byType(HOTPTokenWidget), const Offset(-300, 0)); - await tester.pumpAndSettle(); - await pumpUntilFindNWidgets(tester, find.byType(EditHOTPTokenAction), 1, const Duration(seconds: 2)); - await tester.tap(find.byType(EditHOTPTokenAction)); - await tester.pumpAndSettle(); - expect(find.text('Edit Token'), findsOneWidget); - expect(find.byType(TextFormField), findsNWidgets(3)); - await tester.enterText(find.byType(TextFormField).first, 'Renamed Token again'); - await tester.tap(find.text('Save')); - await tester.pumpAndSettle(); - expect(find.text('Renamed Token again'), findsOneWidget); - }); - testWidgets('Delete Token', (tester) async { - await tester.pumpWidget(TestsAppWrapper( - overrides: [ - settingsProvider.overrideWith((ref) => SettingsNotifier(repository: mockSettingsRepository)), - tokenProvider.overrideWith((ref) => TokenNotifier(repository: mockTokenRepository)), - tokenFolderProvider.overrideWith((ref) => TokenFolderNotifier(repository: mockTokenFolderRepository)), - ], - child: PrivacyIDEAAuthenticator(customization: ApplicationCustomization.defaultCustomization), - )); - await tester.pumpAndSettle(); - await pumpUntilFindNWidgets(tester, find.byType(HOTPTokenWidget), 1, const Duration(seconds: 10)); - expect(find.byType(HOTPTokenWidget), findsOneWidget); - await tester.drag(find.byType(HOTPTokenWidget), const Offset(-300, 0)); - await tester.pumpAndSettle(); - await pumpUntilFindNWidgets(tester, find.byType(EditHOTPTokenAction), 1, const Duration(seconds: 2)); - await tester.tap(find.byType(DefaultDeleteAction)); - await tester.pumpAndSettle(); - expect(find.text('Edit Token'), findsOneWidget); - expect(find.byType(TextFormField), findsNWidgets(3)); - await tester.enterText(find.byType(TextFormField).first, 'Renamed Token'); - await tester.tap(find.text('Save')); - await tester.pumpAndSettle(); - expect(find.text('Renamed Token'), findsOneWidget); + await _renameToken(tester); + await _renameTokenAgain(tester); + await _deleteToken(tester); }); } + +Future _renameToken(WidgetTester tester) async { + // Rename Token + await tester.pumpAndSettle(); + await pumpUntilFindNWidgets(tester, find.byType(HOTPTokenWidget), 1, const Duration(seconds: 10)); + expect(find.byType(HOTPTokenWidget), findsOneWidget); + await tester.drag(find.byType(HOTPTokenWidget), const Offset(-300, 0)); + await tester.pumpAndSettle(); + await pumpUntilFindNWidgets(tester, find.byType(EditHOTPTokenAction), 1, const Duration(seconds: 2)); + await tester.tap(find.byType(EditHOTPTokenAction)); + await tester.pumpAndSettle(); + expect(find.text('Edit Token'), findsOneWidget); + expect(find.byType(TextFormField), findsNWidgets(3)); + await tester.enterText(find.byType(TextFormField).first, 'Renamed Token'); + await tester.tap(find.text('Save')); + await tester.pumpAndSettle(); + expect(find.text('Renamed Token'), findsOneWidget); +} + +Future _renameTokenAgain(WidgetTester tester) async { + await tester.pumpAndSettle(); + await pumpUntilFindNWidgets(tester, find.byType(HOTPTokenWidget), 1, const Duration(seconds: 10)); + expect(find.byType(HOTPTokenWidget), findsOneWidget); + await tester.drag(find.byType(HOTPTokenWidget), const Offset(-300, 0)); + await tester.pumpAndSettle(); + await pumpUntilFindNWidgets(tester, find.byType(EditHOTPTokenAction), 1, const Duration(seconds: 2)); + await tester.tap(find.byType(EditHOTPTokenAction)); + await tester.pumpAndSettle(); + expect(find.text('Edit Token'), findsOneWidget); + expect(find.byType(TextFormField), findsNWidgets(3)); + await tester.enterText(find.byType(TextFormField).first, 'Renamed Token'); + await tester.tap(find.text('Save')); + await tester.pumpAndSettle(); + expect(find.text('Renamed Token'), findsOneWidget); +} + +Future _deleteToken(WidgetTester tester) async { + await tester.pumpAndSettle(); + await pumpUntilFindNWidgets(tester, find.byType(HOTPTokenWidget), 1, const Duration(seconds: 10)); + expect(find.byType(HOTPTokenWidget), findsOneWidget); + await tester.drag(find.byType(HOTPTokenWidget), const Offset(-300, 0)); + await tester.pumpAndSettle(); + await pumpUntilFindNWidgets(tester, find.byType(EditHOTPTokenAction), 1, const Duration(seconds: 2)); + await tester.tap(find.byType(DefaultDeleteAction)); + await tester.pumpAndSettle(); + expect(find.text('Confirm deletion'), findsOneWidget); + expect(find.text('Delete'), findsOneWidget); + await tester.tap(find.text('Delete')); + await tester.pumpAndSettle(); + expect(find.byType(HOTPTokenWidget), findsNothing); +}