2016-02-02 15:22:41 +03:00
|
|
|
/* jshint expr:true */
|
|
|
|
import {
|
|
|
|
describe,
|
|
|
|
it,
|
|
|
|
beforeEach,
|
|
|
|
afterEach
|
|
|
|
} from 'mocha';
|
2016-11-14 16:16:51 +03:00
|
|
|
import {expect} from 'chai';
|
2016-02-02 15:22:41 +03:00
|
|
|
import startApp from '../helpers/start-app';
|
|
|
|
import destroyApp from '../helpers/destroy-app';
|
|
|
|
|
|
|
|
describe('Acceptance: Password Reset', function() {
|
|
|
|
let application;
|
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
application = startApp();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function() {
|
|
|
|
destroyApp(application);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('request reset', function () {
|
2017-04-24 15:29:48 +03:00
|
|
|
it('is successful with valid data', async function () {
|
|
|
|
await visit('/signin');
|
|
|
|
await fillIn('input[name="identification"]', 'test@example.com');
|
|
|
|
await click('.forgotten-link');
|
|
|
|
|
|
|
|
// an alert with instructions is displayed
|
|
|
|
expect(find('.gh-alert-blue').length, 'alert count')
|
|
|
|
.to.equal(1);
|
2016-02-02 15:22:41 +03:00
|
|
|
});
|
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
it('shows error messages with invalid data', async function () {
|
|
|
|
await visit('/signin');
|
2016-02-02 15:22:41 +03:00
|
|
|
|
|
|
|
// no email provided
|
2017-04-24 15:29:48 +03:00
|
|
|
await click('.forgotten-link');
|
|
|
|
|
|
|
|
// email field is invalid
|
|
|
|
expect(
|
|
|
|
find('input[name="identification"]').closest('.form-group').hasClass('error'),
|
|
|
|
'email field has error class (no email)'
|
|
|
|
).to.be.true;
|
|
|
|
|
|
|
|
// password field is valid
|
|
|
|
expect(
|
|
|
|
find('input[name="password"]').closest('.form-group').hasClass('error'),
|
|
|
|
'password field has error class (no email)'
|
|
|
|
).to.be.false;
|
|
|
|
|
|
|
|
// error message shown
|
|
|
|
expect(find('p.main-error').text().trim(), 'error message')
|
|
|
|
.to.equal('We need your email address to reset your password!');
|
2016-02-02 15:22:41 +03:00
|
|
|
|
|
|
|
// invalid email provided
|
2017-04-24 15:29:48 +03:00
|
|
|
await fillIn('input[name="identification"]', 'test');
|
|
|
|
await click('.forgotten-link');
|
|
|
|
|
|
|
|
// email field is invalid
|
|
|
|
expect(
|
|
|
|
find('input[name="identification"]').closest('.form-group').hasClass('error'),
|
|
|
|
'email field has error class (invalid email)'
|
|
|
|
).to.be.true;
|
|
|
|
|
|
|
|
// password field is valid
|
|
|
|
expect(
|
|
|
|
find('input[name="password"]').closest('.form-group').hasClass('error'),
|
|
|
|
'password field has error class (invalid email)'
|
|
|
|
).to.be.false;
|
|
|
|
|
|
|
|
// error message
|
|
|
|
expect(find('p.main-error').text().trim(), 'error message')
|
|
|
|
.to.equal('We need your email address to reset your password!');
|
2016-02-02 15:22:41 +03:00
|
|
|
|
|
|
|
// unknown email provided
|
2017-04-24 15:29:48 +03:00
|
|
|
await fillIn('input[name="identification"]', 'unknown@example.com');
|
|
|
|
await click('.forgotten-link');
|
|
|
|
|
|
|
|
// email field is invalid
|
|
|
|
expect(
|
|
|
|
find('input[name="identification"]').closest('.form-group').hasClass('error'),
|
|
|
|
'email field has error class (unknown email)'
|
|
|
|
).to.be.true;
|
|
|
|
|
|
|
|
// password field is valid
|
|
|
|
expect(
|
|
|
|
find('input[name="password"]').closest('.form-group').hasClass('error'),
|
|
|
|
'password field has error class (unknown email)'
|
|
|
|
).to.be.false;
|
|
|
|
|
|
|
|
// error message
|
|
|
|
expect(find('p.main-error').text().trim(), 'error message')
|
|
|
|
.to.equal('There is no user with that email address.');
|
2016-02-02 15:22:41 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// TODO: add tests for the change password screen
|
|
|
|
});
|