-
Notifications
You must be signed in to change notification settings - Fork 476
[LWM] Staking/Unstaking e2e tests #18901
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
Open
amaslakov
wants to merge
2
commits into
LIVE-32928-tezos-lwd-staking-unstaking-e-2-e-tests
Choose a base branch
from
LIVE-32929-tezos-lwm-staking-unstaking-e-2-e-tests
base: LIVE-32928-tezos-lwd-staking-unstaking-e-2-e-tests
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,5 @@ | ||
| --- | ||
| "live-mobile": patch | ||
| --- | ||
|
|
||
| Add test ids to the Tezos staking-section rows (staked and unstaking) so e2e can target them distinctly from the delegation card |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,102 @@ | ||
| import { Step } from "jest-allure2-reporter/api"; | ||
|
|
||
| const accountScrollViewId = "account-screen-scrollView"; | ||
|
|
||
| // Buttons built from ~/components/Button render their testID with an "enabled-"/"disabled-" | ||
| // prefix reflecting the disabled state; the amount continue buttons are only tappable once enabled. | ||
| const enabled = (id: string) => `enabled-${id}`; | ||
|
|
||
| export default class TezosStakePage { | ||
| // Stake flow (TezosStakeFlow) | ||
| stakeAmountInputId = "tezos-stake-amount-input"; | ||
| stakeAmountContinueId = "tezos-stake-amount-continue"; | ||
| // Unstake flow (TezosUnstakeFlow) | ||
| unstakeAmountInputId = "tezos-unstake-amount-input"; | ||
| unstakeAmountContinueId = "tezos-unstake-amount-continue"; | ||
| // Earning-choice chooser (TezosDelegationFlow -> TezosEarnRewards) and the delegation summary it leads to | ||
| earnRewardsStartButtonId = "tezos-earn-rewards-start-button"; | ||
| delegationSummaryValidatorId = "tezos-delegation-summary-validator"; | ||
| // Account staking-section cards (families/tezos/Delegations) | ||
| stakingRowId = "tezos-staking-row"; | ||
| delegationRowId = "tezos-delegation-row"; | ||
| // DelegationDrawer actions: Touchable sets testID to the analytics event when no explicit testID is given | ||
| stakeMoreActionId = "TezosStakeMore"; | ||
| unstakeActionId = "TezosUnstake"; | ||
| changeValidatorActionId = "TezosChangeBaker"; | ||
| endDelegationActionId = "TezosEndDelegation"; | ||
| // Unstake-required guard drawer | ||
| unstakeRequiredCloseId = "tezos-unstake-required-close"; | ||
|
|
||
| @Step("Verify the earning-choice chooser is shown") | ||
| async verifyEarningChoice() { | ||
| await waitForElementById(this.earnRewardsStartButtonId); | ||
| } | ||
|
|
||
| @Step("Start earning from the earning-choice chooser") | ||
| async startEarning() { | ||
| await tapById(this.earnRewardsStartButtonId); | ||
| } | ||
|
|
||
| @Step("Verify the delegation summary is shown") | ||
| async verifyDelegationSummary() { | ||
| await waitForElementById(this.delegationSummaryValidatorId); | ||
| } | ||
|
|
||
| @Step("Fill stake amount $0") | ||
| async fillStakeAmount(amount: string) { | ||
| await waitForElementById(this.stakeAmountInputId); | ||
| await typeTextById(this.stakeAmountInputId, amount); | ||
| await waitForElementById(enabled(this.stakeAmountContinueId)); // Issue with RN75 : QAA-370 | ||
| } | ||
|
|
||
| @Step("Continue from the stake amount step") | ||
| async continueStakeAmount() { | ||
| await tapById(enabled(this.stakeAmountContinueId)); | ||
| } | ||
|
|
||
| @Step("Open the unstake flow from the staking section") | ||
| async openUnstakeFromStakingSection() { | ||
| await scrollToId(this.stakingRowId, accountScrollViewId); | ||
| await tapById(this.stakingRowId); | ||
| await waitForElementById(this.unstakeActionId); | ||
| await tapById(this.unstakeActionId); | ||
| } | ||
|
|
||
| @Step("Fill unstake amount $0") | ||
| async fillUnstakeAmount(amount: string) { | ||
| await waitForElementById(this.unstakeAmountInputId); | ||
| await typeTextById(this.unstakeAmountInputId, amount); | ||
| await waitForElementById(enabled(this.unstakeAmountContinueId)); // Issue with RN75 : QAA-370 | ||
| } | ||
|
|
||
| @Step("Continue from the unstake amount step") | ||
| async continueUnstakeAmount() { | ||
| await tapById(enabled(this.unstakeAmountContinueId)); | ||
| } | ||
|
|
||
| @Step("Open change-validator from the delegation section") | ||
| async openChangeValidator() { | ||
| await scrollToId(this.delegationRowId, accountScrollViewId); | ||
| await tapById(this.delegationRowId); | ||
| await waitForElementById(this.changeValidatorActionId); | ||
| await tapById(this.changeValidatorActionId); | ||
| } | ||
|
|
||
| @Step("Open stop-delegation from the delegation section") | ||
| async openStopDelegation() { | ||
| await scrollToId(this.delegationRowId, accountScrollViewId); | ||
| await tapById(this.delegationRowId); | ||
| await waitForElementById(this.endDelegationActionId); | ||
| await tapById(this.endDelegationActionId); | ||
| } | ||
|
|
||
| @Step("Verify the unstake-required guard is shown") | ||
| async verifyUnstakeRequired() { | ||
| await waitForElementById(this.unstakeRequiredCloseId); | ||
| } | ||
|
|
||
| @Step("Dismiss the unstake-required guard") | ||
| async dismissUnstakeRequired() { | ||
| await tapById(this.unstakeRequiredCloseId); | ||
| } | ||
| } |
This file contains hidden or 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,6 @@ | ||
| import { Account } from "@ledgerhq/live-common/e2e/enum/Account"; | ||
| import { runUnstakeRequiredTezos } from "./stake"; | ||
|
|
||
| // XTZ_2 (index 1) is DELEGATED + STAKED: changing validator is blocked until the user unstakes first. | ||
| const delegation = new Delegate(Account.XTZ_2, "N/A", "Ledger by Kiln"); | ||
| runUnstakeRequiredTezos(delegation, "changeValidator", ["B2CQA-5919"]); |
This file contains hidden or 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,6 @@ | ||
| import { Account } from "@ledgerhq/live-common/e2e/enum/Account"; | ||
| import { runEarningChoiceTezos } from "./stake"; | ||
|
|
||
| // XTZ_1 (index 0) is funded + UNDELEGATED: with the staking flag on, Earn opens the earning-choice chooser. | ||
| const delegation = new Delegate(Account.XTZ_1, "N/A", "Ledger by Kiln"); | ||
| runEarningChoiceTezos(delegation, ["B2CQA-5915"]); |
This file contains hidden or 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,6 @@ | ||
| import { Account } from "@ledgerhq/live-common/e2e/enum/Account"; | ||
| import { runUnstakeRequiredTezos } from "./stake"; | ||
|
|
||
| // XTZ_2 (index 1) is DELEGATED + STAKED: stopping delegation is blocked until the user unstakes first. | ||
| const delegation = new Delegate(Account.XTZ_2, "N/A", "Ledger by Kiln"); | ||
| runUnstakeRequiredTezos(delegation, "stopDelegation", ["B2CQA-5921"]); |
This file contains hidden or 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,148 @@ | ||
| import { setEnv } from "@ledgerhq/live-env"; | ||
| import { DelegateType } from "@ledgerhq/live-common/e2e/models/Delegate"; | ||
| import { Team } from "@ledgerhq/live-common/e2e/enum/Team"; | ||
| import { setTeamOwner } from "../../helpers/allure/allure-helper"; | ||
|
|
||
| const TEZOS_STAKING_TAGS = [ | ||
| "@NanoSP", | ||
| "@LNS", | ||
| "@NanoX", | ||
| "@Stax", | ||
| "@Flex", | ||
| "@NanoGen5", | ||
| "@tezos", | ||
| "@family-tezos", | ||
| ]; | ||
|
|
||
| // Mobile twin of desktop's lldTezosStaking; the staking screens, routing and the account-screen | ||
| // staking section are all gated on it (default off). | ||
| const STAKING_FEATURE_FLAGS = { llmTezosStaking: { enabled: true } }; | ||
|
|
||
| async function initStakingAccount(delegation: DelegateType) { | ||
| await app.init({ | ||
| speculosApp: delegation.account.currency.speculosApp, | ||
| cliCommands: [liveDataWithAddressCommand(delegation.account)], | ||
| featureFlags: STAKING_FEATURE_FLAGS, | ||
| }); | ||
| await app.mainNavigation.waitForWallet40Ready(); | ||
| } | ||
|
|
||
| async function goToTezosAccount(delegation: DelegateType) { | ||
| await app.portfolio.goToAccounts(delegation.account.currency.name); | ||
| await app.common.goToAccountByName(delegation.account.accountName); | ||
| } | ||
|
|
||
| function tagSuite(tmsLinks: string[], tags: string[]) { | ||
| setTeamOwner(Team.EARN); | ||
| tags.forEach(tag => $Tag(tag)); | ||
| tmsLinks.forEach(tms => $TmsLink(tms)); | ||
| } | ||
|
|
||
| export function runEarningChoiceTezos( | ||
| delegation: DelegateType, | ||
| tmsLinks: string[], | ||
| tags: string[] = TEZOS_STAKING_TAGS, | ||
| ) { | ||
| setEnv("DISABLE_TRANSACTION_BROADCAST", true); | ||
| tagSuite(tmsLinks, tags); | ||
| describe("Earning choice on TEZOS", () => { | ||
| beforeAll(async () => { | ||
| await initStakingAccount(delegation); | ||
| }); | ||
|
|
||
| it("Earning choice routes to the delegation summary", async () => { | ||
| await goToTezosAccount(delegation); | ||
| // Funded + undelegated => Earn opens the earning-choice chooser (not the legacy delegate starter). | ||
| await app.account.tapEarn(); | ||
| await app.tezosStake.verifyEarningChoice(); | ||
| await app.tezosStake.startEarning(); | ||
| // Undelegated => the single chooser CTA leads into the delegation summary. | ||
| await app.tezosStake.verifyDelegationSummary(); | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| export function runStakeTezos( | ||
| delegation: DelegateType, | ||
| tmsLinks: string[], | ||
| tags: string[] = TEZOS_STAKING_TAGS, | ||
| ) { | ||
| // Broadcast off so CI never mutates the seed; the app still reaches the success screen. | ||
| setEnv("DISABLE_TRANSACTION_BROADCAST", true); | ||
| tagSuite(tmsLinks, tags); | ||
| describe("Stake flow on TEZOS", () => { | ||
| beforeAll(async () => { | ||
| await initStakingAccount(delegation); | ||
| }); | ||
|
|
||
| it("Stake on a delegated account", async () => { | ||
| await app.speculos.goToSettings(); | ||
| await app.speculos.activateExpertMode(); | ||
| await goToTezosAccount(delegation); | ||
| // Already delegated => Earn opens the stake amount step directly (skipDelegation). | ||
| await app.account.tapEarn(); | ||
| await app.tezosStake.fillStakeAmount(delegation.amount); | ||
| await app.tezosStake.continueStakeAmount(); | ||
| // Tezos signs stake via the same on-device review flow as delegation. | ||
| await app.speculos.signDelegationTransaction(delegation); | ||
| await app.common.successViewDetails(); | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| export function runUnstakeTezos( | ||
| delegation: DelegateType, | ||
| tmsLinks: string[], | ||
| tags: string[] = TEZOS_STAKING_TAGS, | ||
| ) { | ||
| setEnv("DISABLE_TRANSACTION_BROADCAST", true); | ||
| tagSuite(tmsLinks, tags); | ||
| describe("Unstake flow on TEZOS", () => { | ||
| beforeAll(async () => { | ||
| await initStakingAccount(delegation); | ||
| }); | ||
|
|
||
| it("Unstake from a staked account", async () => { | ||
| await app.speculos.goToSettings(); | ||
| await app.speculos.activateExpertMode(); | ||
| await goToTezosAccount(delegation); | ||
| // Delegated + staked => the staking section card opens the unstake action. | ||
| await app.tezosStake.openUnstakeFromStakingSection(); | ||
| await app.tezosStake.fillUnstakeAmount(delegation.amount); | ||
| await app.tezosStake.continueUnstakeAmount(); | ||
| await app.speculos.signDelegationTransaction(delegation); | ||
| await app.common.successViewDetails(); | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| export function runUnstakeRequiredTezos( | ||
| delegation: DelegateType, | ||
| action: "changeValidator" | "stopDelegation", | ||
| tmsLinks: string[], | ||
| tags: string[] = TEZOS_STAKING_TAGS, | ||
| ) { | ||
| setEnv("DISABLE_TRANSACTION_BROADCAST", true); // assertion-only: never signs or broadcasts | ||
| tagSuite(tmsLinks, tags); | ||
| const title = | ||
| action === "changeValidator" | ||
| ? "Change validator is blocked while staked" | ||
| : "Stopping delegation is blocked while staked"; | ||
| describe(`Unstake required guard on TEZOS - ${action}`, () => { | ||
| beforeAll(async () => { | ||
| await initStakingAccount(delegation); | ||
| }); | ||
|
|
||
| it(title, async () => { | ||
| await goToTezosAccount(delegation); | ||
| // Delegated + staked => both actions hit the "unstake first" guard instead of the real flow. | ||
| if (action === "changeValidator") { | ||
| await app.tezosStake.openChangeValidator(); | ||
| } else { | ||
| await app.tezosStake.openStopDelegation(); | ||
| } | ||
| await app.tezosStake.verifyUnstakeRequired(); | ||
| await app.tezosStake.dismissUnstakeRequired(); | ||
| }); | ||
| }); | ||
| } |
This file contains hidden or 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,6 @@ | ||
| import { Account } from "@ledgerhq/live-common/e2e/enum/Account"; | ||
| import { runStakeTezos } from "./stake"; | ||
|
|
||
| // XTZ_2 (index 1) is DELEGATED + STAKED: Earn opens the stake amount step directly. | ||
| const delegation = new Delegate(Account.XTZ_2, "0.005", "Ledger by Kiln"); | ||
| runStakeTezos(delegation, ["B2CQA-5917"]); |
This file contains hidden or 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,6 @@ | ||
| import { Account } from "@ledgerhq/live-common/e2e/enum/Account"; | ||
| import { runUnstakeTezos } from "./stake"; | ||
|
|
||
| // XTZ_2 (index 1) is DELEGATED + STAKED: the account screen shows the staking section with the unstake action. | ||
| const delegation = new Delegate(Account.XTZ_2, "0.005", "Ledger by Kiln"); | ||
| runUnstakeTezos(delegation, ["B2CQA-5918"]); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.