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

feat(e2e): Expands verification of our Trading tests based on feedback #17363

Merged
merged 4 commits into from
Mar 5, 2025

Conversation

Vere-Grey
Copy link
Contributor

Description

feat(e2e): Expands verification of our Trading tests based on feedback:

  • more verifications of different values and headers
  • ending redirect back to account
  • partners support link

Related Issue

@Vere-Grey Vere-Grey requested a review from HajekOndrej March 3, 2025 18:22
@Vere-Grey Vere-Grey self-assigned this Mar 3, 2025
@Vere-Grey Vere-Grey requested a review from a team as a code owner March 3, 2025 18:22
@@ -1,5 +1,4 @@
{
"status": "SEND_CRYPTO",
"destinationAddress": "ENk2eeP4umP6cjAGRsVG4NEVKEVQmRn6JEpN8hubv2Hf",
"destinationPaymentExtraId": "6d666a5f-b99c-4482-b8bc-2df04fc11b7b"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This value shouldn't be returned for Solana

@@ -5,7 +5,7 @@
"quoteId": "9fd5573d-fb81-423b-84b6-31903770fecf",
"status": "CONFIRM",
"statusUrl": "https://changenow.io/exchange/txs/3b45492e83ae8e",
"exchange": "changenowfr",
"exchange": "changeherofr",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

to match best quote

Copy link

coderabbitai bot commented Mar 3, 2025

Walkthrough

The pull request implements updates across component files, JSON fixtures, and end-to-end tests to improve testability and streamline trade confirmation processes. In UI components, several elements now include data-testid attributes for easier targeting during tests. JSON fixture updates include the removal of an unnecessary key and the modification of an exchange field value. In end-to-end trading tests, method signatures are revised—now accepting explicit parameters (e.g., strings like "Bitcoin #1", "Ethereum #1", or "Solana #1")—and additional assertions validate header texts, formatted addresses, crypto amounts with symbols, fee values, and proper navigation flows. Classes such as DevicePrompt and TradingPage are enhanced with new properties and renamed methods to support these changes. These modifications do not affect the underlying business logic but enhance the precision and reliability of UI and transaction validations during testing.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c7a29cc and c9dd532.

📒 Files selected for processing (20)
  • packages/components/src/components/NewModal/NewModal.tsx (1 hunks)
  • packages/suite-desktop-core/e2e/fixtures/invity/sell/watch-solana.json (1 hunks)
  • packages/suite-desktop-core/e2e/fixtures/invity/swap/trade-solana-usdc.json (1 hunks)
  • packages/suite-desktop-core/e2e/snapshots/web/wallet/cardano.test.ts/cardano-aria.ts (1 hunks)
  • packages/suite-desktop-core/e2e/support/pageObjects/dashboardPage.ts (3 hunks)
  • packages/suite-desktop-core/e2e/support/pageObjects/devicePrompt.ts (2 hunks)
  • packages/suite-desktop-core/e2e/support/pageObjects/tradingPage.ts (5 hunks)
  • packages/suite-desktop-core/e2e/tests/passphrase/passphrase-numbering.test.ts (2 hunks)
  • packages/suite-desktop-core/e2e/tests/trading/buy-bitcoin.test.ts (3 hunks)
  • packages/suite-desktop-core/e2e/tests/trading/buy-ethereum.test.ts (2 hunks)
  • packages/suite-desktop-core/e2e/tests/trading/buy-solana-token.test.ts (2 hunks)
  • packages/suite-desktop-core/e2e/tests/trading/sell-bitcoin.test.ts (3 hunks)
  • packages/suite-desktop-core/e2e/tests/trading/sell-ethereum-token.test.ts (2 hunks)
  • packages/suite-desktop-core/e2e/tests/trading/sell-solana.test.ts (4 hunks)
  • packages/suite-desktop-core/e2e/tests/trading/swap-coin-to-token.test.ts (2 hunks)
  • packages/suite-desktop-core/e2e/tests/trading/swap-coins.test.ts (5 hunks)
  • packages/suite-desktop-core/e2e/tests/trading/swap-token-to-coin.test.ts (3 hunks)
  • packages/suite-desktop-core/e2e/tests/trading/swap-tokens.test.ts (3 hunks)
  • packages/suite/src/views/wallet/trading/common/TradingSelectedOffer/TradingInfo/TradingInfoExchangeType.tsx (1 hunks)
  • packages/suite/src/views/wallet/trading/common/TradingTransactionId.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/suite-desktop-core/e2e/snapshots/web/wallet/cardano.test.ts/cardano-aria.ts
🚧 Files skipped from review as they are similar to previous changes (16)
  • packages/suite-desktop-core/e2e/fixtures/invity/swap/trade-solana-usdc.json
  • packages/suite/src/views/wallet/trading/common/TradingTransactionId.tsx
  • packages/suite-desktop-core/e2e/fixtures/invity/sell/watch-solana.json
  • packages/suite/src/views/wallet/trading/common/TradingSelectedOffer/TradingInfo/TradingInfoExchangeType.tsx
  • packages/suite-desktop-core/e2e/tests/trading/buy-solana-token.test.ts
  • packages/suite-desktop-core/e2e/tests/trading/swap-tokens.test.ts
  • packages/components/src/components/NewModal/NewModal.tsx
  • packages/suite-desktop-core/e2e/tests/trading/sell-ethereum-token.test.ts
  • packages/suite-desktop-core/e2e/tests/trading/sell-solana.test.ts
  • packages/suite-desktop-core/e2e/tests/trading/buy-ethereum.test.ts
  • packages/suite-desktop-core/e2e/support/pageObjects/devicePrompt.ts
  • packages/suite-desktop-core/e2e/tests/trading/swap-coin-to-token.test.ts
  • packages/suite-desktop-core/e2e/tests/trading/sell-bitcoin.test.ts
  • packages/suite-desktop-core/e2e/tests/trading/swap-coins.test.ts
  • packages/suite-desktop-core/e2e/tests/trading/buy-bitcoin.test.ts
  • packages/suite-desktop-core/e2e/tests/trading/swap-token-to-coin.test.ts
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: run-desktop-tests (@group=wallet, trezor-user-env-unix bitcoin-regtest)
  • GitHub Check: Analyze with CodeQL (javascript)
  • GitHub Check: Setup and Cache Dependencies
  • GitHub Check: build-web
🔇 Additional comments (12)
packages/suite-desktop-core/e2e/support/pageObjects/tradingPage.ts (5)

99-99: Good addition for navigation flow testing.

Adding this locator allows for proper testing of the user journey back to their account after completing a trade, which aligns with the PR objective of implementing "an ending redirect that returns users back to their account after completing the Trading tests."


113-115: Enhanced verification capabilities added.

These new locators support the PR objective of "increased verification of various values and headers" by allowing tests to verify exchange type information and transaction ID details in the confirmation view.


174-174: Proper initialization of new button locator.

The locator initialization matches the button's role and text, making it easily identifiable in the DOM.


195-198: Appropriate initialization of transaction ID-related locators.

These initializations provide the correct selectors for verifying transaction details. The structured approach with separate locators for the ID display and copy button follows good testing practices.


365-368: Improved trade confirmation verification.

This method signature change enhances testing by:

  1. Making account name a required parameter, ensuring proper verification
  2. Adding an assertion to validate the account name in the device prompt header
  3. Keeping address verification as an optional step

This change directly supports the PR objective of "increased verification of various values and headers to ensure more comprehensive testing."

packages/suite-desktop-core/e2e/tests/passphrase/passphrase-numbering.test.ts (3)

17-17: Option parameter removed for consistency with default behavior.

This change aligns with the updated default behavior in the addUnusedHiddenWallet method, which now has { skipDiscovery: true } as the default value. The code is now more concise while maintaining the same functionality.


20-20: Option parameter removed for consistency with default behavior.

This change aligns with the updated default behavior in the addUnusedHiddenWallet method, which now has { skipDiscovery: true } as the default value. The code is now more concise while maintaining the same functionality.


35-35: Option parameter removed for consistency with default behavior.

This change aligns with the updated default behavior in the addUnusedHiddenWallet method, which now has { skipDiscovery: true } as the default value. The code is now more concise while maintaining the same functionality.

packages/suite-desktop-core/e2e/support/pageObjects/dashboardPage.ts (4)

38-39: Good addition of explicit locators for multi-step wallet opening.

These new locators improve the code's readability and maintainability by giving descriptive names to the UI elements involved in the two-step process of opening an unused wallet.


69-74: Well-structured locator initialization with clear test IDs.

The initialization is properly placed in the constructor and uses descriptive test IDs that clearly indicate the purpose of each button in the two-step process of opening an unused wallet.


133-139: Improved method signature with informative comments.

The updated method signature now includes:

  1. A default value for the options parameter, making the code more concise
  2. Detailed comments explaining why the discovery bar assertion is skipped, which helps future developers understand the design decision

This change aligns with the modifications in the passphrase-numbering test and improves the overall code quality.


141-146: Enhanced error handling with clear assertions.

This improvement:

  1. Adds an explicit expectation that the button is enabled before attempting to click it
  2. Includes a meaningful error message that explains possible causes if the assertion fails
  3. Uses a reasonable timeout (30 seconds) to accommodate varying performance conditions

This makes the test more robust and easier to debug when failures occur.

✨ 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: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1fe2205 and d6e1675.

📒 Files selected for processing (17)
  • packages/components/src/components/NewModal/NewModal.tsx (1 hunks)
  • packages/suite-desktop-core/e2e/fixtures/invity/sell/watch-solana.json (1 hunks)
  • packages/suite-desktop-core/e2e/fixtures/invity/swap/trade-solana-usdc.json (1 hunks)
  • packages/suite-desktop-core/e2e/support/pageObjects/devicePrompt.ts (2 hunks)
  • packages/suite-desktop-core/e2e/support/pageObjects/tradingPage.ts (5 hunks)
  • packages/suite-desktop-core/e2e/tests/trading/buy-bitcoin.test.ts (3 hunks)
  • packages/suite-desktop-core/e2e/tests/trading/buy-ethereum.test.ts (2 hunks)
  • packages/suite-desktop-core/e2e/tests/trading/buy-solana-token.test.ts (2 hunks)
  • packages/suite-desktop-core/e2e/tests/trading/sell-bitcoin.test.ts (3 hunks)
  • packages/suite-desktop-core/e2e/tests/trading/sell-ethereum-token.test.ts (2 hunks)
  • packages/suite-desktop-core/e2e/tests/trading/sell-solana.test.ts (4 hunks)
  • packages/suite-desktop-core/e2e/tests/trading/swap-coin-to-token.test.ts (2 hunks)
  • packages/suite-desktop-core/e2e/tests/trading/swap-coins.test.ts (5 hunks)
  • packages/suite-desktop-core/e2e/tests/trading/swap-token-to-coin.test.ts (3 hunks)
  • packages/suite-desktop-core/e2e/tests/trading/swap-tokens.test.ts (3 hunks)
  • packages/suite/src/views/wallet/trading/common/TradingSelectedOffer/TradingInfo/TradingInfoExchangeType.tsx (1 hunks)
  • packages/suite/src/views/wallet/trading/common/TradingTransactionId.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/suite-desktop-core/e2e/fixtures/invity/sell/watch-solana.json
🧰 Additional context used
🧠 Learnings (5)
packages/suite-desktop-core/e2e/tests/trading/swap-token-to-coin.test.ts (1)
Learnt from: Vere-Grey
PR: trezor/trezor-suite#17199
File: packages/suite-desktop-core/e2e/tests/trading/swap-coin-to-token.test.ts:34-38
Timestamp: 2025-02-24T15:31:48.018Z
Learning: Network configuration changes (enableNetwork/disableNetwork) in e2e tests only affect the specific suite instance and modify network visibility within that suite. Test isolation is handled by the framework.
packages/suite-desktop-core/e2e/tests/trading/swap-coin-to-token.test.ts (1)
Learnt from: Vere-Grey
PR: trezor/trezor-suite#17199
File: packages/suite-desktop-core/e2e/tests/trading/swap-coin-to-token.test.ts:34-38
Timestamp: 2025-02-24T15:31:48.018Z
Learning: Network configuration changes (enableNetwork/disableNetwork) in e2e tests only affect the specific suite instance and modify network visibility within that suite. Test isolation is handled by the framework.
packages/suite-desktop-core/e2e/tests/trading/sell-bitcoin.test.ts (1)
Learnt from: Vere-Grey
PR: trezor/trezor-suite#16889
File: packages/suite-desktop-core/e2e/fixtures/invity/sell/trade-bitcoin.json:3-5
Timestamp: 2025-02-07T14:56:05.894Z
Learning: The test suite intentionally uses mainnet addresses (e.g. "bc1" prefixed Bitcoin addresses) in test fixtures while mocking all external service interactions. This approach was chosen over using testnet addresses with live endpoints due to previous timeout issues encountered with Invity's testnet endpoints.
packages/suite-desktop-core/e2e/tests/trading/sell-solana.test.ts (1)
Learnt from: Vere-Grey
PR: trezor/trezor-suite#17018
File: packages/suite-desktop-core/e2e/fixtures/invity/sell/trade-solana.json:6-6
Timestamp: 2025-02-15T07:33:25.449Z
Learning: The "pk_live_" prefixed keys in Moonpay API mocked responses are public keys and don't need to be replaced with placeholder values in test fixtures.
packages/suite-desktop-core/e2e/tests/trading/swap-coins.test.ts (1)
Learnt from: Vere-Grey
PR: trezor/trezor-suite#17199
File: packages/suite-desktop-core/e2e/tests/trading/swap-coin-to-token.test.ts:34-38
Timestamp: 2025-02-24T15:31:48.018Z
Learning: Network configuration changes (enableNetwork/disableNetwork) in e2e tests only affect the specific suite instance and modify network visibility within that suite. Test isolation is handled by the framework.
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: run-desktop-tests (@group=wallet, trezor-user-env-unix bitcoin-regtest)
  • GitHub Check: run-desktop-tests (@group=other, trezor-user-env-unix)
  • GitHub Check: run-desktop-tests (@group=passphrase, trezor-user-env-unix)
  • GitHub Check: run-desktop-tests (@group=settings, trezor-user-env-unix bitcoin-regtest)
  • GitHub Check: run-desktop-tests (@group=device-management, trezor-user-env-unix)
  • GitHub Check: build-web
  • GitHub Check: run-desktop-tests (@group=suite, trezor-user-env-unix)
  • GitHub Check: Setup and Cache Dependencies
  • GitHub Check: Analyze with CodeQL (javascript)
🔇 Additional comments (48)
packages/suite/src/views/wallet/trading/common/TradingTransactionId.tsx (1)

41-41: Added test identifier for transaction ID element.

Adding the data-testid attribute improves testability by providing a stable selector for E2E tests to target the transaction ID element. This aligns with the PR objective of expanding verification in Trading tests.

packages/suite/src/views/wallet/trading/common/TradingSelectedOffer/TradingInfo/TradingInfoExchangeType.tsx (1)

25-25: Added test identifier for exchange type information.

The data-testid attribute enhances E2E test coverage by providing a reliable selector for verifying the exchange type display. This supports the PR's goal of increasing verification of trading values.

packages/components/src/components/NewModal/NewModal.tsx (2)

124-128: Added test identifier for modal header.

Adding a data-testid to the modal header makes it easier to verify the content in E2E tests. This is particularly useful for testing user flows that involve modal interactions and confirms the PR's focus on expanding verification.


129-138: Added test identifier for modal description paragraph.

The data-testid for the description paragraph enhances testability by providing a specific selector for verification in E2E tests. This addition seems to support the mentioned "implementation of an ending redirect" in the PR objectives, where confirmation dialogs with descriptive text would need to be verified.

packages/suite-desktop-core/e2e/tests/trading/swap-tokens.test.ts (5)

20-20: Improved test readability by extracting the formatted address.

Good change extracting the formatted address into a named constant. This enhances readability and follows the pattern already established for other formatted values.


59-59: Enhanced the confirmTrade method signature.

The updated call to confirmTrade now explicitly requires the account name ('Solana #1') and the formatted address, which is a good improvement that makes the intention clearer and the test more robust.


82-82: Added validation for the device prompt header.

Good addition - verifying that the device prompt properly displays the account name ('Solana #1') is important for ensuring the user knows which account is being used for the transaction.


85-88: Enhanced device prompt validation for crypto amounts and fees.

The change from cryptoAmountOf to cryptoAmountWithSymbolOf and the addition of a fee validation improves the test by ensuring:

  1. The displayed amount includes the currency symbol
  2. The transaction fee is a non-zero value

This provides more comprehensive verification of what the user will see during the transaction flow.


96-103: Added comprehensive confirmation value verification.

Good addition of verification steps for the transaction details after approval. This ensures the user is shown the correct:

  • Send and receive amounts with proper formatting
  • Exchange type information
  • Provider details

These checks are crucial for validating the entire transaction experience.

packages/suite-desktop-core/e2e/tests/trading/swap-token-to-coin.test.ts (5)

20-20: Improved test readability with consistent address formatting.

Good addition of the formatted address constant, maintaining consistency with other tests and improving code readability.


59-59: Enhanced confirmTrade with explicit account name and address.

The updated method signature for confirmTrade now requires two explicit parameters: the account name ('Bitcoin #1') and the formatted receive address. This makes the test more explicit about the trading destination.


82-82: Added validation for transaction source account.

Good addition verifying that the device prompt header correctly displays 'Solana #1' as the source account, which ensures the user is informed about which account is being used for the transaction.


85-88: Enhanced transaction amount and fee verification.

Good update to use cryptoAmountWithSymbolOf for validating the full amount display (including currency symbol) and adding a check that the fee is greater than zero. This ensures proper display of transaction costs to the user.


96-103: Added comprehensive confirmation value verification.

Good addition of assertions to verify all key transaction details after approval, including:

  • Send and receive amounts with proper formatting
  • Exchange type information ('Fixed-rate offer')
  • Provider details

This provides validation of the complete transaction confirmation experience.

packages/suite-desktop-core/e2e/tests/trading/sell-ethereum-token.test.ts (2)

21-21: Added commented address formatting for future implementation.

The addition of a commented line for formatting the destination address suggests preparation for future implementation. Ensure the import for formatAddress is also added when uncommenting this code.

Is there a specific reason why this part is commented out? When implementing it in the future, remember to add the missing import:

+ import { formatAddress } from '../../support/common';

79-84: Enhanced device prompt validation in commented code.

The commented-out code includes improvements to the device prompt validation, following the same pattern as the other test files:

  1. Verifying the header paragraph contains the account name
  2. Validating the formatted address display
  3. Using cryptoAmountWithSymbolOf for amount verification
  4. Adding a fee verification

This will provide more comprehensive testing once implemented, consistent with the other tests.

packages/suite-desktop-core/e2e/tests/trading/sell-bitcoin.test.ts (3)

11-11: Added import for formatAddress utility.

Good addition of the import for the formatAddress function, which is used to format the provider's destination address.


23-23: Added formatted address constant for improved readability.

Good extraction of the formatted address into a named constant, which improves code readability and follows the pattern established in other test files.


77-82: Enhanced device prompt validation for comprehensive user experience testing.

Excellent improvements to the device prompt verification:

  1. Validating that the header paragraph displays the correct account name
  2. Verifying the formatted address is displayed correctly
  3. Using cryptoAmountWithSymbolOf to check the full amount with currency symbol
  4. Adding validation that the fee is greater than zero

These checks ensure the user is presented with complete and accurate information during the transaction process.

packages/suite-desktop-core/e2e/tests/trading/buy-solana-token.test.ts (2)

58-58: Good enhancement to the confirmTrade method.

The method signature update to include the account name ('Solana #1') as the first parameter improves test clarity and strengthens verification. This change ensures that we're explicitly validating which account is being used for the transaction.


82-85: Great addition of navigation verification.

Adding this test step ensures the user is properly returned to the account buy form after completing the transaction. This improves the end-to-end test coverage by verifying the full user journey.

packages/suite-desktop-core/e2e/tests/trading/sell-solana.test.ts (5)

11-11: Appropriate import addition.

Good addition of the formatAddress import to standardize address formatting across test files.


25-25: Good reuse of formatAddress function.

Creating a formatted address constant improves code readability and ensures consistent address formatting throughout the test.


90-95: Excellent enhancement to device prompt verification.

These new assertions significantly improve test quality by verifying critical elements:

  1. Account name displayed in header
  2. Properly formatted address
  3. Accurate crypto amount with correct symbol
  4. Non-zero fee amount

This comprehensive verification helps catch potential UI and formatting issues early.


115-118: Good additional verification after status change.

These assertions ensure the transaction details remain consistent after the trade status changes to success, providing better confidence in the UI state management.


120-123: Great addition of navigation verification.

This test step verifies the complete user journey by ensuring they can return to the sell form after completing a transaction. The URL pattern check confirms navigation to the correct network and account.

packages/suite-desktop-core/e2e/tests/trading/buy-ethereum.test.ts (5)

61-66: Excellent verification of account selection options.

Testing the visibility of both Ethereum accounts ensures the account selection dropdown is functioning correctly and displaying all available options to users.


70-70: Good verification of the device prompt header.

Checking that the header correctly shows 'Ethereum #1' ensures the prompt is displaying the correct account information to users during confirmation.


84-84: Improved clarity with direct button interaction.

Using a direct button click instead of a commented approach streamlines the test code and makes the flow more explicit.


87-94: Excellent addition of transaction detail verification.

These assertions comprehensively validate the transaction status and details after confirmation, ensuring all values are displayed correctly to the user.


96-100: Great addition of navigation verification with useful comment.

The test step ensures proper navigation after transaction completion. The comment on line 98 highlights a potential design consideration about which account's buy form should be displayed after completion.

This is a good question worth investigating. Should the user be returned to BTC (where the flow started) or ETH (which was bought)? Consider discussing this with the product team to confirm the intended behavior.

packages/suite-desktop-core/e2e/tests/trading/swap-coin-to-token.test.ts (4)

59-59: Good enhancement to the confirmTrade method.

Adding the account name parameter ('Ethereum #1') enhances verification specificity and ensures consistency with other trading tests.


82-87: Excellent enhancement to device prompt verification.

These improved assertions provide more comprehensive validation:

  1. Account name in header
  2. Correctly formatted address
  3. Crypto amount with proper symbol formatting
  4. Non-zero fee verification

These changes align with the verification improvements in other trading test files.


95-103: Great addition of detailed confirmation verification.

These assertions thoroughly verify all aspects of the swap transaction after approval, including:

  1. Send amount
  2. Receive amount
  3. Exchange type
  4. Provider information

This comprehensive verification ensures a complete and accurate user experience.


105-108: Good addition of navigation verification.

Like the other trading tests, this step ensures the full user journey is verified by checking proper navigation back to the account swap form with an appropriate URL pattern.

packages/suite-desktop-core/e2e/tests/trading/swap-coins.test.ts (6)

26-26: Good extraction of formatted address into a variable.

The extracted variable improves code readability by making it clear what data is being passed to the confirmTrade method.


49-49: Method signature update looks good.

The change to accept a parameter object with symbol property improves the method's flexibility and makes the code more self-documenting.


68-68: Improved trade confirmation with explicit account name.

The updated method call now explicitly passes the account name ('Bitcoin #1') along with the formatted address, which aligns with the updated method signature in the TradingPage class.


91-96: Enhanced verification with additional assertions.

The changes now:

  1. Use cryptoAmountWithSymbolOf to verify the amount with the symbol
  2. Add a validation that the fee amount is greater than zero

These improvements provide more thorough validation of the trading process.


107-113: Excellent addition of partner support link verification.

This new test step validates an important user flow - ensuring that the provider support link opens in a new tab with the correct URL pattern, which improves the test coverage.


126-135: Comprehensive transaction value verification added.

The new test step thoroughly verifies all transaction values after the status changes, including:

  • Crypto amounts for both sent and received currencies
  • Exchange type
  • Provider information

This adds significant value to the test coverage.

packages/suite-desktop-core/e2e/support/pageObjects/devicePrompt.ts (2)

16-17: Good separation of cryptocurrency amount getters.

The rename of the original method to cryptoAmountWithSymbolOf and addition of a new cryptoAmountOf method improves the API by clearly differentiating between getting:

  1. Amount with symbol (e.g., "0.01 BTC")
  2. Amount only (e.g., "0.01")

This allows for more precise testing.

Also applies to: 20-21


26-27: Useful header element accessors added.

The new properties header and headerParagraph with their initializations provide access to important UI elements in the modal, enhancing the ability to validate header content during tests.

Also applies to: 39-40

packages/suite-desktop-core/e2e/tests/trading/buy-bitcoin.test.ts (3)

46-46: Updated method call aligns with the new signature.

The confirmTrade method call now includes the account name ('Bitcoin #1') as the first parameter, which correctly aligns with the updated method signature in the TradingPage class.


60-60: Consistent method call update.

Similar to the previous comment, this method call has been updated to match the new signature, maintaining consistency throughout the test file.


91-94: Excellent addition of account redirect verification.

This new test step verifies an important user flow - ensuring that after completing a transaction, users can return to their account page via the "Back to Account" button. This enhances the overall test coverage of the user experience.

packages/suite-desktop-core/e2e/support/pageObjects/tradingPage.ts (2)

99-99: Good addition of new UI element accessors.

The new properties and their initializations provide access to important UI elements:

  • backToAccountButton: Enables verification of navigation back to the account page
  • confirmationExchangeType: Allows checking the type of exchange (e.g., fixed-rate)
  • confirmationTransactionId: Provides access to the transaction identifier
  • copyTransactionIdButton: Enables testing of the copy functionality

These additions enhance the test coverage for the trading pages.

Also applies to: 113-115, 174-174, 194-198


365-368: Improved trade confirmation with account name validation.

The method signature update and the new assertion provide more thorough validation by:

  1. Requiring an explicit account name parameter (making it non-optional)
  2. Verifying that the header paragraph in the device prompt contains the specified account name

This ensures that trades are being confirmed for the correct account, which is an essential check.

@Vere-Grey Vere-Grey force-pushed the feat/suite-desktop-core/enrich-e2e-trading-tests branch from c7a29cc to c9dd532 Compare March 4, 2025 08:49
@Vere-Grey Vere-Grey merged commit 6417720 into develop Mar 5, 2025
28 checks passed
@Vere-Grey Vere-Grey deleted the feat/suite-desktop-core/enrich-e2e-trading-tests branch March 5, 2025 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants