73daa80b7f
no issue - upgrade to latest `ember-source` and related dependencies including `ember-cli` - upgrade to latest `ember-mocha` and modern ember testing setup - https://github.com/emberjs/rfcs/blob/master/text/0268-acceptance-testing-refactor.md - switch from using global acceptance test helpers and `native-dom-helpers` to using the new `ember-test-helpers` methods - use [`chai-dom`](https://github.com/nathanboktae/chai-dom) assertions where in some places (still a lot of places in the tests that could use these) - pin `ember-in-viewport` to 3.0.x to work around incompatibilities between different versions used in `ember-light-table`, `ember-infinity`, and `ember-sticky-element` - incompatibilities manifested as "Invalid value used as weak map key" errors thrown when using `ember-light-table` (subscribers screen) - pin `ember-power-datepicker` to unreleased version that contains a move from global acceptance test helpers to modern test helpers
90 lines
3.4 KiB
JavaScript
90 lines
3.4 KiB
JavaScript
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
|
import {click, fillIn, find, findAll, visit} from '@ember/test-helpers';
|
|
import {describe, it} from 'mocha';
|
|
import {expect} from 'chai';
|
|
import {invalidateSession} from 'ember-simple-auth/test-support';
|
|
import {setupApplicationTest} from 'ember-mocha';
|
|
|
|
describe('Acceptance: Password Reset', function () {
|
|
let hooks = setupApplicationTest();
|
|
setupMirage(hooks);
|
|
|
|
describe('request reset', function () {
|
|
it('is successful with valid data', async function () {
|
|
await invalidateSession();
|
|
await visit('/signin');
|
|
await fillIn('input[name="identification"]', 'test@example.com');
|
|
await click('.forgotten-link');
|
|
|
|
// an alert with instructions is displayed
|
|
expect(findAll('.gh-alert-blue').length, 'alert count')
|
|
.to.equal(1);
|
|
});
|
|
|
|
it('shows error messages with invalid data', async function () {
|
|
await visit('/signin');
|
|
|
|
// no email provided
|
|
await click('.forgotten-link');
|
|
|
|
// email field is invalid
|
|
expect(
|
|
find('input[name="identification"]').closest('.form-group'),
|
|
'email field has error class (no email)'
|
|
).to.match('.error');
|
|
|
|
// password field is valid
|
|
expect(
|
|
find('input[name="password"]').closest('.form-group'),
|
|
'password field has error class (no email)'
|
|
).to.not.match('.error');
|
|
|
|
// error message shown
|
|
expect(find('p.main-error').textContent.trim(), 'error message')
|
|
.to.equal('We need your email address to reset your password!');
|
|
|
|
// invalid email provided
|
|
await fillIn('input[name="identification"]', 'test');
|
|
await click('.forgotten-link');
|
|
|
|
// email field is invalid
|
|
expect(
|
|
find('input[name="identification"]').closest('.form-group'),
|
|
'email field has error class (invalid email)'
|
|
).to.match('.error');
|
|
|
|
// password field is valid
|
|
expect(
|
|
find('input[name="password"]').closest('.form-group'),
|
|
'password field has error class (invalid email)'
|
|
).to.not.match('.error');
|
|
|
|
// error message
|
|
expect(find('p.main-error').textContent.trim(), 'error message')
|
|
.to.equal('We need your email address to reset your password!');
|
|
|
|
// unknown email provided
|
|
await fillIn('input[name="identification"]', 'unknown@example.com');
|
|
await click('.forgotten-link');
|
|
|
|
// email field is invalid
|
|
expect(
|
|
find('input[name="identification"]').closest('.form-group'),
|
|
'email field has error class (unknown email)'
|
|
).to.match('.error');
|
|
|
|
// password field is valid
|
|
expect(
|
|
find('input[name="password"]').closest('.form-group'),
|
|
'password field has error class (unknown email)'
|
|
).to.not.match('.error');
|
|
|
|
// error message
|
|
expect(find('p.main-error').textContent.trim(), 'error message')
|
|
.to.equal('There is no user with that email address.');
|
|
});
|
|
});
|
|
|
|
// TODO: add tests for the change password screen
|
|
});
|