Add specs for new team modal
This commit is contained in:
parent
42c8f4e2ed
commit
8f3f59392d
|
@ -49,7 +49,9 @@ class NewTeamModal extends React.Component {
|
|||
|
||||
render() {
|
||||
return (
|
||||
<Modal.Dialog>
|
||||
<Modal.Dialog
|
||||
id='newServerModal'
|
||||
>
|
||||
<Modal.Header>
|
||||
<Modal.Title>{'Add a new Team'}</Modal.Title>
|
||||
</Modal.Header>
|
||||
|
@ -62,6 +64,7 @@ class NewTeamModal extends React.Component {
|
|||
>
|
||||
<ControlLabel>{'Server Display Name'}</ControlLabel>
|
||||
<FormControl
|
||||
id='teamNameInput'
|
||||
type='text'
|
||||
value={this.state.teamName}
|
||||
placeholder='Server Name'
|
||||
|
@ -75,6 +78,7 @@ class NewTeamModal extends React.Component {
|
|||
>
|
||||
<ControlLabel>{'Team URL'}</ControlLabel>
|
||||
<FormControl
|
||||
id='teamUrlInput'
|
||||
type='text'
|
||||
value={this.state.teamUrl}
|
||||
placeholder='https://example.org'
|
||||
|
@ -88,9 +92,11 @@ class NewTeamModal extends React.Component {
|
|||
|
||||
<Modal.Footer>
|
||||
<Button
|
||||
id='cancelNewServerModal'
|
||||
onClick={this.props.onClose}
|
||||
>{'Cancel'}</Button>
|
||||
<Button
|
||||
id='saveNewServerModal'
|
||||
onClick={() => {
|
||||
this.props.onSave({
|
||||
url: this.state.teamUrl,
|
||||
|
|
|
@ -83,6 +83,7 @@ class TabBar extends React.Component {
|
|||
renderAddTeamButton() {
|
||||
return (
|
||||
<Button
|
||||
id='tabBarAddNewTeam'
|
||||
onClick={this.props.onAddTeam}
|
||||
bsStyle='tabButton'
|
||||
>
|
||||
|
|
|
@ -171,4 +171,11 @@ describe('browser/index.html', function desc() {
|
|||
browserWindow.getTitle().should.eventually.equal('Title 1');
|
||||
});
|
||||
});
|
||||
|
||||
it('should open the new server prompt after clicking the add button', () => {
|
||||
// See settings_test for specs that cover the actual prompt
|
||||
return this.app.client.waitUntilWindowLoaded().
|
||||
click('#tabBarAddNewTeam').
|
||||
isExisting('#newServerModal').should.eventually.be.true;
|
||||
});
|
||||
});
|
||||
|
|
|
@ -245,4 +245,100 @@ describe('browser/settings.html', function desc() {
|
|||
isExisting(modalTitleSelector).should.eventually.false;
|
||||
});
|
||||
});
|
||||
|
||||
describe('NewTeamModal', () => {
|
||||
beforeEach(() => {
|
||||
env.addClientCommands(this.app.client);
|
||||
return this.app.client.
|
||||
loadSettingsPage().
|
||||
click('#addNewServer');
|
||||
});
|
||||
|
||||
it('should open the new server modal', () => {
|
||||
return this.app.client.isExisting('#newServerModal').should.eventually.equal(true);
|
||||
});
|
||||
|
||||
it('should close the window after clicking cancel', () => {
|
||||
return this.app.client.
|
||||
click('#cancelNewServerModal').
|
||||
isExisting('#newServerModal').should.eventually.equal(false);
|
||||
});
|
||||
|
||||
it('should not be valid if no team name has been set', () => {
|
||||
return this.app.client.
|
||||
isExisting('.has-error #teamNameInput').should.eventually.equal(true);
|
||||
});
|
||||
|
||||
it('should not be valid if no server address has been set', () => {
|
||||
return this.app.client.
|
||||
isExisting('.has-error #teamUrlInput').should.eventually.equal(true);
|
||||
});
|
||||
|
||||
describe('Valid server name', () => {
|
||||
beforeEach(() => {
|
||||
return this.app.client.
|
||||
setValue('#teamNameInput', 'TestTeam');
|
||||
});
|
||||
|
||||
it('should not be marked invalid', () => {
|
||||
return this.app.client.
|
||||
isExisting('.has-error #teamNameInput').should.eventually.equal(false);
|
||||
});
|
||||
|
||||
it('should not be possible to click save', () => {
|
||||
return this.app.client.
|
||||
getAttribute('#saveNewServerModal', 'disabled').should.eventually.equal('true');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Valid server url', () => {
|
||||
beforeEach(() => {
|
||||
return this.app.client.
|
||||
setValue('#teamUrlInput', 'http://example.org');
|
||||
});
|
||||
|
||||
it('should be valid', () => {
|
||||
return this.app.client.
|
||||
isExisting('.has-error #teamUrlInput').should.eventually.equal(false);
|
||||
});
|
||||
|
||||
it('should not be possible to click save', () => {
|
||||
return this.app.client.
|
||||
getAttribute('#saveNewServerModal', 'disabled').should.eventually.equal('true');
|
||||
});
|
||||
});
|
||||
|
||||
it('should not be valid if an invalid server address has been set', () => {
|
||||
return this.app.client.
|
||||
setValue('#teamUrlInput', 'superInvalid url').
|
||||
isExisting('.has-error #teamUrlInput').should.eventually.equal(true);
|
||||
});
|
||||
|
||||
describe('Valid Team Settings', () => {
|
||||
beforeEach(() => {
|
||||
return this.app.client.
|
||||
setValue('#teamUrlInput', 'http://example.org').
|
||||
setValue('#teamNameInput', 'TestTeam');
|
||||
});
|
||||
|
||||
it('should be possible to click add', () => {
|
||||
return this.app.client.
|
||||
getAttribute('#saveNewServerModal', 'disabled').should.eventually.equal(null);
|
||||
});
|
||||
|
||||
it('should add the team to the config file', (done) => {
|
||||
this.app.client.
|
||||
click('#saveNewServerModal').
|
||||
click('#btnSave');
|
||||
this.app.client.pause(1000).then(() => {
|
||||
const savedConfig = JSON.parse(fs.readFileSync(env.configFilePath, 'utf8'));
|
||||
savedConfig.teams.should.contain({
|
||||
name: 'TestTeam',
|
||||
url: 'http://example.org'
|
||||
});
|
||||
return done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue