diff --git a/lib/containers/git-tab-container.js b/lib/containers/git-tab-container.js index e8ddef3cf7..7a54ef448c 100644 --- a/lib/containers/git-tab-container.js +++ b/lib/containers/git-tab-container.js @@ -25,6 +25,7 @@ const DEFAULT_REPO_DATA = { export default class GitTabContainer extends React.Component { static propTypes = { + config: PropTypes.object.isRequired, repository: PropTypes.object.isRequired, } diff --git a/lib/containers/github-tab-container.js b/lib/containers/github-tab-container.js index 839314c84c..bb092eef03 100644 --- a/lib/containers/github-tab-container.js +++ b/lib/containers/github-tab-container.js @@ -17,6 +17,7 @@ export default class GitHubTabContainer extends React.Component { repository: PropTypes.object, loginModel: GithubLoginModelPropType.isRequired, rootHolder: RefHolderPropType.isRequired, + config: PropTypes.object.isRequired, changeWorkingDirectory: PropTypes.func.isRequired, onDidChangeWorkDirs: PropTypes.func.isRequired, diff --git a/lib/containers/github-tab-header-container.js b/lib/containers/github-tab-header-container.js index c421ef68b0..01f1f5bbb4 100644 --- a/lib/containers/github-tab-header-container.js +++ b/lib/containers/github-tab-header-container.js @@ -11,6 +11,8 @@ import GithubTabHeaderController from '../controllers/github-tab-header-controll export default class GithubTabHeaderContainer extends React.Component { static propTypes = { + config: PropTypes.object.isRequired, + // Connection loginModel: PropTypes.object.isRequired, endpoint: EndpointPropType.isRequired, @@ -74,6 +76,7 @@ export default class GithubTabHeaderContainer extends React.Component { return ( { + this.setState({disableProjectSelection: newValue}); + } + updateCommitter = async () => { const committer = await this.props.getCommitter() || nullAuthor; if (this._isMounted) { diff --git a/lib/controllers/github-tab-controller.js b/lib/controllers/github-tab-controller.js index 320d48b328..12e4bdfa23 100644 --- a/lib/controllers/github-tab-controller.js +++ b/lib/controllers/github-tab-controller.js @@ -12,6 +12,7 @@ export default class GitHubTabController extends React.Component { refresher: RefresherPropType.isRequired, loginModel: GithubLoginModelPropType.isRequired, rootHolder: RefHolderPropType.isRequired, + config: PropTypes.object.isRequired, workingDirectory: PropTypes.string, repository: PropTypes.object.isRequired, @@ -52,6 +53,7 @@ export default class GitHubTabController extends React.Component { workspace={this.props.workspace} refresher={this.props.refresher} rootHolder={this.props.rootHolder} + config={this.props.config} workingDirectory={this.props.workingDirectory || this.props.currentWorkDir} repository={this.props.repository} diff --git a/lib/controllers/github-tab-header-controller.js b/lib/controllers/github-tab-header-controller.js index 78f4fba875..fbb8f49319 100644 --- a/lib/controllers/github-tab-header-controller.js +++ b/lib/controllers/github-tab-header-controller.js @@ -1,10 +1,12 @@ import React from 'react'; import PropTypes from 'prop-types'; import {AuthorPropType} from '../prop-types'; +import {CompositeDisposable} from 'atom'; import GithubTabHeaderView from '../views/github-tab-header-view'; export default class GithubTabHeaderController extends React.Component { static propTypes = { + config: PropTypes.object.isRequired, user: AuthorPropType.isRequired, // Workspace @@ -18,7 +20,11 @@ export default class GithubTabHeaderController extends React.Component { constructor(props) { super(props); - this.state = {currentWorkDirs: []}; + this.state = { + currentWorkDirs: [], + disableProjectSelection: this.props.config.get('github.useProjectFromActivePanel'), + }; + this.disposable = new CompositeDisposable(); } static getDerivedStateFromProps(props, state) { @@ -28,21 +34,27 @@ export default class GithubTabHeaderController extends React.Component { } componentDidMount() { - this.disposable = this.props.onDidChangeWorkDirs(this.resetWorkDirs); + this.disposable.add( + this.props.onDidChangeWorkDirs(this.resetWorkDirs), + this.props.config.onDidChange('github.useProjectFromActivePanel', this.handleUseProjectFromActivePanelChange), + ); } componentDidUpdate(prevProps) { if (prevProps.onDidChangeWorkDirs !== this.props.onDidChangeWorkDirs) { - if (this.disposable) { - this.disposable.dispose(); - } - this.disposable = this.props.onDidChangeWorkDirs(this.resetWorkDirs); + this.disposable.dispose(); + this.disposeable = new CompositeDisposable(); + this.disposable.add( + this.props.onDidChangeWorkDirs(this.resetWorkDirs), + this.props.config.onDidChange('github.useProjectFromActivePanel', this.handleUseProjectFromActivePanelChange), + ); } } render() { return ( { + this.setState({disableProjectSelection: newValue}); + } + resetWorkDirs = () => { this.setState((state, props) => ({ currentWorkDirs: [], diff --git a/lib/controllers/root-controller.js b/lib/controllers/root-controller.js index 708fdc3561..2bb68e7d2f 100644 --- a/lib/controllers/root-controller.js +++ b/lib/controllers/root-controller.js @@ -308,6 +308,7 @@ export default class RootController extends React.Component { repository={this.props.repository} loginModel={this.props.loginModel} workspace={this.props.workspace} + config={this.props.config} currentWorkDir={this.props.currentWorkDir} getCurrentWorkDirs={getCurrentWorkDirs} onDidChangeWorkDirs={onDidChangeWorkDirs} diff --git a/lib/github-package.js b/lib/github-package.js index f2fb23f72d..2fba369564 100644 --- a/lib/github-package.js +++ b/lib/github-package.js @@ -60,6 +60,7 @@ export default class GithubPackage { this.confirm = confirm; this.startOpen = false; this.activated = false; + this.projectFromActivePanel = false; const criteria = { projectPathCount: this.project.getPaths().length, @@ -181,8 +182,33 @@ export default class GithubPackage { this.scheduleActiveContextUpdate({activeRepositoryPath}); }; + const handleActivePaneChange = item => { + if (!this.projectFromActivePanel || !item || !this.workspace.isTextEditor(item) + || !item.getBuffer() || !item.getBuffer().getPath()) { + return; + } + + const activeDirectory = this.project.getDirectories().find(directory => { + return directory.contains(item.getBuffer().getPath()); + }); + + if (activeDirectory) { + this.workdirCache.find(activeDirectory.getPath()).then(activeRepositoryPath => { + this.scheduleActiveContextUpdate({activeRepositoryPath}, {item}); + }).catch(e => { + throw e; + }); + } + }; + + const handleUseProjectFromActivePanelChange = newValue => { + this.projectFromActivePanel = newValue; + }; + this.subscriptions.add( this.project.onDidChangePaths(handleProjectPathsChange), + this.workspace.getCenter().onDidStopChangingActivePaneItem(handleActivePaneChange), + this.config.observe('github.useProjectFromActivePanel', handleUseProjectFromActivePanelChange), this.styleCalculator.startWatching( 'github-package-styles', ['editor.fontSize', 'editor.fontFamily', 'editor.lineHeight', 'editor.tabLength'], diff --git a/lib/items/git-tab-item.js b/lib/items/git-tab-item.js index e8de6d7cca..359e1ea813 100644 --- a/lib/items/git-tab-item.js +++ b/lib/items/git-tab-item.js @@ -6,6 +6,7 @@ import GitTabContainer from '../containers/git-tab-container'; export default class GitTabItem extends React.Component { static propTypes = { + config: PropTypes.object.isRequired, repository: PropTypes.object.isRequired, } diff --git a/lib/items/github-tab-item.js b/lib/items/github-tab-item.js index 5a4452dc7c..196bfba73b 100644 --- a/lib/items/github-tab-item.js +++ b/lib/items/github-tab-item.js @@ -10,6 +10,7 @@ export default class GitHubTabItem extends React.Component { workspace: PropTypes.object.isRequired, repository: PropTypes.object, loginModel: GithubLoginModelPropType.isRequired, + config: PropTypes.object.isRequired, documentActiveElement: PropTypes.func, diff --git a/lib/views/git-tab-header-view.js b/lib/views/git-tab-header-view.js index 78a71a990c..134a5d4c8e 100644 --- a/lib/views/git-tab-header-view.js +++ b/lib/views/git-tab-header-view.js @@ -5,6 +5,7 @@ import {AuthorPropType} from '../prop-types'; export default class GitTabHeaderView extends React.Component { static propTypes = { + disableProjectSelection: PropTypes.bool, committer: AuthorPropType.isRequired, // Workspace @@ -21,7 +22,8 @@ export default class GitTabHeaderView extends React.Component { {this.renderCommitter()} diff --git a/lib/views/git-tab-view.js b/lib/views/git-tab-view.js index a5f10cc687..8cfd451103 100644 --- a/lib/views/git-tab-view.js +++ b/lib/views/git-tab-view.js @@ -121,6 +121,7 @@ export default class GitTabView extends React.Component { const {repository} = this.props; return ( {}}> + onChange={this.props.handleWorkDirSelect ? this.props.handleWorkDirSelect : () => {}} + disabled={this.props.disableProjectSelection}> {this.renderWorkDirs()} diff --git a/lib/views/github-tab-view.js b/lib/views/github-tab-view.js index a0add89b17..ecc48a64de 100644 --- a/lib/views/github-tab-view.js +++ b/lib/views/github-tab-view.js @@ -19,6 +19,7 @@ export default class GitHubTabView extends React.Component { static propTypes = { refresher: RefresherPropType.isRequired, rootHolder: RefHolderPropType.isRequired, + config: PropTypes.object.isRequired, // Connection loginModel: GithubLoginModelPropType.isRequired, @@ -40,7 +41,7 @@ export default class GitHubTabView extends React.Component { aheadCount: PropTypes.number, pushInProgress: PropTypes.bool.isRequired, - // Event Handelrs + // Event Handlers handleWorkDirSelect: PropTypes.func, handlePushBranch: PropTypes.func.isRequired, handleRemoteSelect: PropTypes.func.isRequired, @@ -131,6 +132,8 @@ export default class GitHubTabView extends React.Component { if (this.props.currentRemote.isPresent()) { return ( {}} - onDidChangeWorkDirs={() => {}} + onDidChangeWorkDirs={() => { return {dispose: () => {}}; }} getCurrentWorkDirs={() => []} openCreateDialog={() => {}} openPublishDialog={() => {}} diff --git a/test/containers/github-tab-header-container.test.js b/test/containers/github-tab-header-container.test.js index 15eb6eeb9b..d802befe01 100644 --- a/test/containers/github-tab-header-container.test.js +++ b/test/containers/github-tab-header-container.test.js @@ -25,6 +25,7 @@ describe('GithubTabHeaderContainer', function() { function buildApp(overrideProps = {}) { return ( null} diff --git a/test/controllers/git-tab-header-controller.test.js b/test/controllers/git-tab-header-controller.test.js index 5c66d545b9..3113e79c0f 100644 --- a/test/controllers/git-tab-header-controller.test.js +++ b/test/controllers/git-tab-header-controller.test.js @@ -13,7 +13,10 @@ describe('GitTabHeaderController', function() { } function buildApp(overrides) { + const atomEnv = global.buildAtomEnvironment(); + const props = { + config: atomEnv.config, getCommitter: () => nullAuthor, getCurrentWorkDirs: () => createWorkdirs([]), onDidUpdateRepo: () => new Disposable(), @@ -117,4 +120,35 @@ describe('GitTabHeaderController', function() { wrapper.unmount(); assert.strictEqual(wrapper.children().length, 0); }); + + describe('disableProjectSelection', function() { + const configKey = 'github.useProjectFromActivePanel'; + + it('initializes from config when true', function() { + const atomEnv = global.buildAtomEnvironment(); + atomEnv.config.set(configKey, true); + const wrapper = shallow(buildApp({config: atomEnv.config})); + assert.strictEqual(wrapper.state('disableProjectSelection'), true); + }); + + it('initializes from config when false', function() { + const atomEnv = global.buildAtomEnvironment(); + atomEnv.config.set(configKey, false); + const wrapper = shallow(buildApp({config: atomEnv.config})); + assert.strictEqual(wrapper.state('disableProjectSelection'), false); + }); + + it('updates state when config changes', function() { + const atomEnv = global.buildAtomEnvironment(); + atomEnv.config.set(configKey, true); + const wrapper = shallow(buildApp({config: atomEnv.config})); + assert.strictEqual(wrapper.state('disableProjectSelection'), true); + + atomEnv.config.set(configKey, false); + assert.strictEqual(wrapper.state('disableProjectSelection'), false); + + atomEnv.config.set(configKey, true); + assert.strictEqual(wrapper.state('disableProjectSelection'), true); + }); + }); }); diff --git a/test/controllers/github-tab-controller.test.js b/test/controllers/github-tab-controller.test.js index ad5e3c2fd2..67430e6866 100644 --- a/test/controllers/github-tab-controller.test.js +++ b/test/controllers/github-tab-controller.test.js @@ -35,6 +35,7 @@ describe('GitHubTabController', function() { refresher={new Refresher()} loginModel={new GithubLoginModel(InMemoryStrategy)} rootHolder={new RefHolder()} + config={atomEnv.config} workingDirectory={repo.getWorkingDirectoryPath()} repository={repo} diff --git a/test/controllers/github-tab-header-controller.test.js b/test/controllers/github-tab-header-controller.test.js index 1e4f8529f1..d08e48e828 100644 --- a/test/controllers/github-tab-header-controller.test.js +++ b/test/controllers/github-tab-header-controller.test.js @@ -13,7 +13,10 @@ describe('GithubTabHeaderController', function() { } function buildApp(overrides) { + const atomEnv = global.buildAtomEnvironment(); + const props = { + config: atomEnv.config, user: nullAuthor, getCurrentWorkDirs: () => createWorkdirs([]), onDidUpdateRepo: () => new Disposable(), @@ -35,22 +38,25 @@ describe('GithubTabHeaderController', function() { }); it('calls onDidChangeWorkDirs after mount', function() { - const onDidChangeWorkDirs = sinon.spy(); + const onDidChangeWorkDirs = sinon.stub(); + onDidChangeWorkDirs.returns({dispose: () => {}}); shallow(buildApp({onDidChangeWorkDirs})); assert.isTrue(onDidChangeWorkDirs.calledOnce); }); it('does not call onDidChangeWorkDirs on update', function() { - const onDidChangeWorkDirs = sinon.spy(); + const onDidChangeWorkDirs = sinon.stub(); + onDidChangeWorkDirs.returns({dispose: () => {}}); const wrapper = shallow(buildApp({onDidChangeWorkDirs})); wrapper.setProps({onDidChangeWorkDirs}); assert.isTrue(onDidChangeWorkDirs.calledOnce); }); it('calls onDidChangeWorkDirs on update to setup new listener', function() { - let onDidChangeWorkDirs = () => null; + let onDidChangeWorkDirs = () => { return {dispose: () => {}}; }; const wrapper = shallow(buildApp({onDidChangeWorkDirs})); - onDidChangeWorkDirs = sinon.spy(); + onDidChangeWorkDirs = sinon.stub(); + onDidChangeWorkDirs.returns({dispose: () => {}}); wrapper.setProps({onDidChangeWorkDirs}); assert.isTrue(onDidChangeWorkDirs.calledOnce); }); @@ -86,4 +92,35 @@ describe('GithubTabHeaderController', function() { wrapper.unmount(); assert.strictEqual(wrapper.children().length, 0); }); + + describe('disableProjectSelection', function() { + const configKey = 'github.useProjectFromActivePanel'; + + it('initializes from config when true', function() { + const atomEnv = global.buildAtomEnvironment(); + atomEnv.config.set(configKey, true); + const wrapper = shallow(buildApp({config: atomEnv.config})); + assert.strictEqual(wrapper.state('disableProjectSelection'), true); + }); + + it('initializes from config when false', function() { + const atomEnv = global.buildAtomEnvironment(); + atomEnv.config.set(configKey, false); + const wrapper = shallow(buildApp({config: atomEnv.config})); + assert.strictEqual(wrapper.state('disableProjectSelection'), false); + }); + + it('updates state when config changes', function() { + const atomEnv = global.buildAtomEnvironment(); + atomEnv.config.set(configKey, true); + const wrapper = shallow(buildApp({config: atomEnv.config})); + assert.strictEqual(wrapper.state('disableProjectSelection'), true); + + atomEnv.config.set(configKey, false); + assert.strictEqual(wrapper.state('disableProjectSelection'), false); + + atomEnv.config.set(configKey, true); + assert.strictEqual(wrapper.state('disableProjectSelection'), true); + }); + }); }); diff --git a/test/github-package.test.js b/test/github-package.test.js index dfb0308011..8856c8c79d 100644 --- a/test/github-package.test.js +++ b/test/github-package.test.js @@ -10,7 +10,7 @@ import GithubPackage from '../lib/github-package'; describe('GithubPackage', function() { async function buildAtomEnvironmentAndGithubPackage(buildAtomEnvironment, options = {}) { - const atomEnv = global.buildAtomEnvironment(); + const atomEnv = buildAtomEnvironment(); await disableFilesystemWatchers(atomEnv); const packageOptions = { @@ -147,7 +147,7 @@ describe('GithubPackage', function() { ({ atomEnv, githubPackage, project, config, configDirPath, contextPool, - } = await buildAtomEnvironmentAndGithubPackage(global.buildAtomEnvironmentAndGithubPackage)); + } = await buildAtomEnvironmentAndGithubPackage(global.buildAtomEnvironment)); }); afterEach(async function() { @@ -237,6 +237,105 @@ describe('GithubPackage', function() { }); }); + describe('with 3 projects and unactivated', function() { + let workdirPath1, workdirPath2, workdirPath3; + beforeEach(async function() { + ([workdirPath1, workdirPath2, workdirPath3] = await Promise.all([ + cloneRepository('three-files'), + cloneRepository('three-files'), + cloneRepository('three-files'), + ])); + project.setPaths([workdirPath1, workdirPath2, workdirPath3]); + }); + + describe('with useProjectFromActivePanel config enabled', function() { + beforeEach(async function() { + atomEnv.config.set('github.useProjectFromActivePanel', true); + await contextUpdateAfter(githubPackage, () => githubPackage.activate({})); + }); + + it('changes repository when active panel is changed', async function() { + await Promise.all([ + atomEnv.workspace.open(path.join(workdirPath1, 'a.txt')), + new Promise((resolve, reject) => { + githubPackage.scheduleActiveContextUpdate = ({activeRepositoryPath}) => { + try { + assert.strictEqual(activeRepositoryPath, workdirPath1); + resolve(); + } catch (e) { reject(e); } + }; + }), + ]); + + await Promise.all([ + atomEnv.workspace.open(path.join(workdirPath2, 'b.txt')), + new Promise((resolve, reject) => { + githubPackage.scheduleActiveContextUpdate = ({activeRepositoryPath}) => { + try { + assert.strictEqual(activeRepositoryPath, workdirPath2); + resolve(); + } catch (e) { reject(e); } + }; + }), + ]); + + await Promise.all([ + atomEnv.workspace.open(path.join(workdirPath3, 'c.txt')), + new Promise((resolve, reject) => { + githubPackage.scheduleActiveContextUpdate = ({activeRepositoryPath}) => { + try { + assert.strictEqual(activeRepositoryPath, workdirPath3); + resolve(); + } catch (e) { reject(e); } + }; + }), + ]); + }); + + it('subscribes to changes in the configuration value', async function() { + const scheduleActiveContextUpdate = githubPackage.scheduleActiveContextUpdate = sinon.stub(); + + await Promise.all([ + atomEnv.workspace.open(path.join(workdirPath1, 'a.txt')), + new Promise((resolve, reject) => { + scheduleActiveContextUpdate.callsFake(({activeRepositoryPath}) => { + try { + assert.strictEqual(activeRepositoryPath, workdirPath1); + resolve(); + } catch (e) { reject(e); } + }); + }), + ]); + + atomEnv.config.set('github.useProjectFromActivePanel', false); + await Promise.all([ + atomEnv.workspace.open(path.join(workdirPath2, 'b.txt')), + new Promise(resolve => { + const disposable = atomEnv.workspace.getCenter().onDidStopChangingActivePaneItem(() => { + disposable.dispose(); + resolve(); + }); + }), + ]); + + atomEnv.config.set('github.useProjectFromActivePanel', true); + await Promise.all([ + atomEnv.workspace.open(path.join(workdirPath3, 'c.txt')), + new Promise((resolve, reject) => { + scheduleActiveContextUpdate.callsFake(({activeRepositoryPath}) => { + try { + assert.strictEqual(activeRepositoryPath, workdirPath3); + resolve(); + } catch (e) { reject(e); } + }); + }), + ]); + + assert.strictEqual(scheduleActiveContextUpdate.callCount, 2); + }); + }); + }); + describe('with 1 project and absent state', function() { let workdirPath1, workdirPath2, context1; beforeEach(async function() { @@ -357,7 +456,7 @@ describe('GithubPackage', function() { ({ atomEnv, githubPackage, project, contextPool, - } = await buildAtomEnvironmentAndGithubPackage(global.buildAtomEnvironmentAndGithubPackage)); + } = await buildAtomEnvironmentAndGithubPackage(global.buildAtomEnvironment)); }); afterEach(async function() { @@ -664,7 +763,7 @@ describe('GithubPackage', function() { ({ atomEnv, githubPackage, project, contextPool, - } = await buildAtomEnvironmentAndGithubPackage(global.buildAtomEnvironmentAndGithubPackage)); + } = await buildAtomEnvironmentAndGithubPackage(global.buildAtomEnvironment)); }); afterEach(async function() { @@ -706,7 +805,7 @@ describe('GithubPackage', function() { ({ atomEnv, githubPackage, project, - } = await buildAtomEnvironmentAndGithubPackage(global.buildAtomEnvironmentAndGithubPackage)); + } = await buildAtomEnvironmentAndGithubPackage(global.buildAtomEnvironment)); }); afterEach(async function() { @@ -774,7 +873,7 @@ describe('GithubPackage', function() { beforeEach(async function() { ({ atomEnv, githubPackage, - } = await buildAtomEnvironmentAndGithubPackage(global.buildAtomEnvironmentAndGithubPackage)); + } = await buildAtomEnvironmentAndGithubPackage(global.buildAtomEnvironment)); sinon.spy(githubPackage, 'rerender'); }); @@ -825,7 +924,7 @@ describe('GithubPackage', function() { beforeEach(async function() { ({ atomEnv, githubPackage, - } = await buildAtomEnvironmentAndGithubPackage(global.buildAtomEnvironmentAndGithubPackage)); + } = await buildAtomEnvironmentAndGithubPackage(global.buildAtomEnvironment)); sinon.spy(githubPackage, 'rerender'); }); @@ -879,7 +978,7 @@ describe('GithubPackage', function() { ({ atomEnv, githubPackage, project, contextPool, - } = await buildAtomEnvironmentAndGithubPackage(global.buildAtomEnvironmentAndGithubPackage)); + } = await buildAtomEnvironmentAndGithubPackage(global.buildAtomEnvironment)); }); let workdirPath1, atomGitRepository1, repository1; diff --git a/test/items/github-tab-item.test.js b/test/items/github-tab-item.test.js index cf52d1e45d..c3489eb613 100644 --- a/test/items/github-tab-item.test.js +++ b/test/items/github-tab-item.test.js @@ -24,6 +24,7 @@ describe('GitHubTabItem', function() { function buildApp(props = {}) { const workspace = props.workspace || atomEnv.workspace; + const config = props.config || atomEnv.config; return ( @@ -34,9 +35,10 @@ describe('GitHubTabItem', function() { workspace={workspace} repository={repository} loginModel={new GithubLoginModel(InMemoryStrategy)} + config={config} changeWorkingDirectory={() => {}} - onDidChangeWorkDirs={() => {}} + onDidChangeWorkDirs={() => { return {dispose: () => {}}; }} getCurrentWorkDirs={() => []} openCreateDialog={() => {}} openPublishDialog={() => {}} diff --git a/test/views/git-tab-header-view.test.js b/test/views/git-tab-header-view.test.js index 5e0d9e8f7b..7d563cbf72 100644 --- a/test/views/git-tab-header-view.test.js +++ b/test/views/git-tab-header-view.test.js @@ -63,5 +63,21 @@ describe('GitTabHeaderView', function() { it('renders an avatar placeholder', function() { assert.strictEqual(wrapper.find('img.github-Project-avatar').prop('src'), 'atom://github/img/avatar.svg'); }); + + it('renders project selection enabled', function() { + assert.strictEqual(wrapper.find('select.github-Project-path').prop('disabled'), undefined); + }); + }); + + describe('with project selection disabled', function() { + let wrapper; + + beforeEach(function() { + wrapper = build({disableProjectSelection: true}); + }); + + it('renders project selection disabled', function() { + assert.strictEqual(wrapper.find('select.github-Project-path').prop('disabled'), true); + }); }); }); diff --git a/test/views/github-tab-header-view.test.js b/test/views/github-tab-header-view.test.js index 43cf57d060..6d5cf7048d 100644 --- a/test/views/github-tab-header-view.test.js +++ b/test/views/github-tab-header-view.test.js @@ -63,5 +63,21 @@ describe('GithubTabHeaderView', function() { it('renders an avatar placeholder', function() { assert.strictEqual(wrapper.find('img.github-Project-avatar').prop('src'), 'atom://github/img/avatar.svg'); }); + + it('renders project selection enabled', function() { + assert.strictEqual(wrapper.find('select.github-Project-path').prop('disabled'), undefined); + }); + }); + + describe('with project selection disabled', function() { + let wrapper; + + beforeEach(function() { + wrapper = build({disableProjectSelection: true}); + }); + + it('renders project selection disabled', function() { + assert.strictEqual(wrapper.find('select.github-Project-path').prop('disabled'), true); + }); }); }); diff --git a/test/views/github-tab-view.test.js b/test/views/github-tab-view.test.js index d78ea5b44b..e157a2824b 100644 --- a/test/views/github-tab-view.test.js +++ b/test/views/github-tab-view.test.js @@ -35,6 +35,7 @@ describe('GitHubTabView', function() { refresher={new Refresher()} loginModel={new GithubLoginModel(InMemoryStrategy)} rootHolder={new RefHolder()} + config={atomEnv.config} workingDirectory={repo.getWorkingDirectoryPath()} repository={repo}