1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00
Ghost-Admin/tests/acceptance/members-test.js

69 lines
2.4 KiB
JavaScript
Raw Normal View History

2019-01-22 17:23:26 +01: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');
expect(currentURL()).to.equal('/');
expect(find('[data-test-nav="members"]'), 'sidebar link')
.to.not.exist;
});
describe('as admin', function () {
beforeEach(async function () {
this.server.loadFixtures('configs');
let config = this.server.schema.configs.first();
2019-01-22 17:23:26 +01:00
config.update({enableDeveloperExperiments: true});
let role = this.server.create('role', {name: 'Administrator'});
this.server.create('user', {roles: [role]});
return await authenticateSession();
});
it('redirects to posts if developer experiments is disabled', async function () {
let config = this.server.schema.configs.first();
2019-01-22 17:23:26 +01:00
config.update({enableDeveloperExperiments: false});
await visit('/members');
expect(currentURL()).to.equal('/');
expect(find('[data-test-nav="members"]'), 'sidebar link')
.to.not.exist;
});
it('shows sidebar link which navigates to members list', async function () {
await visit('/');
expect(find('[data-test-nav="members"]'), 'sidebar link')
.to.exist;
await click('[data-test-nav="members"]');
expect(currentURL()).to.equal('/members');
expect(currentRouteName()).to.equal('members');
2019-01-22 17:23:26 +01:00
expect(find('[data-test-screen-title]')).to.have.text('Members');
});
});
});