-
-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(e2e): Adds new buy Ethereum test (#16785)
minor refactoring, default watch response is approved now
- Loading branch information
Showing
11 changed files
with
624 additions
and
13 deletions.
There are no files selected for viewing
File renamed without changes.
482 changes: 482 additions & 0 deletions
482
packages/suite-desktop-core/e2e/fixtures/invity/buy/quotes-ethereum.json
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
34 changes: 34 additions & 0 deletions
34
packages/suite-desktop-core/e2e/fixtures/invity/buy/trade-ethereum.json
This file contains 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,34 @@ | ||
{ | ||
"trade": { | ||
"receiveAddress": "0x3f2329C9ADFbcCd9A84f52c906E936A42dA18CB8", | ||
"paymentId": "a77943b27141cfc423ad5dd6df7f2865", | ||
"status": "SUBMITTED", | ||
"originalPaymentId": "c3025b52-8836-49f2-a7c9-07a2560d6034", | ||
"partnerData": "https://trezor.banxa.com?expires=1738581904&id=f32568ce-fd75-44ed-a417-9e7e7d2f2a8c&oid=a77943b27141cfc423ad5dd6df7f2865&signature=14165f0d8e2d24af98efea79efddb9df4e808ac8baec1d5f0487d674e7b6f161", | ||
"exchange": "banxa", | ||
"fiatCurrency": "CZK", | ||
"receiveCurrency": "ethereum", | ||
"rate": 66290.62583937685, | ||
"wantCrypto": false, | ||
"exp": "OnGBiPZ211B633dTxSLnUA==", | ||
"country": "CZ", | ||
"paymentMethodName": "Credit Card", | ||
"fiatStringAmount": "1234.00", | ||
"receiveStringAmount": "0.01861500", | ||
"minFiat": 600, | ||
"maxFiat": 50000, | ||
"minCrypto": 0.00946059, | ||
"maxCrypto": 0.7883824, | ||
"paymentMethod": "creditCard", | ||
"quoteId": "6bb961d0-b927-46b0-97e9-338b6d6c95c6", | ||
"orderId": "dd0d10bc-136a-41f0-8fff-9a760cd341fd", | ||
"partnerData2": "6098" | ||
}, | ||
"tradeForm": { | ||
"form": { | ||
"formMethod": "GET", | ||
"formAction": "https://trezor.banxa.com?expires=1738581904&id=f32568ce-fd75-44ed-a417-9e7e7d2f2a8c&oid=a77943b27141cfc423ad5dd6df7f2865&signature=14165f0d8e2d24af98efea79efddb9df4e808ac8baec1d5f0487d674e7b6f161", | ||
"fields": {} | ||
} | ||
} | ||
} |
This file contains 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"status": "SUBMITTED" | ||
"status": "SUCCESS" | ||
} |
This file contains 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 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 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
93 changes: 90 additions & 3 deletions
93
packages/suite-desktop-core/e2e/tests/trading/buy-ethereum.test.ts
This file contains 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 |
---|---|---|
@@ -1,5 +1,92 @@ | ||
import { test } from '../../support/fixtures'; | ||
import { localizeNumber } from '@suite-common/wallet-utils'; | ||
import { capitalizeFirstLetter } from '@trezor/utils'; | ||
|
||
test.describe('Trading - Buy Solana', { tag: ['@group=other', '@webOnly'] }, () => { | ||
test.skip('Buy Ethereum that is not discovered on wallet yet', () => {}); | ||
import { buyQuotesEthereum, buyTradeEthereum, invityEndpoint } from '../../fixtures/invity'; | ||
import { formatAddress } from '../../support/common'; | ||
import { expect, test } from '../../support/fixtures'; | ||
|
||
// Expected values based on our mocked responses | ||
const fiatAmount = buyQuotesEthereum[3].fiatStringAmount; | ||
const provider = capitalizeFirstLetter(buyQuotesEthereum[3].exchange); | ||
const formattedCryptoAmount = `${localizeNumber(buyQuotesEthereum[3].receiveStringAmount)} ETH`; | ||
const formattedFiatAmount = `CZK ${localizeNumber(fiatAmount, 'en', 2)}`; | ||
const { receiveAddress, paymentMethodName } = buyTradeEthereum.trade; | ||
|
||
test.describe('Trading - Buy Ethereum', { tag: ['@group=other', '@webOnly'] }, () => { | ||
test.beforeEach(async ({ page, marketPage, onboardingPage, dashboardPage }) => { | ||
await marketPage.mockInvity(); | ||
await marketPage.mockInvityTrade(buyTradeEthereum, 'eth'); | ||
await page.route(invityEndpoint.buyQuotes, async route => { | ||
await route.fulfill({ json: buyQuotesEthereum }); | ||
}); | ||
await onboardingPage.completeOnboarding(); | ||
await dashboardPage.discoveryShouldFinish(); | ||
}); | ||
|
||
test('Buy Ethereum that is not discovered on wallet yet', async ({ | ||
page, | ||
dashboardPage, | ||
settingsPage, | ||
devicePrompt, | ||
walletPage, | ||
marketPage, | ||
trezorUserEnvLink, | ||
}) => { | ||
await test.step('Request to buy Ethereum', async () => { | ||
await walletPage.tradingBuyButton.click(); | ||
await marketPage.selectAccount('Ethereum', 'eth'); | ||
await marketPage.setYouPayFiatAmount(fiatAmount); | ||
await expect(marketPage.bestOfferAmount).toHaveText(formattedCryptoAmount); | ||
await expect(marketPage.quoteProvider).toHaveText(provider); | ||
await marketPage.buyBestOfferButton.click(); | ||
}); | ||
|
||
await test.step('Create Ethereum account in trade confirmation dialog', async () => { | ||
await marketPage.buyTermsConfirmButton.click(); | ||
await expect(marketPage.confirmationAccountDropdown).toHaveText( | ||
'Select ETHEREUM receive account', | ||
); | ||
await expect(marketPage.confirmationAddress).toHaveText(''); | ||
await expect(page.getByText('Receive address is required')).toBeVisible(); | ||
|
||
await marketPage.confirmationAccountDropdown.click(); | ||
await page.getByRole('option', { name: 'Create a new Ethereum account' }).click(); | ||
await expect(settingsPage.coins.networkButton('eth')).toBeEnabledCoin(); | ||
await page.getByRole('button', { name: 'Find my Ethereum accounts' }).click(); | ||
await dashboardPage.discoveryShouldFinish(); | ||
await expect(marketPage.confirmationAccountDropdown).toHaveText( | ||
'Ethereum #1Balance: 0 ETH', | ||
); | ||
|
||
await expect(marketPage.confirmationAddress).toHaveValue(receiveAddress); | ||
}); | ||
|
||
await test.step('Confirm Trade', async () => { | ||
await marketPage.confirmOnTrezorButton.click(); | ||
await expect(devicePrompt.outputValueOf('address')).toHaveText( | ||
formatAddress(receiveAddress), | ||
); | ||
await devicePrompt.confirmOnDevicePromptIsShown(); | ||
await trezorUserEnvLink.pressYes(); | ||
await devicePrompt.confirmOnDevicePromptIsHidden(); | ||
|
||
await expect(marketPage.confirmationCryptoAmount).toHaveText(formattedCryptoAmount); | ||
await expect(marketPage.confirmationFiatAmount).toHaveText(formattedFiatAmount); | ||
await expect(marketPage.confirmationProvider).toHaveText( | ||
capitalizeFirstLetter(provider), | ||
); | ||
await expect(marketPage.confirmationPaymentMethod).toHaveText(paymentMethodName); | ||
//TODO: #16766 Uncomment once the issue with the trade confirmation dialog is fixed | ||
// await marketPage.confirmTradeButton.click(); | ||
// }); | ||
|
||
// await test.step('Verify transaction detail', async () => { | ||
// await expect(marketPage.transactionDetailStatus).toHaveText('Approved', { | ||
// timeout: 15_000, | ||
// }); | ||
// await expect(marketPage.confirmationFiatAmount).toHaveText(formattedFiatAmount); | ||
// await expect(marketPage.confirmationCryptoAmount).toHaveText(formattedCryptoAmount); | ||
// await expect(marketPage.confirmationProvider).toHaveText(provider); | ||
}); | ||
}); | ||
}); |
This file contains 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 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