2019-01-02 12:58:55 +03:00
|
|
|
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';
|
2019-05-27 11:37:05 +03:00
|
|
|
import {setupMirage} from 'ember-cli-mirage/test-support';
|
2019-01-02 12:58:55 +03:00
|
|
|
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();
|
2021-11-05 15:42:38 +03:00
|
|
|
await visit('/settings/integrations/zapier');
|
2018-10-04 14:16:41 +03:00
|
|
|
|
|
|
|
expect(currentURL(), 'currentURL').to.equal('/signin');
|
|
|
|
});
|
|
|
|
|
2019-02-22 12:43:35 +03:00
|
|
|
it('redirects to staff 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();
|
2021-11-05 15:42:38 +03:00
|
|
|
await visit('/settings/integrations/zapier');
|
2018-10-04 14:16:41 +03:00
|
|
|
|
2021-11-04 11:40:24 +03:00
|
|
|
expect(currentURL(), 'currentURL').to.equal('/settings/staff/test-user');
|
2018-10-04 14:16:41 +03:00
|
|
|
});
|
|
|
|
|
2019-02-22 12:43:35 +03:00
|
|
|
it('redirects to staff 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();
|
2021-11-05 15:42:38 +03:00
|
|
|
await visit('/settings/integrations/zapier');
|
2018-10-04 14:16:41 +03:00
|
|
|
|
2021-11-04 11:40:24 +03:00
|
|
|
expect(currentURL(), 'currentURL').to.equal('/settings/staff/test-user');
|
2018-10-04 14:16:41 +03:00
|
|
|
});
|
|
|
|
|
2019-02-22 12:43:35 +03:00
|
|
|
it('redirects to staff 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();
|
2021-11-05 15:42:38 +03:00
|
|
|
await visit('/settings/integrations/zapier');
|
2018-10-04 14:16:41 +03:00
|
|
|
|
2021-11-04 11:40:24 +03:00
|
|
|
expect(currentURL(), 'currentURL').to.equal('/settings/staff');
|
2018-10-04 14:16:41 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
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 () {
|
2021-11-05 15:42:38 +03:00
|
|
|
await visit('/settings/integrations/zapier');
|
2018-10-04 14:16:41 +03:00
|
|
|
|
|
|
|
// has correct url
|
2021-11-05 15:42:38 +03:00
|
|
|
expect(currentURL(), 'currentURL').to.equal('/settings/integrations/zapier');
|
2018-10-04 14:16:41 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|