-
-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(suite-native): introduce passphrase testing scenarios
- Loading branch information
Showing
5 changed files
with
152 additions
and
0 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,59 @@ | ||
import { TrezorUserEnvLink } from '@trezor/trezor-user-env-link'; | ||
|
||
import { wait, waitForElementByTextToBeVisible } from '../utils'; | ||
|
||
class PassphraseModule { | ||
public async expectEnterPassphraseScreen() { | ||
await waitForElementByTextToBeVisible('Enter your passphrase'); | ||
} | ||
|
||
public async enterPassphrase(passphrase: string) { | ||
await element(by.id('@passphrase/passphraseInput')).tap(); | ||
// wait for animation to finish | ||
await wait(200); | ||
await element(by.id('@passphrase/passphraseInput')).replaceText(passphrase); | ||
await element(by.text('Enter passphrase')).tap(); | ||
} | ||
|
||
public async expectEnablePassphraseOnDeviceRequest() { | ||
await waitForElementByTextToBeVisible('Enable passphrase on your Trezor.'); | ||
} | ||
|
||
public async allowPassphraseOnEmu() { | ||
await TrezorUserEnvLink.swipeEmu('up'); | ||
await TrezorUserEnvLink.swipeEmu('up'); | ||
await TrezorUserEnvLink.pressYes(); | ||
} | ||
|
||
public async expectConfirmPassphraseOnDeviceRequest() { | ||
await waitForElementByTextToBeVisible( | ||
'Go to your device and confirm the passphrase you’ve entered.', | ||
); | ||
} | ||
|
||
public async confirmPassphraseOnEmu() { | ||
await TrezorUserEnvLink.swipeEmu('up'); | ||
await TrezorUserEnvLink.swipeEmu('up'); | ||
await TrezorUserEnvLink.pressYes(); | ||
} | ||
|
||
public async expectCheckingPassphraseScreen() { | ||
await waitForElementByTextToBeVisible('Checking your passphrase'); | ||
} | ||
|
||
public async expectEmptyPassphraseWalletScreen() { | ||
await waitForElementByTextToBeVisible('This passphrase wallet is empty'); | ||
} | ||
|
||
public async openEmptyPassphraseWalletAndConfirmBestPractices() { | ||
await element(by.text('Yes, open')).tap(); | ||
await waitForElementByTextToBeVisible('Passphrase best practices'); | ||
await element(by.text('Got it')).tap(); | ||
} | ||
|
||
public async expectEmptyPassphraseWalletConfirmationScreen() { | ||
await waitForElementByTextToBeVisible('Confirm empty passphrase'); | ||
} | ||
} | ||
|
||
export const onPassphrase = new PassphraseModule(); |
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,80 @@ | ||
import { randomUUID } from 'node:crypto'; | ||
|
||
import { TrezorUserEnvLink } from '@trezor/trezor-user-env-link'; | ||
|
||
import { | ||
appIsFullyLoaded, | ||
disconnectTrezorUserEnv, | ||
openApp, | ||
prepareTrezorEmulator, | ||
restartApp, | ||
} from '../utils'; | ||
import { onOnboarding } from '../pageObjects/onboardingActions'; | ||
import { onConnectingDevice } from '../pageObjects/connectingDevice'; | ||
import { onDeviceManager } from '../pageObjects/deviceManagerActions'; | ||
import { onCoinEnablingInit } from '../pageObjects/coinEnablingActions'; | ||
import { onAlertSheet } from '../pageObjects/alertSheetActions'; | ||
import { onPassphrase } from '../pageObjects/passphraseModule'; | ||
|
||
const INITIAL_ACCOUNT_BALANCE = 3.14; | ||
|
||
describe('passphrase flow', () => { | ||
beforeAll(async () => { | ||
await prepareTrezorEmulator(); | ||
await openApp({ newInstance: true }); | ||
await onOnboarding.skipOnboarding(); | ||
|
||
await TrezorUserEnvLink.sendToAddressAndMineBlock({ | ||
address: 'bcrt1q34up3cga3fkmph47t22mpk5d0xxj3ppghph9da', | ||
btc_amount: INITIAL_ACCOUNT_BALANCE, | ||
}); | ||
|
||
await onCoinEnablingInit.waitForScreen(); | ||
await onCoinEnablingInit.enableNetwork('regtest'); | ||
await onCoinEnablingInit.clickOnConfirmButton(); | ||
|
||
await onAlertSheet.skipViewOnlyMode(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await disconnectTrezorUserEnv(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
await prepareTrezorEmulator(); | ||
await restartApp(); | ||
await appIsFullyLoaded(); | ||
|
||
await onConnectingDevice.waitForScreen(); | ||
}); | ||
|
||
it('Open empty passphrase wallet', async () => { | ||
const passphrase = 'E2E:test passphrase ' + randomUUID(); | ||
|
||
await onDeviceManager.tapDeviceSwitch(); | ||
await onDeviceManager.tapOpenPassphraseButton(); | ||
|
||
await onPassphrase.expectEnablePassphraseOnDeviceRequest(); | ||
await onPassphrase.allowPassphraseOnEmu(); | ||
|
||
await onPassphrase.expectEnterPassphraseScreen(); | ||
await onPassphrase.enterPassphrase(passphrase); | ||
await onPassphrase.expectConfirmPassphraseOnDeviceRequest(); | ||
|
||
await onPassphrase.confirmPassphraseOnEmu(); | ||
// TODO this does not happens, why? | ||
await onPassphrase.expectCheckingPassphraseScreen(); | ||
await onPassphrase.expectEmptyPassphraseWalletScreen(); | ||
await onPassphrase.openEmptyPassphraseWalletAndConfirmBestPractices(); | ||
|
||
await onPassphrase.expectEmptyPassphraseWalletConfirmationScreen(); | ||
await onPassphrase.enterPassphrase(passphrase); | ||
|
||
await onPassphrase.expectConfirmPassphraseOnDeviceRequest(); | ||
await onPassphrase.confirmPassphraseOnEmu(); | ||
}); | ||
|
||
it.todo('Open passphrase wallet with funds'); | ||
|
||
it.todo('non-happy scenarios'); | ||
}); |
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