2016-03-29 11:40:44 +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-03-29 11:40:44 +03:00
|
|
|
import startApp from '../../helpers/start-app';
|
|
|
|
import destroyApp from '../../helpers/destroy-app';
|
2016-11-14 16:16:51 +03:00
|
|
|
import {invalidateSession, authenticateSession} from 'ghost-admin/tests/helpers/ember-simple-auth';
|
2016-03-29 11:40:44 +03:00
|
|
|
|
|
|
|
describe('Acceptance: Settings - Apps', function () {
|
|
|
|
let application;
|
|
|
|
|
2017-01-20 12:33:54 +03:00
|
|
|
beforeEach(function () {
|
2016-03-29 11:40:44 +03:00
|
|
|
application = startApp();
|
|
|
|
});
|
|
|
|
|
2017-01-20 12:33:54 +03:00
|
|
|
afterEach(function () {
|
2016-03-29 11:40:44 +03:00
|
|
|
destroyApp(application);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('redirects to signin when not authenticated', function () {
|
|
|
|
invalidateSession(application);
|
|
|
|
visit('/settings/apps');
|
|
|
|
|
2017-01-20 12:33:54 +03:00
|
|
|
andThen(function () {
|
2016-03-29 11:40:44 +03:00
|
|
|
expect(currentURL(), 'currentURL').to.equal('/signin');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('redirects to team page when authenticated as author', function () {
|
|
|
|
let role = server.create('role', {name: 'Author'});
|
2016-11-14 16:16:51 +03:00
|
|
|
server.create('user', {roles: [role], slug: 'test-user'});
|
2016-03-29 11:40:44 +03:00
|
|
|
|
|
|
|
authenticateSession(application);
|
|
|
|
visit('/settings/apps');
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
expect(currentURL(), 'currentURL').to.equal('/team/test-user');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('redirects to team page when authenticated as editor', function () {
|
|
|
|
let role = server.create('role', {name: 'Editor'});
|
2016-11-14 16:16:51 +03:00
|
|
|
server.create('user', {roles: [role], slug: 'test-user'});
|
2016-03-29 11:40:44 +03:00
|
|
|
|
|
|
|
authenticateSession(application);
|
|
|
|
visit('/settings/apps');
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
expect(currentURL(), 'currentURL').to.equal('/team');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when logged in', function () {
|
|
|
|
beforeEach(function () {
|
|
|
|
let role = server.create('role', {name: 'Administrator'});
|
2016-11-14 16:16:51 +03:00
|
|
|
server.create('user', {roles: [role]});
|
2016-03-29 11:40:44 +03:00
|
|
|
|
|
|
|
return authenticateSession(application);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('it redirects to Slack when clicking on the grid', function () {
|
|
|
|
visit('/settings/apps');
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
// has correct url
|
|
|
|
expect(currentURL(), 'currentURL').to.equal('/settings/apps');
|
|
|
|
});
|
|
|
|
|
|
|
|
click('#slack-link');
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
// has correct url
|
|
|
|
expect(currentURL(), 'currentURL').to.equal('/settings/apps/slack');
|
|
|
|
});
|
|
|
|
});
|
2017-01-20 12:33:54 +03:00
|
|
|
it('it redirects to AMP when clicking on the grid', function () {
|
|
|
|
visit('/settings/apps');
|
2016-03-29 11:40:44 +03:00
|
|
|
|
2017-01-20 12:33:54 +03:00
|
|
|
andThen(() => {
|
|
|
|
// has correct url
|
|
|
|
expect(currentURL(), 'currentURL').to.equal('/settings/apps');
|
|
|
|
});
|
|
|
|
|
|
|
|
click('#amp-link');
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
// has correct url
|
|
|
|
expect(currentURL(), 'currentURL').to.equal('/settings/apps/amp');
|
|
|
|
});
|
|
|
|
});
|
2016-03-29 11:40:44 +03:00
|
|
|
});
|
|
|
|
});
|