Skip to content

Commit

Permalink
✅ Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwredfish committed Jan 8, 2016
1 parent 93ba2d3 commit 49ef8a0
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 52 deletions.
2 changes: 1 addition & 1 deletion gulps/nightwatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = function(gulp, plugins) {
.pipe(plugins.nightwatch({
configFile : './test/nightwatch.json',
cliArgs : [
// '--test ' + 'test/spec-ui/test.js',
// '--test ' + './test/spec-ui/tests/apps/notes/show.js',
'--env ' + (plugins.util.env.env || 'default')
]
}))
Expand Down
2 changes: 1 addition & 1 deletion test/spec-ui/commands/addNote.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exports.command = function(item) {
.expect.element('#editor--input--title').value.to.contain(item.title).before(2000);

this
.click('.ace_content')
.click('.CodeMirror-lines')
.keys(item.content);

if (item.notebook) {
Expand Down
2 changes: 1 addition & 1 deletion test/spec-ui/commands/closeWelcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ exports.command = function() {
this
.click('.modal-header .close')
.keys(this.Keys.ESCAPE)
.expect.element('#welcome--page').not.to.be.present.before(8000);
.expect.element('#welcome--page').not.to.be.present.before(10000);

return this;
};
7 changes: 4 additions & 3 deletions test/spec-ui/tests/apps/encryption/encrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ module.exports = {
},

'asks for a new password': function(client) {
client.expect.element('input[name=password]').to.be.present.before(5000);
client.expect.element('input[name="password"]').to.be.present.before(5000);

client
.setValue('input[name=password]', '1')
.pause(100)
.setValue('input[name="password"]', '1')
.click('[type="submit"]');
},

Expand All @@ -57,6 +58,7 @@ module.exports = {
},

'shows notes in unencrypted format': function(client) {
client.pause(100);
notes.forEach(function(note) {
client.expect.element('.list').text.to.contain(note.title).before(5000);
client.expect.element('.list').text.to.contain(note.content).before(5000);
Expand Down Expand Up @@ -131,5 +133,4 @@ module.exports = {
client.expect.element('.list').text.to.contain(note.content).before(5000);
});
},

};
13 changes: 10 additions & 3 deletions test/spec-ui/tests/apps/notebooks/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,25 @@ module.exports = {
.pause(100)
.urlHash('notebooks');

for (var i = 0, len = 2; i < len; i++) {
for (var i = 0, len = 2; i <= len; i++) {
if (i === 2) {
return;
}

client
.click('#notebooks .list--buttons .drop-edit')
.click('#notebooks .list--buttons .remove-link');
.keys('j')
.pause(100)
.keys([client.Keys.SHIFT, '3', client.Keys.SHIFT]);

client.expect.element('#modal .modal-title').to.be.present.before(5000);
client.expect.element('#modal .modal-title').to.be.visible.before(5000);

client.click('#modal .btn[data-event="confirm"]');
client.pause(500);
}
},

'shows notebooks in the navbar menu': function(client) {
client
.urlHash('notes')
.pause(100)
Expand Down
4 changes: 2 additions & 2 deletions test/spec-ui/tests/apps/notes/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ module.exports = {
.expect.element('#editor--input--title').value.to.contain('Nightwatch').before(1000);

client
.click('.ace_content')
.click('.CodeMirror-lines')
.keys(['Nightwatch test content.']);

client
Expand Down Expand Up @@ -165,7 +165,7 @@ module.exports = {
.expect.element('#editor--input--title').value.to.contain('Night Watch').before(1000);

client
.click('.ace_content')
.click('.CodeMirror-lines')
.keys(['Added a new content.']);

client
Expand Down
22 changes: 4 additions & 18 deletions test/spec-ui/tests/apps/notes/show.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ module.exports = {

'changes a task\'s status when a checkbox is clicked': function(client) {
client
.click('.layout--body.-note .checkbox')
.expect.element('.layout--body.-note .checkbox input:checked').to.be.present.before(5000);
.click('.layout--body.-note .task--checkbox')
.expect.element('.layout--body.-note .task--checkbox input:checked').to.be.present.before(5000);

client.pause(500);
},
Expand Down Expand Up @@ -91,22 +91,8 @@ module.exports = {

'changes favourite status if the button is clicked': function(client) {
client
.perform(function(client, done) {
client.getAttribute('.btn--favourite--icon', 'class', function(res) {
var isFavourite = res.value.search('icon-favorite') > -1;

client
.click('.btn--favourite');

if (isFavourite) {
client.expect.element('.btn--favourite--icon').to.have.attribute('class').which.contains('icon-favorite');
return done();
}

client.expect.element('.btn--favourite--icon').to.have.attribute('class').which.does.not.contain('icon-favorite');
return done();
});
});
.click('.btn--favourite')
.expect.element('.btn--favourite--icon').to.have.attribute('class').which.contains('icon-favorite');
},

'opens edit page if "e" is pressed': function(client) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
/* global describe, before, after, it */
'use strict';

/**
* Test fuzzy search module
*/
describe('FuzzySearch', function() {
module.exports = {
before: function(client) {
client.closeWelcome();
},

before(function(client, done) {
this.timeout(100000);
after: function(client) {
client.end();
},

'wait': function(client) {
client.urlHash('notes');
client.expect.element('#header--add').to.be.visible.before(50000);

client.addNote({title: 'note1', content: 'content1'});
client.addNote({title: 'note2', content: 'content2'});
client.addNote({title: 'note3', content: 'content3'});
client.addNote({title: 'Nightwatch', content: 'Nightwatch'});
client.perform(() => {done();});
});

after(function(client, done) {
done();
});
},

it('can show search form', function(client) {
'can show search form': function(client) {
client.expect.element('#header--sbtn').to.be.present.before(5000);
client.click('#header--sbtn');

client.expect.element('#header--search--input').to.be.present.before(5000);
client.expect.element('#header--search--input').to.be.visible.before(5000);
});
},

it('can search by note\'s name', function(client) {
'can search by note\'s name': function(client) {
client.clearValue('#header--search--input');
client.expect.element('#sidebar--fuzzy').text.to.be.equal('');

Expand All @@ -42,15 +42,15 @@ describe('FuzzySearch', function() {
client.expect.element('#sidebar--fuzzy').text.to.contain('note2');
client.expect.element('#sidebar--fuzzy').text.to.contain('note3');
client.expect.element('#sidebar--fuzzy').text.to.not.contain('Nightwatch');
});
},

it('can close fuzzySearch module on Escape', function(client) {
'can close fuzzySearch module on Escape': function(client) {
client
.setValue('#header--search--input', client.Keys.ESCAPE)
.expect.element('#sidebar--fuzzy').text.to.be.equal('').before(5000);
});
},

it('can search by note\'s content', function(client) {
'can search by note\'s content': function(client) {
client.click('#header--sbtn');
client.expect.element('#header--search--input').to.be.present.before(5000);
client.expect.element('#header--search--input').to.be.visible.before(5000);
Expand All @@ -61,9 +61,9 @@ describe('FuzzySearch', function() {
client.expect.element('#sidebar--fuzzy').text.to.contain('note2');
client.expect.element('#sidebar--fuzzy').text.to.contain('note3');
client.expect.element('#sidebar--fuzzy').text.to.not.contain('Nightwatch');
});
},

it('after hitting ESCAPE notes are normally rendered', function(client) {
'after hitting ESCAPE notes are normally rendered': function(client) {
client
.clearValue('#header--search--input')
.pause(1000)
Expand All @@ -77,9 +77,9 @@ describe('FuzzySearch', function() {
client.expect.element('#sidebar--content').text.to.contain('note2').before(5000);
client.expect.element('#sidebar--content').text.to.contain('note3').before(5000);
client.expect.element('#sidebar--content').text.to.contain('Nightwatch').before(5000);
});
},

it('redirects to notes search page on `enter`', function(client) {
'redirects to notes search page on `enter`': function(client) {
client.expect.element('#header--sbtn').to.be.visible.before(5000);
client.click('#header--sbtn');

Expand All @@ -99,5 +99,5 @@ describe('FuzzySearch', function() {
client
.setValue('#header--search--input', client.Keys.ENTER)
.assert.urlContains('notes/f/search/q/note');
});
});
}
};

0 comments on commit 49ef8a0

Please sign in to comment.