Ghost/ghost/admin/tests/acceptance/dashboard-test.js
Simon Backx 8502ebb96a Moving over the new Dashboard to replace the old (#2389)
refs: https://github.com/TryGhost/Team/issues/1631

Co-authored-by: James Morris <moreofmorris@users.noreply.github.com>
2022-05-17 09:34:34 +02:00

47 lines
1.5 KiB
JavaScript

import {authenticateSession, invalidateSession} from 'ember-simple-auth/test-support';
import {currentURL, visit} from '@ember/test-helpers';
import {describe, it} from 'mocha';
import {enableLabsFlag} from '../helpers/labs-flag';
import {expect} from 'chai';
import {setupApplicationTest} from 'ember-mocha';
import {setupMirage} from 'ember-cli-mirage/test-support';
describe('Acceptance: Dashboard', function () {
const hooks = setupApplicationTest();
setupMirage(hooks);
beforeEach(async function () {
this.server.loadFixtures('configs');
this.server.loadFixtures('settings');
enableLabsFlag(this.server, 'membersActivity');
enableLabsFlag(this.server, 'improvedOnboarding');
let role = this.server.create('role', {name: 'Administrator'});
this.server.create('user', {roles: [role]});
return await authenticateSession();
});
it('can visit /dashboard', async function () {
await visit('/dashboard');
expect(currentURL()).to.equal('/dashboard');
});
it('/ redirects to /dashboard', async function () {
await visit('/');
expect(currentURL()).to.equal('/dashboard');
});
describe('permissions', function () {
beforeEach(async function () {
this.server.db.users.remove();
await invalidateSession();
});
it('is not accessible when logged out', async function () {
await visit('/dashboard');
expect(currentURL()).to.equal('/signin');
});
});
});