-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: first detox speculos delegate tests
- Loading branch information
1 parent
91bb3fa
commit 6c1b4ad
Showing
30 changed files
with
413 additions
and
114 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { Currency } from "@ledgerhq/live-common/e2e/enum/Currency"; | ||
import { Application } from "../page"; | ||
import { Delegate } from "@ledgerhq/live-common/e2e/models/Delegate"; | ||
|
||
export async function verifyAppValidationStakeInfo( | ||
app: Application, | ||
delegation: Delegate, | ||
amount: string, | ||
) { | ||
const currenciesForValidationAmount = [Currency.ATOM, Currency.NEAR]; | ||
const currenciesForValidationProvider = [Currency.ATOM]; | ||
|
||
const currency = delegation.account.currency; | ||
const provider = delegation.provider; | ||
|
||
if (currenciesForValidationAmount.includes(currency)) { | ||
await app.deviceValidation.expectAmount(amount); | ||
} | ||
if (currenciesForValidationProvider.includes(currency)) { | ||
await app.deviceValidation.expectProvider(provider); | ||
} | ||
} | ||
|
||
export async function verifyStakeOperationDetailsInfo( | ||
app: Application, | ||
delegation: Delegate, | ||
amount: string, | ||
) { | ||
const currenciesForProvider = [Currency.ATOM]; | ||
const currenciesForRecipientAsProvider = [Currency.NEAR]; | ||
const currenciesForSender = [Currency.NEAR]; | ||
const currenciesForAmount = [Currency.ATOM, Currency.NEAR]; | ||
const currenciesForDelegateType = [Currency.ATOM, Currency.SOL]; | ||
const currenciesForStakeType = [Currency.NEAR]; | ||
|
||
const currency = delegation.account.currency; | ||
const provider = delegation.provider; | ||
|
||
await app.operationDetails.waitForOperationDetails(); | ||
await app.operationDetails.checkAccount(delegation.account.accountName); | ||
|
||
if (currenciesForAmount.includes(currency)) { | ||
await app.operationDetails.checkDelegatedAmount(amount); | ||
} | ||
if (currenciesForProvider.includes(currency)) { | ||
await app.operationDetails.checkProvider(provider); | ||
} | ||
if (currenciesForRecipientAsProvider.includes(currency)) { | ||
await app.operationDetails.checkRecipient(provider); | ||
} | ||
if (currenciesForSender.includes(currency)) { | ||
await app.operationDetails.checkSender(delegation.account.address); | ||
} | ||
if (currenciesForDelegateType.includes(currency)) { | ||
await app.operationDetails.checkTransactionType("DELEGATE"); | ||
} | ||
if (currenciesForStakeType.includes(currency)) { | ||
await app.operationDetails.checkTransactionType("STAKE"); | ||
} | ||
} |
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
26 changes: 26 additions & 0 deletions
26
apps/ledger-live-mobile/e2e/page/trade/deviceValidation.page.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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { getElementById, waitForElementById } from "../../helpers"; | ||
import { expect } from "detox"; | ||
|
||
export default class DeviceValidationPage { | ||
validationAmountId = "device-validation-amount"; | ||
validationAddressId = (fieldLabel = "To") => `device-validation-address${fieldLabel}`; | ||
validationProviderId = "device-validation-provider"; | ||
|
||
@Step("Expect amount in device validation screen") | ||
async expectAmount(amount: string) { | ||
await waitForElementById(this.validationAmountId); | ||
await expect(getElementById(this.validationAmountId)).toHaveText(amount); | ||
} | ||
|
||
@Step("Expect address in device validation screen") | ||
async expectAddress(recipient: string, fieldLabel?: string) { | ||
await waitForElementById(this.validationAddressId(fieldLabel)); | ||
await expect(getElementById(this.validationAddressId(fieldLabel))).toHaveText(recipient); | ||
} | ||
|
||
@Step("Expect provider in device validation screen") | ||
async expectProvider(provider: string) { | ||
await waitForElementById(this.validationProviderId); | ||
await expect(getElementById(this.validationProviderId)).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
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
Oops, something went wrong.