2019-01-22 19:23:26 +03:00
|
|
|
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
|
|
|
import {authenticateSession, invalidateSession} from 'ember-simple-auth/test-support';
|
|
|
|
import {beforeEach, describe, it} from 'mocha';
|
|
|
|
import {click, currentRouteName, currentURL, find} from '@ember/test-helpers';
|
|
|
|
import {expect} from 'chai';
|
|
|
|
import {setupApplicationTest} from 'ember-mocha';
|
|
|
|
import {visit} from '../helpers/visit';
|
|
|
|
|
|
|
|
describe('Acceptance: Members', function () {
|
|
|
|
let hooks = setupApplicationTest();
|
|
|
|
setupMirage(hooks);
|
|
|
|
|
|
|
|
it('redirects to signin when not authenticated', async function () {
|
|
|
|
await invalidateSession();
|
|
|
|
await visit('/members');
|
|
|
|
|
|
|
|
expect(currentURL()).to.equal('/signin');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('redirects non-admins to posts', async function () {
|
|
|
|
let role = this.server.create('role', {name: 'Editor'});
|
|
|
|
this.server.create('user', {roles: [role]});
|
|
|
|
|
|
|
|
await authenticateSession();
|
|
|
|
await visit('/members');
|
|
|
|
|
2019-03-21 12:33:14 +03:00
|
|
|
expect(currentURL()).to.equal('/site');
|
2019-01-22 19:23:26 +03:00
|
|
|
expect(find('[data-test-nav="members"]'), 'sidebar link')
|
|
|
|
.to.not.exist;
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('as admin', function () {
|
|
|
|
beforeEach(async function () {
|
2019-02-25 17:47:17 +03:00
|
|
|
this.server.loadFixtures('configs');
|
|
|
|
let config = this.server.schema.configs.first();
|
2019-01-22 19:23:26 +03:00
|
|
|
config.update({enableDeveloperExperiments: true});
|
|
|
|
|
|
|
|
let role = this.server.create('role', {name: 'Administrator'});
|
|
|
|
this.server.create('user', {roles: [role]});
|
|
|
|
|
|
|
|
return await authenticateSession();
|
|
|
|
});
|
|
|
|
|
2019-03-21 12:33:14 +03:00
|
|
|
it('redirects to home if developer experiments is disabled', async function () {
|
2019-02-25 17:47:17 +03:00
|
|
|
let config = this.server.schema.configs.first();
|
2019-01-22 19:23:26 +03:00
|
|
|
config.update({enableDeveloperExperiments: false});
|
|
|
|
|
|
|
|
await visit('/members');
|
|
|
|
|
2019-03-21 12:33:14 +03:00
|
|
|
expect(currentURL()).to.equal('/site');
|
2019-01-22 19:23:26 +03:00
|
|
|
expect(find('[data-test-nav="members"]'), 'sidebar link')
|
|
|
|
.to.not.exist;
|
|
|
|
});
|
|
|
|
|
|
|
|
it('shows sidebar link which navigates to members list', async function () {
|
2019-03-11 10:43:55 +03:00
|
|
|
await visit('/settings/labs');
|
|
|
|
await click('#labs-members');
|
2019-01-22 19:23:26 +03:00
|
|
|
await visit('/');
|
|
|
|
|
|
|
|
expect(find('[data-test-nav="members"]'), 'sidebar link')
|
|
|
|
.to.exist;
|
|
|
|
|
|
|
|
await click('[data-test-nav="members"]');
|
|
|
|
|
|
|
|
expect(currentURL()).to.equal('/members');
|
2019-01-25 16:41:45 +03:00
|
|
|
expect(currentRouteName()).to.equal('members');
|
2019-01-22 19:23:26 +03:00
|
|
|
expect(find('[data-test-screen-title]')).to.have.text('Members');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|