Skip to content

Commit

Permalink
QA - Select dynamic fee during stake on testnet (#2136)
Browse files Browse the repository at this point in the history
  • Loading branch information
eunjisong authored and atn4z7 committed Nov 27, 2024
1 parent ed40763 commit d0cf374
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 6 deletions.
2 changes: 2 additions & 0 deletions packages/core-mobile/app/components/EditFees.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ const EditFees = ({
<Space y={24} />
<InputText
label={isBaseUnitRate ? 'Network Fee' : 'Max Base Fee'}
testID="custom_network_fee_input"
mode={'amount'}
text={newMaxFeePerGas}
keyboardType="numeric"
Expand Down Expand Up @@ -255,6 +256,7 @@ const EditFees = ({
/>
</ScrollView>
<Button
testID="custom_network_fee_save_btn"
type={'primary'}
size={'xlarge'}
disabled={saveDisabled}
Expand Down
2 changes: 2 additions & 0 deletions packages/core-mobile/app/components/NetworkFeeSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,14 @@ const NetworkFeeSelector = ({
selected={selectedPreset === FeePreset.Fast}
onSelect={() => handleSelectedPreset(FeePreset.Fast)}
value={displayGasValues?.[FeePreset.Fast]}
testID="fast_base_fee"
/>
<FeeSelector
label={isBtcNetwork ? 'Fast' : FeePreset.Instant}
selected={selectedPreset === FeePreset.Instant}
onSelect={() => handleSelectedPreset(FeePreset.Instant)}
value={displayGasValues?.[FeePreset.Instant]}
testID="instant_base_fee"
/>
<FeeSelector
label={FeePreset.Custom}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const RpcRequestBottomSheet: React.FC<Props> = ({
type="secondary"
size="xlarge"
onPress={onReject}
testID="reject_btn">
testID="reject_button">
Reject
</Button>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ const AlertScreen = (): JSX.Element => {
</Text>
</View>
<View sx={{ gap: 16, padding: 16 }}>
<Button type="primary" size="xlarge" onPress={handleReject}>
<Button
testID="reject_button"
type="primary"
size="xlarge"
onPress={handleReject}>
{params.alert.details.actionTitles?.reject}
</Button>
<Button type="tertiary" size="xlarge" onPress={handleProceed}>
Expand Down
8 changes: 7 additions & 1 deletion packages/core-mobile/e2e/locators/Stake/stakeScreen.loc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,11 @@ export default {
endDateId: 'end_date',
earnedRewardsId: 'earned_rewards',
stakingSuccessful: 'Staking successful!',
customRadio: 'Custom'
customRadio: 'Custom',
customInput: 'custom_network_fee_input',
customSaveBtn: 'custom_network_fee_save_btn',
customBaseFee: 'custom_base_fee',
slowBaseFee: 'slow_base_fee',
fastBaseFee: 'fast_base_fee',
instantBaseFee: 'instant_base_fee'
}
1 change: 1 addition & 0 deletions packages/core-mobile/e2e/locators/popupModal.loc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export default {
linkSvg: 'link_svg',
approveBtn: 'approve_button',
rejectBtn: 'reject_button',
rejectTextBtn: 'Reject',
type: 'Type',
account: 'Account:',
approveTransactionTitle: 'Approve Transaction',
Expand Down
51 changes: 50 additions & 1 deletion packages/core-mobile/e2e/pages/Stake/stake.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,30 @@ class StakePage {
return by.text(stakeScreenLoc.customRadio)
}

get customFeeInput() {
return by.id(stakeScreenLoc.customInput)
}

get customSaveBtn() {
return by.id(stakeScreenLoc.customSaveBtn)
}

get slowBaseFee() {
return by.id(stakeScreenLoc.slowBaseFee)
}

get fastBaseFee() {
return by.id(stakeScreenLoc.fastBaseFee)
}

get instantBaseFee() {
return by.id(stakeScreenLoc.instantBaseFee)
}

get customBaseFee() {
return by.id(stakeScreenLoc.customBaseFee)
}

async tapActiveTab() {
await Actions.tap(this.activeTab)
}
Expand Down Expand Up @@ -313,6 +337,7 @@ class StakePage {
}

async tapStakeNow() {
await Actions.waitForElementNoSync(this.stakeNow, 5000)
await Actions.tapElementAtIndex(this.stakeNow, 0)
}

Expand Down Expand Up @@ -503,17 +528,41 @@ class StakePage {
}
await this.tapNextButton()
await Actions.waitForElementNoSync(this.stakeNow, 30000)
await this.selectRandomDynamicFee()
await this.tapStakeNow()
}

async selectRandomDynamicFee() {
const feeOptions = [
this.slowBaseFee,
this.fastBaseFee,
this.instantBaseFee,
this.customBaseFee
]
const randomIndex = Math.floor(Math.random() * feeOptions.length)
const selectedFeeOption = feeOptions[randomIndex] as Detox.NativeMatcher

await Actions.tap(selectedFeeOption)

// If the selected fee option is custom, set the fee to the instant fee
if (randomIndex === 3) {
const instantFeeText = (await Actions.getElementText(
this.instantBaseFee
)) as string
await Actions.waitForElementNoSync(this.instantBaseFee)
await Actions.setInputText(this.customFeeInput, instantFeeText)
await Actions.tap(this.customSaveBtn)
}
}

async verifyStakeSuccessToast() {
await Actions.waitForElement(this.stakingSuccessful, 60000, 0)
try {
await this.tapNotNowButton()
} catch (e) {
console.log('No stake notification prompt is displayed')
}
await delay(3000)
await delay(5000)
}
}

Expand Down
10 changes: 9 additions & 1 deletion packages/core-mobile/e2e/pages/popUpModal.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,20 @@ class PopUpModalPage {
return by.id(popUpModalLoc.popUpModalScrollView)
}

get rejectTextBtn() {
return by.text(popUpModalLoc.rejectTextBtn)
}

async tapApproveBtn() {
await actions.tapElementAtIndex(this.approveBtn, 0)
}

async tapRejectBtn() {
await actions.tapElementAtIndex(this.rejectBtn, 0)
try {
await actions.tap(this.rejectBtn)
} catch (e) {
await actions.tap(this.rejectTextBtn)
}
}

async verifySignMessageModal() {
Expand Down
4 changes: 3 additions & 1 deletion packages/core-mobile/e2e/tests/plusIcon/bridge/bridge.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ describe('Bridge Screen', () => {
await sendPage.tapMax()
// Verify approve modal with legit fee > Reject
await bridgeTabPage.tapBridgeBtn()
await popUpModalPage.verifyFeeIsLegit(false, false, 0.02)
if (network === portfolioLoc.ethNetwork) {
await popUpModalPage.verifyFeeIsLegit(false, false, 0.02)
}
await popUpModalPage.tapRejectBtn()

// Exit bridge screen
Expand Down

0 comments on commit d0cf374

Please sign in to comment.