Merge pull request #2736 from BlueWallet/limpbrains-settings-test

TST: settings screens test
This commit is contained in:
GLaDOS 2021-03-04 13:30:21 +00:00 committed by GitHub
commit 2446ed348c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 160 additions and 18 deletions

View File

@ -140,6 +140,7 @@ const Broadcast = () => {
placeholderTextColor="#81868e"
value={txHex}
onChangeText={handleUpdateTxHex}
testID="TxHex"
/>
</View>
<BlueSpacing20 />
@ -151,6 +152,7 @@ const Broadcast = () => {
title={loc.send.broadcastButton}
onPress={handleBroadcast}
disabled={broadcastResult === BROADCAST_RESULT.pending}
testID="BroadcastButton"
/>
<BlueSpacing20 />
</BlueCard>

View File

@ -74,7 +74,7 @@ const GeneralSettings = () => {
<BlueListItem
Component={TouchableWithoutFeedback}
title={loc.settings.general_adv_mode}
switch={{ onValueChange: onAdvancedModeSwitch, value: isAdancedModeSwitchEnabled }}
switch={{ onValueChange: onAdvancedModeSwitch, value: isAdancedModeSwitchEnabled, testID: 'AdvancedMode' }}
/>
<BlueCard>
<BlueText>{loc.settings.general_adv_mode_e}</BlueText>

View File

@ -31,9 +31,9 @@ const NetworkSettings = () => {
return (
<SafeBlueArea forceInset={{ horizontal: 'always' }} style={styles.root}>
<ScrollView>
<BlueListItem title={loc.settings.network_electrum} onPress={navigateToElectrumSettings} chevron />
<BlueListItem title={loc.settings.lightning_settings} onPress={navigateToLightningSettings} chevron />
<BlueListItem title={loc.settings.network_broadcast} onPress={navigateToBroadcast} chevron />
<BlueListItem title={loc.settings.network_electrum} onPress={navigateToElectrumSettings} testID="ElectrumSettings" chevron />
<BlueListItem title={loc.settings.lightning_settings} onPress={navigateToLightningSettings} testID="LightningSettings" chevron />
<BlueListItem title={loc.settings.network_broadcast} onPress={navigateToBroadcast} testID="Broadcast" chevron />
</ScrollView>
</SafeBlueArea>
);

View File

@ -86,7 +86,7 @@ const SettingsPrivacy = () => {
hideChevron
title={loc.settings.privacy_read_clipboard}
Component={TouchableWithoutFeedback}
switch={{ onValueChange, value: isReadClipboardAllowed, disabled: isLoading === sections.ALL }}
switch={{ onValueChange, value: isReadClipboardAllowed, disabled: isLoading === sections.ALL, testID: 'ClipboardSwith' }}
/>
<BlueCard>
<BlueText>{loc.settings.privacy_clipboard_explanation}</BlueText>
@ -98,7 +98,12 @@ const SettingsPrivacy = () => {
hideChevron
title={loc.settings.privacy_quickactions}
Component={TouchableWithoutFeedback}
switch={{ onValueChange: onQuickActionsValueChange, value: isQuickActionsEnabled, disabled: isLoading === sections.ALL }}
switch={{
onValueChange: onQuickActionsValueChange,
value: isQuickActionsEnabled,
disabled: isLoading === sections.ALL,
testID: 'QuickActionsSwith',
}}
/>
<BlueCard>
<BlueText>{loc.settings.privacy_quickactions_explanation}</BlueText>
@ -124,7 +129,7 @@ const SettingsPrivacy = () => {
</>
)}
<BlueSpacing20 />
<BlueListItem title={loc.settings.privacy_system_settings} chevron onPress={openApplicationSettings} />
<BlueListItem title={loc.settings.privacy_system_settings} chevron onPress={openApplicationSettings} testID="PrivacySystemSettings" />
<BlueSpacing20 />
</ScrollView>
);

View File

@ -234,7 +234,7 @@ export default class ElectrumSettings extends Component {
<BlueCard>
<View style={styles.serverAddTitle}>
<BlueText style={styles.explain}>{loc.settings.electrum_settings_explain}</BlueText>
<TouchableOpacity onPress={() => this.resetToDefault()}>
<TouchableOpacity testID="ResetToDefault" onPress={() => this.resetToDefault()}>
<BlueText>{loc.settings.electrum_reset}</BlueText>
</TouchableOpacity>
</View>
@ -252,6 +252,7 @@ export default class ElectrumSettings extends Component {
autoCorrect={false}
autoCapitalize="none"
underlineColorAndroid="transparent"
testID="HostInput"
/>
</View>
<BlueSpacing20 />
@ -267,6 +268,7 @@ export default class ElectrumSettings extends Component {
underlineColorAndroid="transparent"
autoCorrect={false}
autoCapitalize="none"
testID="PortInput"
/>
</View>
<BlueSpacing20 />
@ -282,12 +284,13 @@ export default class ElectrumSettings extends Component {
placeholderTextColor="#81868e"
autoCapitalize="none"
underlineColorAndroid="transparent"
testID="SSLPortInput"
/>
</View>
<BlueSpacing20 />
<BlueButtonLink title={loc.wallets.import_scan_qr} onPress={this.importScan} />
<BlueSpacing20 />
{this.state.isLoading ? <BlueLoading /> : <BlueButton onPress={this.save} title={loc.settings.save} />}
{this.state.isLoading ? <BlueLoading /> : <BlueButton testID="Save" onPress={this.save} title={loc.settings.save} />}
</BlueCard>
{serverHistoryItems.length > 0 && !this.state.isLoading && (
<BlueCard>

View File

@ -142,12 +142,13 @@ const LightningSettings = () => {
autoCapitalize="none"
autoCorrect={false}
underlineColorAndroid="transparent"
testID="URIInput"
/>
</View>
<BlueButtonLink title={loc.wallets.import_scan_qr} onPress={importScan} />
<BlueButtonLink title={loc.wallets.import_scan_qr} testID="ImportScan" onPress={importScan} />
<BlueSpacing20 />
{isLoading ? <BlueLoading /> : <BlueButton onPress={save} title={loc.settings.save} />}
{isLoading ? <BlueLoading /> : <BlueButton testID="Save" onPress={save} title={loc.settings.save} />}
</BlueCard>
</SafeBlueArea>
);

View File

@ -98,7 +98,7 @@ const NotificationSettings = () => {
<BlueListItem
Component={TouchableWithoutFeedback}
title={loc.settings.push_notifications}
switch={{ onValueChange: onNotificationsSwitch, value: isNotificationsEnabled }}
switch={{ onValueChange: onNotificationsSwitch, value: isNotificationsEnabled, testID: 'NotificationsSwitch' }}
/>
<BlueSpacing20 />

View File

@ -24,15 +24,20 @@ const Settings = () => {
<ScrollView style={styles.root}>
<StatusBar barStyle="default" />
<BlueHeaderDefaultSub leftText={loc.settings.header} />
<BlueListItem title={loc.settings.general} onPress={() => navigate('GeneralSettings')} chevron />
<BlueListItem title={loc.settings.currency} onPress={() => navigate('Currency')} chevron />
<BlueListItem title={loc.settings.language} onPress={() => navigate('Language')} chevron />
<BlueListItem title={loc.settings.general} onPress={() => navigate('GeneralSettings')} testID="GeneralSettings" chevron />
<BlueListItem title={loc.settings.currency} onPress={() => navigate('Currency')} testID="Currency" chevron />
<BlueListItem title={loc.settings.language} onPress={() => navigate('Language')} testID="Language" chevron />
<BlueListItem title={loc.settings.encrypt_title} onPress={() => navigate('EncryptStorage')} testID="SecurityButton" chevron />
<BlueListItem title={loc.settings.network} onPress={() => navigate('NetworkSettings')} chevron />
<BlueListItem title={loc.settings.network} onPress={() => navigate('NetworkSettings')} testID="NetworkSettings" chevron />
{Notifications.isNotificationsCapable && (
<BlueListItem title={loc.settings.notifications} onPress={() => navigate('NotificationSettings')} chevron />
<BlueListItem
title={loc.settings.notifications}
onPress={() => navigate('NotificationSettings')}
testID="NotificationSettings"
chevron
/>
)}
<BlueListItem title={loc.settings.privacy} onPress={() => navigate('SettingsPrivacy')} chevron />
<BlueListItem title={loc.settings.privacy} onPress={() => navigate('SettingsPrivacy')} testID="SettingsPrivacy" chevron />
<BlueListItem title={loc.settings.about} onPress={() => navigate('About')} testID="AboutButton" chevron />
</ScrollView>
);

View File

@ -29,6 +29,123 @@ describe('BlueWallet UI Tests', () => {
process.env.TRAVIS && require('fs').writeFileSync(lockFile, '1');
});
it('all settings screens are works', async () => {
const lockFile = '/tmp/travislock.' + hashIt(jasmine.currentTest.fullName);
if (process.env.TRAVIS) {
if (require('fs').existsSync(lockFile))
return console.warn('skipping', JSON.stringify(jasmine.currentTest.fullName), 'as it previously passed on Travis');
}
await yo('WalletsList');
// go to settings, press SelfTest and wait for OK
await element(by.id('SettingsButton')).tap();
// general
// enable AdvancedMode
await element(by.id('GeneralSettings')).tap();
await element(by.id('AdvancedMode')).tap();
await device.pressBack();
//
// currency
// change currency to ARS ($) and switch it back to USD ($)
await element(by.id('Currency')).tap();
await element(by.text('ARS ($)')).tap();
await expect(element(by.text('Prices are obtained from Yadio'))).toBeVisible();
await element(by.text('USD ($)')).tap();
await device.pressBack();
// language
// change language to Chinese (ZH), test it and switch back to English
await element(by.id('Language')).tap();
await element(by.text('Chinese (ZH)')).tap();
await device.pressBack();
await expect(element(by.text('语言'))).toBeVisible();
await element(by.id('Language')).tap();
await element(by.text('English')).tap();
await device.pressBack();
// security
await element(by.id('SecurityButton')).tap();
await device.pressBack();
// network
await element(by.id('NetworkSettings')).tap();
// network -> electrum server
// change electrum server to electrum.blockstream.info and revert it back
await element(by.id('ElectrumSettings')).tap();
await element(by.id('HostInput')).replaceText('electrum.blockstream.info\n');
await element(by.id('PortInput')).replaceText('50001\n');
await element(by.id('SSLPortInput')).replaceText('50002\n');
await element(by.id('Save')).tap();
await sup('OK');
await element(by.text('OK')).tap();
await element(by.id('ResetToDefault')).tap();
await sup('OK');
await element(by.text('OK')).tap();
await expect(element(by.id('HostInput'))).toHaveText('');
await expect(element(by.id('PortInput'))).toHaveText('');
await expect(element(by.id('SSLPortInput'))).toHaveText('');
await device.pressBack();
// network -> lightning
// change URI and revert it back
await element(by.id('LightningSettings')).tap();
await element(by.id('URIInput')).replaceText('invalid\n');
await element(by.id('Save')).tap();
await sup('OK');
await expect(element(by.text('Not a valid LNDHub URI'))).toBeVisible();
await element(by.text('OK')).tap();
await element(by.id('URIInput')).replaceText('https://lndhub.herokuapp.com\n');
await element(by.id('Save')).tap();
await sup('OK');
await expect(element(by.text('Your changes have been saved successfully.'))).toBeVisible();
await element(by.text('OK')).tap();
await element(by.id('URIInput')).replaceText('\n');
await element(by.id('Save')).tap();
await sup('OK');
await expect(element(by.text('Your changes have been saved successfully.'))).toBeVisible();
await element(by.text('OK')).tap();
await device.pressBack();
// network -> broadcast
// try to broadcast wrong tx
await element(by.id('Broadcast')).tap();
await element(by.id('TxHex')).replaceText('invalid\n');
await element(by.id('BroadcastButton')).tap();
await sup('OK');
// await expect(element(by.text('the transaction was rejected by network rules....'))).toBeVisible();
await element(by.text('OK')).tap();
await device.pressBack();
await device.pressBack();
// notifications
// turn on notifications if available
if (await expectToBeVisible('NotificationSettings')) {
await element(by.id('NotificationSettings')).tap();
await element(by.id('NotificationsSwitch')).tap();
await sup('OK');
await element(by.text('OK')).tap();
await element(by.id('NotificationsSwitch')).tap();
await device.pressBack();
}
// privacy
// trigger switches
await element(by.id('SettingsPrivacy')).tap();
await element(by.id('ClipboardSwith')).tap();
await element(by.id('ClipboardSwith')).tap();
await element(by.id('QuickActionsSwith')).tap();
await element(by.id('QuickActionsSwith')).tap();
await device.pressBack();
// about
await element(by.id('AboutButton')).tap();
await device.pressBack();
process.env.TRAVIS && require('fs').writeFileSync(lockFile, '1');
});
it('can create wallet, reload app and it persists. then go to receive screen, set custom amount and label. Dismiss modal and go to WalletsList.', async () => {
const lockFile = '/tmp/travislock.' + hashIt(jasmine.currentTest.fullName);
if (process.env.TRAVIS) {
@ -999,3 +1116,12 @@ async function extractTextFromElementById(id) {
}
}
}
const expectToBeVisible = async id => {
try {
await expect(element(by.id(id))).toBeVisible();
return true;
} catch (e) {
return false;
}
};