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

Hide pre-release preference, since Linux builds don't auto-update #9650

Merged
merged 1 commit into from
Jun 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion app/renderer/components/preferences/advancedTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,26 @@ const {scaleSize} = require('../../../common/constants/toolbarUserInterfaceScale

// Utils
const {changeSetting} = require('../../lib/settingsUtil')
const platformUtil = require('../../../common/lib/platformUtil')

class AdvancedTab extends ImmutableComponent {
previewReleases () {
return platformUtil.isLinux()
? null
: <SettingCheckbox
dataL10nId='updateToPreviewReleases'
data-test-id='update-to-preview-releases'
prefKey={settings.UPDATE_TO_PREVIEW_RELEASES}
settings={this.props.settings}
onChangeSetting={this.props.onChangeSetting} />
}

render () {
return <section>
<main className={css(styles.advancedTabMain)}>
<DefaultSectionTitle data-l10n-id='contentSettings' />
<SettingsList>
<SettingCheckbox dataL10nId='updateToPreviewReleases' prefKey={settings.UPDATE_TO_PREVIEW_RELEASES} settings={this.props.settings} onChangeSetting={this.props.onChangeSetting} />
{this.previewReleases()}
<SettingCheckbox dataL10nId='useHardwareAcceleration' prefKey={settings.HARDWARE_ACCELERATION_ENABLED} settings={this.props.settings} onChangeSetting={this.props.onChangeSetting} />
<SettingCheckbox dataL10nId='useSmoothScroll' prefKey={settings.SMOOTH_SCROLL_ENABLED} settings={this.props.settings} onChangeSetting={this.props.onChangeSetting} />
<SettingCheckbox dataL10nId='sendCrashReports' prefKey={settings.SEND_CRASH_REPORTS} settings={this.props.settings} onChangeSetting={this.props.onChangeSetting} />
Expand Down
76 changes: 76 additions & 0 deletions test/unit/app/renderer/components/preferences/advancedTabTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
/* global describe, before, after, it */

const mockery = require('mockery')
const {mount} = require('enzyme')
const assert = require('assert')
const fakeElectron = require('../../../../lib/fakeElectron')
let AdvancedTab
require('../../../../braveUnit')

describe('AdvancedTab component', function () {
before(function () {
mockery.enable({
warnOnReplace: false,
warnOnUnregistered: false,
useCleanCache: true
})
mockery.registerMock('../../less/switchControls.less', {})
mockery.registerMock('../../less/about/preferences.less', {})
mockery.registerMock('../../less/forms.less', {})
mockery.registerMock('../../less/button.less', {})
mockery.registerMock('../../node_modules/font-awesome/css/font-awesome.css', {})
mockery.registerMock('../../../extensions/brave/img/caret_down_grey.svg')

// default platformUtil to non-Linux
mockery.registerMock('../../../common/lib/platformUtil', {isLinux: () => false})

mockery.registerMock('electron', fakeElectron)
window.chrome = fakeElectron

AdvancedTab = require('../../../../../../app/renderer/components/preferences/advancedTab')
})
after(function () {
mockery.disable()
})

describe('AdvancedTab', function () {
describe('previewReleases', function () {
describe('on macOS', function () {
it('is shown', function () {
const wrapper = mount(
<AdvancedTab onChangeSetting={null} />
)
const instance = wrapper.instance()
assert(instance.previewReleases())
})
})

describe('on Linux', function () {
before(function () {
mockery.deregisterMock('../../../common/lib/platformUtil')
mockery.registerMock('../../../common/lib/platformUtil', {isLinux: () => true})
mockery.resetCache()
AdvancedTab = require('../../../../../../app/renderer/components/preferences/advancedTab')
})

after(function () {
mockery.deregisterMock('../../../common/lib/platformUtil')
mockery.registerMock('../../../common/lib/platformUtil', {isLinux: () => false})
mockery.resetCache()
AdvancedTab = require('../../../../../../app/renderer/components/preferences/advancedTab')
})

it('is hidden', function () {
const wrapper = mount(
<AdvancedTab onChangeSetting={null} />
)
const instance = wrapper.instance()
assert.equal(instance.previewReleases(), null)
})
})
})
})
})