Skip to content

Commit 0942b36

Browse files
author
Walker Leite
committed
fix(template): fix wrong route and add create-admin test
1 parent b6711ab commit 0942b36

File tree

2 files changed

+41
-5
lines changed

2 files changed

+41
-5
lines changed

template/client/store/modules/auth/actions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function signIn({commit, dispatch, state}, {email, password}) {
1616
})
1717
.then(token => {
1818
commit('setAccessToken', token);
19-
router.push({name: 'agenda'});
19+
router.push({name: 'dashboard'});
2020
return dispatch('loadAccount', state.access_token.userId);
2121
});
2222
}

template/test/server/boot.test.js

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ import root from '../../server/boot/root.js';
77
import auth from '../../server/boot/authentication.js';
88
import createAdmin from '../../server/boot/create-admin.js';
99

10-
import initialAccount from '../../server/initial-data/manutencao-account';
11-
import initialProf from '../../server/initial-data/example1-professor';
12-
import initialAula from '../../server/initial-data/example1-aula';
13-
import initialAluno from '../../server/initial-data/example1-aluno';
10+
import initialAccount from '../../server/initial-data/maintenance-account';
11+
1412
{{/extended}}
1513
describe('boot process', () => {
1614
{{#extended}}
@@ -63,5 +61,43 @@ describe('boot process', () => {
6361
}, done);
6462
}).slow(5000).timeout(30000);
6563
});
64+
65+
describe('create-admin.js', () => {
66+
it('should have Account model', () => {
67+
expect(server.models).has.property('Account');
68+
});
69+
70+
it('should create a default admin user', () => {
71+
return server.models.Account.find().then(res => {
72+
expect(res).to.have.lengthOf(1);
73+
expect(res[0]).to.have.property('createdAt');
74+
expect(res[0]).to.have.property('updatedAt');
75+
expect(res[0].id).to.equal(1);
76+
expect(res[0].email).to.equal(initialAccount.email);
77+
expect(res[0].password).to.be.an('string');
78+
});
79+
});
80+
81+
it('should create a default admin role', () => {
82+
return server.models.Role.find().then(res => {
83+
expect(res).to.have.lengthOf(1);
84+
expect(res[0]).to.have.property('created');
85+
expect(res[0]).to.have.property('modified');
86+
expect(res[0].id).to.equal(1);
87+
expect(res[0].name).to.equal('admin');
88+
});
89+
});
90+
91+
it('should create RoleMapping entry for admin', () => {
92+
const RoleMapping = server.models.RoleMapping;
93+
return RoleMapping.find().then(res => {
94+
expect(res).to.have.lengthOf(1);
95+
expect(res[0].id).to.equal(1);
96+
expect(res[0].roleId).to.equal(1);
97+
expect(res[0].principalId).to.equal(1);
98+
expect(res[0].principalType).to.equal(RoleMapping.USER);
99+
});
100+
});
101+
});
66102
{{/extended}}
67103
});

0 commit comments

Comments
 (0)