Skip to content
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

test(suite-native): receive flow e2e test added #17264

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

PeKne
Copy link
Contributor

@PeKne PeKne commented Feb 26, 2025

Description

  • receive flow with on Trezor device confirmation e2e test added

@PeKne PeKne added the mobile Suite Lite issues and PRs label Feb 26, 2025
@PeKne PeKne self-assigned this Feb 26, 2025
@PeKne PeKne requested a review from a team as a code owner February 26, 2025 15:48
Copy link

coderabbitai bot commented Feb 26, 2025

Walkthrough

The changes enhance the "Receive" functionality by adding both new actions and testing support. A new asynchronous method is introduced to interact with the receive UI element, and a dedicated actions class is created to encapsulate behaviors such as waiting for the receive screen, clicking the address button, and verifying the displayed address. Complementing these actions, an end-to-end test specifically for Android devices has been added, which simulates the complete user journey including emulator setup, onboarding bypass, network and asset navigation, and verifying receive address outcomes. Additionally, UI components now include extra identifiers (via testID props) to improve their testability without altering existing logic or behavior. Overall, the modifications are aimed at extending functionality and robustness in testing scenarios related to the receive feature.

Tip

CodeRabbit's docstrings feature is now available as part of our Pro Plan! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
suite-native/app/e2e/pageObjects/accountReceiveActions.ts (2)

3-3: Class naming should use PascalCase.

The class name uses camelCase (accountReceiveActions) which is inconsistent with other action classes in the codebase that use PascalCase (like AccountDetailActions).

-class accountReceiveActions {
+class AccountReceiveActions {

26-26: Update exported instance name to match class name.

If you update the class name to PascalCase, make sure to update the exported instance name as well for consistency.

-export const onAccountReceive = new accountReceiveActions();
+export const onAccountReceive = new AccountReceiveActions();
suite-native/app/e2e/tests/receive.test.ts (3)

14-14: Consider documenting why this test is Android-specific.

The conditionalDescribe limits execution to Android platforms, but there's no explanation why. If there are platform-specific behaviors or limitations, adding a brief comment would help other developers understand the test's scope.


33-36: Replace hardcoded address with a dynamic expectation.

The test verifies against a hardcoded address (bc1qa55m6kz3crfse5xg2rukulyap4eyp75w0puawz), which could make the test brittle if addresses change due to emulator resets or configuration changes.

Consider either:

  1. Retrieving the expected address dynamically from the Trezor emulator
  2. Using address pattern validation instead of exact matching
  3. Adding a comment explaining why this specific address is used
- await onAccountReceive.verifyReceiveAddress('bc1qa55m6kz3crfse5xg2rukulyap4eyp75w0puawz');
+ // Example of dynamic address retrieval (implementation would depend on your architecture)
+ const expectedAddress = await TrezorUserEnvLink.getFirstAvailableAddress('btc');
+ await onAccountReceive.verifyReceiveAddress(expectedAddress);

37-37: Consider adding error handling for disconnection.

The disconnect operation lacks error handling. If the disconnection fails, the test might not clean up properly.

- disconnectTrezorUserEnv();
+ try {
+   await disconnectTrezorUserEnv();
+ } catch (error) {
+   console.error('Failed to disconnect Trezor user environment:', error);
+   // Consider whether to fail the test or just log the error
+ }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fce4f90 and 5b33c28.

📒 Files selected for processing (5)
  • suite-native/app/e2e/pageObjects/accountDetailActions.ts (1 hunks)
  • suite-native/app/e2e/pageObjects/accountReceiveActions.ts (1 hunks)
  • suite-native/app/e2e/tests/receive.test.ts (1 hunks)
  • suite-native/qr-code/src/components/AddressQRCode.tsx (1 hunks)
  • suite-native/receive/src/components/ShowAddressButtons.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: prepare_android_test_app
  • GitHub Check: Setup and Cache Dependencies
  • GitHub Check: Analyze with CodeQL (javascript)
🔇 Additional comments (8)
suite-native/app/e2e/pageObjects/accountDetailActions.ts (1)

19-22: Excellent addition of the openReceive method.

The implementation follows the same pattern as the existing openSend method, maintaining consistency in the codebase.

suite-native/receive/src/components/ShowAddressButtons.tsx (1)

40-45: Good testability improvement with testID addition.

Adding the testID to the Button component enhances the component's testability without changing any functionality, which is exactly what we want for E2E testing support.

suite-native/qr-code/src/components/AddressQRCode.tsx (1)

42-46: Well-implemented testID for address verification.

Adding the testID to this Text component is essential for the E2E test to verify the displayed address. Good implementation that doesn't affect the component's core functionality.

suite-native/app/e2e/pageObjects/accountReceiveActions.ts (2)

8-16: Good implementation of button interaction with appropriate timeouts.

The method properly waits for the button to become visible with a reasonable timeout, taps it, and then verifies that it's no longer visible after the interaction. This ensures that the test will correctly handle any delays in the UI rendering.


18-23: Well-structured address verification method.

This method appropriately waits for the address text to be visible and then verifies that it matches the expected address. The 30-second timeout provides adequate flexibility for device confirmation processes.

suite-native/app/e2e/tests/receive.test.ts (3)

1-13: Well-structured imports and dependencies.

The imports are well-organized, clearly separating test utilities, page objects, and helper functions.


15-29: Test flow is clear and follows best practices.

The test follows a logical progression:

  1. Setting up the emulator and application
  2. Configuring the environment (enabling Bitcoin network)
  3. Navigating to the relevant screen

This organization makes the test easy to understand and maintain.


30-32: Good separation of concerns with page objects.

Using dedicated page objects (onAccountDetail and onAccountReceive) for different screens follows best practices for E2E testing, improving maintainability and reusability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mobile Suite Lite issues and PRs
Projects
Status: 🏃‍♀️ In progress
Development

Successfully merging this pull request may close these issues.

1 participant