mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-01-18 21:35:21 +01:00
TST: wallet details tests
This commit is contained in:
parent
b0e6c8674c
commit
3feaeb8461
@ -334,6 +334,7 @@ export class BlueWalletNavigationHeader extends Component {
|
||||
}}
|
||||
/>
|
||||
<Text
|
||||
testID="WalletLabel"
|
||||
numberOfLines={1}
|
||||
style={{
|
||||
backgroundColor: 'transparent',
|
||||
|
@ -120,7 +120,7 @@ const Broadcast = () => {
|
||||
behavior={Platform.OS === 'ios' ? 'position' : null}
|
||||
keyboardShouldPersistTaps="handled"
|
||||
>
|
||||
<View style={styles.wrapper}>
|
||||
<View style={styles.wrapper} testID="BroadcastView">
|
||||
{BROADCAST_RESULT.success !== broadcastResult && (
|
||||
<BlueCard style={styles.mainCard}>
|
||||
<View style={styles.topFormRow}>
|
||||
|
@ -99,6 +99,7 @@ const IsItMyAddress = () => {
|
||||
placeholderTextColor="#81868e"
|
||||
value={address}
|
||||
onChangeText={handleUpdateAddress}
|
||||
testID="AddressInput"
|
||||
/>
|
||||
</View>
|
||||
|
||||
@ -107,9 +108,14 @@ const IsItMyAddress = () => {
|
||||
<BlueSpacing10 />
|
||||
<BlueButton title={loc.send.input_clear} onPress={clearAddressInput} />
|
||||
<BlueSpacing20 />
|
||||
<BlueButton disabled={address.trim().length === 0} title={loc.is_it_my_address.check_address} onPress={checkAddress} />
|
||||
<BlueButton
|
||||
disabled={address.trim().length === 0}
|
||||
title={loc.is_it_my_address.check_address}
|
||||
onPress={checkAddress}
|
||||
testID="CheckAddress"
|
||||
/>
|
||||
<BlueSpacing20 />
|
||||
<BlueText>{result}</BlueText>
|
||||
<BlueText testID="Result">{result}</BlueText>
|
||||
</BlueCard>
|
||||
</View>
|
||||
</KeyboardAvoidingView>
|
||||
|
@ -135,7 +135,7 @@ const WalletDetails = () => {
|
||||
|
||||
const setLabel = async () => {
|
||||
if (walletName.trim().length > 0) {
|
||||
wallet.setLabel(walletName);
|
||||
wallet.setLabel(walletName.trim());
|
||||
if (wallet.type === WatchOnlyWallet.type && wallet.getSecret().startsWith('zpub')) {
|
||||
wallet.setUseWithHardwareWalletEnabled(useWithHardwareWallet);
|
||||
}
|
||||
@ -150,7 +150,7 @@ const WalletDetails = () => {
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
setOptions({
|
||||
headerRight: () => (
|
||||
<TouchableOpacity disabled={isLoading} style={styles.save} onPress={setLabel}>
|
||||
<TouchableOpacity testID="Save" disabled={isLoading} style={styles.save} onPress={setLabel}>
|
||||
<Text style={stylesHook.saveText}>{loc.wallets.details_save}</Text>
|
||||
</TouchableOpacity>
|
||||
),
|
||||
@ -236,6 +236,7 @@ const WalletDetails = () => {
|
||||
return Platform.select({
|
||||
android: (
|
||||
<SecondButton
|
||||
testID="Marketplace"
|
||||
onPress={() =>
|
||||
navigate('Marketplace', {
|
||||
fromWallet: wallet,
|
||||
@ -246,6 +247,7 @@ const WalletDetails = () => {
|
||||
),
|
||||
ios: (
|
||||
<SecondButton
|
||||
testID="Marketplace"
|
||||
onPress={async () => {
|
||||
Linking.openURL('https://bluewallet.io/marketplace-btc/');
|
||||
}}
|
||||
@ -400,7 +402,7 @@ const WalletDetails = () => {
|
||||
<SafeBlueArea style={styles.root}>
|
||||
<StatusBar barStyle="default" />
|
||||
<TouchableWithoutFeedback onPress={Keyboard.dismiss} accessible={false}>
|
||||
<ScrollView contentContainerStyle={styles.scrollViewContent}>
|
||||
<ScrollView contentContainerStyle={styles.scrollViewContent} testID="WalletDetailsScroll">
|
||||
<BlueCard style={styles.address}>
|
||||
{(() => {
|
||||
if (
|
||||
@ -428,6 +430,7 @@ const WalletDetails = () => {
|
||||
style={styles.inputText}
|
||||
editable={!isLoading}
|
||||
underlineColorAndroid="transparent"
|
||||
testID="WalletNameInput"
|
||||
/>
|
||||
</View>
|
||||
</KeyboardAvoidingView>
|
||||
@ -506,7 +509,7 @@ const WalletDetails = () => {
|
||||
)}
|
||||
<BlueSpacing20 />
|
||||
|
||||
<SecondButton onPress={navigateToWalletExport} title={loc.wallets.details_export_backup} />
|
||||
<SecondButton onPress={navigateToWalletExport} testID="WalletExport" title={loc.wallets.details_export_backup} />
|
||||
|
||||
<BlueSpacing20 />
|
||||
|
||||
@ -514,6 +517,7 @@ const WalletDetails = () => {
|
||||
<>
|
||||
<SecondButton
|
||||
onPress={navigateToMultisigCoordinationSetup}
|
||||
testID="MultisigCoordinationSetup"
|
||||
title={loc.multisig.export_coordination_setup.replace(/^\w/, c => c.toUpperCase())}
|
||||
/>
|
||||
</>
|
||||
@ -522,7 +526,7 @@ const WalletDetails = () => {
|
||||
{wallet.type === MultisigHDWallet.type && (
|
||||
<>
|
||||
<BlueSpacing20 />
|
||||
<SecondButton onPress={navigateToViewEditCosigners} title={loc.multisig.view_edit_cosigners} />
|
||||
<SecondButton onPress={navigateToViewEditCosigners} testID="ViewEditCosigners" title={loc.multisig.view_edit_cosigners} />
|
||||
</>
|
||||
)}
|
||||
|
||||
@ -531,7 +535,7 @@ const WalletDetails = () => {
|
||||
wallet.type === HDSegwitBech32Wallet.type ||
|
||||
wallet.type === HDSegwitP2SHWallet.type) && (
|
||||
<>
|
||||
<SecondButton onPress={navigateToXPub} title={loc.wallets.details_show_xpub} />
|
||||
<SecondButton onPress={navigateToXPub} testID="XPub" title={loc.wallets.details_show_xpub} />
|
||||
|
||||
<BlueSpacing20 />
|
||||
{renderMarketplaceButton()}
|
||||
@ -540,16 +544,16 @@ const WalletDetails = () => {
|
||||
{wallet.type !== LightningCustodianWallet.type && (
|
||||
<>
|
||||
<BlueSpacing20 />
|
||||
<SecondButton onPress={navigateToBroadcast} title={loc.settings.network_broadcast} />
|
||||
<SecondButton onPress={navigateToBroadcast} testID="Broadcast" title={loc.settings.network_broadcast} />
|
||||
</>
|
||||
)}
|
||||
<>
|
||||
<BlueSpacing20 />
|
||||
<SecondButton onPress={navigateToIsItMyAddress} title={loc.is_it_my_address.title} />
|
||||
<SecondButton onPress={navigateToIsItMyAddress} testID="IsItMyAddress" title={loc.is_it_my_address.title} />
|
||||
</>
|
||||
<BlueSpacing20 />
|
||||
<BlueSpacing20 />
|
||||
<TouchableOpacity onPress={handleDeleteButtonTapped}>
|
||||
<TouchableOpacity onPress={handleDeleteButtonTapped} testID="DeleteButton">
|
||||
<Text textBreakStrategy="simple" style={styles.delete}>{`${loc.wallets.details_delete}${' '}`}</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
|
@ -94,7 +94,7 @@ const WalletExport = () => {
|
||||
) : (
|
||||
<SafeBlueArea style={stylesHook.root}>
|
||||
<StatusBar barStyle="light-content" />
|
||||
<ScrollView contentContainerStyle={styles.scrollViewContent}>
|
||||
<ScrollView contentContainerStyle={styles.scrollViewContent} testID="WalletExportScroll">
|
||||
<View>
|
||||
<BlueText style={stylesHook.type}>{wallet.current.typeReadable}</BlueText>
|
||||
</View>
|
||||
@ -126,7 +126,9 @@ const WalletExport = () => {
|
||||
{wallet.current.type === LightningCustodianWallet.type || wallet.current.type === WatchOnlyWallet.type ? (
|
||||
<BlueCopyTextToClipboard text={wallet.current.getSecret()} />
|
||||
) : (
|
||||
<BlueText style={stylesHook.secret}>{wallet.current.getSecret()}</BlueText>
|
||||
<BlueText style={stylesHook.secret} testID="Secret">
|
||||
{wallet.current.getSecret()}
|
||||
</BlueText>
|
||||
)}
|
||||
</ScrollView>
|
||||
</SafeBlueArea>
|
||||
|
@ -304,7 +304,7 @@ const WalletsList = () => {
|
||||
case WalletsListSections.TRANSACTIONS:
|
||||
if (dataSource.length === 0 && !isLoading) {
|
||||
return (
|
||||
<View style={styles.footerRoot}>
|
||||
<View style={styles.footerRoot} testID="NoTransactionsMessage">
|
||||
<Text style={styles.footerEmpty}>{loc.wallets.list_empty_txs1}</Text>
|
||||
<Text style={styles.footerStart}>{loc.wallets.list_empty_txs2}</Text>
|
||||
</View>
|
||||
|
@ -57,6 +57,7 @@ export default class Marketplace extends Component {
|
||||
|
||||
return (
|
||||
<WebView
|
||||
testID="MarketplaceWebView"
|
||||
ref={this.webview}
|
||||
onNavigationStateChange={this._onNavigationStateChange}
|
||||
source={{
|
||||
|
@ -721,6 +721,7 @@ WalletTransactions.navigationOptions = navigationStyle({}, (options, { theme, na
|
||||
return {
|
||||
headerRight: () => (
|
||||
<TouchableOpacity
|
||||
testID="WalletDetails"
|
||||
disabled={route.params.isLoading === true}
|
||||
style={styles.walletDetails}
|
||||
onPress={() =>
|
||||
|
@ -544,6 +544,65 @@ describe('BlueWallet UI Tests', () => {
|
||||
|
||||
// this is fully-signed tx, "this is tx hex" help text should appear
|
||||
await yo('DynamicCode');
|
||||
await device.pressBack();
|
||||
await device.pressBack();
|
||||
|
||||
// let's test wallet details screens
|
||||
await element(by.id('WalletDetails')).tap();
|
||||
|
||||
// rename test
|
||||
await element(by.id('WalletNameInput')).replaceText('testname\n');
|
||||
await element(by.id('Save')).tap();
|
||||
await sup('OK');
|
||||
await element(by.text('OK')).tap();
|
||||
await expect(element(by.id('WalletLabel'))).toHaveText('testname');
|
||||
await element(by.id('WalletDetails')).tap();
|
||||
|
||||
// wallet export
|
||||
await element(by.id('WalletDetailsScroll')).swipe('up', 'fast', 1);
|
||||
await element(by.id('WalletExport')).tap();
|
||||
await element(by.id('WalletExportScroll')).swipe('up', 'fast', 1);
|
||||
await expect(element(by.id('Secret'))).toHaveText(process.env.HD_MNEMONIC_BIP84);
|
||||
await device.pressBack();
|
||||
|
||||
// XPUB
|
||||
await element(by.id('WalletDetailsScroll')).swipe('up', 'fast', 1);
|
||||
await element(by.id('XPub')).tap();
|
||||
await expect(element(by.id('BlueCopyTextToClipboard'))).toBeVisible();
|
||||
await device.pressBack();
|
||||
|
||||
// Marketplace
|
||||
await element(by.id('WalletDetailsScroll')).swipe('up', 'fast', 1);
|
||||
await element(by.id('Marketplace')).tap();
|
||||
await expect(element(by.id('MarketplaceWebView'))).toBeVisible();
|
||||
await device.pressBack();
|
||||
await device.pressBack();
|
||||
|
||||
// Broadcast
|
||||
await element(by.id('WalletDetailsScroll')).swipe('up', 'fast', 1);
|
||||
await element(by.id('Broadcast')).tap();
|
||||
await expect(element(by.id('BroadcastView'))).toBeVisible();
|
||||
await device.pressBack();
|
||||
|
||||
// IsItMyAddress
|
||||
await element(by.id('WalletDetailsScroll')).swipe('up', 'fast', 1);
|
||||
await element(by.id('IsItMyAddress')).tap();
|
||||
await element(by.id('AddressInput')).replaceText('bc1q063ctu6jhe5k4v8ka99qac8rcm2tzjjnuktyrl');
|
||||
await element(by.id('CheckAddress')).tap();
|
||||
await expect(element(by.id('Result'))).toHaveText('testname owns bc1q063ctu6jhe5k4v8ka99qac8rcm2tzjjnuktyrl');
|
||||
await element(by.id('AddressInput')).replaceText('invalid');
|
||||
await element(by.id('CheckAddress')).tap();
|
||||
await expect(element(by.id('Result'))).toHaveText('None of the available wallets own the provided address.');
|
||||
await device.pressBack();
|
||||
|
||||
// Delete
|
||||
await element(by.id('WalletDetailsScroll')).swipe('up', 'fast', 1);
|
||||
await element(by.id('DeleteButton')).tap();
|
||||
await sup('Yes, delete');
|
||||
await element(by.text('Yes, delete')).tap();
|
||||
await element(by.type('android.widget.EditText')).typeText('105526');
|
||||
await element(by.text('OK')).tap();
|
||||
await expect(element(by.id('NoTransactionsMessage'))).toBeVisible();
|
||||
|
||||
process.env.TRAVIS && require('fs').writeFileSync(lockFile, '1');
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user