2022-03-07 16:26:52 +03:00
|
|
|
import {authenticateSession, invalidateSession} from 'ember-simple-auth/test-support';
|
2022-05-17 10:34:34 +03:00
|
|
|
import {currentURL, visit} from '@ember/test-helpers';
|
2021-01-21 12:11:51 +03:00
|
|
|
import {describe, it} from 'mocha';
|
|
|
|
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);
|
|
|
|
|
2022-03-07 16:26:52 +03:00
|
|
|
beforeEach(async function () {
|
|
|
|
this.server.loadFixtures('configs');
|
|
|
|
this.server.loadFixtures('settings');
|
|
|
|
|
|
|
|
let role = this.server.create('role', {name: 'Administrator'});
|
2022-03-08 22:23:03 +03:00
|
|
|
this.server.create('user', {roles: [role]});
|
2022-03-07 16:26:52 +03:00
|
|
|
|
|
|
|
return await authenticateSession();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('can visit /dashboard', async function () {
|
2021-01-21 12:11:51 +03:00
|
|
|
await visit('/dashboard');
|
2022-03-07 16:26:52 +03:00
|
|
|
expect(currentURL()).to.equal('/dashboard');
|
2021-01-21 12:11:51 +03:00
|
|
|
});
|
|
|
|
|
2022-03-07 16:26:52 +03:00
|
|
|
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');
|
2021-01-21 12:11:51 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|