mirror of
https://github.com/zhigang1992/wallet.git
synced 2026-04-29 05:05:32 +08:00
feat: add btc set fee choice
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { Locator, Page } from '@playwright/test';
|
||||
import { CryptoAssetSelectors } from '@tests/selectors/crypto-asset.selectors';
|
||||
import { SendCryptoAssetSelectors } from '@tests/selectors/send.selectors';
|
||||
import { SharedComponentsSelectors } from '@tests/selectors/shared-component.selectors';
|
||||
import { createTestSelector } from '@tests/utils';
|
||||
|
||||
import { RouteUrls } from '@shared/route-urls';
|
||||
|
||||
@@ -21,6 +23,7 @@ export class SendPage {
|
||||
readonly sendMaxButton: Locator;
|
||||
readonly feesRow: Locator;
|
||||
readonly memoRow: Locator;
|
||||
readonly feesCard: Locator;
|
||||
|
||||
constructor(page: Page) {
|
||||
this.page = page;
|
||||
@@ -52,6 +55,7 @@ export class SendPage {
|
||||
this.memoRow = page.getByTestId(SendCryptoAssetSelectors.ConfirmationDetailsMemo);
|
||||
|
||||
this.sendMaxButton = page.getByTestId(SendCryptoAssetSelectors.SendMaxBtn);
|
||||
this.feesCard = page.getByTestId(SharedComponentsSelectors.FeeCard);
|
||||
}
|
||||
|
||||
async selectBtcAndGoToSendForm() {
|
||||
@@ -71,4 +75,10 @@ export class SendPage {
|
||||
await this.page.waitForURL('**' + `${RouteUrls.SendCryptoAsset}/stx`);
|
||||
await this.page.getByTestId(SendCryptoAssetSelectors.SendForm).waitFor();
|
||||
}
|
||||
|
||||
async waitForSendPageReady() {
|
||||
await this.page.waitForSelector(createTestSelector(SendCryptoAssetSelectors.SendPageReady), {
|
||||
state: 'attached',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,4 +20,6 @@ export enum SendCryptoAssetSelectors {
|
||||
RecipientBnsAddressCopyToClipboard = 'recipient-bns-address-copy-to-clipboard',
|
||||
SendForm = 'send-form',
|
||||
SendMaxBtn = 'send-max-btn',
|
||||
|
||||
SendPageReady = 'send-page-ready',
|
||||
}
|
||||
|
||||
@@ -15,4 +15,6 @@ export enum SharedComponentsSelectors {
|
||||
FeeToBePaidLabel = 'fee-to-be-paid-label',
|
||||
LowFeeEstimateItem = 'low-fee',
|
||||
MiddleFeeEstimateItem = 'standard-fee',
|
||||
FeeCard = 'fee-card',
|
||||
FeeCardFeeValue = 'fee-card-fee-value',
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { TEST_TESTNET_ACCOUNT_2_BTC_ADDRESS } from '@tests/mocks/constants';
|
||||
import { SendCryptoAssetSelectors } from '@tests/selectors/send.selectors';
|
||||
import { SharedComponentsSelectors } from '@tests/selectors/shared-component.selectors';
|
||||
import { getDisplayerAddress } from '@tests/utils';
|
||||
|
||||
import { FormErrorMessages } from '@app/common/error-messages';
|
||||
import { BtcFeeType } from '@app/query/bitcoin/bitcoin-client';
|
||||
|
||||
import { test } from '../../fixtures/fixtures';
|
||||
|
||||
@@ -13,27 +14,17 @@ test.describe('send btc', () => {
|
||||
await homePage.enableTestMode();
|
||||
await homePage.sendButton.click();
|
||||
await sendPage.selectBtcAndGoToSendForm();
|
||||
await sendPage.waitForSendPageReady();
|
||||
});
|
||||
|
||||
test.describe('btc send form', () => {
|
||||
test('that it shows preview of tx details to be confirmed', async ({ sendPage }) => {
|
||||
await sendPage.amountInput.fill('0.0001');
|
||||
await sendPage.recipientInput.fill(TEST_TESTNET_ACCOUNT_2_BTC_ADDRESS);
|
||||
await sendPage.previewSendTxButton.click();
|
||||
const details = await sendPage.confirmationDetails.allInnerTexts();
|
||||
test.expect(details).toBeTruthy();
|
||||
});
|
||||
|
||||
test('that it shows preview of tx details after validation error is resolved', async ({
|
||||
sendPage,
|
||||
}) => {
|
||||
await sendPage.amountInput.fill('0.00006');
|
||||
await sendPage.amountInput.blur();
|
||||
const errorMsg = await sendPage.amountInputErrorLabel.innerText();
|
||||
test.expect(errorMsg).toEqual(FormErrorMessages.InsufficientFunds);
|
||||
await sendPage.recipientInput.fill(TEST_TESTNET_ACCOUNT_2_BTC_ADDRESS);
|
||||
|
||||
await sendPage.amountInput.fill('0.0001');
|
||||
await sendPage.previewSendTxButton.click();
|
||||
await sendPage.feesCard.filter({ hasText: BtcFeeType.High }).click();
|
||||
|
||||
const details = await sendPage.confirmationDetails.allInnerTexts();
|
||||
test.expect(details).toBeTruthy();
|
||||
});
|
||||
@@ -48,6 +39,7 @@ test.describe('send btc', () => {
|
||||
await sendPage.page.waitForTimeout(1000);
|
||||
|
||||
await sendPage.previewSendTxButton.click();
|
||||
await sendPage.feesCard.filter({ hasText: BtcFeeType.High }).click();
|
||||
|
||||
const displayerAddress = await getDisplayerAddress(sendPage.confirmationDetailsRecipient);
|
||||
test.expect(displayerAddress).toEqual(TEST_TESTNET_ACCOUNT_2_BTC_ADDRESS);
|
||||
@@ -57,5 +49,27 @@ test.describe('send btc', () => {
|
||||
.innerText();
|
||||
test.expect(confirmationAssetValue).toEqual(`${amount} ${amountSymbol}`);
|
||||
});
|
||||
|
||||
test('that fee value on preview match chosen one', async ({ sendPage }) => {
|
||||
await sendPage.amountInput.fill('0.00006');
|
||||
await sendPage.recipientInput.fill(TEST_TESTNET_ACCOUNT_2_BTC_ADDRESS);
|
||||
|
||||
await sendPage.previewSendTxButton.click();
|
||||
|
||||
const feeType = BtcFeeType.Standard;
|
||||
const fee = await sendPage.feesCard
|
||||
.filter({ hasText: feeType })
|
||||
.getByTestId(SharedComponentsSelectors.FeeCardFeeValue)
|
||||
.innerText();
|
||||
|
||||
await sendPage.feesCard.filter({ hasText: feeType }).click();
|
||||
|
||||
const confirmationFee = await sendPage.confirmationDetails
|
||||
.getByTestId(SendCryptoAssetSelectors.ConfirmationDetailsFee)
|
||||
.getByTestId(SharedComponentsSelectors.InfoCardRowValue)
|
||||
.innerText();
|
||||
|
||||
test.expect(confirmationFee).toEqual(fee);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user