7596-devToTest_2426 #2600

Merged
alexm merged 115 commits from 7596-devToTest_2426 into test 2024-06-18 06:19:51 +00:00
2 changed files with 16 additions and 1 deletions
Showing only changes of commit 14afd8246a - Show all commits

View File

@ -134,12 +134,14 @@ module.exports = Self => {
if (isFreelance || !client) { if (isFreelance || !client) {
const [{password}] = await models.Worker.rawSql('SELECT account.passwordGenerate() as password;'); const [{password}] = await models.Worker.rawSql('SELECT account.passwordGenerate() as password;');
const freelancer = isFreelance && await models.VnRole.findOne({fields: ['id'], where: {name: 'freelancer'}});
user = await models.VnUser.create({ user = await models.VnUser.create({
name, name,
nickname, nickname,
password, password,
email, email,
roleFk, roleFk: freelancer ? freelancer.id : roleFk,
}, myOptions); }, myOptions);
await models.Account.create({ await models.Account.create({

View File

@ -97,6 +97,19 @@ describe('Worker new', () => {
await models.Worker.destroyById(newWorker.id); await models.Worker.destroyById(newWorker.id);
} }
}); });
it('should create a new external worker', async() => {
let newWorker;
try {
newWorker = await createWorker(ctx, undefined, {isFreelance: true});
const client = await models.Client.findById(newWorker.id);
expect(newWorker.id).toBeDefined();
expect(client).toBeNull();
} finally {
await removeWorker(newWorker.id);
}
});
}); });
async function removeWorker(id) { async function removeWorker(id) {