solved test
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
17b2b02246
commit
112d7a84e3
|
@ -1,68 +0,0 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
describe('VnUser addAlias()', () => {
|
||||
const employeeId = 1;
|
||||
const sysadminId = 66;
|
||||
const developerId = 9;
|
||||
const customerId = 2;
|
||||
const mailAlias = 1;
|
||||
it('should throw an error when user not has privileges', async() => {
|
||||
const ctx = {req: {accessToken: {userId: employeeId}}};
|
||||
const tx = await models.VnUser.beginTransaction({});
|
||||
|
||||
let error;
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
await models.VnUser.addAlias(ctx, employeeId, mailAlias, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
await tx.rollback();
|
||||
}
|
||||
|
||||
expect(error.message).toContain(`You don't have grant privilege`);
|
||||
});
|
||||
|
||||
it('should throw an error when user has privileges but not has the role from user', async() => {
|
||||
const ctx = {req: {accessToken: {userId: sysadminId}}};
|
||||
const tx = await models.VnUser.beginTransaction({});
|
||||
|
||||
let error;
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
await models.VnUser.addAlias(ctx, employeeId, mailAlias, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
await tx.rollback();
|
||||
}
|
||||
|
||||
expect(error.message).toContain(`You cannot assign an alias that you are not assigned to`);
|
||||
});
|
||||
|
||||
it('should add an alias', async() => {
|
||||
const ctx = {req: {accessToken: {userId: developerId}}};
|
||||
const tx = await models.VnUser.beginTransaction({});
|
||||
|
||||
let result;
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const user = await models.VnUser.findById(developerId, null, options);
|
||||
await user.updateAttribute('hasGrant', true, options);
|
||||
|
||||
result = await models.VnUser.addAlias(ctx, customerId, mailAlias, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
}
|
||||
|
||||
expect(result.mailAlias).toBe(mailAlias);
|
||||
expect(result.account).toBe(customerId);
|
||||
});
|
||||
});
|
|
@ -270,7 +270,7 @@ class Controller extends Section {
|
|||
});
|
||||
}
|
||||
|
||||
return this.$http.post(`Tickets/invoiceTickets`, params)
|
||||
return this.$http.post(`Tickets/invoiceTickets`, {ticketsIds: [this.id]})
|
||||
.then(() => this.reload())
|
||||
.then(() => this.vnApp.showSuccess(this.$t('Ticket invoiced')));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue