Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NejcZdovc committed Mar 5, 2017
1 parent cd94b65 commit b4ae95e
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class AdvanceSettingsContent extends ImmutableComponent {

// TODO translate seconds, minute and visits
return <div className={css(paymentCommon.board)}>
<div className={css(paymentCommon.panel, styles.advancedSettings, commonStyles.noMarginTop, commonStyles.noMarginBottom)}>
<div className={css(paymentCommon.panel, styles.advancedSettings, commonStyles.noMarginTop, commonStyles.noMarginBottom)} data-test-id='advancedSettings'>
<div className={css(styles.settingsPanelDivider, styles.deviderFirst)}>
<div className={css(styles.minimumSetting)} data-l10n-id='minimumPageTimeSetting' />
<SettingsList>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class BitcoinDashboard extends ImmutableComponent {
window.addEventListener('message', this.onMessage.bind(this), false)

// TODO remove bitcoinDashboard class
return <div className='bitcoinDashboard'>
return <div className='bitcoinDashboard' data-test-id='bitcoinDashboard'>
{
this.props.bitcoinOverlayVisible
? <ModalOverlay
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const CoinBase2 = require('../../../../extensions/brave/img/coinbase_2x.png')

class DisabledContent extends ImmutableComponent {
render () {
return <div>
<div className={css(styles.paymentsMessage, styles.walletBarMargin)}>
return <div data-test-id='disabledContent'>
<div className={css(styles.paymentsMessage, styles.walletBarMargin)} data-test-id='paymentsMessage'>
<h3 className={css(styles.h3)} data-l10n-id='paymentsWelcomeTitle' />
<div className={css(styles.text)} data-l10n-id='paymentsWelcomeText1' />
<div className={css(styles.boldText, styles.text)} data-l10n-id='paymentsWelcomeText2' />
Expand Down
21 changes: 13 additions & 8 deletions app/renderer/components/preferences/payment/enabledContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const LedgerTable = require('./ledgerTable')
// style
const globalStyles = require('../../styles/global')
const {paymentStyles} = require('../../styles/payment')
const commonStyles = require('../../styles/commonStyles')
const cx = require('../../../../../js/lib/classSet')

// other
Expand All @@ -39,14 +40,14 @@ class EnabledContent extends ImmutableComponent {
? this.props.showOverlay.bind(this, 'addFunds')
: (ledgerData.get('creating') ? () => {} : this.createWallet(ledgerData))

return <Button data-test-id={buttonText}
return <Button
testId={buttonText}
test2Id={'addFunds'}
l10nId={buttonText}
className={cx({
primaryButton: true,
[css(styles.addFunds)]: true
})}
className={css(commonStyles.buttonPrimary, styles.addFunds)}
onClick={onButtonClick.bind(this)}
disabled={ledgerData.get('creating')} />
disabled={ledgerData.get('creating')}
/>
}

paymentHistoryButton (ledgerData) {
Expand All @@ -71,6 +72,7 @@ class EnabledContent extends ImmutableComponent {
const onButtonClick = this.props.showOverlay.bind(this, 'paymentHistory')

return <Button
testId='paymentHistoryButton'
className={css(styles.paymentHistoryButton)}
l10nId={buttonText}
l10nArgs={l10nDataArgs}
Expand Down Expand Up @@ -184,7 +186,7 @@ class EnabledContent extends ImmutableComponent {
const walletStatus = this.walletStatus(ledgerData)

return <div>
<div className={css(styles.walletBar)}>
<div className={css(styles.walletBar)} data-test-id='walletBar'>
<table>
<thead>
<tr className={css(styles.tableTr)}>
Expand Down Expand Up @@ -233,7 +235,10 @@ class EnabledContent extends ImmutableComponent {
}
</td>
<td className={css(styles.tableTd)}>
<div data-l10n-id={walletStatus.id} data-l10n-args={walletStatus.args ? JSON.stringify(walletStatus.args) : null} />
<div data-test-id='walletStatus'
data-l10n-id={walletStatus.id}
data-l10n-args={walletStatus.args ? JSON.stringify(walletStatus.args) : null}
/>
{this.nextReconcileMessage(ledgerData)}
</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class LedgerRecoveryContent extends ImmutableComponent {
{
(recoverySucceeded === false && recoveryError && isNetworkError)
? <div className={css(styles.recoveryOverlay)}>
<h1 className={css(styles.recoveryOverlay__h1)} data-l10n-id='ledgerRecoveryNetworkFailedTitle' />
<h1 className={css(styles.recoveryOverlay__h1)} data-l10n-id='ledgerRecoveryNetworkFailedTitle' data-test-id='recoveryError' />
<p className={css(styles.recoveryOverlay__p, styles.spaceAround)}
data-l10n-id='ledgerRecoveryNetworkFailedMessage'
/>
Expand Down
2 changes: 1 addition & 1 deletion app/renderer/components/preferences/payment/ledgerTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class LedgerTable extends ImmutableComponent {
if (!this.synopsis || !this.synopsis.size) {
return null
}
return <div>
return <div data-test-id='ledgerTable'>
<div className={css(styles.hideExcludedSites)}>
<div className={css(styles.columnOffset)} />
<div className={css(styles.rightColumn)}>
Expand Down
4 changes: 2 additions & 2 deletions app/renderer/components/preferences/paymentsTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class PaymentsTab extends ImmutableComponent {
return <div className={cx({
paymentsContainer: true,
[css(styles.paymentsContainer)]: true
})}>
})} data-test-id='paymentsContainer'>
{
this.enabled && this.props.addFundsOverlayVisible
? <ModalOverlay title={this.overlayTitle} content={this.overlayContent} onHide={this.props.hideOverlay.bind(this, 'addFunds')} />
Expand Down Expand Up @@ -166,7 +166,7 @@ class PaymentsTab extends ImmutableComponent {
<span className='sectionSubTitle'>beta</span>
</div>
<div className={css(styles.paymentsSwitches)}>
<div className={css(styles.switchWrap)}>
<div className={css(styles.switchWrap)} data-test-id='enablePaymentsSwitch'>
<span data-l10n-id='off' />
<SettingCheckbox dataL10nId='on'
prefKey={settings.PAYMENTS_ENABLED}
Expand Down
4 changes: 4 additions & 0 deletions js/components/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class Button extends ImmutableComponent {
if (this.props.iconClass) {
return <button disabled={this.props.disabled}
data-l10n-id={this.props.l10nId}
data-test-id={this.props.testId}
data-test2-id={this.props.test2Id}
style={this.props.inlineStyles}
data-button-value={this.props.dataButtonValue}
className={cx({
Expand All @@ -23,6 +25,8 @@ class Button extends ImmutableComponent {
}
return <button disabled={this.props.disabled}
data-l10n-id={this.props.l10nId}
data-test-id={this.props.testId}
data-test2-id={this.props.test2Id}
data-l10n-args={JSON.stringify(this.props.l10nArgs || {})}
style={this.props.inlineStyles}
className={cx({
Expand Down
18 changes: 9 additions & 9 deletions test/lib/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,28 +66,28 @@ module.exports = {
doneButton: '[data-l10n-id="done"]',
homepageInput: '[data-l10n-id="homepageInput"]',
syncSwitch: '.syncContainer .switchBackground',
walletSwitch: '.enablePaymentsSwitch .switchBackground',
addFundsButton: '.addFunds',
advancedSettings: '.advancedSettings',
walletSwitch: '[data-test-id="enablePaymentsSwitch"] .switchBackground',
addFundsButton: '[data-test2-id="addFunds"]',
advancedSettings: '[data-l10n-id="advancedSettings"]',
fundsSelectBox: '[data-test-id="fundsSelectBox"]',
paymentsStatus: '.walletStatus',
paymentsStatus: '[data-test-id="walletStatus"]',
siteSettingItem: '.siteSettingItem',
ledgerTable: '.ledgerTable',
bitcoinDashboard: '.bitcoinDashboard',
ledgerTable: '[data-test-id="ledgerTable"]',
bitcoinDashboard: '[data-test-id="bitcoinDashboard"]',
advancedSettingsButton: '[data-l10n-id="advancedSettings"]',
backupWallet: '[data-l10n-id="backupLedger"]',
recoverWallet: '[data-l10n-id="recoverLedger"]',
recoverWalletFromFileButton: '[data-l10n-id="recoverFromFile"]',
recoveryOverlayOkButton: '.recoveryOverlay [data-l10n-id="ok"]',
saveWalletFile: '[data-l10n-id="saveRecoveryFile"]',
balanceRecovered: '[data-l10n-id="balanceRecovered"]',
balanceNotRecovered: '.recoveryError',
balanceNotRecovered: '[data-test-id="recoveryError"]',
modalCloseButton: 'button.close',
coinbaseBuyButton: '[data-l10n-id="add"]',
paymentQRCode: '[title="Brave wallet QR code"]',
removeButton: '[data-l10n-id="remove"]',
paymentHistoryButton: '.paymentHistoryButton',
paymentsWelcomePage: '.paymentsMessage',
paymentHistoryButton: '[data-test-id="paymentHistoryButton"]',
paymentsWelcomePage: '[data-test-id="paymentsMessage"',
autofillAddressPanel: '.autofillAddressPanel',
autofillCreditCardPanel: '.autofillCreditCardPanel',
allowRunInsecureContentButton: '.allowRunInsecureContentButton',
Expand Down
13 changes: 11 additions & 2 deletions test/unit/about/preferencesTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,17 @@ describe('Preferences component', function () {
mockery.registerMock('../../../extensions/brave/img/preferences/browser_prefs_payments.svg', 'browser_prefs_payments.svg')
mockery.registerMock('../../../extensions/brave/img/preferences/browser_prefs_sync.svg', 'browser_prefs_sync.svg')
mockery.registerMock('../../../extensions/brave/img/preferences/browser_prefs_advanced.svg', 'browser_prefs_advanced.svg')
mockery.registerMock('../../../extensions/brave/img/ledger/verified_green_icon.svg')
mockery.registerMock('../../../extensions/brave/img/ledger/verified_white_icon.svg')
mockery.registerMock('../../../../extensions/brave/img/ledger/verified_green_icon.svg')
mockery.registerMock('../../../../extensions/brave/img/ledger/verified_white_icon.svg')
mockery.registerMock('../../../../extensions/brave/img/private_internet_access.png')
mockery.registerMock('../../../../extensions/brave/img/private_internet_access_2x.png')
mockery.registerMock('../../../../extensions/brave/img/bitgo.png')
mockery.registerMock('../../../../extensions/brave/img/bitgo_2x.png')
mockery.registerMock('../../../../extensions/brave/img/coinbase.png')
mockery.registerMock('../../../../extensions/brave/img/coinbase_2x.png')
mockery.registerMock('../../../../extensions/brave/img/coinbase_logo.png')
mockery.registerMock('../../../../extensions/brave/img/android_download.svg')
mockery.registerMock('../../../../extensions/brave/img/ios_download.svg')

window.chrome = fakeElectron
window.CustomEvent = {}
Expand Down
Loading

0 comments on commit b4ae95e

Please sign in to comment.