Last active
January 4, 2016 03:48
-
-
Save jmreidy/8563814 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
suite('Edit account', function() { | |
test('Change name', function(done) { | |
var self = this; | |
this.browser | |
.get(e2eConfig.baseUrl + "/user/edit") | |
.waitForElementByCss('form', self.mochaOptions.timeout); | |
.then(function (form) { | |
self.form = form; | |
}) | |
.waitForElementByCss('aside h2 a') | |
.text() | |
.then(function (h2Text) { | |
expect(h2Text).to.equal(e2eConfig.user.first_name + ' ' + e2eConfig.user.last_name) | |
}) | |
.then(function () { | |
return self.form.elementByCss('#first_name'); | |
}) | |
.type('2') | |
.then(function () { | |
return self.form.elementByCss('#last_name'); | |
}) | |
.type('3') | |
.then(function () { | |
return self.form.submit(); | |
}) | |
.waitForElementByCss('aside h2 a'); | |
.text(); | |
.then(function(h2Text) { | |
expect(h2Text).to.equal( | |
e2eConfig.user.first_name + | |
'2 ' + | |
e2eConfig.user.last_name + | |
'3' | |
); | |
.then(function () { | |
done(); | |
}, function (err) { done(err) }) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var User = require('./../../../server/lib/models/user'); | |
suite('Reset/Edit Password (story)', function() { | |
test('Initiate a password reset', function(done) { | |
var self = this; | |
async.waterfall([ | |
function(cb) { | |
self.browser.get(e2eConfig.baseUrl + "/user/password/reset", cb); | |
}, | |
function(cb) { | |
self.browser.waitForElementByCss('form', self.mochaOptions.timeout, cb); | |
}, | |
function(form, cb) { | |
self.form = form; | |
cb(); | |
}, | |
function(cb) { | |
self.form.elementByCss('#email', cb); | |
}, | |
function(emailInput, cb) { | |
emailInput.type(e2eConfig.user.email, cb); | |
}, | |
function(cb) { | |
self.form.submit(cb); | |
}, | |
function(cb) { | |
self.browser.waitForElementByCss('article.reset p strong', self.mochaOptions.timeout, cb); | |
}, | |
function(strong, cb) { | |
self.browser.text(strong, cb); | |
}, | |
function(strongText, cb) { | |
expect(strongText).to.equal(e2eConfig.user.email); | |
cb(); | |
} | |
], function(err) { | |
expect(err).to.equal(undefined); | |
done(); | |
}); | |
}); | |
test('edit password will fail when input is correct but code is wrong', function(done) { | |
var self = this; | |
async.waterfall([ | |
function(cb) { | |
self.browser.get( | |
e2eConfig.baseUrl + | |
"/user/password/edit/345o78he4098435g08345", | |
cb | |
); | |
}, | |
function(cb) { | |
self.browser.waitForElementByCss('form', self.mochaOptions.timeout, cb); | |
}, | |
function(form, cb) { | |
self.form = form; | |
cb(); | |
}, | |
function(cb) { | |
self.form.elementByCss('#password', cb); | |
}, | |
function(passwordInput, cb) { | |
passwordInput.type( | |
e2eConfig.user.password, | |
cb | |
); | |
}, | |
function(cb) { | |
self.form.elementByCss('#repeat_password', cb); | |
}, | |
function(repeatPasswordInput, cb) { | |
repeatPasswordInput.type(e2eConfig.user.password, cb); | |
}, | |
function(cb) { | |
self.form.submit(cb); | |
}, | |
function(cb) { | |
self.browser.waitForElementByCss('form p.warning label', self.mochaOptions.timeout, cb); | |
}, | |
function(hint, cb) { | |
self.browser.text(hint, cb); | |
}, | |
function(hintText, cb) { | |
expect(hintText).to.equal('Password and reset link do not match'); | |
cb(); | |
} | |
], function(err) { | |
expect(err).to.equal(undefined); | |
done(); | |
}); | |
}); | |
test('cheat password reset and edit the password', function(done) { | |
var self = this; | |
async.waterfall([ | |
function(cb) { | |
var user = new User(); | |
user.set('alias', e2eConfig.user.alias); | |
user.set('email', e2eConfig.user.email); | |
user.load(function(err) { | |
expect(err).to.equal(undefined); | |
self.browser.get(user.getPasswordEditUrl(true), cb); | |
}); | |
}, | |
function(cb) { | |
self.browser.waitForElementByCss('form', self.mochaOptions.timeout, cb); | |
}, | |
function(form, cb) { | |
self.form = form; | |
cb(); | |
}, | |
function(cb) { | |
self.form.elementByCss('#password', cb); | |
}, | |
function(passwordInput, cb) { | |
passwordInput.type(e2eConfig.user.newPassword, cb); | |
}, | |
function(cb) { | |
self.form.elementByCss('#repeat_password', cb); | |
}, | |
function(repeatPasswordInput, cb) { | |
repeatPasswordInput.type(e2eConfig.user.newPassword, cb); | |
}, | |
function(cb) { | |
self.form.submit(function() { | |
setTimeout(function() { | |
cb(); | |
}, self.mochaOptions.timeout / 3); | |
}); | |
} | |
], function(err) { | |
expect(err).to.equal(undefined); | |
done(); | |
}); | |
}); | |
test('do the logout', function(done) { | |
var self = this; | |
async.waterfall([ | |
function(cb) { | |
self.browser.waitForElementByCss('nav > button', self.mochaOptions.timeout, cb); | |
}, | |
function(button, cb) { | |
button.click(cb); | |
}, | |
function(cb) { | |
self.browser.waitForElementByCss('nav > menu', self.mochaOptions.timeout, cb); | |
}, | |
function(menu, cb) { | |
self.browser.elementByCss('menu > li > ul > li.logout a', cb); | |
}, | |
function(logoutButton, cb) { | |
logoutButton.click(cb); | |
} | |
], function(err) { | |
expect(err).to.equal(null); | |
done(); | |
}); | |
}); | |
test('login with new password', function(done) { | |
var self = this; | |
async.waterfall([ | |
function(cb) { | |
self.browser.waitForElementByCss('nav > button', self.mochaOptions.timeout, cb); | |
}, | |
function(button, cb) { | |
button.click(cb); | |
}, | |
function(cb) { | |
self.browser.waitForElementByCss('nav > menu', self.mochaOptions.timeout, cb); | |
}, | |
function(menu, cb) { | |
self.browser.elementByCss('menu > li.login a', cb); | |
}, | |
function(loginButton, cb) { | |
loginButton.click(cb); | |
}, | |
function(cb) { | |
self.browser.waitForElementByCss('form', self.mochaOptions.timeout, cb); | |
}, | |
function(form, cb) { | |
self.form = form; | |
cb(); | |
}, | |
function(cb) { | |
self.form.elementByCss('#email', cb); | |
}, | |
function(emailInput, cb) { | |
emailInput.type(e2eConfig.user.email, cb); | |
}, | |
function(cb) { | |
self.form.elementByCss('#password', cb); | |
}, | |
function(passwordInput, cb) { | |
passwordInput.type(e2eConfig.user.newPassword, cb); | |
}, | |
function(cb) { | |
self.form.submit(function() { | |
// kludge, replace that bad timeout with | |
// a new waitForElementByCss afterwards to query for contents | |
// of home page (landing page) | |
setTimeout(function() { | |
cb(); | |
}, self.mochaOptions.timeout / 3); | |
}); | |
}, | |
function(cb) { | |
self.browser.waitForElementByCss('nav > button', self.mochaOptions.timeout, cb); | |
cb(); | |
} | |
], function(err) { | |
expect(err).to.equal(undefined); | |
done(); | |
}); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
function testMenuLinks(width, height, browser, done) { | |
async.waterfall([ | |
function(cb) { | |
browser.setWindowSize(width, height, cb); | |
}, | |
function(cb) { | |
browser.elementsByCss('menu > li', cb); | |
}, | |
function(lis, cb) { | |
expect(lis, 'two li tags exist').to.have.length.of(2); | |
browser.elementByCss('menu > li.signup .button', cb); | |
}, | |
function(signUpButton, cb) { | |
browser.text(signUpButton, cb); | |
}, | |
function(signUpButtonText, cb) { | |
expect(signUpButtonText, 'Sign up button text is correct').to.equal('Sign Up'); | |
browser.elementByCss('menu > li.login .button', cb); | |
}, | |
function(loginButton, cb) { | |
browser.text(loginButton, cb); | |
}, | |
function(loginButtonText, cb) { | |
expect(loginButtonText, 'Login button text is correct').to.equal('Login'); | |
cb(); | |
} | |
], function(err) { | |
expect(err).to.equal(undefined); | |
done(); | |
}); | |
} | |
suite('Basic HTML structure', function() { | |
suiteSetup(function(done) { | |
this.browser.get(e2eConfig.baseUrl, function() { | |
done(); | |
}); | |
}); | |
test('has correct html attribute(s)', function(done) { | |
var self = this; | |
async.waterfall([ | |
function(cb) { | |
self.browser.elementByTagName('html', cb); | |
}, | |
function(html, cb) { | |
html.getAttribute('data-version', cb); | |
}, | |
function(dataVersion, cb) { | |
expect(dataVersion).to.be.above('0.0.14'); | |
expect(dataVersion).to.match(/[0-9]+\.[0-9]+\.[0-9]+$/); | |
cb(); | |
} | |
], function(err) { | |
expect(err).to.equal(undefined); | |
done(); | |
}); | |
}); | |
test('has title', function(done) { | |
this.browser.title(function(err, title) { | |
expect(err).to.equal(null); | |
expect(title).to.be.eql('SignDNA'); | |
done(); | |
}); | |
}); | |
test('has one link', function(done) { | |
this.browser.elementsByTagName('link', function(err, links) { | |
expect(err).to.equal(null); | |
expect(links).to.have.length.of(1); | |
done(); | |
}); | |
}); | |
test('has one canvas', function(done) { | |
this.browser.elementsByTagName('canvas', function(err, canvases) { | |
expect(err).to.equal(null); | |
expect(canvases).to.have.length.of(1); | |
done(); | |
}); | |
}); | |
test('has one header', function(done) { | |
this.browser.elementsByTagName('header', function(err, headers) { | |
expect(err).to.equal(null); | |
expect(headers).to.have.length.of(1); | |
done(); | |
}); | |
}); | |
test('has one h1', function(done) { | |
this.browser.elementsByTagName('h1', function(err, h1s) { | |
expect(err).to.equal(null); | |
expect(h1s).to.have.length.of(1); | |
done(); | |
}); | |
}); | |
test('has one nav + button when for mobile', function(done) { | |
var self = this; | |
async.waterfall([ | |
function(cb) { | |
self.browser.elementsByTagName('nav', cb); | |
}, | |
function(navs, cb) { | |
expect(navs).to.have.length.of(1); | |
self.browser.waitForElementByCss('nav > button', self.mochaOptions.timeout, cb); | |
}, | |
function(button, cb) { | |
self.browser.text(button, cb); | |
}, | |
function(buttonText, cb) { | |
expect(buttonText).to.equal('Show menu'); | |
cb(); | |
} | |
], function(err) { | |
expect(err).to.equal(undefined); | |
done(); | |
}); | |
}); | |
/* | |
see https://github.com/WickyNilliams/enquire.js/issues/91 | |
test('has two menu links (login/sign up) for tablets', function(done) { | |
testMenuLinks(e2eConfig.tablet.width, e2eConfig.tablet.height, this.browser, done); | |
}); | |
test('has two menu links (login/sign up) for desktops', function(done) { | |
testMenuLinks(e2eConfig.tablet.width, e2eConfig.tablet.height, this.browser, done); | |
}); | |
*/ | |
test('has one main', function(done) { | |
this.browser.elementsByTagName('main', function(err, mains) { | |
expect(err).to.equal(null); | |
expect(mains).to.have.length.of(1); | |
done(); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment