2019-01-02 12:58:55 +03:00
|
|
|
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
|
|
|
import {authenticateSession, invalidateSession} from 'ember-simple-auth/test-support';
|
2018-10-04 14:16:41 +03:00
|
|
|
import {
|
|
|
|
beforeEach,
|
|
|
|
describe,
|
|
|
|
it
|
|
|
|
} from 'mocha';
|
2019-01-02 12:58:55 +03:00
|
|
|
import {currentURL} from '@ember/test-helpers';
|
2018-10-04 14:16:41 +03:00
|
|
|
import {expect} from 'chai';
|
2019-01-02 12:58:55 +03:00
|
|
|
import {setupApplicationTest} from 'ember-mocha';
|
|
|
|
import {visit} from '../../helpers/visit';
|
2018-10-04 14:16:41 +03:00
|
|
|
|
|
|
|
describe('Acceptance: Settings - Integrations - Zapier', function () {
|
2019-01-02 12:58:55 +03:00
|
|
|
let hooks = setupApplicationTest();
|
|
|
|
setupMirage(hooks);
|
2018-10-04 14:16:41 +03:00
|
|
|
|
|
|
|
it('redirects to signin when not authenticated', async function () {
|
2019-01-02 12:58:55 +03:00
|
|
|
await invalidateSession();
|
2018-10-04 14:16:41 +03:00
|
|
|
await visit('/settings/integrations/zapier');
|
|
|
|
|
|
|
|
expect(currentURL(), 'currentURL').to.equal('/signin');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('redirects to team page when authenticated as contributor', async function () {
|
2019-01-02 12:58:55 +03:00
|
|
|
let role = this.server.create('role', {name: 'Contributor'});
|
|
|
|
this.server.create('user', {roles: [role], slug: 'test-user'});
|
2018-10-04 14:16:41 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
await authenticateSession();
|
2018-10-04 14:16:41 +03:00
|
|
|
await visit('/settings/integrations/zapier');
|
|
|
|
|
|
|
|
expect(currentURL(), 'currentURL').to.equal('/team/test-user');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('redirects to team page when authenticated as author', async function () {
|
2019-01-02 12:58:55 +03:00
|
|
|
let role = this.server.create('role', {name: 'Author'});
|
|
|
|
this.server.create('user', {roles: [role], slug: 'test-user'});
|
2018-10-04 14:16:41 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
await authenticateSession();
|
2018-10-04 14:16:41 +03:00
|
|
|
await visit('/settings/integrations/zapier');
|
|
|
|
|
|
|
|
expect(currentURL(), 'currentURL').to.equal('/team/test-user');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('redirects to team page when authenticated as editor', async function () {
|
2019-01-02 12:58:55 +03:00
|
|
|
let role = this.server.create('role', {name: 'Editor'});
|
|
|
|
this.server.create('user', {roles: [role], slug: 'test-user'});
|
2018-10-04 14:16:41 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
await authenticateSession();
|
2018-10-04 14:16:41 +03:00
|
|
|
await visit('/settings/integrations/zapier');
|
|
|
|
|
|
|
|
expect(currentURL(), 'currentURL').to.equal('/team');
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when logged in', function () {
|
2019-01-02 12:58:55 +03:00
|
|
|
beforeEach(async function () {
|
|
|
|
let role = this.server.create('role', {name: 'Administrator'});
|
|
|
|
this.server.create('user', {roles: [role]});
|
2018-10-04 14:16:41 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
return await authenticateSession();
|
2018-10-04 14:16:41 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('it loads', async function () {
|
|
|
|
await visit('/settings/integrations/zapier');
|
|
|
|
|
|
|
|
// has correct url
|
|
|
|
expect(currentURL(), 'currentURL').to.equal('/settings/integrations/zapier');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|