-
Notifications
You must be signed in to change notification settings - Fork 45
feat: TW-2991 display recovery key in the app #2914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
integration_test/robots/setting/settings_recovery_key_robot.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| import 'dart:io'; | ||
|
|
||
| import 'package:flutter/cupertino.dart'; | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:flutter/services.dart'; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
| import 'package:patrol/patrol.dart'; | ||
|
|
||
| import 'package:fluffychat/generated/l10n/app_localizations.dart'; | ||
|
|
||
| import '../home_robot.dart'; | ||
|
|
||
| class SettingsRecoveryKeyRobot extends HomeRobot { | ||
| SettingsRecoveryKeyRobot(super.$); | ||
|
|
||
| PatrolFinder recoveryKeyItem() { | ||
| return $(const Key('recovery_key_settings_item')); | ||
| } | ||
|
|
||
| PatrolFinder recoveryKeyCopyButton() { | ||
| return $(const Key('recovery_key_copy_button')); | ||
| } | ||
|
|
||
| Future<void> waitForRecoveryKeyVisible() async { | ||
| await $.waitUntilVisible(recoveryKeyItem()); | ||
| } | ||
|
|
||
| /// Taps the copy button, then confirms the warning dialog by tapping "Copy". | ||
| Future<void> tapCopyAndConfirm() async { | ||
| await recoveryKeyCopyButton().tap(); | ||
| await _tapConfirmCopyInDialog(); | ||
| } | ||
|
|
||
| /// Taps the recovery key row, then confirms the warning dialog. | ||
| Future<void> tapRowAndConfirm() async { | ||
| await recoveryKeyItem().tap(); | ||
| await _tapConfirmCopyInDialog(); | ||
| } | ||
|
|
||
| Future<void> _tapConfirmCopyInDialog() async { | ||
| final context = $.tester.element(find.byType(Scaffold).first); | ||
| final l10n = L10n.of(context)!; | ||
|
|
||
| if (Platform.isAndroid) { | ||
| final copyButton = $( | ||
| AlertDialog, | ||
| ).$(TextButton).containing(find.text(l10n.copy.toUpperCase())); | ||
| await $.waitUntilVisible(copyButton); | ||
| await copyButton.tap(); | ||
| } else { | ||
| final copyButton = $( | ||
| CupertinoAlertDialog, | ||
| ).$(CupertinoDialogAction).containing(find.text(l10n.copy)); | ||
| await $.waitUntilVisible(copyButton); | ||
| await copyButton.tap(); | ||
| } | ||
| } | ||
|
|
||
| /// Reads the current text content from the system clipboard. | ||
| Future<String?> getClipboardText() async { | ||
| final data = await Clipboard.getData(Clipboard.kTextPlain); | ||
| return data?.text; | ||
| } | ||
|
|
||
| /// Verifies the snackbar "Recovery key copied to clipboard" is shown. | ||
| Future<void> verifySnackBarIsShown() async { | ||
| final context = $.tester.element(find.byType(Scaffold).first); | ||
| final l10n = L10n.of(context)!; | ||
| await $.waitUntilVisible($(l10n.recoveryKeyCopiedToClipboard)); | ||
| } | ||
| } |
54 changes: 54 additions & 0 deletions
54
integration_test/tests/setting/settings_recovery_key_test.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import 'package:flutter/services.dart'; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
|
|
||
| import '../../base/test_base.dart'; | ||
| import '../../robots/home_robot.dart'; | ||
| import '../../robots/setting/setting_robot.dart'; | ||
| import '../../robots/setting/settings_recovery_key_robot.dart'; | ||
|
|
||
| void main() { | ||
| TestBase().twakePatrolTest( | ||
| description: | ||
| 'Copy recovery key and verify clipboard contains the actual key', | ||
| test: ($) async { | ||
| // Clear clipboard before test | ||
| await Clipboard.setData(const ClipboardData(text: '')); | ||
|
|
||
| // Navigate to Settings > Privacy and Security | ||
| await HomeRobot($).gotoSettingScreen(); | ||
| await SettingRobot($).openPrivacyAndSecuritySetting(); | ||
|
|
||
| final recoveryKeyRobot = SettingsRecoveryKeyRobot($); | ||
|
|
||
| // Verify recovery key item is visible | ||
| await recoveryKeyRobot.waitForRecoveryKeyVisible(); | ||
|
|
||
| // Tap the copy button and confirm the warning dialog | ||
| await recoveryKeyRobot.tapCopyAndConfirm(); | ||
|
|
||
| // Verify the snackbar confirmation is shown | ||
| await recoveryKeyRobot.verifySnackBarIsShown(); | ||
|
|
||
| // Read clipboard content and verify it contains the actual key | ||
| final clipboardText = await recoveryKeyRobot.getClipboardText(); | ||
|
|
||
| expect( | ||
| clipboardText, | ||
| isNotNull, | ||
| reason: 'Clipboard should contain the recovery key after copy', | ||
| ); | ||
| expect( | ||
| clipboardText, | ||
| isNotEmpty, | ||
| reason: 'Recovery key in clipboard should not be empty', | ||
| ); | ||
| // Ensure the clipboard contains the real key, not the masked bullets | ||
| expect( | ||
| clipboardText, | ||
| isNot(equals('\u2022' * 32)), | ||
| reason: | ||
| 'Clipboard should contain the actual recovery key, not the masked value', | ||
| ); | ||
| }, | ||
| ); | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thank you for that, please separate the refactoring for route path in other PR, then the PR for recovery. It is better to review and make it merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.