Ghost/ghost/admin/tests/acceptance/settings/zapier-test.js
Peter Zimon 9568f703c3 Fixed staff tests
- fixed all staff related tests after Admin route restructure
2021-11-04 09:40:24 +01:00

70 lines
2.4 KiB
JavaScript

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