message: test: better acceptance tests for change password
diff: -import { currentURL, fillIn, settled, visit } from '@ember/test-helpers';
  +import { fillIn, visit } from '@ember/test-helpers';
  import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
  import { TestContext } from 'ember-test-helpers';
  -import { module, skip, test } from 'qunit';
  +import { module, test } from 'qunit';
  +import sinon, { SinonStub } from 'sinon';
  +import CurrentUser from 'ember-osf-web/services/current-user';
  import { click, setupOSFApplicationTest } from 'ember-osf-web/tests/helpers';
  module('Acceptance | settings/account | change password', hooks => {
  setupOSFApplicationTest(hooks);
  setupMirage(hooks);
  + hooks.beforeEach(function(this: TestContext) {
  + // Stub currentUser.logout
  + const currentUser = this.owner.lookup('service:current-user') as CurrentUser & { logout: SinonStub };
  + currentUser.set('logout', sinon.stub(currentUser, 'logout'));
  + });
  +
  // Changing password works
  - skip('it works', async function(this: TestContext, assert) {
  - // Currently doesn't work.
  - // Will need to revist later, might need to install addons to get to work
  + test('it works', async function(this: TestContext, assert) {
  server.create('user', 'loggedIn', 'withSettings');
  await visit('/settings/account');
  - assert.ok(true);
  const currentPassword = 'oldpassword';
  const newPassword = 'oldpassword239901abc';
  @@ -26,13 +31,12 @@ module('Acceptance | settings/account | change password', hooks => {
  await fillIn('[data-test-confirm-password] input', newPassword);
  await click('[data-test-update-password-button]');
  - settled().then(() => {
  - assert.ok(true);
  - });
  + const currentUser = this.owner.lookup('service:current-user') as CurrentUser & { logout: SinonStub };
  + assert.ok(currentUser.logout.called, 'User is logged out after successful password change');
  });
  // Changing password fails with wrong current password
  - test('wrong current password', async assert => {
  + test('wrong current password', async function(this: TestContext, assert) {
  server.create('user', 'loggedIn', 'withSettings');
  await visit('/settings/account');
  @@ -45,8 +49,7 @@ module('Acceptance | settings/account | change password', hooks => {
  await fillIn('[data-test-confirm-password] input', newPassword);
  await click('[data-test-update-password-button]');
  - const root = server.schema.roots.first();
  - assert.ok(root.currentUser);
  - assert.equal(currentURL(), '/settings/account');
  + const currentUser = this.owner.lookup('service:current-user') as CurrentUser & { logout: SinonStub };
  + assert.ok(currentUser.logout.notCalled, 'User is not logged out on unsuccessful password change');
  });
  });
  